2018-12-01 10:13:28 +00:00
|
|
|
import consola from 'consola'
|
|
|
|
import { Nuxt } from '../utils'
|
|
|
|
|
2019-03-20 09:17:53 +00:00
|
|
|
const NO_BUILD_MSG = /Use either `nuxt build` or `builder\.build\(\)` or start nuxt in development mode/
|
|
|
|
const NO_MODERN_BUILD_MSG = /Use either `nuxt build --modern` or `modern` option to build modern files/
|
2018-12-01 10:13:28 +00:00
|
|
|
|
|
|
|
describe('renderer', () => {
|
2018-12-04 12:11:18 +00:00
|
|
|
afterEach(() => {
|
|
|
|
consola.fatal.mockClear()
|
|
|
|
})
|
|
|
|
|
2018-12-01 10:13:28 +00:00
|
|
|
test('detect no-build (Universal)', async () => {
|
|
|
|
const nuxt = new Nuxt({
|
|
|
|
_start: true,
|
|
|
|
mode: 'universal',
|
|
|
|
dev: false,
|
|
|
|
buildDir: '/path/to/404'
|
|
|
|
})
|
2019-03-30 18:53:56 +00:00
|
|
|
|
|
|
|
await expect(nuxt.ready()).rejects.toThrow(expect.objectContaining({
|
2019-03-20 09:17:53 +00:00
|
|
|
message: expect.stringMatching(NO_BUILD_MSG)
|
|
|
|
}))
|
2018-12-01 10:13:28 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('detect no-build (SPA)', async () => {
|
|
|
|
const nuxt = new Nuxt({
|
|
|
|
_start: true,
|
|
|
|
mode: 'spa',
|
|
|
|
dev: false,
|
|
|
|
buildDir: '/path/to/404'
|
|
|
|
})
|
2019-03-30 18:53:56 +00:00
|
|
|
|
|
|
|
await expect(nuxt.ready()).rejects.toThrow(expect.objectContaining({
|
2019-03-20 09:17:53 +00:00
|
|
|
message: expect.stringMatching(NO_BUILD_MSG)
|
|
|
|
}))
|
2018-12-01 10:13:28 +00:00
|
|
|
})
|
2018-12-04 12:11:18 +00:00
|
|
|
test('detect no-modern-build', async () => {
|
|
|
|
const nuxt = new Nuxt({
|
|
|
|
_start: true,
|
|
|
|
mode: 'universal',
|
|
|
|
modern: 'client',
|
|
|
|
dev: false,
|
2019-03-20 09:17:53 +00:00
|
|
|
buildDir: '/path/to/404'
|
2018-12-04 12:11:18 +00:00
|
|
|
})
|
2019-03-30 18:53:56 +00:00
|
|
|
|
|
|
|
await expect(nuxt.ready()).rejects.toThrow(expect.objectContaining({
|
2019-03-20 09:17:53 +00:00
|
|
|
message: expect.stringMatching(NO_MODERN_BUILD_MSG)
|
|
|
|
}))
|
2018-12-04 12:11:18 +00:00
|
|
|
})
|
2018-12-01 10:13:28 +00:00
|
|
|
})
|