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.

Jest hangs on last test suite constantly

See original GitHub issue

🐛 Bug Report

Jest is hanging constantly on last test suite runs. Every time the last test suite is different. I have tried with runInBand options but no luck.

screen shot 2018-07-23 at 10 42 47 am

screen shot 2018-07-23 at 10 43 31 am

I got some luck after running node_modules/.bin/jest --clearCache then node_modules/.bin/jest now works mostly. But still, it’s not stable enough.

"scripts": { "test": "jest --clearCache && jest --silent" }

I have installed watchman via homebrew also as pointed out on other issues but no luck. Could please help us to fix the issue. Please let me know if any information is needed.

Environment Information:

System:
      OS: macOS Sierra 10.12.6
      CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
      Node: 6.11.1 - ~/.nvm/versions/node/v6.11.1/bin/node
      npm: 5.3.0 - ~/.nvm/versions/node/v6.11.1/bin/npm
  npmPackages:
      jest: ^23.4.1 => 23.4.1

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

7reactions
mindplay-dkcommented, Oct 10, 2019

I have a completely trivial test like the following:

test('something', async () => {
  let value = await something();
  expect(value).toBe(true)
})

Even if I explicitly finish the test with done, it just spins forever:

test('something', async (done) => {
  let value = await something();
  expect(value).toBe(true)
  done()
})

Most likely because something() never resolves - but the test never times out, so my only option is CTRL+C, which doesn’t tell me where it was or what it was doing.

Why doesn’t it respect the timeout?

How do you diagnose something like this?

3reactions
RajaJaganathancommented, Dec 12, 2018

@laumair There is no issue with jest, I have fixed this issue by modifing my tests code. I faced this issue when I migrated from mocha to jest. One notable issue is that we need to call ‘done’ callback properly if test is asynchronous.

For example, Test might completed before our asynchronous function call gets completed. Those asynchronous call might be the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - jest hangs indefinitely, runs no tests - Stack Overflow
Most of my test where running but one suite was continuously running and never erroring. It turned out I had a race condition...
Read more >
Why Jest freezes after tests run? (Jest hangs indefinitely)
If you noticed that Jest (npm / yarn) test hang at the end of the test execution while you run tests in parallel...
Read more >
How to Stop Jest Tests from Hanging in Angular | by Paul Kim
Jest test hangs, hanging, stuck, never finishes, not running, won't stop. An article to stop hanging Jest tests in an Angular project.
Read more >
Jest / npm / yarn test hang at the end of the test (e.g. at Ran all ...
Note: This feature is an escape-hatch. If Jest doesn't exit at the end of a test run, it means external resources are still...
Read more >
Runner hangs sometimes after all Jest tests are completed
I use GitLab cloud CI to run Jest tests on my node project and after deploy the app to AWS. It happened now...
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