From a14d9750b314c26d72daa9f33598ad9d66d3e61c Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Tue, 10 Dec 2024 16:18:41 -0800 Subject: [PATCH] docs: #33837 Clarify that clock.install must precede clock operations (#33901) --- docs/src/clock.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/src/clock.md b/docs/src/clock.md index 2f846e4fd3..44582f450b 100644 --- a/docs/src/clock.md +++ b/docs/src/clock.md @@ -34,6 +34,10 @@ The recommended approach is to use `setFixedTime` to set the time to a specific - `Event.timeStamp` ::: +:::warning +If you call `install` at any point in your test, the call _MUST_ occur before any other clock related calls (see note above for list). Calling these methods out of order will result in undefined behavior. For example, you cannot call `setInterval`, followed by `install`, then `clearInterval`, as `install` overrides the native definition of the clock functions. +::: + ## Test with predefined time Often you only need to fake `Date.now` while keeping the timers going.