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 runner in the background after exit

See original GitHub issue

Environment

  1. node -v: v13.7.0

  2. npm -v: 6.13.6

  3. npm ls jest or npm ls react-scripts (if you haven’t ejected): jest@25.1.0 / react-scripts@3.3.0 (see below)

  4. your vscode-jest settings if customized:

    • jest.pathToJest? Not customized
    • jest.pathToConfig? Not customized
    • anything else that you think might be relevant? Multi-root project, with Jest 25 on its own on back-end and react-scripts on the front-end
  5. Operating system: Ubuntu 18.04

Prerequisite

  • are you able to run jest test from command line? Yes
  • how do you run your tests from command line? (for example: npm run test or node_modules/.bin/jest) npm run test

Steps to Reproduce

Not sure how to create a relevant repository. Would appreciate guidance on the diagnostic path. I’ve tried enabling debug, nothing suspicious emerges.

Expected Behavior

Jest runs correctly in the extension. Icons are fine, test results are reported correctly. Upon termination of VS Code, no Jest processes are left behind.

Actual Behavior

Jest runs correctly in the extension. Icons are fine, test results are reported correctly.

Upon termination of VS Code, I am left with a number of ghost processes. See below for the output of ps aux:

paolo    14981 22.6  0.7 981876 128424 tty2    Sl+  09:55   0:06 node /home/paolo/react/CongressGuru/congress-guru/backend/lambdas/node_modules/.bin/jest --testLocationInResults --json --useStderr --outputFile /tmp/jest_runner_lambda.json --watch --coverage --no-color --reporters default --reporters /home/paolo/.vscode/extensions/orta.vscode-jest-3.1.1/out/reporter.js
paolo    15418  0.2  0.1 587628 24740 tty2     Sl+  09:55   0:00 node /home/paolo/react/CongressGuru/congress-guru/frontend/node_modules/.bin/react-scripts test --testLocationInResults --json --useStderr --outputFile /tmp/jest_runner_front_end.json --watch --coverage --no-color --reporters default --reporters /home/paolo/.vscode/extensions/orta.vscode-jest-3.1.1/out/reporter.js
paolo    15425  8.1  0.4 954260 68880 tty2     Sl+  09:55   0:01 node /home/paolo/react/CongressGuru/congress-guru/frontend/node_modules/react-scripts/scripts/test.js --testLocationInResults --json --useStderr --outputFile /tmp/jest_runner_front_end.json --watch --coverage --no-color --reporters default --reporters /home/paolo/.vscode/extensions/orta.vscode-jest-3.1.1/out/reporter.js

The only solution I have found is running a pkill node.


The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
connectdotzcommented, Apr 18, 2020

thanks for everybody’s data points, I was able to reproduce this and observed these 2 types of behaviors:

  1. if I close the workspace before jest can complete the run, I see all jest child process became orphan processes … there could be some race condition that we didn’t get to close the spawned child-process
  2. when the spawned process spawns another child process in the background, such as in react-scripts use case, even when we close the jest process, the react-script spawned process will not be terminated. I am guessing this probably started to happen when we switched spawn child_process with shell option a few months back…

@jeantil I could not reproduce your observation with coverage toggle, but I suspect it probably falls into one of the categories mentioned above…

Apology if this has happened to your project, I am afraid you will have to manually kill these orphan processes for now (such as pkill -f jest or pkill -f jest_runner). I will take a look to see how we can address this ASAP…

1reaction
connectdotzcommented, Apr 27, 2020

hi, we have a new release candidate with the fix: v3.2.0. Would appreciate more testing before release, please feel free to give it a try and let us know if it worked, or not…

(to try the new release candidate, just to install the .vsix file (vscode-jest-3.2.0.vsix) in your vscode: https://code.visualstudio.com/docs/editor/extension-gallery#_install-from-a-vsix)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run background task inside Jest - node.js - Stack Overflow
For this, I need to run some background tasks under certain intervals. In summary, this is like polling. Let's give an example with...
Read more >
Configuring Jest
This allows for a custom configuration of the background color of the ... Jest will run .mjs and .js files with nearest package.json...
Read more >
Using Visual Studio Code to debug Jest based unit tests
We got a launch.json file under the folder .vscode including a default implementation: In the next step we will replace the content of...
Read more >
Background in Cucumber - Tools QA
Background with Hooks · @Before: Print the starting logs · @Before: Start browser and Clear the cookies · @After: Close the browser ·...
Read more >
Node JS tests with Jest hang after successful test (locally ...
It looks like whatever command you're running doesn't exit for some reason after the tests are done. Probably some background activity ...
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