11/* eslint-disable @typescript-eslint/no-non-null-assertion */
2- import { promises as fspromises } from 'fs' ;
32import { MongoClient } from 'mongodb' ;
43import * as tmp from 'tmp' ;
54import MongoMemoryServer , {
@@ -461,7 +460,7 @@ describe('MongoMemoryServer', () => {
461460 describe ( 'cleanup()' , ( ) => {
462461 // "beforeAll" dosnt work here, thanks to the top-level "afterAll" hook
463462 beforeEach ( ( ) => {
464- jest . spyOn ( fspromises , 'stat ' ) ;
463+ jest . spyOn ( utils , 'statPath ' ) ;
465464 // @ts -expect-error because "default" dosnt exist in the definitions
466465 jest . spyOn ( semver . default , 'lt' ) ; // it needs to be ".default" otherwise "lt" is only an getter
467466 } ) ;
@@ -471,7 +470,7 @@ describe('MongoMemoryServer', () => {
471470 const dbPath = mongoServer . instanceInfo ! . dbPath ;
472471 await mongoServer . stop ( false ) ;
473472 await mongoServer . cleanup ( ) ;
474- expect ( fspromises . stat ) . not . toHaveBeenCalled ( ) ;
473+ expect ( utils . statPath ) . toHaveBeenCalledTimes ( 0 ) ;
475474 expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
476475 expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
477476 expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
@@ -483,7 +482,7 @@ describe('MongoMemoryServer', () => {
483482 const dbPath = mongoServer . instanceInfo ! . dbPath ;
484483 await mongoServer . stop ( false ) ;
485484 await mongoServer . cleanup ( true ) ;
486- expect ( fspromises . stat ) . toHaveBeenCalledTimes ( 1 ) ;
485+ expect ( utils . statPath ) . toHaveBeenCalledTimes ( 1 ) ;
487486 expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
488487 expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
489488 expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
@@ -496,7 +495,7 @@ describe('MongoMemoryServer', () => {
496495 const dbPath = mongoServer . instanceInfo ! . dbPath ;
497496 await mongoServer . stop ( false ) ;
498497 await mongoServer . cleanup ( true ) ;
499- expect ( fspromises . stat ) . toHaveBeenCalledTimes ( 1 ) ;
498+ expect ( utils . statPath ) . toHaveBeenCalledTimes ( 1 ) ;
500499 expect ( semver . lt ) . toHaveBeenCalledTimes ( 1 ) ;
501500 expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
502501 expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
0 commit comments