jest-community / vscode-jest

The optimal flow for Jest based testing in VS Code
MIT License
2.83k stars 291 forks source link

jest --watch fill fail on Windows machines if git is not in the user's PATH #283

Open ashwinm76 opened 6 years ago

ashwinm76 commented 6 years ago

Environment

  1. node -v: 6.9.4

  2. npm -v: 3.10.10

  3. npm ls react-scripts (if you haven’t ejected): `-- (empty)

  4. Operating system: Windows 10 Home 64-bit build 16299.309

Steps to Reproduce

Open any project with jest tests in it on a Windows 10 machine, where git is not in your PATH env variable. Note that this applies to the PATH as seen by cmd.exe

Expected Behavior

The jest extension runs the tests once, then runs jest in watch mode.

Actual Behavior

Watch mode fails with the error "watch is not supported without git/hg", presumably because jest cannot see git.exe in the path.

It would be very helpful to users on Windows to have the vscode-jest extension mention on it's page that git.exe must be in the PATH. This is easy to miss if like me you are running vscode with the default terminal shell set to git-bash, because you will find that the vscode-jest extension fails to run jest in watch mode, but manually running "jest --watch" in vscode's git-bash terminal works fine.

orta commented 6 years ago

Sounds like something the extension can test for itself and present a warning, would you like to try take a stab at that?

seanpoulter commented 6 years ago

If we detect that error, you could prompt the user if they'd like to run with --watchAll instead. The jest-editor-support runner should support it: https://github.com/facebook/jest/blob/master/packages/jest-editor-support/src/Runner.js#L23

ph1p commented 6 years ago

Today I ran into the same error and fixed it by running git init in my working directory. If you get this error afterwards: git has too many active changes, only a subset of Git features will be enabled., simply add a .gitignore file with node_modules in it.

bradyep commented 6 years ago

I'm using Subversion and this error pretty much breaks this extension. Is there any way to tell the extension to use --watchAll instead of --watch?

seanpoulter commented 6 years ago

The runner has supported this for the last 2 months with the watchAll option in start(...). From what I can see in JestProcess.ts we're not passing the option to start().

That means if that version of jest-editor-support has shipped a PR could fix your problem. Want to try it @bradyep?