Skip to content

Commit

Permalink
docs: #33837 Clarify that clock.install must precede clock operations (
Browse files Browse the repository at this point in the history
  • Loading branch information
agg23 authored Dec 11, 2024
1 parent 4bcf505 commit a14d975
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/src/clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a14d975

Please sign in to comment.