File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,16 +42,13 @@ BeforeAll(async function () {
4242} ) ;
4343
4444Before ( async function ( this : GdbWorld ) {
45- // DB cleanup for scenario isolation — drop collections to bypass server caching
45+ // DB cleanup for scenario isolation — delete documents but preserve collections/indexes
46+ // to avoid server-side inconsistencies caused by full collection drops
4647 const db = mongoClient . db ( ) ;
4748 const collections = await db . listCollections ( ) . toArray ( ) ;
4849 for ( const c of collections ) {
4950 if ( ! c . name . startsWith ( "system." ) ) {
50- await db . collection ( c . name ) . drop ( ) . catch ( ( err : Error & { code ?: number } ) => {
51- if ( err . code !== 26 && ! err . message . includes ( "ns not found" ) ) {
52- console . warn ( `Warning: failed to drop collection ${ c . name } : ${ err . message } ` ) ;
53- }
54- } ) ;
51+ await db . collection ( c . name ) . deleteMany ( { } ) ;
5552 }
5653 }
5754
You can’t perform that action at this time.
0 commit comments