@@ -1013,6 +1013,7 @@ describe('Change Streams', function () {
10131013 const docs = [ { city : 'New York City' } , { city : 'Seattle' } , { city : 'Boston' } ] ;
10141014 await collection . insertMany ( docs ) ;
10151015
1016+ await changeStreamIterator . next ( ) ;
10161017 await changeStreamIterator . return ( ) ;
10171018 expect ( changeStream . closed ) . to . be . true ;
10181019 expect ( changeStream . cursor . closed ) . to . be . true ;
@@ -1074,12 +1075,8 @@ describe('Change Streams', function () {
10741075 changeStream . on ( 'change' , sinon . stub ( ) ) ;
10751076 const changeStreamIterator = changeStream [ Symbol . asyncIterator ] ( ) ;
10761077
1077- try {
1078- await changeStreamIterator . next ( ) ;
1079- expect . fail ( 'Async iterator was used with emitter-based iteration' ) ;
1080- } catch ( error ) {
1081- expect ( error ) . to . be . instanceOf ( MongoAPIError ) ;
1082- }
1078+ const error = await changeStreamIterator . next ( ) . catch ( e => e ) ;
1079+ expect ( error ) . to . be . instanceOf ( MongoAPIError ) ;
10831080 }
10841081 ) ;
10851082
@@ -2465,15 +2462,10 @@ describe('ChangeStream resumability', function () {
24652462 } as FailPoint ) ;
24662463
24672464 await collection . insertOne ( { city : 'New York City' } ) ;
2468- try {
2469- await changeStreamIterator . next ( ) ;
2470- expect . fail (
2471- 'Change stream did not throw unresumable error and did not produce any events'
2472- ) ;
2473- } catch ( error ) {
2474- expect ( error ) . to . be . instanceOf ( MongoServerError ) ;
2475- expect ( aggregateEvents ) . to . have . lengthOf ( 1 ) ;
2476- }
2465+
2466+ const error = await changeStreamIterator . next ( ) . catch ( e => e ) ;
2467+ expect ( error ) . to . be . instanceOf ( MongoServerError ) ;
2468+ expect ( aggregateEvents ) . to . have . lengthOf ( 1 ) ;
24772469 }
24782470 ) ;
24792471 } ) ;
0 commit comments