Documentation Index
Fetch the complete documentation index at: https://kubo-47e69177.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Testing Patterns
Live status
Run tests locally
Latest local run from this repository:
@zapaction/core: Test Files 5 passed, Tests 35 passed
@zapaction/react: Test Files 2 passed, Tests 14 passed
@zapaction/query: Test Files 3 passed, Tests 6 passed
Total tests passed: 55
Action contract test
features/todos/actions.test.ts
import { beforeEach, describe, expect, it, vi } from "vitest";
import { __resetActionContextForTests, setActionContext } from "@zapaction/core";
import { createTodo } from "./actions";
vi.mock("next/cache", () => ({ revalidateTag: vi.fn() }));
describe("createTodo", () => {
beforeEach(() => {
__resetActionContextForTests();
setActionContext(async () => ({ userId: "test-user" }));
});
it("creates a todo with valid input", async () => {
const result = await createTodo({ title: "Write tests" });
expect(result.title).toContain("Write tests");
});
});
Hook state test
packages/react/src/useAction.test.ts
import { act, renderHook } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { useAction } from "./useAction";
it("tracks status transitions", async () => {
const action = vi.fn(async (input: { value: string }) => ({ ok: input.value }));
const { result } = renderHook(() => useAction(action));
await act(async () => {
await result.current.execute({ value: "ok" });
});
expect(result.current.isSuccess).toBe(true);
});
Mutation invalidation test
packages/query/src/useActionMutation.test.ts
import { vi } from "vitest";
vi.mock("@tanstack/react-query", () => ({
useQueryClient: () => ({ invalidateQueries: vi.fn() })
}));