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
804 stars 106 forks source link

Faking performance when not present should throw an error (and minor changes) - fix for #374 #400

Closed itayperry closed 2 years ago

itayperry commented 3 years ago

Original purpose: enabling adding performance to toFake array - apparently this was already possible so a few minor changes were made.

Issue #374 refers to the fact that fake-timers overrides performance object (as in other properties/methods in addition to overriding performance.now()). The first suggested solution/notion was to enable users to add performance to the toFake array - after realizing this was already possible a test was added to make sure an error is thrown when a user puts performance in the toFake array but the performance object isn't present.

I don't know if this PR makes a good addition/improvement - I'm waiting for your notes and comments and I'll fix whatever's needed.

codecov[bot] commented 2 years ago

Codecov Report

Merging #400 (584a20c) into master (a13a054) will increase coverage by 0.18%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #400      +/-   ##
==========================================
+ Coverage   94.10%   94.29%   +0.18%     
==========================================
  Files           1        1              
  Lines         611      613       +2     
==========================================
+ Hits          575      578       +3     
+ Misses         36       35       -1     
Flag Coverage Δ
unit 94.29% <100.00%> (+0.18%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/fake-timers-src.js 94.29% <100.00%> (+0.18%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a13a054...584a20c. Read the comment docs.

itayperry commented 2 years ago

Hi @fatso83 :) I didn't edit the README file, but I still get a prettier error because of it - should I fix that and just make another commit?

[warn] README.md

fatso83 commented 2 years ago

Yup, that was me editing the README in the web UI.

itayperry commented 2 years ago

For glory, for fake-timers! lol :)