(advance-timers-by-time ms)
Advances timers by the provides ms
value. Will run any macrotasks that are currently
or get queued within that time frame.
Advances timers by the provides `ms` value. Will run any macrotasks that are currently or get queued within that time frame.
(advance-timers-by-time+ ms)
Async version of advance-timers-by-time. Runs scheduled promises before macrotasks.
Async version of advance-timers-by-time. Runs scheduled promises _before_ macrotasks.
(advance-timers-to-next-timer)
(advance-timers-to-next-timer steps)
Advances all timers by the needed milliseconds so that only the next timeouts/intervals will run.
If given, will run steps
amount of next timeouts/intervals.
Advances all timers by the needed milliseconds so that only the next timeouts/intervals will run. If given, will run `steps` amount of next timeouts/intervals.
(advance-timers-to-next-timer+)
(advance-timers-to-next-timer+ steps)
Async version of advance-timers-to-next-timer
. Runs scheduled promises before timers.
Async version of `advance-timers-to-next-timer`. Runs scheduled promises _before_ timers.
(clear-all-timers)
Removes all pending timers.
Removes all pending timers.
(get-real-system-time)
Gets the actual system time, even if the timers are currently faked.
Gets the actual system time, even if the timers are currently faked.
(get-timer-count)
Gets the count of queued timers.
Gets the count of queued timers.
(now)
Returns current clock time, in ms. Equivalent to (js/Date.now)
if using real timers or if Date
is mocked.
Returns current clock time, in ms. Equivalent to `(js/Date.now)` if using real timers or if `Date` is mocked.
(run-all-ticks)
Exhaust the microtask queue (runs all pending tasks queued via process.nextTick).
Exhaust the microtask queue (runs all pending tasks queued via process.nextTick).
(run-all-timers)
Exhaust the macrotask and microtask queues.
Exhaust the macrotask and microtask queues.
(run-all-timers+)
Async version of run-all-timers. Runs any schedules promises before timers.
Async version of run-all-timers. Runs any schedules promises _before_ timers.
(run-only-pending-timers)
Executes only the currently pending macrotasks. Does not exhaust and any newly queued macrotasks won't get executed.
Executes only the currently pending macrotasks. Does not exhaust and any newly queued macrotasks won't get executed.
(run-only-pending-timers+)
Async version of run-only-pending-timers
. Runs scheduled promise callbacks before executing pending
macrotasks.
Async version of `run-only-pending-timers`. Runs scheduled promise callbacks _before_ executing pending macrotasks.
(set-system-time)
(set-system-time now)
Sets the current system time used by the fake timers. Will not run any pending timers, even if changing the time to the future would theoretically cause them to run.
Sets the current system time used by the fake timers. Will _not_ run any pending timers, even if changing the time to the future would theoretically cause them to run.
(use-fake-timers!)
(use-fake-timers! options)
Uses fake timers within this block of tests, essentially calling jest.useFakeTimers
before each test and useRealTimers
after each test.
Must be run on the top or describe level. For test level fake timers,
use cljest.timers/with-fake-timers
.
Uses fake timers within this block of tests, essentially calling `jest.useFakeTimers` before each test and `useRealTimers` after each test. Must be run on the top or describe level. For test level fake timers, use `cljest.timers/with-fake-timers`.
(with-fake-timers maybe-options & other-forms)
Runs the provided forms with fake timers, resetting to using real timers at the end of the forms execution. Handles promises.
You can optionally provide options to the fake timers setup, and these options must be a JS value (you need to use the #js reader).
Runs the provided forms with fake timers, resetting to using real timers at the end of the forms execution. Handles promises. You can optionally provide options to the fake timers setup, and these options must be a JS value (you need to use the #js reader).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close