Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setSystemTime throws when modernTimers are imported twice #11767

Closed
aliaksandr-yermalayeu opened this issue Aug 19, 2021 · 3 comments · Fixed by #11946
Closed

setSystemTime throws when modernTimers are imported twice #11767

aliaksandr-yermalayeu opened this issue Aug 19, 2021 · 3 comments · Fixed by #11946

Comments

@aliaksandr-yermalayeu
Copy link

aliaksandr-yermalayeu commented Aug 19, 2021

🐛 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
@sigveio
Copy link
Contributor

sigveio commented Aug 24, 2021

Screenshot 2021-08-24 at 18 20 38

Doesn't fail here (tested on Linux, and Mac OS). With both running it as a script from the package.json via Yarn, and executing via node in the same fashion as what you are doing with your run_jest.cmd. Unfortunately I don't have a windows VM readily available to match your environment exactly at the moment.

Could it perhaps be related to what some users mention in the issues you link to?
i.e. some form of version mismatch on your end?

@sergei-startsev
Copy link

@sigveio I don't think there're version mismatch issues, package.json contains only "jest": "^27.0.6" as a dependency.

I've tried to reproduce the issue using the repo above and got the same error for d:\:

image

minijus added a commit to minijus/jest that referenced this issue Oct 10, 2021
minijus added a commit to minijus/jest that referenced this issue Oct 10, 2021
minijus added a commit to minijus/jest that referenced this issue Oct 15, 2021
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants