Forest Logo
search
package_2

jest-fake-timers

By @eyycheev

Roblox

Mirrored

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:

  • delay
  • tick
  • time
  • os
    • os.time
    • os.clock
  • task.delay
    • task.delay
    • task.cancel
    • task.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.

Package Details

Install command (Click to copy)


Version

3.14.0-rbx.2

License

MIT

check_circle

Safe for commercial use

infoThe package archive does not include its license text; the license is declared in its manifest metadata.

Automated license review — not legal advice.