Skip to content

Commit 59d514e

Browse files
committed
stop watching files after running tests
1 parent 1708222 commit 59d514e

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

server/hot-reloader.js

+13
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ export default class HotReloader {
5050
this.stats = await this.waitUntilValid()
5151
}
5252

53+
async stop () {
54+
if (this.watcher) this.watcher.close()
55+
56+
if (this.webpackDevMiddleware) {
57+
return new Promise((resolve, reject) => {
58+
this.webpackDevMiddleware.close((err) => {
59+
if (err) reject(err)
60+
resolve()
61+
})
62+
})
63+
}
64+
}
65+
5366
async prepareMiddlewares (compiler) {
5467
compiler.plugin('after-emit', (compilation, callback) => {
5568
const { assets } = compilation

server/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export default class Server {
4343
}
4444
}
4545

46+
async close () {
47+
if (this.hotReloader) {
48+
await this.hotReloader.stop()
49+
}
50+
}
51+
4652
defineRoutes () {
4753
this.router.get('/_next-prefetcher.js', async (req, res, params) => {
4854
const p = join(__dirname, '../client/next-prefetcher-bundle.js')

test/integration.test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global expect, jasmine, describe, test, beforeAll */
1+
/* global expect, jasmine, describe, test, beforeAll, afterAll */
22

33
'use strict'
44

@@ -18,6 +18,8 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000
1818
describe('integration tests', () => {
1919
beforeAll(() => app.prepare())
2020

21+
afterAll(() => app.close())
22+
2123
test('renders a stateless component', async () => {
2224
const html = await render('/stateless')
2325
expect(html.includes('<meta charset="utf-8" class="next-head"/>')).toBeTruthy()

0 commit comments

Comments
 (0)