@@ -8,7 +8,6 @@ import MongoMemoryServer, {
88} from '../MongoMemoryServer' ;
99import MongoInstance from '../util/MongoInstance' ;
1010import * as utils from '../util/utils' ;
11- import * as semver from 'semver' ;
1211import { EnsureInstanceError , StateError } from '../util/errors' ;
1312import { assertIsError } from './testUtils/test_utils' ;
1413import { promises as fspromises } from 'fs' ;
@@ -773,8 +772,7 @@ describe('MongoMemoryServer', () => {
773772 // "beforeAll" dosnt work here, thanks to the top-level "afterAll" hook
774773 beforeEach ( ( ) => {
775774 jest . spyOn ( utils , 'statPath' ) ;
776- // @ts -expect-error because "default" dosnt exist in the definitions
777- jest . spyOn ( semver . default , 'lt' ) ; // it needs to be ".default" otherwise "lt" is only an getter
775+ jest . spyOn ( utils , 'removeDir' ) ;
778776 } ) ;
779777
780778 afterEach ( async ( ) => {
@@ -795,7 +793,7 @@ describe('MongoMemoryServer', () => {
795793 await mongoServer . cleanup ( ) ;
796794
797795 expect ( utils . statPath ) . not . toHaveBeenCalled ( ) ;
798- expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
796+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
799797 expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
800798 expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
801799 expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -811,7 +809,7 @@ describe('MongoMemoryServer', () => {
811809 await mongoServer . cleanup ( true ) ;
812810
813811 expect ( utils . statPath ) . toHaveBeenCalledTimes ( 1 ) ;
814- expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
812+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
815813 expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
816814 expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
817815 expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -828,7 +826,7 @@ describe('MongoMemoryServer', () => {
828826 await mongoServer . cleanup ( true ) ;
829827
830828 expect ( utils . statPath ) . toHaveBeenCalledTimes ( 1 ) ;
831- expect ( semver . lt ) . toHaveBeenCalled ( ) ; // not testing on how many, because it would change with nodejs version
829+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
832830 expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
833831 expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
834832 expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -845,7 +843,7 @@ describe('MongoMemoryServer', () => {
845843 await mongoServer . stop ( { doCleanup : false } ) ;
846844 await mongoServer . cleanup ( ) ;
847845 expect ( utils . statPath ) . not . toHaveBeenCalled ( ) ;
848- expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
846+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
849847 expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
850848 expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
851849 expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -863,7 +861,7 @@ describe('MongoMemoryServer', () => {
863861 await mongoServer . stop ( { doCleanup : false } ) ;
864862 await mongoServer . cleanup ( { doCleanup : true , force : true } ) ;
865863 expect ( utils . statPath ) . toHaveBeenCalledTimes ( 1 ) ;
866- expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
864+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
867865 expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
868866 expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
869867 expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -882,7 +880,7 @@ describe('MongoMemoryServer', () => {
882880 await mongoServer . stop ( { doCleanup : false } ) ;
883881 await mongoServer . cleanup ( { doCleanup : true , force : true } ) ;
884882 expect ( utils . statPath ) . toHaveBeenCalledTimes ( 1 ) ;
885- expect ( semver . lt ) . toHaveBeenCalled ( ) ; // not testing on how many, because it would change with nodejs version
883+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
886884 expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
887885 expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
888886 expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
0 commit comments