mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-18 02:07:14 +00:00
b0b9101a8d
Nuxt constructor is now returning a promise, so we should await it before using
36 lines
977 B
JavaScript
36 lines
977 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 = await 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!')
|
|
})
|
|
})
|
|
})
|