Skip to content

Commit

Permalink
Add a notice that the Fake Timers API doc is incomplete (#2570)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 authored Nov 5, 2023
1 parent 93db3ef commit 6c9f5c2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/release-source/release/fake-timers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ breadcrumb: fake timers

Fake timers are synchronous implementations of `setTimeout` and friends that
Sinon.JS can overwrite the global functions with to allow you to more easily
test code using them.
test code using them. It also has utilities for working with `async`/Promise code.

Fake timers provide a `clock` object to pass time, which can also be used to control `Date` objects created through either `new Date();`
or `Date.now();` (if supported by the browser).

> The separate Fake Timers project is constantly being added to and updated, and we have a hard time keeping these docs in sync! Therefore it might be better to just refer directly to the [fake-timer API reference][api reference], as that shows all it has to offer. The `clock` object is not wrapped, so everything `fake-timers` has to offer can be used through it.
For standalone usage of fake timers it is recommended to use [fake-timers](https://github.com/sinonjs/fake-timers) package instead. It provides the same
set of features (Sinon uses it under the hood) and was previously extracted from Sinon.JS.

Expand Down Expand Up @@ -39,6 +41,8 @@ set of features (Sinon uses it under the hood) and was previously extracted from

## Fake timers API

> This is just the most important subset of the available methods. Refer to the [Fake Timers API reference][api reference] for the full _smørgåsbord_ of available methods.
#### `var clock = sinon.useFakeTimers();`

Causes Sinon to replace the global `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval`, `setImmediate`, `clearImmediate`, `process.hrtime`, `performance.now`(when available) and `Date` with a custom implementation which is bound to the returned `clock` object.
Expand Down Expand Up @@ -176,3 +180,5 @@ The `runAllAsync()` will also break the event loop, allowing any scheduled promi
Restore the faked methods.

Call in e.g. `tearDown`.

[api reference]: https://github.com/sinonjs/fake-timers#api-reference

0 comments on commit 6c9f5c2

Please sign in to comment.