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

274
Visualizações
What is the best way to automatically set jest timeout when debugging tests?

I have a nodejs project. I'm using the debugger (in IntelliJ if it matters) to step through tests. I'd like to configure my project using best practices so that when I'm using the debugger I modify the test timeout to be longer than the default 5 seconds. I am aware that I can put the following line in package.json to change the timeout.

{
  "name": "my-project",
  "jest": {
    "testTimeout": 20000
  }
}

But I'm looking for a way to modify the timeout only (and automatically) when debugging. I'm sure there is a good way, but I'm fairly new to nodejs and the conventions/mechanisms for setting up various envionments.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If using create-react-app, the setupFilesAfterEnv is configured to src\setupTests.ts.

This is the entry point before any tests are executed/debugged and if you can detect that you're in a DEBUG mode then you can set a new timeout.

e.g.,

if (process.env.DEBUG === 'jest') {
  jest.setTimeout(5 * 60 * 1000);
}

In VS Code, you can add launch.json configuration as documented with "DEBUG": "jest" added to the env.

{
  "name": "Debug CRA Tests",
  "type": "node",
  "request": "launch",
  "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-app-rewired",
  "args": ["test", "--runInBand", "--no-cache", "--watchAll=false"],
  "cwd": "${workspaceRoot}",
  "protocol": "inspector",
  "console": "integratedTerminal",
  "internalConsoleOptions": "neverOpen",
  "env": {
    "CI": "true",
    "DEBUG": "jest"
  },
  "disableOptimisticBPs": true
}
about 4 years ago · Juan Pablo Isaza 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