
harness
Run integrations around every test, on any Jest-compatible runner.
Wrap your runner's describe and it once. Every test then runs inside the integrations you configured, and gets what they provide as its first argument.
import { , type } from "@ghostry/harness";
import * as from "bun:test";
import { , } from "node:fs/promises";
import { } from "node:os";
import { } from "node:path";
// Every test gets a fresh directory, removed when the test settles.
const : <{ : string }, string> = {
: "temp directory",
: { : ({ }) => },
async *() {
const = await (((), "test-"));
try {
yield () => ();
} finally {
await (, { : true });
}
},
};
export const { , , } = ({
,
: [],
});
("config", () => {
("writes to its own directory", async ({ dir }) => {
().("test-");
});
});bun, vitest, jest, mocha, and node:test get the same describe, it, hooks, and .each. You pass the runner in, and harness imports nothing of its own.
An integration's frame is a generator with one yield. Setup goes before it, teardown after it, and a try/finally means what it looks like, even for an async test.
Each test's first argument holds what every integration provides, typed from the integrations you passed. Nothing is threaded through by hand.
A test is identified by its describe names, its own name, and its .each row. Integrations derive per-test state from it, so that state doesn't depend on which other tests ran.
attest checks a value with your runner's own expect and narrows its TypeScript type in the same call. No ! or cast on the next line.
A conformance suite tests that your runner, at your version, behaves the way harness needs. Compatibility is something you run, not a list to trust.