Skip to main content
Bun’s test runner supports setting the system time programmatically with the setSystemTime function.

The setSystemTime function is commonly used on conjunction with Lifecycle Hooks to configure a testing environment with a deterministic “fake clock”.

To reset the system clock to the actual time, call setSystemTime with no arguments.

See Docs > Test Runner > Date and time for complete documentation on mocking with the Bun test runner.