Jest throws TypeError: Cannot read properties of undefined (reading 'isFake')

Viewed 13

When I run in NX monorepo jest unit tests, In some tests (not in all test files) jest >= 28 throws the error:

TypeError: Cannot read properties of undefined (reading 'isFake')

  150 |
  151 |   beforeEach(() => {
> 152 |     jest.useFakeTimers();

what is an issue in the fake-timers lib on the line: if (_global.Date.isFake === true) {

When I downgraded jest to version 27.5.1 all tests are passing. Seems like issue in initialisation of the tests.

What could be the issue ?

0 Answers
Related