-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 and getRealSystemTime always throw if yarn/npm does not deduplicate @jest/fake-timers #11662
Comments
I was running into this when I had both |
Is there any reason the test can't just look for the existence of
becomes
The current check seems oddly fragile - Duck-typing seems safe enough. I haven't dug through the code all that much, but if we -need- the packages de-duped (eg, singleton access or something) then perhaps we could tweak the error message to be a bit more explicit? |
My |
…rnFakeTimers and LegacyFakeTimers methods Closes jestjs#11660 jestjs#11767 jestjs#11662
…rnFakeTimers and LegacyFakeTimers methods Closes jestjs#11660 jestjs#11767 jestjs#11662
…ernFakeTimers and LegacyFakeTimers methods Closes jestjs#11660 jestjs#11767 jestjs#11662
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. |
🐛 Bug Report
Jest relies on yarn/npm to deduplicate
@jest/fake-timers
. If it is not deduplicated, the following functions always throw the errorsetSystemTime is not available when not using modern/legacy timers
.It's caused by the instanceof checks in this file: https://github.com/facebook/jest/blob/master/packages/jest-runtime/src/index.ts.
I've attached my real yarn lock file to prove that deduplication can fail in the wild, and not just in the contrived example below. yarn.lock.zip
To Reproduce
Run the following
It will output this:
Expected behavior
Jest should not rely on yarn/npm deduplication behavior.
Link to repl or repo (highly encouraged)
Just run the script above in an empty folder.
envinfo
The text was updated successfully, but these errors were encountered: