@@ -8,7 +8,6 @@ import MongoMemoryServer, {
8
8
} from '../MongoMemoryServer' ;
9
9
import MongoInstance from '../util/MongoInstance' ;
10
10
import * as utils from '../util/utils' ;
11
- import * as semver from 'semver' ;
12
11
import { EnsureInstanceError , StateError } from '../util/errors' ;
13
12
import { assertIsError } from './testUtils/test_utils' ;
14
13
import { promises as fspromises } from 'fs' ;
@@ -773,8 +772,7 @@ describe('MongoMemoryServer', () => {
773
772
// "beforeAll" dosnt work here, thanks to the top-level "afterAll" hook
774
773
beforeEach ( ( ) => {
775
774
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' ) ;
778
776
} ) ;
779
777
780
778
afterEach ( async ( ) => {
@@ -795,7 +793,7 @@ describe('MongoMemoryServer', () => {
795
793
await mongoServer . cleanup ( ) ;
796
794
797
795
expect ( utils . statPath ) . not . toHaveBeenCalled ( ) ;
798
- expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
796
+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
799
797
expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
800
798
expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
801
799
expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -811,7 +809,7 @@ describe('MongoMemoryServer', () => {
811
809
await mongoServer . cleanup ( true ) ;
812
810
813
811
expect ( utils . statPath ) . toHaveBeenCalledTimes ( 1 ) ;
814
- expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
812
+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
815
813
expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
816
814
expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
817
815
expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -828,7 +826,7 @@ describe('MongoMemoryServer', () => {
828
826
await mongoServer . cleanup ( true ) ;
829
827
830
828
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 ( ) ;
832
830
expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
833
831
expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
834
832
expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -845,7 +843,7 @@ describe('MongoMemoryServer', () => {
845
843
await mongoServer . stop ( { doCleanup : false } ) ;
846
844
await mongoServer . cleanup ( ) ;
847
845
expect ( utils . statPath ) . not . toHaveBeenCalled ( ) ;
848
- expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
846
+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
849
847
expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
850
848
expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
851
849
expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -863,7 +861,7 @@ describe('MongoMemoryServer', () => {
863
861
await mongoServer . stop ( { doCleanup : false } ) ;
864
862
await mongoServer . cleanup ( { doCleanup : true , force : true } ) ;
865
863
expect ( utils . statPath ) . toHaveBeenCalledTimes ( 1 ) ;
866
- expect ( semver . lt ) . not . toHaveBeenCalled ( ) ;
864
+ expect ( utils . removeDir ) . toHaveBeenCalled ( ) ;
867
865
expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
868
866
expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
869
867
expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
@@ -882,7 +880,7 @@ describe('MongoMemoryServer', () => {
882
880
await mongoServer . stop ( { doCleanup : false } ) ;
883
881
await mongoServer . cleanup ( { doCleanup : true , force : true } ) ;
884
882
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 ( ) ;
886
884
expect ( await utils . statPath ( dbPath ) ) . toBeUndefined ( ) ;
887
885
expect ( mongoServer . state ) . toEqual ( MongoMemoryServerStates . new ) ;
888
886
expect ( mongoServer . instanceInfo ) . toBeUndefined ( ) ;
0 commit comments