Skip to content

createTestAudit

function createTestAudit<A>(options?): TestAudit<A>;

Defined in: src/testing.ts:131

An in-memory audit core for tests, with a collecting sink streamed from the beginning of every tenant’s log. No timers run: call flush() to stream.

Type Parameter Default type
A extends ActionMap ActionMap
Parameter Type
options? TestAuditOptions<A>

TestAudit<A>

import { createTestAudit, expectRecorded } from "@xtandard/audit/testing";
const { core, sink, flush } = createTestAudit();
await core.record({ tenant: "acme", action: "invoice.paid", actor: { id: "u1" } });
await expectRecorded(core, { tenant: "acme", action: "invoice.paid", actor: { id: "u1" } });
await flush();
sink.events(); // → [the invoice.paid event]