mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
update nuxt tests
This commit is contained in:
parent
030273db49
commit
103365d81b
@ -8,32 +8,17 @@ test('Nuxt.js Class', t => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Nuxt.js Instance', async t => {
|
test.serial('Nuxt.js Instance', async t => {
|
||||||
const nuxt = new Nuxt({ dev: false })
|
const nuxt = new Nuxt({
|
||||||
|
dev: false,
|
||||||
|
rootDir: resolve(__dirname, 'fixtures', 'empty')
|
||||||
|
})
|
||||||
t.is(typeof nuxt, 'object')
|
t.is(typeof nuxt, 'object')
|
||||||
t.is(nuxt.options.dev, false)
|
t.is(nuxt.options.dev, false)
|
||||||
t.is(typeof nuxt.build, 'function')
|
t.is(typeof nuxt.build, 'function')
|
||||||
t.is(typeof nuxt.generate, 'function')
|
t.is(typeof nuxt.generate, 'function')
|
||||||
})
|
t.is(typeof nuxt._init.then, 'function')
|
||||||
|
await nuxt.init()
|
||||||
test.serial('Fail when build not done and try to render', async t => {
|
t.is(nuxt.initialized, true)
|
||||||
const nuxt = new Nuxt({
|
|
||||||
dev: false,
|
|
||||||
rootDir: resolve(__dirname, 'fixtures/empty')
|
|
||||||
})
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
let oldExit = process.exit
|
|
||||||
let oldCE = console.error // eslint-disable-line no-console
|
|
||||||
let _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, please run `nuxt build` before launching `nuxt start`'))
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
nuxt.render()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test.serial('Fail to build when no pages/ directory but is in the parent', async t => {
|
test.serial('Fail to build when no pages/ directory but is in the parent', async t => {
|
||||||
@ -45,7 +30,9 @@ test.serial('Fail to build when no pages/ directory but is in the parent', async
|
|||||||
let oldExit = process.exit
|
let oldExit = process.exit
|
||||||
let oldCE = console.error // eslint-disable-line no-console
|
let oldCE = console.error // eslint-disable-line no-console
|
||||||
let _log = ''
|
let _log = ''
|
||||||
console.error = (s) => { _log += s } // eslint-disable-line no-console
|
console.error = (s) => {
|
||||||
|
_log += s
|
||||||
|
} // eslint-disable-line no-console
|
||||||
process.exit = (code) => {
|
process.exit = (code) => {
|
||||||
process.exit = oldExit
|
process.exit = oldExit
|
||||||
console.error = oldCE // eslint-disable-line no-console
|
console.error = oldCE // eslint-disable-line no-console
|
||||||
@ -66,7 +53,9 @@ test.serial('Fail to build when no pages/ directory', async t => {
|
|||||||
let oldExit = process.exit
|
let oldExit = process.exit
|
||||||
let oldCE = console.error // eslint-disable-line no-console
|
let oldCE = console.error // eslint-disable-line no-console
|
||||||
let _log = ''
|
let _log = ''
|
||||||
console.error = (s) => { _log += s } // eslint-disable-line no-console
|
console.error = (s) => {
|
||||||
|
_log += s
|
||||||
|
} // eslint-disable-line no-console
|
||||||
process.exit = (code) => {
|
process.exit = (code) => {
|
||||||
process.exit = oldExit
|
process.exit = oldExit
|
||||||
console.error = oldCE // eslint-disable-line no-console
|
console.error = oldCE // eslint-disable-line no-console
|
||||||
|
Loading…
Reference in New Issue
Block a user