miqro · @miqro/core · @miqro/parser · @miqro/query · @miqro/jsx · @miqro/jsx-dom · @miqro/jsx-node · @miqro/request · @miqro/runner · @miqro/test · @miqro/test-http
test utilities used by the miqro test runner. (deprecated)
spy function.
import { fake } from "@miqro/test";
const fn = fake((x) => x * 2);
fn(5);
fn(10);
fn.callCount; // 2
fn.callArgs[0]; // [5]
fn.callArgs[1]; // [10]
fn.returnValues[0]; // 10
fn.returnValues[1]; // 20
fn.reset(); // reset counts
mock CJS module dependencies.
import { requireMock } from "@miqro/test";
const module = requireMock("./my-module.js", {
"./dependency.js": {
someFunction: () => "mocked"
}
});
run tests in a forked process.
import { setIsolate } from "@miqro/test";
describe("isolated tests", () => {
setIsolate(true);
it("runs in own process", async () => { ... });
});
note: globalThis.test is not available in isolated processes. use node:test directly for isolated tests.
import { setTestTimeout } from "@miqro/test";
describe("slow tests", () => {
setTestTimeout(10000);
it("takes a while", async () => { ... });
});