@@ -29,6 +29,9 @@ describe('Changestream Examples', function() {
2929 if ( err ) return console . log ( err ) ;
3030 expect ( err ) . to . equal ( null ) ;
3131 expect ( next ) . to . exist ;
32+
33+ // Since changeStream has an implicit seession,
34+ // we need to close the changeStream for unit testing purposes
3235 changeStream . close ( ) ;
3336 client . close ( ) ;
3437 done ( ) ;
@@ -67,6 +70,9 @@ describe('Changestream Examples', function() {
6770 const changeStream = collection . watch ( ) ;
6871 changeStream . on ( 'change' , function ( change ) {
6972 expect ( change ) . to . exist ;
73+
74+ // Since changeStream has an implicit seession,
75+ // we need to close the changeStream for unit testing purposes
7076 changeStream . close ( ) ;
7177 client . close ( ) ;
7278 done ( ) ;
@@ -102,6 +108,9 @@ describe('Changestream Examples', function() {
102108
103109 changeStream . stream ( { transform : JSON . stringify } ) . once ( 'data' , function ( chunk ) {
104110 expect ( chunk ) . to . exist ;
111+
112+ // Since changeStream has an implicit seession,
113+ // we need to close the changeStream for unit testing purposes
105114 changeStream . close ( ) ;
106115 client . close ( ) ;
107116 done ( ) ;
@@ -138,6 +147,9 @@ describe('Changestream Examples', function() {
138147 const changeStream = collection . watch ( { fullDocument : 'updateLookup' } ) ;
139148 changeStream . on ( 'change' , function ( change ) {
140149 expect ( change ) . to . exist ;
150+
151+ // Since changeStream has an implicit seession,
152+ // we need to close the changeStream for unit testing purposes
141153 changeStream . close ( ) ;
142154 client . close ( ) ;
143155 done ( ) ;
@@ -196,6 +208,9 @@ describe('Changestream Examples', function() {
196208 if ( err ) return console . log ( err ) ;
197209 expect ( err ) . to . equal ( null ) ;
198210 expect ( next ) . to . exist ;
211+
212+ // Since changeStream has an implicit seession,
213+ // we need to close the changeStream for unit testing purposes
199214 newChangeStream . close ( ) ;
200215 client . close ( ) ;
201216 done ( ) ;
@@ -245,6 +260,8 @@ describe('Changestream Examples', function() {
245260 expect ( next . newField ) . to . exist ;
246261 expect ( next . newField ) . to . equal ( 'this is an added field!' ) ;
247262
263+ // Since changeStream has an implicit seession,
264+ // we need to close the changeStream for unit testing purposes
248265 changeStream . close ( ) ;
249266 client . close ( ) ;
250267 done ( ) ;
0 commit comments