Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ describe('HttpServer (integration)', () => {
const req = httpGetAsync(server.url, agent);
// Wait until the request is accepted by the server
await pEvent(server.server, 'request');
// Set up error handler for expected rejection before the event is emitted
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note pEvent uses server.server.on('error', ...) behind the scene. We need to call it first so that an error handler is registered before the error event is emitted.

const socketPromise = expect(req).to.be.rejectedWith(/socket hang up/);
// Stop the server
await server.stop();
// No more new connections are accepted
await expect(httpGetAsync(server.url)).to.be.rejectedWith(/ECONNREFUSED/);
// We never send `finish` to the pending request
// The inflight request is aborted as it takes longer than the grace period
await expect(req).to.be.rejectedWith(/socket hang up/);
await socketPromise;
});

it('exports original port', async () => {
Expand Down