Install
npx skillscat add elie222/inbox-zero/testing Install via the SkillsCat registry.
SKILL.md
Testing Guidelines
Testing Framework
vitestis used for testing- Run tests using
cd apps/web && pnpm test --run(notnpx vitest). Don't use sandbox or the test won't run. - Tests are colocated next to the tested file
- Example:
dir/format.tsanddir/format.test.ts
- Example:
- AI tests are placed in the
__tests__directory and are not run by default (they use a real LLM)
Common Mocks
Server-Only Mock
vi.mock("server-only", () => ({}));Prisma Mock
import { beforeEach } from "vitest";
import prisma from "@/utils/__mocks__/prisma";
vi.mock("@/utils/prisma");
describe("example", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("test", async () => {
prisma.group.findMany.mockResolvedValue([]);
});
});Helpers
You can get mocks for emails, accounts, and rules here:
import { getEmail, getEmailAccount, getRule } from "@/__tests__/helpers";Best Practices
- Each test should be independent
- Use descriptive test names
- Mock external dependencies
- Clean up mocks between tests
- Avoid testing implementation details
- Do not mock the Logger