Skip to content

Developer

Testing

How to run and write tests across the Allocate monorepo.

Allocate has Vitest unit tests in every package and Playwright end-to-end suites in the web app. Run a package when checking one layer. Use the full suite for cross-package behavior.

Running tests

Shell
pnpm test                            # All unit and script tests
pnpm --filter @allocate/sdk test     # SDK tests
pnpm --filter @allocate/agent test   # Agent tests
pnpm --filter @allocate/web test     # Web app tests
pnpm --filter @allocate/web lint     # Web app typecheck

Each package's lint script runs tsc --noEmit. Style formatting is checked separately.

Where the tests are

Vitest suites live next to the code they cover or under a package __tests__ directory. Each package concentrates on a different layer:

PackageFocus
@allocate/sdkSchema validation, lifecycle, limits, and contribution safety
@allocate/mcpPublic and authenticated tools, transport, and auth
@allocate/cliCommands, reconciliation, and the stdio MCP server
@allocate/agentProviders, orchestrators, and the checkpoint contract
@allocate/webAPI routes, components, OAuth, and the MCP route

The web app also carries Playwright journeys under apps/web/e2e/ for the public launch, project directory, finding lifecycle, and contribution flows.

Writing tests

  • Group related assertions with describe blocks.
  • Test both valid and invalid inputs for schema validation.
  • For lifecycle tests, verify allowed transitions and the rejection of invalid ones.
  • Use vi.hoisted() for mock state that must exist before vi.mock().

Validating a contribution

validateOutput() dispatches to the correct Zod schema by the type field and returns { valid, errors, warnings }:

TypeScript
import { validateOutput } from "@allocate/sdk";

const result = validateOutput({
  type: "research_finding",
  // ...finding fields
});

if (!result.valid) {
  console.error(result.errors);
}

warnings carries non-fatal guidance: a deprecated schema_version, a thin methodology, or a high-confidence claim with too few sources. A result can have warnings while valid remains true.