I believe that since v1.x nuxt now returns a promise, would this then be an acceptable way to run tests against it? And if not how? and should/can we update the documentation?
import test from 'ava'
import Nuxt from 'nuxt'
import { resolve } from 'path'
let nuxt = null
let server = null
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).then(nuxt => {
test.before('Initializing Nuxt.js', async t => {
await nuxt.build()
server = new nuxt.Server(nuxt)
server.listen(4000, 'localhost')
})
test('Route / exits and renders HTML', async t => {
let context = {}
const { html } = await nuxt.renderRoute('/', context)
t.true(html.includes('<div class="page home">'))
})
test.after('Closing the server and nuxt.js', t => {
server.close()
nuxt.close()
})
})
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c855">#c855</a>)</em></sub></div>