Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

662
Visualizações
"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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda