@patricio0312rev/skillset 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/bin/cli.js +37 -0
- package/package.json +55 -0
- package/src/commands/init.js +301 -0
- package/src/index.js +168 -0
- package/src/lib/config.js +200 -0
- package/src/lib/generator.js +166 -0
- package/src/utils/display.js +95 -0
- package/src/utils/readme.js +196 -0
- package/src/utils/tool-specific.js +233 -0
- package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
- package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
- package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
- package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
- package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
- package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
- package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
- package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
- package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
- package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
- package/templates/architecture/adr-writer/ SKILL.md +250 -0
- package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
- package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
- package/templates/architecture/migration-planner/ SKILL.md +376 -0
- package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
- package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
- package/templates/architecture/rfc-generator/ SKILL.md +362 -0
- package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
- package/templates/architecture/system-design-generator/ SKILL.md +339 -0
- package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
- package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
- package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
- package/templates/backend/auth-module-builder/ SKILL.md +99 -0
- package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
- package/templates/backend/caching-strategist/ SKILL.md +190 -0
- package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
- package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
- package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
- package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
- package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
- package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
- package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
- package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
- package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
- package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
- package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
- package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
- package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
- package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
- package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
- package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
- package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
- package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
- package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
- package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
- package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
- package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
- package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
- package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
- package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
- package/templates/foundation/changelog-writer/ SKILL.md +431 -0
- package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
- package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
- package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
- package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
- package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
- package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
- package/templates/foundation/explaining-code/SKILL.md +13 -0
- package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
- package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
- package/templates/foundation/project-scaffolder/references/templates.md +126 -0
- package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
- package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
- package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
- package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
- package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
- package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
- package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
- package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
- package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
- package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
- package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
- package/templates/frontend/table-builder/ SKILL.md +350 -0
- package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
- package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
- package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
- package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
- package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
- package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
- package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
- package/templates/performance/observability-setup/ SKILL.md +232 -0
- package/templates/performance/postmortem-writer/ SKILL.md +203 -0
- package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
- package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
- package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
- package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
- package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
- package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
- package/templates/security/secrets-scanner/ SKILL.md +462 -0
- package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
- package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
- package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
- package/templates/security/threat-model-generator/ SKILL.md +394 -0
- package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
- package/templates/testing/coverage-strategist/ SKILL.md +436 -0
- package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
- package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
- package/templates/testing/integration-test-builder/ SKILL.md +525 -0
- package/templates/testing/mocking-assistant/ SKILL.md +383 -0
- package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
- package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
- package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
- package/templates/testing/unit-test-generator/ SKILL.md +548 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mocking-assistant
|
|
3
|
+
description: Creates stable mocks for APIs, services, and UI components using MSW (Mock Service Worker), fixture conventions, and example patterns. Use for "API mocking", "MSW", "test mocks", or "service mocking".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Mocking Assistant
|
|
7
|
+
|
|
8
|
+
Create reliable mocks for APIs and services in tests.
|
|
9
|
+
|
|
10
|
+
## MSW API Mocking
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// mocks/handlers.ts
|
|
14
|
+
import { http, HttpResponse } from "msw";
|
|
15
|
+
|
|
16
|
+
export const handlers = [
|
|
17
|
+
// GET endpoint
|
|
18
|
+
http.get("/api/users/:id", ({ params }) => {
|
|
19
|
+
const { id } = params;
|
|
20
|
+
|
|
21
|
+
return HttpResponse.json({
|
|
22
|
+
id,
|
|
23
|
+
name: "John Doe",
|
|
24
|
+
email: "john@example.com",
|
|
25
|
+
});
|
|
26
|
+
}),
|
|
27
|
+
|
|
28
|
+
// POST endpoint
|
|
29
|
+
http.post("/api/users", async ({ request }) => {
|
|
30
|
+
const body = await request.json();
|
|
31
|
+
|
|
32
|
+
return HttpResponse.json(
|
|
33
|
+
{
|
|
34
|
+
id: Math.random().toString(),
|
|
35
|
+
...body,
|
|
36
|
+
createdAt: new Date().toISOString(),
|
|
37
|
+
},
|
|
38
|
+
{ status: 201 }
|
|
39
|
+
);
|
|
40
|
+
}),
|
|
41
|
+
|
|
42
|
+
// Error response
|
|
43
|
+
http.get("/api/products/:id", ({ params }) => {
|
|
44
|
+
const { id } = params;
|
|
45
|
+
|
|
46
|
+
if (id === "404") {
|
|
47
|
+
return HttpResponse.json({ error: "Product not found" }, { status: 404 });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return HttpResponse.json({
|
|
51
|
+
id,
|
|
52
|
+
name: "MacBook Pro",
|
|
53
|
+
price: 2499.99,
|
|
54
|
+
});
|
|
55
|
+
}),
|
|
56
|
+
|
|
57
|
+
// Delayed response
|
|
58
|
+
http.get("/api/slow-endpoint", async () => {
|
|
59
|
+
await delay(2000);
|
|
60
|
+
return HttpResponse.json({ data: "Slow response" });
|
|
61
|
+
}),
|
|
62
|
+
];
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## MSW Setup
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// mocks/server.ts
|
|
69
|
+
import { setupServer } from "msw/node";
|
|
70
|
+
import { handlers } from "./handlers";
|
|
71
|
+
|
|
72
|
+
export const server = setupServer(...handlers);
|
|
73
|
+
|
|
74
|
+
// tests/setup.ts
|
|
75
|
+
import { beforeAll, afterEach, afterAll } from "vitest";
|
|
76
|
+
import { server } from "../mocks/server";
|
|
77
|
+
|
|
78
|
+
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
|
79
|
+
afterEach(() => server.resetHandlers());
|
|
80
|
+
afterAll(() => server.close());
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Fixture Conventions
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// mocks/fixtures/users.ts
|
|
87
|
+
export const userFixtures = {
|
|
88
|
+
admin: {
|
|
89
|
+
id: "1",
|
|
90
|
+
email: "admin@example.com",
|
|
91
|
+
name: "Admin User",
|
|
92
|
+
role: "ADMIN",
|
|
93
|
+
},
|
|
94
|
+
customer: {
|
|
95
|
+
id: "2",
|
|
96
|
+
email: "customer@example.com",
|
|
97
|
+
name: "Customer User",
|
|
98
|
+
role: "USER",
|
|
99
|
+
},
|
|
100
|
+
guest: {
|
|
101
|
+
id: "3",
|
|
102
|
+
email: "guest@example.com",
|
|
103
|
+
name: "Guest User",
|
|
104
|
+
role: "GUEST",
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// mocks/fixtures/products.ts
|
|
109
|
+
export const productFixtures = {
|
|
110
|
+
laptop: {
|
|
111
|
+
id: "100",
|
|
112
|
+
name: "MacBook Pro",
|
|
113
|
+
price: 2499.99,
|
|
114
|
+
stock: 10,
|
|
115
|
+
category: "Electronics",
|
|
116
|
+
},
|
|
117
|
+
phone: {
|
|
118
|
+
id: "101",
|
|
119
|
+
name: "iPhone 15",
|
|
120
|
+
price: 999.99,
|
|
121
|
+
stock: 50,
|
|
122
|
+
category: "Electronics",
|
|
123
|
+
},
|
|
124
|
+
outOfStock: {
|
|
125
|
+
id: "102",
|
|
126
|
+
name: "Sold Out Item",
|
|
127
|
+
price: 499.99,
|
|
128
|
+
stock: 0,
|
|
129
|
+
category: "Electronics",
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Usage in handlers
|
|
134
|
+
http.get("/api/users/:id", ({ params }) => {
|
|
135
|
+
const user = Object.values(userFixtures).find((u) => u.id === params.id);
|
|
136
|
+
|
|
137
|
+
if (!user) {
|
|
138
|
+
return HttpResponse.json({ error: "User not found" }, { status: 404 });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return HttpResponse.json(user);
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Test-Specific Mocks
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
// tests/components/UserProfile.test.tsx
|
|
149
|
+
import { server } from "../mocks/server";
|
|
150
|
+
import { http, HttpResponse } from "msw";
|
|
151
|
+
|
|
152
|
+
test("should display user profile", async () => {
|
|
153
|
+
// Override handler for this test
|
|
154
|
+
server.use(
|
|
155
|
+
http.get("/api/users/123", () => {
|
|
156
|
+
return HttpResponse.json({
|
|
157
|
+
id: "123",
|
|
158
|
+
name: "Test User",
|
|
159
|
+
email: "test@example.com",
|
|
160
|
+
});
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
render(<UserProfile userId="123" />);
|
|
165
|
+
|
|
166
|
+
await waitFor(() => {
|
|
167
|
+
expect(screen.getByText("Test User")).toBeInTheDocument();
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("should handle API error", async () => {
|
|
172
|
+
// Mock error response
|
|
173
|
+
server.use(
|
|
174
|
+
http.get("/api/users/123", () => {
|
|
175
|
+
return HttpResponse.json({ error: "Server error" }, { status: 500 });
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
render(<UserProfile userId="123" />);
|
|
180
|
+
|
|
181
|
+
await waitFor(() => {
|
|
182
|
+
expect(screen.getByText("Failed to load user")).toBeInTheDocument();
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Service Mocking
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// src/services/paymentService.ts
|
|
191
|
+
export interface PaymentService {
|
|
192
|
+
processPayment(amount: number, cardToken: string): Promise<PaymentResult>;
|
|
193
|
+
refund(transactionId: string): Promise<void>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// mocks/services/mockPaymentService.ts
|
|
197
|
+
export class MockPaymentService implements PaymentService {
|
|
198
|
+
async processPayment(
|
|
199
|
+
amount: number,
|
|
200
|
+
cardToken: string
|
|
201
|
+
): Promise<PaymentResult> {
|
|
202
|
+
// Simulate successful payment
|
|
203
|
+
if (cardToken.startsWith("tok_success")) {
|
|
204
|
+
return {
|
|
205
|
+
transactionId: "txn_" + Math.random().toString(36),
|
|
206
|
+
status: "success",
|
|
207
|
+
amount,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Simulate failed payment
|
|
212
|
+
if (cardToken.startsWith("tok_fail")) {
|
|
213
|
+
throw new Error("Payment failed");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Simulate slow payment
|
|
217
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
218
|
+
return {
|
|
219
|
+
transactionId: "txn_" + Math.random().toString(36),
|
|
220
|
+
status: "success",
|
|
221
|
+
amount,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async refund(transactionId: string): Promise<void> {
|
|
226
|
+
// Mock refund
|
|
227
|
+
console.log(`Refunding transaction: ${transactionId}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// tests/checkout.test.ts
|
|
232
|
+
const mockPaymentService = new MockPaymentService();
|
|
233
|
+
|
|
234
|
+
test("should process payment successfully", async () => {
|
|
235
|
+
const result = await mockPaymentService.processPayment(
|
|
236
|
+
100,
|
|
237
|
+
"tok_success_123"
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
expect(result.status).toBe("success");
|
|
241
|
+
expect(result.transactionId).toBeDefined();
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Function Mocking with Vitest
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
// src/utils/analytics.ts
|
|
249
|
+
export const trackEvent = (event: string, data: any) => {
|
|
250
|
+
// Send to analytics service
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// tests/component.test.ts
|
|
254
|
+
import { vi } from "vitest";
|
|
255
|
+
import * as analytics from "@/utils/analytics";
|
|
256
|
+
|
|
257
|
+
test("should track button click", () => {
|
|
258
|
+
// Mock function
|
|
259
|
+
const trackEventSpy = vi.spyOn(analytics, "trackEvent");
|
|
260
|
+
|
|
261
|
+
render(<Button onClick={handleClick} />);
|
|
262
|
+
fireEvent.click(screen.getByRole("button"));
|
|
263
|
+
|
|
264
|
+
expect(trackEventSpy).toHaveBeenCalledWith("button_click", {
|
|
265
|
+
buttonId: "submit",
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Date/Time Mocking
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
// tests/date-sensitive.test.ts
|
|
274
|
+
import { vi } from "vitest";
|
|
275
|
+
|
|
276
|
+
test("should show correct greeting based on time", () => {
|
|
277
|
+
// Mock date to morning
|
|
278
|
+
vi.setSystemTime(new Date("2024-01-01 09:00:00"));
|
|
279
|
+
|
|
280
|
+
render(<Greeting />);
|
|
281
|
+
expect(screen.getByText("Good morning!")).toBeInTheDocument();
|
|
282
|
+
|
|
283
|
+
// Mock date to evening
|
|
284
|
+
vi.setSystemTime(new Date("2024-01-01 19:00:00"));
|
|
285
|
+
|
|
286
|
+
render(<Greeting />);
|
|
287
|
+
expect(screen.getByText("Good evening!")).toBeInTheDocument();
|
|
288
|
+
|
|
289
|
+
// Restore real time
|
|
290
|
+
vi.useRealTimers();
|
|
291
|
+
});
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Module Mocking
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
// src/lib/database.ts
|
|
298
|
+
export const db = {
|
|
299
|
+
user: {
|
|
300
|
+
findById: (id: string) => {
|
|
301
|
+
// Real database query
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// tests/mocks/database.ts
|
|
307
|
+
export const mockDb = {
|
|
308
|
+
user: {
|
|
309
|
+
findById: vi.fn((id: string) => ({
|
|
310
|
+
id,
|
|
311
|
+
name: "Mock User",
|
|
312
|
+
email: "mock@example.com",
|
|
313
|
+
})),
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// tests/userService.test.ts
|
|
318
|
+
vi.mock("@/lib/database", () => ({
|
|
319
|
+
db: mockDb,
|
|
320
|
+
}));
|
|
321
|
+
|
|
322
|
+
test("should fetch user from database", async () => {
|
|
323
|
+
const user = await userService.getUser("123");
|
|
324
|
+
|
|
325
|
+
expect(mockDb.user.findById).toHaveBeenCalledWith("123");
|
|
326
|
+
expect(user.name).toBe("Mock User");
|
|
327
|
+
});
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## GraphQL Mocking
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
// mocks/graphql-handlers.ts
|
|
334
|
+
import { graphql, HttpResponse } from "msw";
|
|
335
|
+
|
|
336
|
+
export const graphqlHandlers = [
|
|
337
|
+
graphql.query("GetUser", ({ variables }) => {
|
|
338
|
+
return HttpResponse.json({
|
|
339
|
+
data: {
|
|
340
|
+
user: {
|
|
341
|
+
id: variables.id,
|
|
342
|
+
name: "John Doe",
|
|
343
|
+
email: "john@example.com",
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
}),
|
|
348
|
+
|
|
349
|
+
graphql.mutation("CreateUser", ({ variables }) => {
|
|
350
|
+
return HttpResponse.json({
|
|
351
|
+
data: {
|
|
352
|
+
createUser: {
|
|
353
|
+
id: Math.random().toString(),
|
|
354
|
+
...variables.input,
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
}),
|
|
359
|
+
];
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## Best Practices
|
|
363
|
+
|
|
364
|
+
1. **Use MSW for HTTP**: More realistic than mocking fetch
|
|
365
|
+
2. **Centralize fixtures**: Single source of truth
|
|
366
|
+
3. **Test-specific overrides**: Override defaults per test
|
|
367
|
+
4. **Mock at boundaries**: Services, APIs, not internals
|
|
368
|
+
5. **Realistic data**: Fixtures should match production
|
|
369
|
+
6. **Error scenarios**: Test failure cases
|
|
370
|
+
7. **Timing control**: Mock delays for loading states
|
|
371
|
+
|
|
372
|
+
## Output Checklist
|
|
373
|
+
|
|
374
|
+
- [ ] MSW handlers created
|
|
375
|
+
- [ ] Fixture conventions established
|
|
376
|
+
- [ ] Common fixtures defined
|
|
377
|
+
- [ ] Test-specific mock overrides
|
|
378
|
+
- [ ] Service mocks implemented
|
|
379
|
+
- [ ] Function spies used appropriately
|
|
380
|
+
- [ ] Date/time mocking when needed
|
|
381
|
+
- [ ] Error scenarios mocked
|
|
382
|
+
- [ ] GraphQL mocks (if applicable)
|
|
383
|
+
- [ ] Documentation for mock usage
|