-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Labels
Description
- FakeTimers version : 10.0.2
- Environment : Node v18.12.1
- Example URL : https://github.com/kevinyou/wtf-performance-now-mocking/tree/main/sinon-fake-timers
- Other libraries you are using: N/A
What did you expect to happen? After calling useFakeTimers(), perf_hooks.performance.now() should return a fake time, just like how performance.now() does.
What actually happens 1. perf_hooks.performance.now() is not the same as performance.now(). The latter is correctly hijacked and returns a fake time. 2. perf_hooks.performance.now() returns a negative value -- undefined behavior?
How to reproduce
https://github.com/kevinyou/wtf-performance-now-mocking/tree/main/sinon-fake-timers
var perf_hooks = require('perf_hooks');
var FakeTimers = require("@sinonjs/fake-timers");
console.log(perf_hooks.performance === performance); // true
console.log(perf_hooks.performance.now()); // 36.97510700020939
console.log(performance.now()); // 37.08340699970722
var clock = FakeTimers.install({
now: Date.now(),
shouldClearNativeTimers: true,
});
console.log(perf_hooks.performance === performance); // now false
console.log(perf_hooks.performance.now()); // -4217337.086744
console.log(performance.now()); // 0benjamingr