mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-18 02:07:14 +00:00
c5ca8c64f1
by not returning a promise we can expose .render method also the old way of using nuxt won't change by 1.x release
36 lines
971 B
JavaScript
36 lines
971 B
JavaScript
import test from 'ava'
|
|
import { resolve } from 'path'
|
|
|
|
test('Fail with routes() which throw an error', async t => {
|
|
const Nuxt = require('../')
|
|
const options = {
|
|
rootDir: resolve(__dirname, 'fixtures/basic'),
|
|
dev: false,
|
|
generate: {
|
|
routes: function () {
|
|
return new Promise((resolve, reject) => {
|
|
reject(new Error('Not today!'))
|
|
})
|
|
}
|
|
}
|
|
}
|
|
const nuxt = new Nuxt(options)
|
|
return new Promise((resolve) => {
|
|
var oldExit = process.exit
|
|
var oldCE = console.error // eslint-disable-line no-console
|
|
var _log = ''
|
|
console.error = (s) => { _log += s } // eslint-disable-line no-console
|
|
process.exit = (code) => {
|
|
process.exit = oldExit
|
|
console.error = oldCE // eslint-disable-line no-console
|
|
t.is(code, 1)
|
|
t.true(_log.includes('Could not resolve routes'))
|
|
resolve()
|
|
}
|
|
nuxt.generate()
|
|
.catch((e) => {
|
|
t.true(e.message === 'Not today!')
|
|
})
|
|
})
|
|
})
|