"MongoMemoryReplSet" in "jest" gives open handle error
See original GitHub issueIf I close the client & await replSet.stop()
, jest spits out an error:
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
If I don’t use a replset, then it works.
describe('MyTests', () => {
let replSet: MongoMemoryReplSet;
let client: MongoClient;
beforeAll(async () => {
replSet = new MongoMemoryReplSet({
binary: {
version: '4.0.5'
},
instanceOpts: [{
storageEngine: 'wiredTiger'
}],
autoStart: true,
debug: true
});
await replSet.waitUntilRunning();
// ... connect to client, etc
});
afterAll(async () => {
await client.close();
await replSet.stop();
});
// ...
});
If I replace the above with just a single mongo server and stop it, it works.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:20
Top Results From Across the Web
MongoMemoryReplSet from mongodb-memory-server with ...
Running the test file throws following error: Jest did not exit one second after the test run has completed. This usually means that...
Read more >"MongoMemoryReplSet" in "jest" gives open handle error
If I close the client & await replSet.stop() , jest spits out an error: Jest did not exit one second after the test...
Read more >mongodb-memory-server-global-4.0 | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Need help, code seems right but still getting error when i test ...
and here is the error from the test :- > server@1.0.0 test > jest --passWithNoTests "user-report" Determining test suites to run.
Read more >Details for Errors & Warnings | mongodb-memory-server
This Error gets thrown if an function (or setter) is called, but the state is not what it should be. (like calling start...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@abishek28007 like i said, there isnt an “smooth” transition release yet, please read the changelog on what changed
this is because
getUri
is in 7.0.0 not async anymore and dosnt wait for the server start anymoreaside from this,
autoStart
got removed, so you need to either manually call.start
, or use the static method.create
@JonasWestAlro please open an new issue, with all the information required
PS: all 7.0.0 betas below .7 were broken, and if possible always use the latest beta