Skip to content

setSystemTime throws when modernTimers are imported twice #11767

@aliaksandr-yermalayeu

Description

@aliaksandr-yermalayeu

🐛 Bug Report

Jest uses instanceof check to ensure modern version of fakeTimers is being used. Which in addition with inconsistent file resolution system causes double import and the following error in test:

TypeError: setSystemTime is not available when not using modern timers

Related Issues: #11660, #11662

To Reproduce

Steps to reproduce the behavior:
1.Clone example repo.
2.On windows open cmd and navigate to working directory using cd command.
cd c:\workingdir
Make sure the disk letter is lowercase on the cwd, not C:\
3.Run jest cli

Expected behavior

Test shouldn't fail

Link to repl or repo (highly encouraged)

https://github.com/aliaksandr-yermalayeu/jest-faketimers-repro

envinfo

System:
    OS: Windows 10 10.0.19043
    CPU: (12) x64 Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz
  Binaries:
    Node: 14.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: ^27.0.6 => 27.0.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions