@@ -6,7 +6,7 @@ import MongoMemoryReplSet, {
66import { MongoClient , MongoServerError } from 'mongodb' ;
77import MongoMemoryServer , { AutomaticAuth } from '../MongoMemoryServer' ;
88import * as utils from '../util/utils' ;
9- import { MongoMemoryInstanceOpts } from '../util/MongoInstance' ;
9+ import MongoInstance , { MongoMemoryInstanceOpts } from '../util/MongoInstance' ;
1010import { ReplsetCountLowError , StateError , WaitForPrimaryTimeoutError } from '../util/errors' ;
1111import { assertIsError } from './testUtils/test_utils' ;
1212import * as debug from 'debug' ;
@@ -705,4 +705,23 @@ describe('MongoMemoryReplSet', () => {
705705
706706 await replSet . stop ( ) ;
707707 } ) ;
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+ } ) ;
708727} ) ;
0 commit comments