Skip to main content
使用 bun:test 中的 setSystemTime 函数在测试中设置系统时间。

生命周期钩子(如 beforeAll)中调用 setSystemTime,为你的测试提供确定性的”假时钟”。

要将系统时钟重置为实际时间,请不带参数调用 setSystemTime

参见 日期和时间