fake-timers: Performance is not defined
Hello, I’m getting
ReferenceError: Performance is not defined
at createClock (node_modules/lolex/src/lolex-src.js:736:36)
at Object.install (node_modules/lolex/src/lolex-src.js:791:21)
at Sandbox.exports.useFakeTimers (node_modules/sinon/lib/sinon/util/fake_timers.js:26:21)
with the new release 2.4.1.
├─┬ sinon@4.5.0
│ ├─┬ @sinonjs/formatio@2.0.0
│ │ └── samsam@1.3.0
│ ├── lodash.get@4.4.2
│ ├── lolex@2.4.1
When used lolex@2.3.2 it was working fine.
Thanks!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 19 (10 by maintainers)
There is an integration test with jsdom, showing it works: https://github.com/sinonjs/lolex/blob/master/integration-test/lolex-integration-test.js
Might need the
runScriptspart, I needed it forDate@panzerdp As #181 discusses, we could need some more information on this regarding browsers affected. Could you tell us which browser/environment this bug appears?
https://github.com/sinonjs/lolex/pull/181
@fatso83 on it
Weird. We only check that
global.performanceis defined, notPerformance. Seems like we missed a check.@fatso83, The problem was introduced by this commit.
P.S. @benjamingr You might want to check out those scripts as well, as they have made life as a regression hunter much easier in the past 😺
@panzerdp As this is closed, and most issues we have seen mentioned here seems to be due to something else and fixed, could you please open a PR and try to make a minimal, reproducible case? As the test and build steps at Travis are fine, it’s clear that we are not catching it in our tests, and I wouldn’t know what the problem is or how to test for it (or its resolution).
The best solution would of course be if you could find the bug yourself, or which commit introduced it … 🙏 In which case I advice you to check out these git bisect templates I use myself to quickly find regresions in Sinon. You can use your own project as the test for the bug (read the source).
Background on Git bisect
Hi @dwoowb we are using enzyme + jsdom and running tests in node env. So what we did was overriding the node global env with jsom (which is not recommended by jsdom btw). So when lolex is executing global.Performance it’s actually reading the node env. If yours is the same case, have a look at this: https://github.com/airbnb/enzyme/blob/master/docs/guides/jsdom.md
@benjamingr turns out it was related to jsdom. All good now. Thanks anyway!
Since we cannot test this without code, I am assuming this was closed with #162, releases as 2.4.2.
@benjamingr I have tried to fix the missing details problem by adding templates in 598580931758d61bdf79aa052ff05261d1813b0b