question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"MongoMemoryReplSet" in "jest" gives open handle error

See original GitHub issue

If 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:20

github_iconTop GitHub Comments

3reactions
hasezoeycommented, Nov 9, 2020

@abishek28007 like i said, there isnt an “smooth” transition release yet, please read the changelog on what changed

not sure what was added in beta 7 but getting “instanceInfo” is undefined for const uri = await mongod.getUri(); for MongoMemoryServer

this is because getUri is in 7.0.0 not async anymore and dosnt wait for the server start anymore


aside from this, autoStart got removed, so you need to either manually call .start, or use the static method .create

0reactions
hasezoeycommented, Dec 6, 2020

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found