@@ -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
@@ -2406,15 +2403,10 @@ describe('ChangeStream resumability', function () {
2406
2403
} as FailPoint ) ;
2407
2404
2408
2405
await collection . insertOne ( { city : 'New York City' } ) ;
2409
- try {
2410
- await changeStreamIterator . next ( ) ;
2411
- expect . fail (
2412
- 'Change stream did not throw unresumable error and did not produce any events'
2413
- ) ;
2414
- } catch ( error ) {
2415
- expect ( error ) . to . be . instanceOf ( MongoServerError ) ;
2416
- expect ( aggregateEvents ) . to . have . lengthOf ( 1 ) ;
2417
- }
2406
+
2407
+ const error = await changeStreamIterator . next ( ) . catch ( e => e ) ;
2408
+ expect ( error ) . to . be . instanceOf ( MongoServerError ) ;
2409
+ expect ( aggregateEvents ) . to . have . lengthOf ( 1 ) ;
2418
2410
}
2419
2411
) ;
2420
2412
} ) ;
0 commit comments