-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add API for custom time functions implementation #310
Comments
Hello @movpushmov ! Thank you for the RFC! I see the problem with the custom timers API, that it is kinda replicates that of Jest/Vitest - which is probably not desirable, as those are already built-in into those frameworks, and are much more complicated and feature-rich. I would suggest something simpler, like just to expose internal effects of timer-based operators, like this: const scope = fork({
handlers: [
[debounce.timerFx, myMock],
[throttle.timerFx, myMock],
[delay.timerFx, ...],
]
}) ☝️ So this work much like I like this approach more, since it is simple, straightforward and much easier for mainteiners of What do you think? |
sounds very good) |
Looks good to me! |
Hey! Could you elaborate on motivation a bit? I do not see any reason for adding a new API based on provided motivation.
Any modern test-runner allows users to mock timers by something like
If we are going to solve a particular bug/race in Jest (single test runner), shall we address this RFC to the Jest repository? It seems quite overwhelming to introduce a new API to a library to fix a bug in some other tool. So, I would like to hear more motivation for adding a new API because any new API increases library complexity for users (they need to learn more APIs — Furthermore, I read documentation provided in #327 and I cannot catch it. Can I completely replace Before this motivation clarification and API design description, I suggest holding PR #327 🙏 |
Hello, @igorkamyshev! If you don't mind, I'll help @movpushmov answer the questions.
Both of these assumptions can be violated and debugging such tests is time-consuming and painful. For example, imagine that the code under test remembers the current time or the
It seems that we should not solve the problem in
The essence of the proposal is to support the |
Hello! |
Proposal
Now patronum delay, interval, debounce, time works with global time functions (window.setTimeout, window.setInterval, window.Date.now) what make testing of some features impossible. The solution is create API where developer can manually set implementations of setTimeout/setInterval
Someting like this:
Motivation
Related links:
The text was updated successfully, but these errors were encountered: