The simplest tests call procedures directly with .callable().
Test a callable procedure
import { describe, expect, it } from "vitest";
import { router } from "./router";
describe("users.get", () => {
it("returns a user", async () => {
const getUser = router.users.get.callable();
await expect(getUser({ id: "1" })).resolves.toEqual({
id: "1",
name: "Ada Lovelace",
});
});
});
Test request context
If the procedure requires context, pass callable options according to your oRPC setup.
const me = router.users.me.callable({
context: {
user: { id: "u_123", role: "member" },
},
});
await expect(me()).resolves.toEqual({ id: "u_123", role: "member" });
Test Effect errors
const getUser = router.users.get.callable();
await expect(getUser({ id: "missing" })).rejects.toMatchObject({
code: "USER_NOT_FOUND_ERROR",
status: 404,
});
Test through HTTP only when needed
Use direct procedure tests for business logic. Add HTTP tests when you need to verify framework mounting, headers, CORS, serialization, or OpenAPI routes.
Repository examples
The package test suite in packages/effect-orpc/src/tests is a good source of low-level examples for builder behavior, contracts, tagged errors, and runtime boundaries. Last modified on June 15, 2026