@@ -1831,9 +1831,22 @@ describe('Change Streams', function () {
18311831 } ) ;
18321832
18331833 describe ( "NODE-4763 - doesn't produce duplicates after resume" , function ( ) {
1834+ let client : MongoClient ;
1835+ let collection : Collection ;
1836+ let changeStream : ChangeStream ;
1837+ let aggregateEvents : CommandStartedEvent [ ] = [ ] ;
18341838 const resumableError = { code : 6 , message : 'host unreachable' } ;
18351839
18361840 beforeEach ( async function ( ) {
1841+ const dbName = 'node-4763' ;
1842+ const collectionName = 'test-collection' ;
1843+
1844+ client = this . configuration . newClient ( { monitorCommands : true } ) ;
1845+ client . on ( 'commandStarted' , filterForCommands ( [ 'aggregate' ] , aggregateEvents ) ) ;
1846+ collection = client . db ( dbName ) . collection ( collectionName ) ;
1847+
1848+ changeStream = collection . watch ( [ ] ) ;
1849+
18371850 await client . db ( 'admin' ) . command ( {
18381851 configureFailPoint : is4_2Server ( this . configuration . version )
18391852 ? 'failCommand'
@@ -1844,7 +1857,7 @@ describe('Change Streams', function () {
18441857 errorCode : resumableError . code ,
18451858 errmsg : resumableError . message
18461859 }
1847- } as FailPoint ) ;
1860+ } as FailCommandFailPoint ) ;
18481861 } ) ;
18491862
18501863 afterEach ( async function ( ) {
@@ -1853,7 +1866,11 @@ describe('Change Streams', function () {
18531866 ? 'failCommand'
18541867 : 'failGetMoreAfterCursorCheckout' ,
18551868 mode : 'off'
1856- } as FailPoint ) ;
1869+ } as FailCommandFailPoint ) ;
1870+
1871+ await changeStream . close ( ) ;
1872+ await client . close ( ) ;
1873+ aggregateEvents = [ ] ;
18571874 } ) ;
18581875
18591876 describe ( 'when using iterator form' , function ( ) {
@@ -1873,6 +1890,8 @@ describe('Change Streams', function () {
18731890 operationType : 'insert' ,
18741891 fullDocument : { a : 2 }
18751892 } ) ;
1893+
1894+ expect ( aggregateEvents . length ) . to . equal ( 2 ) ;
18761895 } ) ;
18771896
18781897 it ( '#tryNext' , { requires : { topology : 'replicaset' } } , async function test ( ) {
@@ -1891,6 +1910,8 @@ describe('Change Streams', function () {
18911910 operationType : 'insert' ,
18921911 fullDocument : { a : 2 }
18931912 } ) ;
1913+
1914+ expect ( aggregateEvents . length ) . to . equal ( 2 ) ;
18941915 } ) ;
18951916 } ) ;
18961917
@@ -1911,6 +1932,8 @@ describe('Change Streams', function () {
19111932 operationType : 'insert' ,
19121933 fullDocument : { a : 2 }
19131934 } ) ;
1935+
1936+ expect ( aggregateEvents . length ) . to . equal ( 2 ) ;
19141937 } ) ;
19151938 } ) ;
19161939} ) ;
0 commit comments