InstructionsForAI
testing-best-practices.mdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---globs: - "**/*.test.ts" - "**/*.test.tsx" - "**/*.spec.ts" - "**/*.spec.tsx"alwaysApply: false--- ## Testing Guidelines ### Test Structure Use the Arrange-Act-Assert pattern: ```typescriptdescribe("calculateTotal", () => { it("should sum items with tax", () => { // Arrange const items = [{ price: 100 }, { price: 50 }]; const taxRate = 0.1;  // Act const result = calculateTotal(items, taxRate);  // Assert expect(result).toBe(165); });});``` ### Naming Conventions - Test files: `*.test.ts` or `*.spec.ts`- Describe blocks: noun (the thing being tested)- It blocks: "should [expected behavior] when [condition]" ### Mocking Use `vi.mock` for module mocks: ```typescriptvi.mock("@/lib/supabase/client", () => ({ createClient: vi.fn(() => mockSupabaseClient),}));``` ### Coverage Requirements - Aim for 80% coverage on business logic- 100% coverage on utility functions- Skip coverage for UI components (use E2E instead)
MDC (Frontmatter)Markdown