Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

656
Views
"Error: spawn git ENOENT" when running react-scripts test

I have a project that I created using the create-react-app. When I first created the project the tests ran fine. I decided to run the tests after not running them for a while (I still haven't written any so the generated test class is all I have) and now I'm getting the following error:

Determining test suites to run...Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)

Git is definitely on the path, I can run git --version from the command line and it outputs as expected. I get the same error if I run in cygwin or the windows command line.

My package.json looks like:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "immutable": "^3.8.1",
    "react": "^15.5.4",
    "react-dom": "^15.5.4"
  },
  "devDependencies": {
    "react-scripts": "0.9.5"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

EDIT: After some playing around I've discovered that my tests only fail when the project is in a git repository. If I take a copy of the project, without the '.git' folder then run the tests from the copy they all run fine.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I eventually figured out what was causing this. Something about my local setup is causing an error when git is launched as part of the Jest watcher (still not clear what). From the create-react-app docs:

By default, when you run npm test, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests runs fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests.

Source

Running the tests as if they were running in a CI environment with set CI=true&&npm test bypasses the git functionality and I can run my tests. More information here

There is also an open bug in the jest project: https://github.com/facebook/jest/issues/3214

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!