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
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 typecheckEach 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:
| Package | Focus |
|---|---|
@allocate/sdk | Schema validation, lifecycle, limits, and contribution safety |
@allocate/mcp | Public and authenticated tools, transport, and auth |
@allocate/cli | Commands, reconciliation, and the stdio MCP server |
@allocate/agent | Providers, orchestrators, and the checkpoint contract |
@allocate/web | API 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
describeblocks. - 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 beforevi.mock().
Validating a contribution
validateOutput() dispatches to the correct Zod schema by the type field and returns { valid, errors, warnings }:
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.