@@ -1013,6 +1013,7 @@ describe('Change Streams', function () {
1013
1013
const docs = [ { city : 'New York City' } , { city : 'Seattle' } , { city : 'Boston' } ] ;
1014
1014
await collection . insertMany ( docs ) ;
1015
1015
1016
+ await changeStreamIterator . next ( ) ;
1016
1017
await changeStreamIterator . return ( ) ;
1017
1018
expect ( changeStream . closed ) . to . be . true ;
1018
1019
expect ( changeStream . cursor . closed ) . to . be . true ;
@@ -1074,12 +1075,8 @@ describe('Change Streams', function () {
1074
1075
changeStream . on ( 'change' , sinon . stub ( ) ) ;
1075
1076
const changeStreamIterator = changeStream [ Symbol . asyncIterator ] ( ) ;
1076
1077
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 ) ;
1083
1080
}
1084
1081
) ;
1085
1082
@@ -2465,15 +2462,10 @@ describe('ChangeStream resumability', function () {
2465
2462
} as FailPoint ) ;
2466
2463
2467
2464
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 ) ;
2477
2469
}
2478
2470
) ;
2479
2471
} ) ;
0 commit comments