Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

411
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda