@rbxts-js/jest-fake-timers
v3.13.3-ts.3
Published
Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-fake-timers
Readme
jest-fake-timers
Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-fake-timers
This package contains the fake timers implementation for Jest. It can be activated by calling jest.useFakeTimers(). You can find its documentation in the Jest documentation.
The following timers are mocked:
delayticktimeosos.timeos.clock
task.delaytask.delaytask.canceltask.wait
DateTime
:pencil2: Notes
:exclamation: The fake timer API in Jest Roblox is aligned with the "modern" fake timer implementation in Jest. However, the actual implementation of fake timers in Jest Roblox under the hood massively deviates from upstream so that it works natively with the Roblox ecosystem.
Similar to how Jest fake timers work by mocking the native timer functions (i.e. setTimeout, setInterval, clearTimeout, clearInterval) and Date, Jest Roblox fake timers work by mocking the native timer functions in Roblox (i.e. delay, tick), the Roblox DateTime and the Lua native timer methods os.time and os.clock.
Additionally, Jest Roblox fake timers support a configurable engine frame time. By default, the engine frame time is 0 (i.e. continuous time), but if set, Jest Roblox fake timers will be processed by multiples of frame time. If engine frame time is set, then timers will be processed in the first frame after they are triggered.
