sinonjs / fake-timers

Fake setTimeout and friends (collectively known as "timers"). Useful in your JavaScript tests. Extracted from Sinon.JS
BSD 3-Clause "New" or "Revised" License
793 stars 103 forks source link

Add clock.jump method #465

Closed CreativeTechGuy closed 1 year ago

CreativeTechGuy commented 1 year ago

Purpose (TL;DR)

Closes #452 by creating the clock.jump(time) method enabling skipping forward in time and running any timers at most once.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.04 :tada:

Comparison is base (947a7e7) 95.53% compared to head (9d4689e) 95.57%.

:exclamation: Current head 9d4689e differs from pull request most recent head 2a99c0c. Consider uploading reports for the commit 2a99c0c to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #465 +/- ## ========================================== + Coverage 95.53% 95.57% +0.04% ========================================== Files 2 2 Lines 649 656 +7 ========================================== + Hits 620 627 +7 Misses 29 29 ``` | Flag | Coverage Δ | | |---|---|---| | unit | `95.57% <100.00%> (+0.04%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://app.codecov.io/gh/sinonjs/fake-timers/pull/465?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs) | Coverage Δ | | |---|---|---| | [src/fake-timers-src.js](https://app.codecov.io/gh/sinonjs/fake-timers/pull/465?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs#diff-c3JjL2Zha2UtdGltZXJzLXNyYy5qcw==) | `95.56% <100.00%> (+0.04%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

fatso83 commented 1 year ago

I think this looks good. Cannot see any reason not to merge?

fatso83 commented 1 year ago

Any chance of adding this to the Sinon docs on fake timers? https://github.com/sinonjs/sinon/blob/main/docs/release-source/release/fake-timers.md

fatso83 commented 1 year ago

This is part of @sinonjs/fake-timers@10.1.0

CreativeTechGuy commented 1 year ago

Any chance of adding this to the Sinon docs on fake timers? https://github.com/sinonjs/sinon/blob/main/docs/release-source/release/fake-timers.md

Yeah. Those docs look far more out of sync than just this, but I can add this new method if you'd like!