Negative timestamp using sinon fakeTimers when testing node:perf_hooks

19 views Asked by At

I'm currently testing a performance package I wrote, which relies on node:perf_hooks. Specifically the performance.mark() and performance.measure() methods. I am collecting metrics which I'm monitoring in specific, configurable time intervals and now would like to test whether the collection of the metrics is working correctly. For that I want to simulate the recording of values through simply calling the performance.measure() and performance.mark() methods with dummy data, then elapsing the time of the interval using fakeTimers and simply checking if the marks and measures were correctly recorded for each metric and then checking that these metrics were indeed collected. However, when I call the mark() and measure() methods in conjunction with using fakeTimers, perf_hooks complains about the timestamp being negative. Does anyone know how to resolve this? I tried passing a configuration to fakeTimers in which I set 'now' to the highest possible value - with no effect whatsoever. Help is much appreciated!

0

There are 0 answers