Skip to content

@xtandard/entitlements/testing

Test helpers: an in-memory engine with a controllable clock, so tests can cross period boundaries, trial ends and grant expiries deterministically.

import { createTestEntitlements } from "@xtandard/entitlements/testing";
const { ent, clock } = createTestEntitlements({ catalog, now: "2026-11-30T23:00:00Z" });
await ent.consume("org_1", "api_calls", 1000);
clock.advance("2h"); // new month → fresh allowance
import { … } from "@xtandard/entitlements/testing";
Name Summary
createTestClock Create a TestClock starting at start (default: real now).
createTestEntitlements An engine on in-memory storage + counters with a test clock, collecting usage, threshold and hook events. User-supplied listeners still run.
Name Summary
TestClock A controllable clock.
TestEntitlements What createTestEntitlements returns.
Name Summary
TestEntitlementsOptions Options for createTestEntitlements.