@glinr/theauth-test-utils
v0.1.0
Published
Test utilities for TheAuth — mock providers, factories, and assertions for auth test suites
Readme
@glinr/theauth-test-utils
Test helpers for apps using TheAuth: mock providers, factories, and assertions so your auth tests don't have to spin up a real database or an OAuth round-trip.
npm install --save-dev @glinr/@glinr/theauth-test-utilsWhat's in the box
MockKavachProvider: drop-in React provider that returns a fake session, agent, and user. Pair with@testing-library/react.- Factories for
Session,User,AgentIdentity,OrgMembership. Pass overrides; defaults are filled in. - Assertion helpers like
expectSignedIn,expectAgentScope,expectAuditEntryso test failures read clearly.
Example
import { render, screen } from "@testing-library/react";
import { MockKavachProvider, makeUser } from "@glinr/theauth-test-utils";
import { Dashboard } from "../src/dashboard.js";
test("dashboard greets the signed-in user", () => {
const user = makeUser({ name: "Ada Lovelace" });
render(
<MockKavachProvider user={user}>
<Dashboard />
</MockKavachProvider>,
);
expect(screen.getByText(/welcome, ada/i)).toBeInTheDocument();
});Peer deps
react and @glinr/theauth-react are optional peers. Install them only if you're testing React UI. Server-side helpers work without either.
Links
- TheAuth repo: https://github.com/glincker/theauth
- Docs: https://docs.theauth.com
License
MIT
