Skip to content

Commit

Permalink
skip test for Node 14
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-scheer committed Jul 22, 2023
1 parent e6e1aa0 commit c7e0570
Showing 1 changed file with 37 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,36 +145,43 @@ Object.keys(schemes).forEach((schemeName) => {
expect(closed).toBe(isNode20 ? 1 : 0);
});

it('with unfinished requests', async () => {
const server = scheme.server(async (_req, res) => {
res.writeHead(200);
res.write('hi'); // note lack of end()!
});
// The server will prevent itself from closing while the connection
// remains open (default no timeout). This will close the connection
// after 100ms so the test can finish.
server.setTimeout(100);

server.listen(0);
const p = port(server);

const response = await request(`${schemeName}://localhost:${p}`).agent(
scheme.agent({ keepAlive: true }),
);
// ensure we got the headers, etc.
expect(response.status).toBe(200);

server.close();
await a.event(server, 'close');

try {
await response.text();
} catch (e: any) {
expect(e.code).toMatch(/ECONNRESET/);
}
// ensure the expectation in the catch block is reached (+ the one above)
expect.assertions(2);
});
// This test specifically added for Node 20 fails for Node 14. Just going
// to skip it since we're dropping Node 14 soon anyway.
const node14 = !!process.version.match(/^v14\./);
(node14 ? it.skip : it)(
'with unfinished requests',
async () => {
const server = scheme.server(async (_req, res) => {
res.writeHead(200);
res.write('hi'); // note lack of end()!
});
// The server will prevent itself from closing while the connection
// remains open (default no timeout). This will close the connection
// after 100ms so the test can finish.
server.setTimeout(100);

server.listen(0);
const p = port(server);

const response = await request(
`${schemeName}://localhost:${p}`,
).agent(scheme.agent({ keepAlive: true }));
// ensure we got the headers, etc.
expect(response.status).toBe(200);

server.close();
await a.event(server, 'close');

try {
await response.text();
} catch (e: any) {
expect(e.code).toMatch(/ECONNRESET/);
}
// ensure the expectation in the catch block is reached (+ the one above)
expect.assertions(2);
},
35000,
);
});

describe('Stopper', function () {
Expand Down

0 comments on commit c7e0570

Please sign in to comment.