1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

stop watching files after running tests

This commit is contained in:
nkzawa 2016-12-17 13:04:40 +09:00
parent 1708222381
commit 59d514e071
3 changed files with 22 additions and 1 deletions

View file

@ -50,6 +50,19 @@ export default class HotReloader {
this.stats = await this.waitUntilValid() this.stats = await this.waitUntilValid()
} }
async stop () {
if (this.watcher) this.watcher.close()
if (this.webpackDevMiddleware) {
return new Promise((resolve, reject) => {
this.webpackDevMiddleware.close((err) => {
if (err) reject(err)
resolve()
})
})
}
}
async prepareMiddlewares (compiler) { async prepareMiddlewares (compiler) {
compiler.plugin('after-emit', (compilation, callback) => { compiler.plugin('after-emit', (compilation, callback) => {
const { assets } = compilation const { assets } = compilation

View file

@ -43,6 +43,12 @@ export default class Server {
} }
} }
async close () {
if (this.hotReloader) {
await this.hotReloader.stop()
}
}
defineRoutes () { defineRoutes () {
this.router.get('/_next-prefetcher.js', async (req, res, params) => { this.router.get('/_next-prefetcher.js', async (req, res, params) => {
const p = join(__dirname, '../client/next-prefetcher-bundle.js') const p = join(__dirname, '../client/next-prefetcher-bundle.js')

View file

@ -1,4 +1,4 @@
/* global expect, jasmine, describe, test, beforeAll */ /* global expect, jasmine, describe, test, beforeAll, afterAll */
'use strict' 'use strict'
@ -18,6 +18,8 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000
describe('integration tests', () => { describe('integration tests', () => {
beforeAll(() => app.prepare()) beforeAll(() => app.prepare())
afterAll(() => app.close())
test('renders a stateless component', async () => { test('renders a stateless component', async () => {
const html = await render('/stateless') const html = await render('/stateless')
expect(html.includes('<meta charset="utf-8" class="next-head"/>')).toBeTruthy() expect(html.includes('<meta charset="utf-8" class="next-head"/>')).toBeTruthy()