-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Jest fake-timer support #62
Conversation
I'm also interested in this PR - fake timers is the only feature we still use the base jest runner for. Is there anything we can assist with to get this PR merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took so long to land this, thank you! :)
@@ -20,4 +29,20 @@ globalThis.jest = { | |||
clearAllMocks: jestMock.clearAllMocks.bind(jestMock), | |||
resetAllMocks: jestMock.resetAllMocks.bind(jestMock), | |||
restoreAllMocks: jestMock.restoreAllMocks.bind(jestMock), | |||
useFakeTimers() { | |||
jestTimer.useFakeTimers(); | |||
return this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this
defined here? should it be return globalThis.jest
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this
in method of object equals the object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh well, this
is defined if you call jest.useFakeTimers().something
. Does it work in Jest if you do (jest.useFakeTimers, 0)().something
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't
this
in method of object equals the object?
Hah, TIL 😀
Does it work in Jest if you do
(jest.useFakeTimers, 0)().something
?
(jest.useFakeTimers , 0) is not a function
which seems fair? I get the same doing (document.createElement, 0)()
in a browser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He mean (0, jest.useFakeTimers)().something
.
The following won't work either 😄
const {useFakeTimers} = jest
useFakeTimers().something
jest.useFakeTimers.call(null).something
const foo = {useFakeTimers: jest.useFakeTimers}
foo.useFakeTimers().something
Uhh I just noticed I never release this, I'm doing it now. |
Thanks for creating this wonderful runner :)
PR implements the base of jest fake-timer.