fake-timers
fake-timers copied to clipboard
Support performance.measure method
- FakeTimers version : 11.2.2
- Environment : Windows 11
- Example URL : N/A
- Other libraries you are using: Playwright (but should be irrelevant)
What did you expect to happen?
Faking timers with default settings (which will fake performance) should fake all of the performance methods including performance.mark, performance.measure, etc.
What actually happens
These methods exist and can be called, but seem to do nothing since calling performance.measure() returns undefined which isn't a valid return value and then the code crashes when trying to access the properties which are expected to exist on the result.
How to reproduce
const FakeTimers = await import("https://esm.sh/@sinonjs/[email protected]");
FakeTimers.install();
performance.mark("start");
performance.mark("end");
const measurement = performance.measure("duration", "start", "end");
console.log("duration is", measurement.duration); // Crashes here since measurement is undefined