1
1
/* eslint-disable @typescript-eslint/no-empty-function */
2
2
import { expect } from 'chai' ;
3
3
4
+ import { type Collection , type FindCursor , type MongoClient } from '../../mongodb' ;
4
5
import { type TestConfiguration } from '../../tools/runner/config' ;
5
6
import { runScriptAndGetProcessInfo } from './resource_tracking_script_builder' ;
6
7
@@ -699,16 +700,24 @@ describe('MongoClient.close() Integration', () => {
699
700
700
701
describe ( 'Server resource: Cursor' , ( ) => {
701
702
describe ( 'after cursors are created' , ( ) => {
702
- let client ;
703
- let coll ;
704
- let cursor ;
705
- let utilClient ;
703
+ let client : MongoClient ;
704
+ let coll : Collection ;
705
+ let cursor : FindCursor ;
706
+ let utilClient : MongoClient ;
706
707
707
708
beforeEach ( async function ( ) {
708
709
client = this . configuration . newClient ( ) ;
709
710
utilClient = this . configuration . newClient ( ) ;
710
711
await client . connect ( ) ;
711
- coll = await client . db ( 'db' ) . collection ( 'coll' , { capped : true , size : 1_000_000 } ) ;
712
+ await client
713
+ . db ( 'db' )
714
+ . collection ( 'coll' )
715
+ ?. drop ( )
716
+ . catch ( ( ) => null ) ;
717
+ coll = await client
718
+ . db ( 'db' )
719
+ . createCollection ( 'coll' , { capped : true , size : 1_000 , max : 4 } ) ;
720
+ await coll . insertMany ( [ { a : 1 } , { b : 2 } , { c : 3 } ] ) ;
712
721
} ) ;
713
722
714
723
afterEach ( async function ( ) {
@@ -717,7 +726,7 @@ describe('MongoClient.close() Integration', () => {
717
726
await cursor ?. close ( ) ;
718
727
} ) ;
719
728
720
- it . skip ( 'all active server-side cursors are closed by client.close()' , async function ( ) {
729
+ it ( 'all active server-side cursors are closed by client.close()' , async function ( ) {
721
730
const getCursors = async ( ) => {
722
731
const res = await utilClient
723
732
. db ( )
@@ -732,8 +741,7 @@ describe('MongoClient.close() Integration', () => {
732
741
) ;
733
742
} ;
734
743
735
- await coll . insertMany ( [ { a : 1 } , { b : 2 } , { c : 3 } ] ) ;
736
- cursor = await coll . find (
744
+ cursor = coll . find (
737
745
{ } ,
738
746
{
739
747
tailable : true ,
0 commit comments