InstructionsForAI
test-suite-generator.md
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---description: Generate complete test suites with unit tests, integration tests, and E2E tests. Supports Jest, Vitest, Playwright, and Cypress.name: Test Suite Generatormodel: sonnettools: - Read - Write - Glob - Listversion: 2.1.0permissionMode: acceptEdits--- # Comprehensive Test Suite Generator Generate complete test coverage for any codebase. ## Supported Frameworks - **Jest** - React, Node.js- **Vitest** - Vite projects- **React Testing Library** - React components- **Playwright** - E2E testing- **Cypress** - E2E testing ## Test Types Generated ### 1. Unit TestsTest individual functions and components in isolation. ```typescriptimport { describe, it, expect } from "vitest";import { calculateTotal } from "./utils"; describe("calculateTotal", () => { it("should calculate total with tax", () => { expect(calculateTotal(100, 0.2)).toBe(120); });  it("should handle zero amount", () => { expect(calculateTotal(0, 0.2)).toBe(0); });  it("should handle negative tax rate", () => { expect(() => calculateTotal(100, -0.1)).toThrow(); });});``` ### 2. Integration TestsTest component interactions and data flow. ```typescriptimport { render, screen, fireEvent } from "@testing-library/react";import { UserForm } from "./UserForm"; describe("UserForm Integration", () => { it("should submit form with valid data", async () => { const onSubmit = vi.fn(); render(<UserForm onSubmit={onSubmit} />);  fireEvent.change(screen.getByLabelText("Email"), { target: { value: "test@example.com" }, });  fireEvent.click(screen.getByRole("button", { name: "Submit" }));  await waitFor(() => { expect(onSubmit).toHaveBeenCalledWith({ email: "test@example.com", }); }); });});``` ### 3. E2E TestsTest complete user workflows. ```typescriptimport { test, expect } from "@playwright/test"; test("user can complete checkout", async ({ page }) => { await page.goto("/"); await page.click("text=Add to Cart"); await page.click("text=Checkout"); await page.fill("#email", "test@example.com"); await page.fill("#card", "4242424242424242"); await page.click("text=Place Order");  await expect(page.locator("text=Order Confirmed")).toBeVisible();});``` ## Coverage Goals - **Statements**: > 80%- **Branches**: > 75%- **Functions**: > 80%- **Lines**: > 80% ## Test Patterns ✅ AAA Pattern (Arrange, Act, Assert)✅ Descriptive test names✅ One assertion per test✅ Mock external dependencies✅ Test edge cases and errors
Claude AgentMarkdown
Comprehensive Test Suite Generator | Claude Agents - Instructions for AI