Skip to content

Commit 6061779

Browse files
committed
test: fix flaky change stream test
1 parent 84733ff commit 6061779

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

test/functional/change_stream.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,20 +1601,21 @@ describe('Change Streams', function() {
16011601
const collection = database.collection('MongoNetworkErrorTestPromises');
16021602
const changeStream = collection.watch(pipeline);
16031603

1604-
const outStream = fs.createWriteStream(filename);
1604+
const outStream = fs.createWriteStream(filename, { flags: 'w' });
16051605
this.defer(() => outStream.close());
16061606

1607-
changeStream.stream({ transform: JSON.stringify }).pipe(outStream);
1607+
changeStream
1608+
.stream({ transform: change => JSON.stringify(change) + '\n' })
1609+
.pipe(outStream);
16081610
this.defer(() => changeStream.close());
16091611
// Listen for changes to the file
16101612
const watcher = fs.watch(filename, eventType => {
16111613
this.defer(() => watcher.close());
16121614
expect(eventType).to.equal('change');
16131615

16141616
const fileContents = fs.readFileSync(filename, 'utf8');
1615-
const parsedFileContents = JSON.parse(fileContents);
1617+
const parsedFileContents = JSON.parse(fileContents.split(/\n/)[0]);
16161618
expect(parsedFileContents).to.have.nested.property('fullDocument.a', 1);
1617-
16181619
done();
16191620
});
16201621
});

test/tools/runner/config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ class NativeConfiguration {
8686
newClient(dbOptions, serverOptions) {
8787
// support MongoClient contructor form (url, options) for `newClient`
8888
if (typeof dbOptions === 'string') {
89-
return new MongoClient(
90-
dbOptions,
91-
Object.assign({}, this.unifiedOptions, this.tlsOptions, serverOptions)
92-
);
89+
return new MongoClient(dbOptions, Object.assign({}, this.unifiedOptions, serverOptions));
9390
}
9491

9592
dbOptions = dbOptions || {};

0 commit comments

Comments
 (0)