Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest stops working after too many restarts #168

Closed
owennicol opened this issue Nov 13, 2017 · 10 comments
Closed

Jest stops working after too many restarts #168

owennicol opened this issue Nov 13, 2017 · 10 comments

Comments

@owennicol
Copy link

owennicol commented Nov 13, 2017

Environment

  1. node -v: [8.9.0]

  2. npm -v: [5.4.2]

  3. Operating system: [macOS v10.12.5]

Steps to Reproduce

Install Jest extension
Restart VS Code

Expected Behavior

Jest extension runs without error

Actual Behavior

Jest extension errors after multiple attempts at running
Task bar says "Jest: stopped (too many restarts)

Jest OUTPUT
image

Error in console
image

Package.json scripts:

 "scripts": {
    "start": "concurrently --kill-others \"better-npm-run start-prod\" \"npm run start-api\"",
    "test": "jest",
    "updateSnapshots": "jest --updateSnapshot",
    "test-watch": "jest --watch",
  },

Let me know if you need any further info

Thanks,

Owen

@seanpoulter
Copy link
Member

What version of Jest do you have? Run npm ls jest
Is it possible to try and reproduce this issue on a different OS?

From what I can gather, this is an issue with the way Jest handles file watching when watchman hasn't been installed, and there have been Mac-specific issues. There is an issue in the create-react-app project that suggests that Jest 21 should fix the problem, and can be tracked by this issue in the jest repo.

@owennicol
Copy link
Author

owennicol commented Nov 14, 2017

@seanpoulter thanks for the reply, I've upgraded to v21.x.x now and it works the first time. Whenever I have a failing test however, and then re-save having fixed the test, it doesn't mark it as 'passing'

@seanpoulter
Copy link
Member

If the tests aren't updating, are there any hints why in the Jest Output Panel?

My hunch is that Jest runs once then starts in watch mode where it defaults to only watching files that have changed based on the status from a git/hg repository (-o/--onlyChanged). If you haven't set up version control, then you'll end up with a vague error message in the Jest output about -o. Your options are to set up Jest to watch all files (--watchAll).

Here's what that looks like on my end:

  • The window loads, Jest runs once and we can see the test has failed
  • The code is updated, file saved, but nothing happens
  • Opening the Jest Output panel we can see that "watch mode" has (quietly) failed
    • FYI: You can get to it quickly by double clicking on the extension status in the status bar, or using the command Jest: Show Test Output Channel

2017-11-20 -- vscode-jest 168 - jest --watch fails without repo

@knee-cola
Copy link

I've been receiving similar message from Jest.

Jest addon does run the initial test successfully, however fails when trying to start the watch mode.
Watch mode works fine if I run it manually from terminal.

My setup

  • OS: Win10
  • node: v6.11.5
  • jest: v21.2.1
  • vscode-jest: v2.45
  • ts-jest: v21.2.3

Config

Here's my jest.config.js:

module.exports = {
    "name": "json-proxy",
    "verbose": true,
    "testRegex": "/test/.*\\.spec\\.(ts|tsx|js)$",
    "moduleFileExtensions": [
        "ts",
        "tsx",
        "js"
    ],
    "transform": {
        "\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
    }
};

Debug info

Here's the content of the debug pannel:

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: UNKNOWN: unknown error, lstat 'c:\Users\Nikola\Documents\web-projects\json-proxy\node_modules\.bin\_mocha'
    at Error (native)

Closed Jest
Jest exited unexpectedly, restarting watch mode
Closed Jest
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: UNKNOWN: unknown error, lstat 'c:\Users\Nikola\Documents\web-projects\json-proxy\node_modules\.bin\atob'
    at Error (native)

Closed Jest
Jest exited unexpectedly, restarting watch mode
Closed Jest
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: UNKNOWN: unknown error, lstat 'c:\Users\Nikola\Documents\web-projects\json-proxy\node_modules\.bin\atob'
    at Error (native)

Closed Jest
Jest exited unexpectedly, restarting watch mode
Closed Jest
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: UNKNOWN: unknown error, lstat 'c:\Users\Nikola\Documents\web-projects\json-proxy\node_modules\.bin\_mocha'
    at Error (native)

Closed Jest
Closed Jest

Here's the content of the Chrome Dev-tools console:

jest:2 Uncaught SyntaxError: missing ) after argument list
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
    at ontimeout (timers.js:386:11)
    at tryOnTimeout (timers.js:250:5)
createScript @ vm.js:56
runInThisContext @ vm.js:97
Module._compile @ module.js:542
Module._extensions..js @ module.js:579
Module.load @ module.js:487
tryModuleLoad @ module.js:446
Module._load @ module.js:438
Module.runMain @ module.js:604
ontimeout @ timers.js:386
tryOnTimeout @ timers.js:250
listOnTimeout @ timers.js:214

@seanpoulter
Copy link
Member

Have you had any luck figuring out the cause @knee-cola? If not, do you have a test case we can use to reproduce the issue?

@knee-cola
Copy link

While trying to create a test-case I managed to figure it out (@seanpoulter thanks for your question)!

The problem was caused by me installing ts-jest via bash terminal (WLS) instead of using CMD Terminal. As the result it's dependency cpx was not compiled correctly - there was no cpx.cmd' inside the node_modules/.bin/` directory.

I managed to fix the problem by deleting the node_modules directory and doing npm install from CMD/DOS terminal. That re-installed and compiled correctly all the modules.

It's probably safest option to always install all the modules from CMD/DOS terminal. That way they will work both in in bash and cmd terminal!

@obiwanjacobi
Copy link

I also have this issue and also use ts-jest, but I think (pretty sure) I installed it thru the dos/cmd prompt...
Any tips what I can look for to solve this (I'm a newbie - first ts/jest project).
Thanx.

@knee-cola
Copy link

Well I'm bi longer sure that installing things from CMD helped. Later I cloned my repo onto another machine and everything worked fine.

@seanpoulter
Copy link
Member

Could you debug the extension with your ts-jest project @obiwanjacobi, or provide a minimal repo we can try?

@myatt95
Copy link

myatt95 commented Jun 14, 2018

Installing watchman fixed this issue for me:
brew update
brew install watchman

Then reload the Jest plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants