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 return this
} }
close (cb) {
return this.server.close(cb)
}
} }
module.exports = Server module.exports = Server

View File

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