Installation
Harness is ESM only and has no runtime dependencies. Install it as a dev dependency:
It's also published to JSR.
Requirements
- Node 20 or later, Bun, or Deno.
- A Jest-compatible test runner: bun, vitest, jest, mocha, or
node:test. Harness doesn't depend on any of them. You pass the one you use toinitialize. - TypeScript is not required, but it is strongly recommended. The test context and the wrapped API are typed from your integrations and your runner. Harness's types need TypeScript 5.0 or later.
Bun 1.2.23 or later
The recommended setup is one shared module that calls initialize and that every test file imports. Bun before 1.2.23 ties a module's bun:test import to the first test file that loads it, so every later file's tests are dropped with no error. That happens with or without harness.
On an older Bun, export a function from the setup module instead, and have each test file call it with its own runner import:
// test/setup.ts
import { initialize } from "@ghostry/harness";
import type * as Bun from "bun:test";
export const setup = (framework: typeof Bun) =>
initialize({ framework, integrations });// test/user.test.ts
import * as framework from "bun:test";
import { setup } from "./setup";
const { describe, it, expect } = setup(framework);Integrations from other libraries
An integration lives in the library it integrates, and harness depends on none of them. Fabricator's, for example, is @ghostry/fabricator/harnessing. See fabricator's Harness guide.
