mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 06:35:10 +00:00
b0b9101a8d
Nuxt constructor is now returning a promise, so we should await it before using
33 lines
858 B
JavaScript
33 lines
858 B
JavaScript
import test from 'ava'
|
|
import { resolve } from 'path'
|
|
const port = 4005
|
|
const url = (route) => 'http://localhost:' + port + route
|
|
|
|
let nuxt = null
|
|
let server = null
|
|
|
|
// Init nuxt.js and create server listening on localhost:4000
|
|
test.before('Init Nuxt.js', async t => {
|
|
const Nuxt = require('../')
|
|
const options = {
|
|
rootDir: resolve(__dirname, 'fixtures/basic'),
|
|
dev: true
|
|
}
|
|
nuxt = await new Nuxt(options)
|
|
await nuxt.build()
|
|
server = new nuxt.Server(nuxt)
|
|
server.listen(port, 'localhost')
|
|
})
|
|
|
|
test('/stateless', async t => {
|
|
const window = await nuxt.renderAndGetWindow(url('/stateless'))
|
|
const html = window.document.body.innerHTML
|
|
t.true(html.includes('<h1>My component!</h1>'))
|
|
})
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
test.after('Closing server and nuxt.js', t => {
|
|
server.close()
|
|
nuxt.close()
|
|
})
|