Closed Noriller closed 4 months ago
At the time I didn't think of that. I've started from 0 with the new set of changes.
Attention: 3 lines
in your changes are missing coverage. Please review.
Comparison is base (
ad1d43c
) 95.52% compared to head (b7cbb33
) 95.14%. Report is 47 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
src/fake-timers-src.js | 78.57% | 3 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Yeah, as Simen asked (to be answered) in the original issue, I also don't understand the usecase or what isn't handled by .runAll() or tick(n*1000).
So an elaboration in the original issue would make understanding the WHY a bit smoother 🙂 Minimal API surface is a quality.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
See https://github.com/sinonjs/fake-timers/issues/459#issuecomment-1936981297.
This is not a full stop! It can be reopened if someone provides a good usecase for why this is needed and makes sense!
Purpose (TL;DR) - mandatory
Adding feature:
warpFactor
that changes the normal delay/timeout by the factor provided. Issues: #459 #16This is a dependency of Jest that is widely used. In frontend testing, many component libraries abstract micro animations that take time to complete and slow down testing.
Using fake timers would mean having to spam methods to run the timers, which is not optimal.
This PR aims to add a way to speed up all those hidden timers without anything more than passing a flag with the factor to be used.
Mainly, I added the
warpFactor
to the config and when present, it takes the delay and divides it by the factor.The one thing I want to highlight is that if the factor is higher than the timeout, then the timeouts are rounded to zero.
This would throw off the ordering of timers, since you can possibly make all timers 0. So I added something to keep track of what would be the actual
callAt
to make use in the compare timers function.I'm not sure in what scenario it could be useful, but this implementation also lets you use an fraction as the
warpFactor
, making all timeouts run slower than normal.