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

Fail when a timer is not available in the context #491

Closed fatso83 closed 4 months ago

fatso83 commented 4 months ago

Purpose (TL;DR) - mandatory

fix #490

This makes FakeTimers stricter by failing when trying to fake a timer or object that is not present on the (chosen) global object.

To make transitioning easier, we provide a flag to revert to the behavior where missing timers were (mostly) ignored.

Background (Problem in detail) - optional

See #490

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (cc58937) 97.50% compared to head (4667c29) 97.50%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #491 +/- ## ======================================= Coverage 97.50% 97.50% ======================================= Files 16 16 Lines 3960 3968 +8 ======================================= + Hits 3861 3869 +8 Misses 99 99 ``` | [Flag](https://app.codecov.io/gh/sinonjs/fake-timers/pull/491/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/sinonjs/fake-timers/pull/491/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs) | `97.50% <100.00%> (+<0.01%)` | :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.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.