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

399
Views
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
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!