Jest did not exit one second after the test run has completed

See original GitHub issue

Goals

Trying to close Realm instance after each unit test.

Expected Results

Everything shutdown nicely.

Actual Results

Test succeeds but Jest complains there are asynchronous operations that weren't stopped, then the Jest process will hang.

Steps to Reproduce

  1. Minimal realm set up
  2. Open the database during one test
  3. Close the database once done.

Code Sample

https://github.com/simophin/realm-close-issue

$ npm install && npm run test

This is the result I got:

npm run test

> testrealm@1.0.0 test /Users/***/Temp/testrealm
> jest ./src

 PASS  src/__tests__/realm-tests.ts
  realmTest
    ✓ should exist (17 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.339 s, estimated 2 s
Ran all test suites matching /.\/src/i.
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.

Also, if I add --detectOpenHandles to jest, the test will succeed, without the complain, but still hang. If I added --detectOpenHandles --forceExit to jest, the test will succeed, without the complain, and terminate successfully.

This does not happen in realm-js 5.0.x, only after we upgraded to 6.0.

Version of Realm and Tooling

  • Realm JS SDK Version: 6.0.2
  • Node or React Native: Node 10.21.0
  • Client OS & Version: Mac OS
  • Which debugger for React Native: None

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:14
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
knethcommented, Oct 7, 2021

The fix has been released in version 10.8.0.

0reactions
takameyercommented, Sep 6, 2021

@simophin we have found the issue and the fix should arrive in the next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest did not exit one second after the test run has completed ...
Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped...
Read more >
Jest did not exit one second after the test run has completed.
Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped...
Read more >
How To Fix: Jest Did Not Exit - DONN FELKER
Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped...
Read more >
Testing Asynchronous Code · Jest
When you have code that runs asynchronously, Jest needs to know when the code it is testing has completed, before it can move...
Read more >
Jest did not exit one second after the test run has ... - 인프런
Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped...
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