Skip to main content
Set the system time in tests with the setSystemTime function from bun:test.

Call setSystemTime in a lifecycle hook like beforeAll to give your tests a deterministic “fake clock”.

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

See Dates and times.