-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
performance.mark
doesn't exist in node@16 when using jsdom globals
#420
Comments
While it's not strictly a bug I think it's very reasonable to support this use case and the fix shouldn't be too hard. |
This is currently impacting me, but on node v18. What would an acceptable unit test be for this? |
From my own manual testing, swapping the order here: fake-timers/src/fake-timers-src.js Lines 1755 to 1760 in b568150
|
@zbyte64 feel free to open a PR |
PR merged 🥳 Thanks a bunch |
@sinonjs/[email protected]
global-jsdom
What did you expect to happen?
performance.mark
is a functionWhat actually happens
performance.mark
is undefinedHow to reproduce
Minimal repro is available here: https://github.com/msluther/sinon-timers-jsdom-bug
Effectly though it's just this in node@16:
This is related to this issue: #394
From my comment on that issue:
Hrm. So, the fix works but makes the assumption that the functions on
global.Performance.prototype
are a superset ofglobal.performance.*
functions. This is currently not the case when usingnode@16
andjsdom
.jsdom
is injecting aglobal.Performance
object based on the minimal W3C spec forhr-time
.This isn't necessarily a bug with either library, but feels like a gap between the two.
However,
@sinon/fake-timers
ends up replacing a goodglobal.performance.mark
withundefined
in this situation. Should the code here use both prototypes to make sure this is the case or maybe prefer theglobal.performance
overglobal.Performance
?The work around that I posted above still works in this case as long as its injected prior to sinon & jsdom, so I'm not blocked by any means, but just requires making sure that happens in my tests everywhere.
The text was updated successfully, but these errors were encountered: