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

400
Visualizações
Why does jest think `TypeError: _global.setTimeout is not a function` in my TS app?

i'm having trouble setting up jest on an existing typescript app.

when i try to run a basic, "hello world" style test like:

test('foo', () => console.log('foo'))

i get:

  ● Test suite failed to run

    TypeError: _global.setTimeout is not a function

      at withGlobal (node_modules/@sinonjs/fake-timers/src/fake-timers-src.js:146:35)
      at new FakeTimers (node_modules/@jest/fake-timers/build/modernFakeTimers.js:45:53)

why would this be?

my jest.config.js file is:

module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',

  roots: ['<rootDir>/src'],
  transform: {
    '^.+\\.(js|ts|tsx)?$': 'ts-jest',
  },
  testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  transformIgnorePatterns: ['"node_modules/(?!p-queue/.*)"'],
}

that transformIgnorePatterns in there is helping me get around a module that is written in esmodules, which otherwise causes a syntax error.

my relevant dependencies:

  "dependencies": {
    "@types/jest": "^27.5.0",
    "@types/p-queue": "^3.2.1",
    "jest": "^28.1.0",
    "p-queue": "^7.1.0",
    "ts-jest": "^28.0.2",
    "typescript": "^4.5.5",
    // etc...
  }
about 4 years ago · Juan Pablo Isaza
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