Skip to content

Commit f74a2ed

Browse files
committed
test: update to use sleep
1 parent e8631da commit f74a2ed

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/integration/retryable-writes/retryable_writes.spec.prose.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { once } from 'node:events';
44
import { expect } from 'chai';
55
import * as sinon from 'sinon';
66

7+
import { sleep } from '../../tools/utils';
8+
79
import {
810
Collection,
911
MongoClient,
@@ -322,9 +324,10 @@ describe('Retryable Writes Spec Prose', () => {
322324
});
323325

324326
const willBeCommandSucceeded = once(client, 'commandSucceeded').catch(error => error);
325-
const willBeCommandFailed = once(client, 'commandFailed', {
326-
signal: AbortSignal.timeout(1000)
327-
}).catch(error => error);
327+
const willBeCommandFailed = Promise.race([
328+
once(client, 'commandFailed'),
329+
sleep(1000).then(() => Promise.reject(new Error('timeout')))
330+
]).catch(error => error);
328331

329332
const insertResult = await collection.insertOne({ _id: 1 }).catch(error => error);
330333

@@ -335,7 +338,7 @@ describe('Retryable Writes Spec Prose', () => {
335338
expect(
336339
noCommandFailedEvent.message,
337340
'expected timeout, since no failure event should emit'
338-
).to.include('operation was aborted');
341+
).to.equal('timeout');
339342
expect(insertResult).to.deep.equal({ acknowledged: true, insertedId: 1 });
340343
}
341344
);

0 commit comments

Comments
 (0)