Skip to content

Commit 171f1fb

Browse files
committed
fix(MongoMemoryServer): change options instead of creating new instance for auth creation
1 parent 2563fcc commit 171f1fb

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

packages/mongodb-memory-server-core/src/MongoMemoryServer.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export class MongoMemoryServer extends EventEmitter {
402402
);
403403

404404
// After that startup MongoDB instance
405-
let instance = await MongoInstance.create(mongodOptions);
405+
const instance = await MongoInstance.create(mongodOptions);
406406
log('_startUpInstance: Instance Started');
407407

408408
// another "isNullOrUndefined" because otherwise typescript complains about "this.auth" possibly being not defined
@@ -414,15 +414,9 @@ export class MongoMemoryServer extends EventEmitter {
414414
log('_startUpInstance: Killing No-Auth instance');
415415
await instance.stop();
416416

417-
// TODO: change this to just change the options instead of an new instance after adding getters & setters
418417
log('_startUpInstance: Starting Auth Instance');
419-
instance = await MongoInstance.create({
420-
...mongodOptions,
421-
instance: {
422-
...mongodOptions.instance,
423-
auth: true,
424-
},
425-
});
418+
instance.instanceOpts.auth = true;
419+
await instance.start();
426420
} else {
427421
console.warn(
428422
'Not Restarting MongoInstance for Auth\n' +

0 commit comments

Comments
 (0)