Skip to content

Commit 0123b5a

Browse files
committed
test(NODE-5295): reduce error message match strictness
1 parent abbe61a commit 0123b5a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/integration/client-side-encryption/client_side_encryption.prose.test.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,11 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
11781178
.to.be.instanceOf(Error)
11791179
.to.have.property('name', 'MongoServerSelectionError');
11801180

1181-
expect(insertError).to.match(/connect ECONNREFUSED 127.0.0.1:27021/);
1181+
expect(insertError, 'Error must contain ECONNREFUSED').to.satisfy(
1182+
error =>
1183+
/ECONNREFUSED/.test(error.message) ||
1184+
error.cause.cause.errors.every(e => e.code === 'ECONNREFUSED')
1185+
);
11821186

11831187
expect(insertError).not.to.be.instanceOf(
11841188
MongoServerSelectionError,
@@ -1270,9 +1274,16 @@ TODO(NODE-5283): The error thrown in this test fails an instanceof check with Mo
12701274
client = new MongoClient('mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000');
12711275
const error = await client.connect().catch(e => e);
12721276

1273-
expect(error)
1277+
expect(
1278+
error,
1279+
'Error MUST be a MongoServerSelectionError error that contains ECONNREFUSED information'
1280+
)
12741281
.to.be.instanceOf(MongoServerSelectionError)
1275-
.to.match(/connect ECONNREFUSED 127.0.0.1:27021/);
1282+
.that.satisfies(
1283+
error =>
1284+
/ECONNREFUSED/.test(error.message) ||
1285+
error.cause.cause.errors.every(e => e.code === 'ECONNREFUSED')
1286+
);
12761287
});
12771288
});
12781289

0 commit comments

Comments
 (0)