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

[Feature]: Please expose runToFrame() from sinon/fake_timers in @jest/fake-timers #14593

Closed
alexreardon opened this issue Oct 3, 2023 · 5 comments · Fixed by #14598
Closed

Comments

@alexreardon
Copy link
Contributor

alexreardon commented Oct 3, 2023

🚀 Feature Proposal

Hi legends,

Could you please expose clock.runToFrame() from sinon/fake-timers in @jest/fake-timers? (@jest/fake-timers is mostly a re-export of sinon/fake-timers)

clock.runToFrame()
Advances the clock to the next frame, firing all scheduled animation frame callbacks, if any, for that frame as well as any other timers scheduled along the way.

Right now I am doing this workaround:

jest.advanceTimersByTime(16);

But this seems suboptimal as there is a bit of logic controlling how long the frame duration should be.

Motivation

I am looking to explicitly have a scheduled animation frame run in a test.

Example

// release the next animation frame
jest.runToFrame();

Pitch

It would be helpful to be able to use the runToFrame() to have more explicit control over animation frames

@SimenB
Copy link
Member

SimenB commented Oct 3, 2023

Yeah, happy to 🙂 Wanna send a PR?

@alexreardon
Copy link
Contributor Author

Yep, can do

@SimenB
Copy link
Member

SimenB commented Oct 3, 2023

Awesome 👍 The work is mostly adding to types (incl. type tests) and docs I think, not necessarily the code change itself 😅

It should also throw when using legacy timers

@alexreardon
Copy link
Contributor Author

alexreardon commented Oct 3, 2023

Pull request raised @SimenB

#14598

Copy link

github-actions bot commented Nov 5, 2023

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 5, 2023
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.

2 participants