mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
Add test when no build and call render
This commit is contained in:
parent
6b7062046e
commit
3606d2a576
@ -1,14 +1,37 @@
|
|||||||
import test from 'ava'
|
import test from 'ava'
|
||||||
const Nuxt = require('../')
|
import { resolve } from 'path'
|
||||||
const nuxt = new Nuxt()
|
|
||||||
|
|
||||||
test('Nuxt.js Class', (t) => {
|
const Nuxt = require('../')
|
||||||
|
|
||||||
|
test('Nuxt.js Class', t => {
|
||||||
t.is(typeof Nuxt, 'function')
|
t.is(typeof Nuxt, 'function')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Nuxt.js Instance', (t) => {
|
test('Nuxt.js Instance', t => {
|
||||||
|
const nuxt = new Nuxt()
|
||||||
t.is(typeof nuxt, 'object')
|
t.is(typeof nuxt, 'object')
|
||||||
t.is(nuxt.dev, true)
|
t.is(nuxt.dev, true)
|
||||||
t.is(typeof nuxt.build, 'function')
|
t.is(typeof nuxt.build, 'function')
|
||||||
t.is(typeof nuxt.generate, 'function')
|
t.is(typeof nuxt.generate, 'function')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Fail when build not done and try to render', async t => {
|
||||||
|
const nuxt = new Nuxt({
|
||||||
|
dev: false,
|
||||||
|
rootDir: resolve(__dirname, 'empty')
|
||||||
|
})
|
||||||
|
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('No build files found'))
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
nuxt.render()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user