Use Nuxt server for tests

This commit is contained in:
Sébastien Chopin 2016-12-09 23:07:18 +01:00
parent 530cb9f272
commit 6b7062046e
2 changed files with 5 additions and 2 deletions

View File

@ -24,6 +24,10 @@ class Server {
return this
}
close (cb) {
return this.server.close(cb)
}
}
module.exports = Server

View File

@ -1,6 +1,5 @@
import test from 'ava'
import jsdom from 'jsdom'
import { createServer } from 'http'
import { resolve } from 'path'
const port = 4002
const url = (route) => 'http://localhost:' + port + route
@ -18,7 +17,7 @@ test.before('Init Nuxt.js', t => {
nuxt = new Nuxt(options)
return nuxt.build()
.then(function () {
server = createServer((req, res) => nuxt.render(req, res))
server = new nuxt.Server(nuxt)
server.listen(port, 'localhost')
})
})