diff --git a/examples/with-ava/package.json b/examples/with-ava/package.json
index 248e6b34eb..e05b6c01f1 100755
--- a/examples/with-ava/package.json
+++ b/examples/with-ava/package.json
@@ -1,11 +1,16 @@
{
"name": "nuxt-with-ava",
"scripts": {
- "start": "../../bin/nuxt .",
+ "dev": "nuxt",
+ "build": "nuxt build",
+ "start": "nuxt start",
"test": "ava"
},
"devDependencies": {
"ava": "^0.16.0",
"jsdom": "^9.8.3"
+ },
+ "dependencies": {
+ "nuxt": "^0.9.5"
}
}
diff --git a/examples/with-ava/pages/index.vue b/examples/with-ava/pages/index.vue
index cac2fde6a3..a3d80ae170 100755
--- a/examples/with-ava/pages/index.vue
+++ b/examples/with-ava/pages/index.vue
@@ -1,7 +1,5 @@
- Hello {{ name }}!Hello {{ name }}!
diff --git a/examples/with-ava/test/index.test.js b/examples/with-ava/test/index.test.js
index c19d0a692c..21c25e9320 100755
--- a/examples/with-ava/test/index.test.js
+++ b/examples/with-ava/test/index.test.js
@@ -1,48 +1,39 @@
-/*
-** Test with Ava can be written in ES6 \o/
-*/
import test from 'ava'
-import { createServer } from 'http'
+import Nuxt from 'nuxt'
import { resolve } from 'path'
+// We keep the nuxt and server instance
+// So we can close them at the end of the test
let nuxt = null
let server = null
-// Init nuxt.js and create server listening on localhost:4000
-test.before('Init Nuxt.js', (t) => {
- const Nuxt = require('../../../')
- const options = {
- rootDir: resolve(__dirname, '..'),
- dev: false
- }
- nuxt = new Nuxt(options)
- return nuxt.build()
- .then(function () {
- server = createServer((req, res) => nuxt.render(req, res))
- server.listen(4000, 'localhost')
- })
+// Init Nuxt.js and create a server listening on localhost:4000
+test.before('Init Nuxt.js', async t => {
+ const rootDir = resolve(__dirname, '..')
+ let config = {}
+ try { config = require(resolve(rootDir, 'nuxt.config.js')) } catch (e) {}
+ config.rootDir = rootDir // project folder
+ config.dev = false // production build
+ nuxt = new Nuxt(config)
+ await nuxt.build()
+ server = new nuxt.Server(nuxt)
+ server.listen(4000, 'localhost')
})
-/*
-** Example of testing only the html
-*/
+// Example of testing only generated html
test('Route / exits and render HTML', async t => {
let context = {}
const { html } = await nuxt.renderRoute('/', context)
- t.true(html.includes('
Hello world!
')) - t.is(context.nuxt.error, null) - t.is(context.nuxt.data[0].name, 'world') + t.true(html.includes('