Skip to content

Commit

Permalink
chore: better skipping of failing unit tests on NOde18+
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Mar 29, 2024
1 parent f8d9c7c commit 5321999
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import * as dns from 'dns';
import { once } from 'events';
import { coerce } from 'semver';
import { satisfies } from 'semver';
import * as sinon from 'sinon';

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

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

if (test.skipReason) this.skip();
});
Expand Down
5 changes: 2 additions & 3 deletions test/unit/connection_string.spec.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { coerce } from 'semver';
import { satisfies } from 'semver';

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

const { major } = coerce(process.version);
const skippedTests = [
'Invalid port (zero) with IP literal',
'Invalid port (zero) with hostname'
];
test.skipReason =
major === 20 && skippedTests.includes(test.title)
satisfies(process.version, '>=20.0.0') && skippedTests.includes(test.title)
? 'TODO(NODE-5666): fix failing unit tests on Node18'
: undefined;

Expand Down
5 changes: 2 additions & 3 deletions test/unit/sdam/monitor.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as net from 'node:net';

import { expect } from 'chai';
import { coerce } from 'semver';
import { satisfies } from 'semver';
import * as sinon from 'sinon';
import { setTimeout } from 'timers';

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

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

Expand Down
10 changes: 4 additions & 6 deletions test/unit/sdam/topology.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai';
import { once } from 'events';
import * as net from 'net';
import { type AddressInfo } from 'net';
import { coerce, type SemVer } from 'semver';
import { satisfies } from 'semver';
import * as sinon from 'sinon';
import { clearTimeout } from 'timers';

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

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

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

Expand Down

0 comments on commit 5321999

Please sign in to comment.