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:
const $timers = createStore({ setTimeout: (cb) => cb() });
const startDelay = createEvent();
const triggered = delay({ source: startDelay, timeout: 200, timers: $timers });
Motivation
- Developer can set their own implementations of time functions (this make testing very easy)
- This solution much better than jest fake timers, 'cause it can't create race condition even in theory
Related links:
- Jest mock race condition
- Jest async race condition
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: