Skip to content

Commit 7dad465

Browse files
committed
feat(NODE-7441): add comment about write concern usage in tests
1 parent 4bbdf20 commit 7dad465

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

test/integration/change-streams/change_stream.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,12 @@ describe('Change Streams', function () {
11681168
});
11691169
});
11701170

1171+
// Note that `insertOne` in these tests is called with write concern `{ w: 'majority' }`.
1172+
// This is to avoid eventual consistency issues that make these tests brittle.
1173+
// A change stream won't see the new documents until they are persisted in the oplog and
1174+
// some MongoDB server versions (4.2-) used for testing default to write concern `{ w: 1 }`.
1175+
// Using write concern `{ w: 'majority' }` ensures that the new documents are persisted in
1176+
// the oplog when the `insertOne` promise resolves, making these tests more reliable.
11711177
describe('#bufferedCount()', function () {
11721178
it(
11731179
'should return 0 before starting to consume the change stream (empty collection)',

0 commit comments

Comments
 (0)