File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -1601,20 +1601,21 @@ describe('Change Streams', function() {
1601
1601
const collection = database . collection ( 'MongoNetworkErrorTestPromises' ) ;
1602
1602
const changeStream = collection . watch ( pipeline ) ;
1603
1603
1604
- const outStream = fs . createWriteStream ( filename ) ;
1604
+ const outStream = fs . createWriteStream ( filename , { flags : 'w' } ) ;
1605
1605
this . defer ( ( ) => outStream . close ( ) ) ;
1606
1606
1607
- changeStream . stream ( { transform : JSON . stringify } ) . pipe ( outStream ) ;
1607
+ changeStream
1608
+ . stream ( { transform : change => JSON . stringify ( change ) + '\n' } )
1609
+ . pipe ( outStream ) ;
1608
1610
this . defer ( ( ) => changeStream . close ( ) ) ;
1609
1611
// Listen for changes to the file
1610
1612
const watcher = fs . watch ( filename , eventType => {
1611
1613
this . defer ( ( ) => watcher . close ( ) ) ;
1612
1614
expect ( eventType ) . to . equal ( 'change' ) ;
1613
1615
1614
1616
const fileContents = fs . readFileSync ( filename , 'utf8' ) ;
1615
- const parsedFileContents = JSON . parse ( fileContents ) ;
1617
+ const parsedFileContents = JSON . parse ( fileContents . split ( / \n / ) [ 0 ] ) ;
1616
1618
expect ( parsedFileContents ) . to . have . nested . property ( 'fullDocument.a' , 1 ) ;
1617
-
1618
1619
done ( ) ;
1619
1620
} ) ;
1620
1621
} ) ;
You can’t perform that action at this time.
0 commit comments