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

Use Jest.useFakeTimers in IO debounce/throttle tests #184

Open
andywhite37 opened this issue Oct 30, 2019 · 2 comments
Open

Use Jest.useFakeTimers in IO debounce/throttle tests #184

andywhite37 opened this issue Oct 30, 2019 · 2 comments
Labels
type:enhancement New feature or request

Comments

@andywhite37
Copy link
Member

andywhite37 commented Oct 30, 2019

I noticed the IO debounce/throttle tests fail sometimes, seemingly from timing issues. In the Relude_Timer, Relude_Debounce, and Relude_Throttle tests, I tried the Jest.useFakeTimers/Jest.advanceTimerBy (or whatever) API and it seemed to work really nicely, so we should switch these IO tests to use that too.

@andywhite37
Copy link
Member Author

Note: I found that when using Jest.useFakeTimers, the Js.Date values are not affected by the spoofed timer changes (which makes sense in hindsight), so we'll have to figure out a different way to run these tests with more deterministic timing, while still testing the timing aspect of them.

@andywhite37
Copy link
Member Author

Here's an example of using the fake timers in the Relude_Debounce test

https://github.com/reazen/relude/blob/master/__tests__/Relude_Debounce_test.re

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant