fake-timers: window.performance.mark becomes undefined after timer install
I have noticed the following behavior in the browser:
import { useFakeTimers } from 'sinon';
console.log('1', window.performance.mark) // '1', function mark() { ... }
clock = useFakeTimers();
console.log('2', window.performance.mark) // '2', undefined
window.performance became a function after calling useFakeTimers. I believe that the issue is coming from this line:
https://github.com/sinonjs/lolex/blob/c08ff362a47e9786bc62da6c37175838bb7bd21e/src/lolex-src.js#L406-L408
One simple workaround is the following:
-clock = useFakeTimers();
+clock = useFakeTimers({
+ toFake: ["setTimeout", "clearTimeout", "setImmediate", "clearImmediate","setInterval", + "clearInterval", "Date"]
+});
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 15
- Comments: 25 (13 by maintainers)
Commits related to this issue
- Add regression test for #136 — committed to sinonjs/fake-timers by fatso83 6 years ago
- Upgrade lolex to pull in a clock fix See https://github.com/sinonjs/lolex/issues/136 We don't use fake timers, but we do use lolex's clock, which probably causes the same thing. Jumping from 2.x to ... — committed to matrix-org/matrix-react-sdk by turt2live 5 years ago
sorry, completely forgot about it - can take a look early next week
As a temporary solution, I used the following function:
It works with:
react@16.2.0sinon@4.2.0enzyme-adapter-react-16@1.1.1enzyme@3.3.0Ok, I’m gonna make a patch soon!
@fatso83 I still can’t assign myself to issues by the way 😄 I’ll take a stab next week hopefully