diff --git a/lib/utils/routes.js b/lib/utils/routes.js index 21460068a9..5bb6ff2c62 100644 --- a/lib/utils/routes.js +++ b/lib/utils/routes.js @@ -28,17 +28,17 @@ function routes(server) { createReadStream(join(clientBasePath, 'index.bundle.js')).pipe(res); }); + app.get('/webpack-dev-server/invalidate', (_req, res) => { + server.invalidate(); + res.end(); + }); + app.get('/webpack-dev-server/*', (req, res) => { res.setHeader('Content-Type', 'text/html'); createReadStream(join(clientBasePath, 'live.html')).pipe(res); }); - app.get('/invalidate', (_req, res) => { - server.invalidate(); - res.end(); - }); - app.get('/webpack-dev-server', (req, res) => { res.setHeader('Content-Type', 'text/html'); diff --git a/test/server/utils/routes.test.js b/test/server/utils/routes.test.js index afe5dd40a2..ce2eea7044 100644 --- a/test/server/utils/routes.test.js +++ b/test/server/utils/routes.test.js @@ -64,8 +64,12 @@ describe('routes util', () => { }); }); - it('GET request to invalidate endpoint', (done) => { - req.get('/invalidate').expect(200, done); + it('should handles GET request to invalidate endpoint', (done) => { + req.get('/webpack-dev-server/invalidate').then(({ res }) => { + expect(res.headers['content-type']).not.toEqual('text/html'); + expect(res.statusCode).toEqual(200); + done(); + }); }); it('should handles GET request to live html', (done) => {