mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
[tests] await for nuxt initialization
Nuxt constructor is now returning a promise, so we should await it before using
This commit is contained in:
parent
d57ea4de88
commit
b0b9101a8d
@ -13,7 +13,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||
dev: true
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
nuxt = await new Nuxt(options)
|
||||
await nuxt.build()
|
||||
server = new nuxt.Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
|
@ -1,7 +1,7 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
|
||||
test('Fail with routes() which throw an error', t => {
|
||||
test('Fail with routes() which throw an error', async t => {
|
||||
const Nuxt = require('../')
|
||||
const options = {
|
||||
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||
@ -14,7 +14,7 @@ test('Fail with routes() which throw an error', t => {
|
||||
}
|
||||
}
|
||||
}
|
||||
const nuxt = new Nuxt(options)
|
||||
const nuxt = await new Nuxt(options)
|
||||
return new Promise((resolve) => {
|
||||
var oldExit = process.exit
|
||||
var oldCE = console.error // eslint-disable-line no-console
|
||||
|
@ -17,7 +17,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
let config = require(resolve(rootDir, 'nuxt.config.js'))
|
||||
config.rootDir = rootDir
|
||||
config.dev = false
|
||||
nuxt = new Nuxt(config)
|
||||
nuxt = await new Nuxt(config)
|
||||
try {
|
||||
await nuxt.generate() // throw an error (of /validate route)
|
||||
} catch (err) {}
|
||||
|
@ -14,7 +14,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||
dev: false
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
nuxt = await new Nuxt(options)
|
||||
await nuxt.build()
|
||||
server = new nuxt.Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
|
@ -13,7 +13,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
rootDir: resolve(__dirname, 'fixtures/children'),
|
||||
dev: false
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
nuxt = await new Nuxt(options)
|
||||
await nuxt.build()
|
||||
server = new nuxt.Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
|
@ -7,7 +7,7 @@ const readFile = pify(fs.readFile)
|
||||
// Init nuxt.js and create server listening on localhost:4000
|
||||
test.before('Init Nuxt.js', async t => {
|
||||
const Nuxt = require('../')
|
||||
const nuxt = new Nuxt({
|
||||
const nuxt = await new Nuxt({
|
||||
rootDir: resolve(__dirname, 'fixtures/dynamic-routes'),
|
||||
dev: false
|
||||
})
|
||||
|
@ -13,7 +13,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
rootDir: resolve(__dirname, 'fixtures/error'),
|
||||
dev: false
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
nuxt = await new Nuxt(options)
|
||||
await nuxt.build()
|
||||
server = new nuxt.Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
|
@ -7,16 +7,16 @@ test('Nuxt.js Class', t => {
|
||||
t.is(typeof Nuxt, 'function')
|
||||
})
|
||||
|
||||
test('Nuxt.js Instance', t => {
|
||||
const nuxt = new Nuxt()
|
||||
test('Nuxt.js Instance', async t => {
|
||||
const nuxt = await new Nuxt()
|
||||
t.is(typeof nuxt, 'object')
|
||||
t.is(nuxt.dev, true)
|
||||
t.is(typeof nuxt.build, 'function')
|
||||
t.is(typeof nuxt.generate, 'function')
|
||||
})
|
||||
|
||||
test.serial('Fail when build not done and try to render', t => {
|
||||
const nuxt = new Nuxt({
|
||||
test.serial('Fail when build not done and try to render', async t => {
|
||||
const nuxt = await new Nuxt({
|
||||
dev: false,
|
||||
rootDir: resolve(__dirname, 'fixtures/empty')
|
||||
})
|
||||
@ -36,8 +36,8 @@ test.serial('Fail when build not done and try to render', t => {
|
||||
})
|
||||
})
|
||||
|
||||
test.serial('Fail to build when no pages/ directory but is in the parent', t => {
|
||||
const nuxt = new Nuxt({
|
||||
test.serial('Fail to build when no pages/ directory but is in the parent', async t => {
|
||||
const nuxt = await new Nuxt({
|
||||
dev: false,
|
||||
rootDir: resolve(__dirname, 'fixtures', 'empty', 'pages')
|
||||
})
|
||||
@ -57,8 +57,8 @@ test.serial('Fail to build when no pages/ directory but is in the parent', t =>
|
||||
})
|
||||
})
|
||||
|
||||
test.serial('Fail to build when no pages/ directory', t => {
|
||||
const nuxt = new Nuxt({
|
||||
test.serial('Fail to build when no pages/ directory', async t => {
|
||||
const nuxt = await new Nuxt({
|
||||
dev: false,
|
||||
rootDir: resolve(__dirname)
|
||||
})
|
||||
|
@ -5,7 +5,7 @@ let utils
|
||||
// Init nuxt.js and create server listening on localhost:4000
|
||||
test.before('Init Nuxt.js', async t => {
|
||||
const Nuxt = require('../')
|
||||
let nuxt = new Nuxt({ dev: false })
|
||||
let nuxt = await new Nuxt({ dev: false })
|
||||
utils = nuxt.utils
|
||||
})
|
||||
|
||||
|
@ -13,7 +13,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
let config = require(resolve(rootDir, 'nuxt.config.js'))
|
||||
config.rootDir = rootDir
|
||||
config.dev = false
|
||||
nuxt = new Nuxt(config)
|
||||
nuxt = await new Nuxt(config)
|
||||
await nuxt.build()
|
||||
server = new nuxt.Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
@ -96,11 +96,11 @@ test.after('Closing server and nuxt.js', t => {
|
||||
nuxt.close()
|
||||
})
|
||||
|
||||
test.after('Should be able to start Nuxt with build done', t => {
|
||||
test.after('Should be able to start Nuxt with build done', async t => {
|
||||
const Nuxt = require('../')
|
||||
const rootDir = resolve(__dirname, 'fixtures/with-config')
|
||||
let config = require(resolve(rootDir, 'nuxt.config.js'))
|
||||
config.rootDir = rootDir
|
||||
config.dev = false
|
||||
nuxt = new Nuxt(config)
|
||||
nuxt = await new Nuxt(config)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user