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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
A extends ActionMap |
ActionMap |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
TestAuditOptions<A> |
Returns
Section titled “Returns”TestAudit<A>
Example
Section titled “Example”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]