2016-12-21 19:51:43 +00:00
|
|
|
import test from 'ava'
|
|
|
|
import { resolve } from 'path'
|
2017-12-12 09:42:29 +00:00
|
|
|
import { Nuxt, Builder, Generator } from '..'
|
2017-12-17 19:30:26 +00:00
|
|
|
import { intercept } from './helpers/console'
|
2016-12-21 19:51:43 +00:00
|
|
|
|
2017-05-11 19:49:02 +00:00
|
|
|
test('Fail with routes() which throw an error', async t => {
|
2016-12-21 19:51:43 +00:00
|
|
|
const options = {
|
|
|
|
rootDir: resolve(__dirname, 'fixtures/basic'),
|
2017-12-17 19:30:26 +00:00
|
|
|
buildDir: '.nuxt-fail',
|
2016-12-21 19:51:43 +00:00
|
|
|
dev: false,
|
2017-12-17 19:30:26 +00:00
|
|
|
build: {
|
|
|
|
stats: false
|
|
|
|
},
|
2016-12-21 19:51:43 +00:00
|
|
|
generate: {
|
2017-10-30 16:51:11 +00:00
|
|
|
async routes() {
|
2017-06-13 22:09:03 +00:00
|
|
|
throw new Error('Not today!')
|
2016-12-21 19:51:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-17 19:30:26 +00:00
|
|
|
const spies = await intercept(async () => {
|
|
|
|
const nuxt = new Nuxt(options)
|
|
|
|
const builder = new Builder(nuxt)
|
|
|
|
const generator = new Generator(nuxt, builder)
|
|
|
|
|
|
|
|
return generator.generate()
|
|
|
|
.catch((e) => {
|
|
|
|
t.true(e.message === 'Not today!')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
t.true(spies.log.calledWithMatch('DONE'))
|
|
|
|
t.true(spies.error.withArgs('Could not resolve routes').calledOnce)
|
2016-12-21 19:51:43 +00:00
|
|
|
})
|