Closed swenzel-arc closed 1 year ago
All done :)
Btw. do you think we should add a config flag that allows to skip altering the timers module?
Btw. do you think we should add a config flag that allows to skip altering the timers module?
No but that's a good point, it should respect the regular "should I mock setTimeout/setInterval or whatever" option (toFake)
Does it correctly not mock methods if they're not part of toFake?
Yes it does :)
Out as 10.2.0
Seems like #470 made a good candidate for why this could have been behind a flag. Some weird regression hitting us.
Purpose (TL;DR) - mandatory
Fix issue #466
Solution
It works like this:
Try to import
timers
module astimersModule
. If it doesn't work, that's okay.Upon
FakeTimers.install()
, iff we're installing on theglobalObject
andtimersModule
was successfully imported: For each property that was mocked on the globalObject iff it also exists ontimersModule
: Safe its name and original value fromtimersModule
to a new property on the Clock object. Then set it to the same property as the faked property onglobalObject
.Upon
FakeTimers.uninstall()
, iff the object holdingtimersModule
's originals is truthy: For each entry set the corresponding property back to the original.