Introduce a way to easily override current time in tests #4705
Labels
package:watchdog
type:task
This issue reports a chore (non-production change) and other types of "todos".
Milestone
Testing error handling depending on time is pretty complex because
sinon.useFakeTimers()
make async functions synchronous, which makes promises crashing instantly.E.g. the following test will fail instantly when the
CKEditorError
error is thrown:as it boils down to something like this:
Code after the error isn't executed, thus the test fails instantly. If the error would be in the
setTimeout
, even with timeout 0, the rest of the code would execute and such error wouldn't have an impact on the test behavior.Thus I'm proposing adding the protected
_now()
method to the watchdog, which would return theDate.now()
, so it could be overridden later in tests without affecting other mechanisms depending on time.The text was updated successfully, but these errors were encountered: