Skip to content

Commit e9134a7

Browse files
author
Idan Attias
committed
fix(MongoMemoryServer): change state to stopped when start fails
1 parent 3d57fed commit e9134a7

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ export class MongoMemoryServer extends EventEmitter {
277277
console.warn('Starting the instance failed, enable debug for more information');
278278
}
279279

280+
this.stateChange(MongoMemoryServerStates.stopped);
281+
280282
throw err;
281283
});
282284

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ describe('MongoMemoryServer', () => {
6363

6464
await expect(mongoServer.start()).rejects.toThrow('unknown error');
6565

66+
expect(mongoServer.state).toStrictEqual(MongoMemoryServerStates.stopped);
6667
expect(mongoServer._startUpInstance).toHaveBeenCalledTimes(1);
6768
expect(console.warn).toHaveBeenCalledTimes(1);
6869
});

0 commit comments

Comments
 (0)