import { useFakeTimer } from "https://deno.land/x/unitest@v1.0.0-beta.82/fake_timer/mod.ts";
Use fake versions of the standard timer functions. The fakeTimer
object is the
return value. Contains a side effect of hijacking the globalThis timer.
import {
expect,
test,
useFakeTimer,
} from "https://deno.land/x/unitest@$VERSION/mod.ts";
test("should hijack default globalThis timer functions", () => {
expect(globalThis["setTimeout"]).toEqual(globalThis["setTimeout"]);
const setTimeout = globalThis["setTimeout"];
const fakeTimer = useFakeTimer();
expect(globalThis["setTimeout"]).not.toEqual(setTimeout);
fakeTimer.useRealTimer();
});