Skip to content

Commit 0e51fb1

Browse files
fix: invalidate route (#2584)
1 parent f857c40 commit 0e51fb1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/utils/routes.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ function routes(server) {
2828
createReadStream(join(clientBasePath, 'index.bundle.js')).pipe(res);
2929
});
3030

31+
app.get('/webpack-dev-server/invalidate', (_req, res) => {
32+
server.invalidate();
33+
res.end();
34+
});
35+
3136
app.get('/webpack-dev-server/*', (req, res) => {
3237
res.setHeader('Content-Type', 'text/html');
3338

3439
createReadStream(join(clientBasePath, 'live.html')).pipe(res);
3540
});
3641

37-
app.get('/invalidate', (_req, res) => {
38-
server.invalidate();
39-
res.end();
40-
});
41-
4242
app.get('/webpack-dev-server', (req, res) => {
4343
res.setHeader('Content-Type', 'text/html');
4444

test/server/utils/routes.test.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ describe('routes util', () => {
6464
});
6565
});
6666

67-
it('GET request to invalidate endpoint', (done) => {
68-
req.get('/invalidate').expect(200, done);
67+
it('should handles GET request to invalidate endpoint', (done) => {
68+
req.get('/webpack-dev-server/invalidate').then(({ res }) => {
69+
expect(res.headers['content-type']).not.toEqual('text/html');
70+
expect(res.statusCode).toEqual(200);
71+
done();
72+
});
6973
});
7074

7175
it('should handles GET request to live html', (done) => {

0 commit comments

Comments
 (0)