feat: update with-ava example

This commit is contained in:
Clark Du 2017-10-20 14:41:06 +08:00 committed by Pooya Parsa
parent 50ade95694
commit d2a57bc329
2 changed files with 4 additions and 7 deletions

View File

@ -11,6 +11,6 @@
"jsdom": "^11.0.0" "jsdom": "^11.0.0"
}, },
"dependencies": { "dependencies": {
"nuxt": "^1.0.0-alpha2" "nuxt": "latest"
} }
} }

View File

@ -1,11 +1,10 @@
import test from 'ava' import test from 'ava'
import Nuxt from 'nuxt' import { Nuxt, Builder } from 'nuxt'
import { resolve } from 'path' import { resolve } from 'path'
// We keep the nuxt and server instance // We keep the nuxt and server instance
// So we can close them at the end of the test // So we can close them at the end of the test
let nuxt = null let nuxt = null
let server = null
// Init Nuxt.js and create a server listening on localhost:4000 // Init Nuxt.js and create a server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
@ -15,9 +14,8 @@ test.before('Init Nuxt.js', async t => {
config.rootDir = rootDir // project folder config.rootDir = rootDir // project folder
config.dev = false // production build config.dev = false // production build
nuxt = new Nuxt(config) nuxt = new Nuxt(config)
await nuxt.build() await new Builder(nuxt).build()
server = new nuxt.Server(nuxt) await nuxt.listen(4000, 'localhost')
server.listen(4000, 'localhost')
}) })
// Example of testing only generated html // Example of testing only generated html
@ -39,6 +37,5 @@ test('Route / exits and render HTML with CSS applied', async t => {
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', t => { test.after('Closing server and nuxt.js', t => {
server.close()
nuxt.close() nuxt.close()
}) })