提交 59d514e0 编写于 作者: N nkzawa

stop watching files after running tests

上级 17082223
......@@ -50,6 +50,19 @@ export default class HotReloader {
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) {
compiler.plugin('after-emit', (compilation, callback) => {
const { assets } = compilation
......
......@@ -43,6 +43,12 @@ export default class Server {
}
}
async close () {
if (this.hotReloader) {
await this.hotReloader.stop()
}
}
defineRoutes () {
this.router.get('/_next-prefetcher.js', async (req, res, params) => {
const p = join(__dirname, '../client/next-prefetcher-bundle.js')
......
/* global expect, jasmine, describe, test, beforeAll */
/* global expect, jasmine, describe, test, beforeAll, afterAll */
'use strict'
......@@ -18,6 +18,8 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000
describe('integration tests', () => {
beforeAll(() => app.prepare())
afterAll(() => app.close())
test('renders a stateless component', async () => {
const html = await render('/stateless')
expect(html.includes('<meta charset="utf-8" class="next-head"/>')).toBeTruthy()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册