Skip to content

Commit cc7b286

Browse files
committed
Drop various old Node test workarounds & skips
This also notably ensures a few tests that were skipped in browsers previously are properly covered, now that we can know what the behaviour will be even without knowing the Node version.
1 parent 83e8a1f commit cc7b286

File tree

5 files changed

+8
-38
lines changed

5 files changed

+8
-38
lines changed

test/integration/form-data.spec.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {
33
expect,
44
File,
55
fetch as fetchPolyfill,
6-
NATIVE_FETCH_SUPPORTED,
7-
nodeSatisfies
6+
nodeSatisfies,
7+
isNode
88
} from "../test-utils";
99

1010
const fetch = globalThis.fetch ?? fetchPolyfill;
@@ -63,11 +63,6 @@ describe("Body getXFormData methods", () => {
6363
});
6464

6565
describe("given multipart/form-data", () => {
66-
before(function () {
67-
// Polyfill fetch encodes polyfill FormData into "[object FormData]", which is not parsable
68-
if (!nodeSatisfies(NATIVE_FETCH_SUPPORTED)) this.skip();
69-
});
70-
7166
it("should automatically parse as form data", async () => {
7267
const endpoint = await server.forPost("/mocked-endpoint").thenReply(200);
7368

test/integration/handlers/broken-response.spec.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
openRawTlsSocket,
1111
http2ProxyRequest,
1212
nodeSatisfies,
13-
SOCKET_RESET_SUPPORTED,
1413
BROKEN_H1_OVER_H2_TUNNELLING
1514
} from "../../test-utils";
1615

@@ -33,14 +32,12 @@ describe("Broken response handlers", function () {
3332
});
3433

3534
it("should allow forcibly resetting the connection", async function () {
36-
if (!nodeSatisfies(SOCKET_RESET_SUPPORTED)) this.skip();
37-
3835
await server.forGet('/mocked-endpoint').thenResetConnection();
3936

4037
let result = await fetch(server.urlFor('/mocked-endpoint')).catch(e => e);
4138

4239
expect(result).to.be.instanceof(Error);
43-
expect(result.message).to.contain('read ECONNRESET');
40+
expect(result.message).to.contain(isNode ? 'read ECONNRESET' : 'Failed to fetch');
4441
});
4542

4643

@@ -71,8 +68,6 @@ describe("Broken response handlers", function () {
7168

7269
nodeOnly(() => {
7370
it("should allow forcibly closing proxied connections", async function () {
74-
if (!nodeSatisfies(SOCKET_RESET_SUPPORTED)) this.skip();
75-
7671
await server.forGet('example.com').thenResetConnection();
7772

7873
const tunnel = await openRawTlsSocket(server);
@@ -93,8 +88,6 @@ describe("Broken response handlers", function () {
9388
});
9489

9590
it("should allow forcibly closing h2-over-h2 proxy connections", async function () {
96-
if (!nodeSatisfies(SOCKET_RESET_SUPPORTED)) this.skip();
97-
9891
await server.forGet('example.com').thenResetConnection();
9992

10093
const response: any = await http2ProxyRequest(server, `https://example.com`)
@@ -107,7 +100,6 @@ describe("Broken response handlers", function () {
107100
});
108101

109102
it("should allow forcibly closing h1.1-over-h2 proxy connections", async function () {
110-
if (!nodeSatisfies(SOCKET_RESET_SUPPORTED)) this.skip();
111103
if (nodeSatisfies(BROKEN_H1_OVER_H2_TUNNELLING)) this.skip();
112104

113105
await server.forGet('example.com').thenResetConnection();

test/integration/https.spec.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {
1212
openRawSocket,
1313
openRawTlsSocket,
1414
http2ProxyRequest,
15-
nodeSatisfies,
16-
DETAILED_TLS_ERROR_CODES
15+
nodeSatisfies
1716
} from "../test-utils";
1817
import { streamToBuffer } from '../../src/util/buffer-utils';
1918

@@ -451,11 +450,7 @@ describe("When configured for HTTPS", () => {
451450
});
452451
throw new Error('Expected connection to fail');
453452
} catch (e: any) {
454-
expect(e.code).to.equal(
455-
nodeSatisfies(DETAILED_TLS_ERROR_CODES)
456-
? 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION'
457-
: 'ECONNRESET'
458-
);
453+
expect(e.code).to.equal('ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION');
459454
}
460455
});
461456

@@ -468,11 +463,7 @@ describe("When configured for HTTPS", () => {
468463
});
469464
throw new Error('Expected connection to fail');
470465
} catch (e: any) {
471-
expect(e.code).to.equal(
472-
nodeSatisfies(DETAILED_TLS_ERROR_CODES)
473-
? 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION'
474-
: 'ECONNRESET'
475-
);
466+
expect(e.code).to.equal('ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION');
476467
}
477468
});
478469

test/integration/proxying/https-proxying.spec.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import {
1515
makeDestroyable,
1616
DestroyableServer,
1717
ignoreNetworkError,
18-
nodeSatisfies,
19-
SOCKET_RESET_SUPPORTED
18+
nodeSatisfies
2019
} from "../../test-utils";
2120
import { CA } from "../../../src/util/tls";
2221
import { streamToBuffer } from "../../../src/util/buffer-utils";
@@ -368,11 +367,7 @@ nodeOnly(() => {
368367
}).catch(e => e);
369368

370369
expect(result).to.be.instanceof(Error);
371-
if (nodeSatisfies(SOCKET_RESET_SUPPORTED)) {
372-
expect((result as any).message).to.include('ECONNRESET');
373-
} else {
374-
expect((result as any).message).to.include('socket hang up');
375-
}
370+
expect((result as any).message).to.include('ECONNRESET');
376371
});
377372

378373
it("should tag failed requests", async () => {

test/test-utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,6 @@ export async function startDnsServer(callback: (question: dns2.DnsQuestion) => s
301301
export const nodeSatisfies = (range: string) =>
302302
isNode && semver.satisfies(process.version, range);
303303

304-
export const DETAILED_TLS_ERROR_CODES = ">=18";
305-
export const NATIVE_FETCH_SUPPORTED = ">=18";
306-
export const SOCKET_RESET_SUPPORTED = ">=18.3";
307304
export const BROKEN_H1_OVER_H2_TUNNELLING = "^18.8";
308305
export const DEFAULT_KEEP_ALIVE = ">=19";
309306
export const FIXED_KEEP_ALIVE_BEHAVIOUR = ">=20";

0 commit comments

Comments
 (0)