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

favor the constructor of the performance instance if it exists #478

Closed zbyte64 closed 10 months ago

zbyte64 commented 11 months ago

Purpose

Fix issue #420 by favoring the constructor of the performance instance over the Performance class

Background

jsdom also patches the Performance class and doesn't implement all of the methods.

I could not use the workaround mentioned: https://github.com/sinonjs/fake-timers/issues/394#issuecomment-1021665619 because I'm using vitest with jsdom as the environment.

Solution

This simply favors the prototype of the performance instance, since that seems to be untouched by jsdom.

codecov[bot] commented 10 months ago

Codecov Report

Patch coverage: 50.00% and no project coverage change.

Comparison is base (b568150) 96.47% compared to head (4982ed0) 96.47%.

:exclamation: Current head 4982ed0 differs from pull request most recent head 0fdc0ad. Consider uploading reports for the commit 0fdc0ad to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #478 +/- ## ======================================= Coverage 96.47% 96.47% ======================================= Files 2 2 Lines 680 680 ======================================= Hits 656 656 Misses 24 24 ``` | Flag | Coverage Δ | | |---|---|---| | unit | `96.47% <50.00%> (ø)` | | 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. | [Files Changed](https://app.codecov.io/gh/sinonjs/fake-timers/pull/478?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/478?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs#diff-c3JjL2Zha2UtdGltZXJzLXNyYy5qcw==) | `96.49% <50.00%> (ø)` | |

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