Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
bun:test
setSystemTime
import { test, expect, setSystemTime } from "bun:test"; test("像 1999 年一样狂欢", () => { const date = new Date("1999-01-01T00:00:00.000Z"); setSystemTime(date); // 现在时间是 1999 年 1 月 1 日 const now = new Date(); expect(now.getFullYear()).toBe(1999); expect(now.getMonth()).toBe(0); expect(now.getDate()).toBe(1); });
beforeAll
import { test, expect, beforeAll, setSystemTime } from "bun:test"; beforeAll(() => { const date = new Date("1999-01-01T00:00:00.000Z"); setSystemTime(date); // 现在时间是 1999 年 1 月 1 日 }); // 测试...
import { test, expect, beforeAll, setSystemTime } from "bun:test"; setSystemTime(); // 重置为实际时间