@@ -6,7 +6,7 @@ import MongoMemoryReplSet, {
6
6
import { MongoClient , MongoServerError } from 'mongodb' ;
7
7
import MongoMemoryServer , { AutomaticAuth } from '../MongoMemoryServer' ;
8
8
import * as utils from '../util/utils' ;
9
- import { MongoMemoryInstanceOpts } from '../util/MongoInstance' ;
9
+ import MongoInstance , { MongoMemoryInstanceOpts } from '../util/MongoInstance' ;
10
10
import { ReplsetCountLowError , StateError , WaitForPrimaryTimeoutError } from '../util/errors' ;
11
11
import { assertIsError } from './testUtils/test_utils' ;
12
12
import * as debug from 'debug' ;
@@ -705,4 +705,23 @@ describe('MongoMemoryReplSet', () => {
705
705
706
706
await replSet . stop ( ) ;
707
707
} ) ;
708
+
709
+ it ( 'should transfer "launchTimeout" option to the MongoInstance' , async ( ) => {
710
+ jest . spyOn ( MongoInstance . prototype , 'start' ) . mockImplementation (
711
+ // @ts -expect-error This can work, because the instance is not used in the function that is tested here, beyond setting some extra options
712
+ ( ) => Promise . resolve ( { } )
713
+ ) ;
714
+
715
+ const replSet = new MongoMemoryReplSet ( { instanceOpts : [ { launchTimeout : 2000 } ] } ) ;
716
+
717
+ // @ts -expect-error "initAllServers" is protected
718
+ await replSet . initAllServers ( ) ;
719
+
720
+ // @ts -expect-error "_instanceInfo" is protected
721
+ const instanceInfo = replSet . servers [ 0 ] . _instanceInfo ;
722
+ expect ( instanceInfo ) . toBeDefined ( ) ;
723
+ utils . assertion ( ! utils . isNullOrUndefined ( instanceInfo ) ) ;
724
+ expect ( instanceInfo . instance ) . toBeDefined ( ) ;
725
+ expect ( instanceInfo ?. launchTimeout ) . toStrictEqual ( 2000 ) ;
726
+ } ) ;
708
727
} ) ;
0 commit comments