Nuxt/test/unit/basic.fail.generate.test.js

32 lines
821 B
JavaScript
Raw Normal View History

import { loadFixture, Nuxt, Generator } from '../utils'
2018-03-16 19:52:17 +00:00
2018-03-18 19:31:32 +00:00
describe('basic fail generate', () => {
test('Fail with routes() which throw an error', async () => {
const options = await loadFixture('basic', {
2018-03-18 19:31:32 +00:00
generate: {
routes () {
2018-03-18 19:31:32 +00:00
throw new Error('Not today!')
}
2016-12-21 19:51:43 +00:00
}
2018-03-18 23:41:14 +00:00
})
const nuxt = new Nuxt(options)
await nuxt.ready()
2018-03-18 23:41:14 +00:00
const generator = new Generator(nuxt)
await generator.generate({ build: false }).catch((e) => {
2018-03-18 23:41:14 +00:00
expect(e.message).toBe('Not today!')
2018-01-13 05:22:11 +00:00
})
2018-03-18 23:41:14 +00:00
})
test('Fail when generate.dir equals rootDir', async () => {
const options = await loadFixture('basic', {
generate: { dir: '../basic' }
})
expect(() => {
new Nuxt(options) /* eslint-disable-line no-new */
}).toThrow(/options.generate.dir cannot be/)
})
2016-12-21 19:51:43 +00:00
})