Skip to content

Commit 5321999

Browse files
chore: better skipping of failing unit tests on NOde18+
1 parent f8d9c7c commit 5321999

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

test/unit/assorted/polling_srv_records_for_mongos_discovery.prose.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from 'chai';
22
import * as dns from 'dns';
33
import { once } from 'events';
4-
import { coerce } from 'semver';
4+
import { satisfies } from 'semver';
55
import * as sinon from 'sinon';
66

77
import {
@@ -51,11 +51,9 @@ describe('Polling Srv Records for Mongos Discovery', () => {
5151
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
5252
const test = this.currentTest!;
5353

54-
const { major } = coerce(process.version);
55-
test.skipReason =
56-
major === 18 || major === 20
57-
? 'TODO(NODE-5666): fix failing unit tests on Node18'
58-
: undefined;
54+
test.skipReason = satisfies(process.version, '>=18.0.0')
55+
? `TODO(NODE-5666): fix failing unit tests on Node18 (Running with Nodejs ${process.version})`
56+
: undefined;
5957

6058
if (test.skipReason) this.skip();
6159
});

test/unit/connection_string.spec.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { coerce } from 'semver';
1+
import { satisfies } from 'semver';
22

33
import { loadSpecTests } from '../spec';
44
import { executeUriValidationTest } from '../tools/uri_spec_runner';
@@ -15,13 +15,12 @@ describe('Connection String spec tests', function () {
1515
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1616
const test = this.currentTest!;
1717

18-
const { major } = coerce(process.version);
1918
const skippedTests = [
2019
'Invalid port (zero) with IP literal',
2120
'Invalid port (zero) with hostname'
2221
];
2322
test.skipReason =
24-
major === 20 && skippedTests.includes(test.title)
23+
satisfies(process.version, '>=20.0.0') && skippedTests.includes(test.title)
2524
? 'TODO(NODE-5666): fix failing unit tests on Node18'
2625
: undefined;
2726

test/unit/sdam/monitor.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as net from 'node:net';
22

33
import { expect } from 'chai';
4-
import { coerce } from 'semver';
4+
import { satisfies } from 'semver';
55
import * as sinon from 'sinon';
66
import { setTimeout } from 'timers';
77

@@ -49,7 +49,6 @@ describe('monitoring', function () {
4949
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
5050
const test = this.currentTest!;
5151

52-
const { major } = coerce(process.version);
5352
const failingTests = [
5453
'should connect and issue an initial server check',
5554
'should ignore attempts to connect when not already closed',
@@ -58,7 +57,7 @@ describe('monitoring', function () {
5857
'should upgrade to hello from legacy hello when initial handshake contains helloOk'
5958
];
6059
test.skipReason =
61-
(major === 18 || major === 20) && failingTests.includes(test.title)
60+
satisfies(process.version, '>=18.0.0') && failingTests.includes(test.title)
6261
? 'TODO(NODE-5666): fix failing unit tests on Node18'
6362
: undefined;
6463

test/unit/sdam/topology.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22
import { once } from 'events';
33
import * as net from 'net';
44
import { type AddressInfo } from 'net';
5-
import { coerce, type SemVer } from 'semver';
5+
import { satisfies } from 'semver';
66
import * as sinon from 'sinon';
77
import { clearTimeout } from 'timers';
88

@@ -284,11 +284,9 @@ describe('Topology (unit)', function () {
284284
it('should encounter a server selection timeout on garbled server responses', function () {
285285
const test = this.test;
286286

287-
const { major } = coerce(process.version) as SemVer;
288-
test.skipReason =
289-
major === 18 || major === 20
290-
? 'TODO(NODE-5666): fix failing unit tests on Node18'
291-
: undefined;
287+
test.skipReason = satisfies(process.version, '>=18.0.0')
288+
? 'TODO(NODE-5666): fix failing unit tests on Node18'
289+
: undefined;
292290

293291
if (test.skipReason) this.skip();
294292

0 commit comments

Comments
 (0)