@theda/test
v0.7.6
Published
Test doubles, in-memory backends, and deterministic context factories for @theda/sdk
Readme
@theda/test
Test doubles, in-memory backends, and deterministic context factories for testing Theda apps.
Install
npm install -D @theda/testQuick start
import { describe, it, expect } from "vitest";
import { createTestContext, inMemoryDb } from "@theda/test";
describe("my command", () => {
it("should transact data", async () => {
const ctx = createTestContext.command();
const result = await ctx.dbTransact.transact("main", {
kind: "concrete",
preconditions: [],
actions: [
{ kind: "assert_single", entityId: "e1", attribute: "name", value: "Alice" },
],
});
expect(result.ok).toBe(true);
});
});What's included
createTestContext— factory forCommandContext,RouteContext,TaskContext, andWorkflowStepContextinMemoryDb— full in-memory database with seeding supportfixedClock/advancingClock— deterministic time for reproducible testssequentialIds— predictable ID generationcannedHttp— stub HTTP responsescaptureJournal— capture and assert on journal entriesinMemoryBlobStore— in-memory blob storagecreateTestWorkflow— step-by-step workflow execution for testing
License
Apache-2.0
