2016-12-21 19:51:43 +00:00
|
|
|
import test from 'ava'
|
|
|
|
import { resolve } from 'path'
|
|
|
|
|
2017-03-17 17:52:46 +00:00
|
|
|
test('Fail with routes() which throw an error', t => {
|
2016-12-21 19:51:43 +00:00
|
|
|
const Nuxt = require('../')
|
|
|
|
const options = {
|
|
|
|
rootDir: resolve(__dirname, 'fixtures/basic'),
|
|
|
|
dev: false,
|
|
|
|
generate: {
|
2017-03-17 17:52:46 +00:00
|
|
|
routes: function () {
|
|
|
|
return new Promise((resolve, reject) => {
|
2017-03-20 16:52:35 +00:00
|
|
|
reject(new Error('Not today!'))
|
2017-03-17 17:52:46 +00:00
|
|
|
})
|
2016-12-21 19:51:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
2017-03-17 17:52:46 +00:00
|
|
|
t.true(_log.includes('Could not resolve routes'))
|
2016-12-21 19:51:43 +00:00
|
|
|
resolve()
|
|
|
|
}
|
|
|
|
nuxt.generate()
|
|
|
|
.catch((e) => {
|
2017-03-20 16:52:35 +00:00
|
|
|
t.true(e.message === 'Not today!')
|
2016-12-21 19:51:43 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|