Skip to content

Commit

Permalink
fix: invalidate route (#2584)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed May 8, 2020
1 parent f857c40 commit 0e51fb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/utils/routes.js
Expand Up @@ -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');

Expand Down
8 changes: 6 additions & 2 deletions test/server/utils/routes.test.js
Expand Up @@ -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) => {
Expand Down

0 comments on commit 0e51fb1

Please sign in to comment.