Closed slightlytwisted closed 4 years ago
Love a bug report with a WHATWG link to the reference ❤️
Hey everyone, I'm taking a look at this :)
A question :) This clearTimer()
function appears in 2 different files, why is that? I need to change it, should I change it in both files? I would love for some help.
It seems like only the fake-timers-src.js
affects this process:
@itayperry fake-timers is generated from fake-timers-src through bundling it: https://github.com/sinonjs/fake-timers/blob/7f8322effa73a94dc43896cdfb49d63e821b32d1/package.json#L24 - you should generally only need to edit fake-timers-src.
All ready and tested :) I hope this solves the issue properly.
In the mean time, I've got my test working again by patching the code from the commit mentioned above using patch-package
. Here are the instructions for anyone wants to do the same
node_modules/@sinonjs/fake-timers/src/fake-timers-src.js
and patch this codenpx patch-package @sinonjs/fake-timers
After that, there should be a new file at patches/@sinonjs+fake-timers+6.0.1.patch
with the following content
diff --git a/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js b/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js
index f723db5..7cdd059 100644
--- a/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js
+++ b/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js
@@ -444,7 +444,11 @@ function withGlobal(_global) {
if (clock.timers.hasOwnProperty(id)) {
// check that the ID matches a timer of the correct type
var timer = clock.timers[id];
- if (timer.type === ttype) {
+ if (
+ timer.type === ttype ||
+ (timer.type === "Timeout" && ttype === "Interval") ||
+ (timer.type === "Interval" && ttype === "Timeout")
+ ) {
delete clock.timers[id];
} else {
var clear =
How do I disable this functionality completely? I just want to mock dates and now face timers give an error with node pg, which is not my code. So I need to use something else than sinonjs because it has this kind of side effects.
@tapz Are you running 7.0.1? Cause this was released yesterday and includes the fix for this issue. Not sure how it applies to your case, as I have no idea what you are talking about (way too inspecific), but I would try to npm install @sinonjs/fake-timers@latest
.
@tapz you can .install
with a parameter indicating what to fake - and you can just not mock timers and only mock date.
fake-timers should not assert that calls to
clearTimer()
be passed only timers created bycreateTimer()
and that calls toclearInterval()
be passed only timers created bycreateInterval()
because the HTML Living Standard indicates that:The assertion in fake-timer should probably be relaxed.