mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 10:04:05 +00:00
36 lines
965 B
JavaScript
36 lines
965 B
JavaScript
import test from 'ava'
|
|
import { resolve } from 'path'
|
|
|
|
test('Fail with routes() which throw an error', 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!')
|
|
})
|
|
})
|
|
})
|