@baselane/packs 0.1.4 → 0.1.5

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.
Files changed (97) hide show
  1. package/dist/aliases.js +1 -0
  2. package/package.json +2 -2
  3. package/packs/database-review/pack.json +75 -9
  4. package/packs/database-review/rendered/.claude/agents/database-reviewer.md +75 -2
  5. package/packs/database-review/rendered/.claude/commands/migration-review.md +6 -0
  6. package/packs/database-review/rendered/.claude/settings.json +11 -0
  7. package/packs/database-review/rendered/.claude/skills/database-migrations/SKILL.md +431 -0
  8. package/packs/database-review/rendered/.claude/skills/mysql-patterns/SKILL.md +414 -0
  9. package/packs/database-review/rendered/.claude/skills/postgres-patterns/SKILL.md +149 -0
  10. package/packs/database-review/rendered/.github/copilot-instructions.md +1096 -14
  11. package/packs/database-review/rendered/AGENTS.md +45 -16
  12. package/packs/database-review/rendered/CLAUDE.md +4 -0
  13. package/packs/database-review/rendered/GEMINI.md +987 -0
  14. package/packs/go-rules/pack.json +65 -9
  15. package/packs/go-rules/rendered/.claude/agents/go-build-resolver.md +90 -0
  16. package/packs/go-rules/rendered/.claude/agents/go-reviewer.md +72 -2
  17. package/packs/go-rules/rendered/.claude/commands/go-build.md +6 -0
  18. package/packs/go-rules/rendered/.claude/commands/go-review.md +1 -1
  19. package/packs/go-rules/rendered/.claude/commands/go-test.md +6 -0
  20. package/packs/go-rules/rendered/.claude/settings.json +9 -0
  21. package/packs/go-rules/rendered/.claude/skills/golang-patterns/SKILL.md +673 -0
  22. package/packs/go-rules/rendered/.claude/skills/golang-testing/SKILL.md +719 -0
  23. package/packs/go-rules/rendered/.github/copilot-instructions.md +1783 -7
  24. package/packs/go-rules/rendered/AGENTS.md +244 -8
  25. package/packs/go-rules/rendered/CLAUDE.md +5 -0
  26. package/packs/go-rules/rendered/GEMINI.md +1394 -0
  27. package/packs/python-rules/pack.json +87 -10
  28. package/packs/python-rules/rendered/.claude/agents/django-reviewer.md +159 -0
  29. package/packs/python-rules/rendered/.claude/agents/fastapi-reviewer.md +70 -0
  30. package/packs/python-rules/rendered/.claude/agents/python-reviewer.md +92 -2
  31. package/packs/python-rules/rendered/.claude/commands/django-review.md +6 -0
  32. package/packs/python-rules/rendered/.claude/commands/fastapi-review.md +6 -0
  33. package/packs/python-rules/rendered/.claude/commands/python-review.md +1 -1
  34. package/packs/python-rules/rendered/.claude/settings.json +1 -1
  35. package/packs/python-rules/rendered/.claude/skills/django-security/SKILL.md +642 -0
  36. package/packs/python-rules/rendered/.claude/skills/django-tdd/SKILL.md +728 -0
  37. package/packs/python-rules/rendered/.claude/skills/fastapi-patterns/SKILL.md +512 -0
  38. package/packs/python-rules/rendered/.claude/skills/python-patterns/SKILL.md +749 -0
  39. package/packs/python-rules/rendered/.claude/skills/python-testing/SKILL.md +815 -0
  40. package/packs/python-rules/rendered/.github/copilot-instructions.md +3815 -12
  41. package/packs/python-rules/rendered/AGENTS.md +73 -13
  42. package/packs/python-rules/rendered/CLAUDE.md +9 -0
  43. package/packs/python-rules/rendered/GEMINI.md +3448 -0
  44. package/packs/security-review/pack.json +51 -7
  45. package/packs/security-review/rendered/.claude/agents/security-reviewer.md +29 -2
  46. package/packs/security-review/rendered/.claude/settings.json +11 -0
  47. package/packs/security-review/rendered/.claude/skills/security-review/SKILL.md +302 -0
  48. package/packs/security-review/rendered/.claude/skills/security-review/cloud-infrastructure-security.md +171 -0
  49. package/packs/security-review/rendered/.claude/skills/security-scan-config/SKILL.md +56 -0
  50. package/packs/security-review/rendered/.github/copilot-instructions.md +658 -15
  51. package/packs/security-review/rendered/AGENTS.md +283 -17
  52. package/packs/security-review/rendered/CLAUDE.md +2 -0
  53. package/packs/security-review/rendered/GEMINI.md +352 -0
  54. package/packs/software-engineer-harness/pack.json +249 -13
  55. package/packs/software-engineer-harness/rendered/.claude/agents/code-explorer.md +67 -0
  56. package/packs/software-engineer-harness/rendered/.claude/agents/performance-optimizer.md +444 -0
  57. package/packs/software-engineer-harness/rendered/.claude/agents/pr-test-analyzer.md +43 -0
  58. package/packs/software-engineer-harness/rendered/.claude/commands/feature-dev.md +6 -0
  59. package/packs/software-engineer-harness/rendered/.claude/settings.json +29 -0
  60. package/packs/software-engineer-harness/rendered/.claude/skills/api-design/SKILL.md +522 -0
  61. package/packs/software-engineer-harness/rendered/.claude/skills/architecture-decision-records/SKILL.md +178 -0
  62. package/packs/software-engineer-harness/rendered/.claude/skills/backend-patterns/SKILL.md +560 -0
  63. package/packs/software-engineer-harness/rendered/.claude/skills/codebase-onboarding/SKILL.md +232 -0
  64. package/packs/software-engineer-harness/rendered/.claude/skills/deployment-patterns/SKILL.md +426 -0
  65. package/packs/software-engineer-harness/rendered/.claude/skills/docker-patterns/SKILL.md +363 -0
  66. package/packs/software-engineer-harness/rendered/.claude/skills/e2e-testing/SKILL.md +325 -0
  67. package/packs/software-engineer-harness/rendered/.claude/skills/tdd-workflow/SKILL.md +580 -0
  68. package/packs/software-engineer-harness/rendered/.github/copilot-instructions.md +3948 -2
  69. package/packs/software-engineer-harness/rendered/AGENTS.md +194 -4
  70. package/packs/software-engineer-harness/rendered/CLAUDE.md +20 -0
  71. package/packs/software-engineer-harness/rendered/GEMINI.md +3208 -0
  72. package/packs/typescript-rules/pack.json +68 -5
  73. package/packs/typescript-rules/rendered/.claude/agents/react-reviewer.md +165 -0
  74. package/packs/typescript-rules/rendered/.claude/agents/type-design-analyzer.md +48 -0
  75. package/packs/typescript-rules/rendered/.claude/commands/react-review.md +6 -0
  76. package/packs/typescript-rules/rendered/.claude/settings.json +9 -0
  77. package/packs/typescript-rules/rendered/.claude/skills/react-patterns/SKILL.md +340 -0
  78. package/packs/typescript-rules/rendered/.claude/skills/react-performance/SKILL.md +573 -0
  79. package/packs/typescript-rules/rendered/.claude/skills/react-testing/SKILL.md +422 -0
  80. package/packs/typescript-rules/rendered/.github/copilot-instructions.md +2459 -53
  81. package/packs/typescript-rules/rendered/AGENTS.md +893 -17
  82. package/packs/typescript-rules/rendered/CLAUDE.md +6 -0
  83. package/packs/typescript-rules/rendered/GEMINI.md +1335 -0
  84. package/packs/ecc-essentials/pack.json +0 -93
  85. package/packs/ecc-essentials/rendered/.claude/settings.json +0 -37
  86. package/packs/ecc-essentials/rendered/.github/copilot-instructions.md +0 -110
  87. package/packs/ecc-essentials/rendered/AGENTS.md +0 -74
  88. package/packs/ecc-essentials/rendered/CLAUDE.md +0 -14
  89. package/packs/ecc-essentials/rendered/GEMINI.md +0 -25
  90. /package/packs/{ecc-essentials → software-engineer-harness}/rendered/.claude/agents/build-error-resolver.md +0 -0
  91. /package/packs/{ecc-essentials → software-engineer-harness}/rendered/.claude/agents/refactor-cleaner.md +0 -0
  92. /package/packs/{ecc-essentials → software-engineer-harness}/rendered/.claude/agents/silent-failure-hunter.md +0 -0
  93. /package/packs/{ecc-essentials → software-engineer-harness}/rendered/.claude/agents/tdd-guide.md +0 -0
  94. /package/packs/{ecc-essentials → software-engineer-harness}/rendered/.claude/commands/fix-build.md +0 -0
  95. /package/packs/{ecc-essentials → software-engineer-harness}/rendered/.claude/commands/hunt-silent-failures.md +0 -0
  96. /package/packs/{ecc-essentials → software-engineer-harness}/rendered/.claude/commands/tdd.md +0 -0
  97. /package/packs/{ecc-essentials → software-engineer-harness}/rendered/.claude/skills/tdd-red-green-refactor/SKILL.md +0 -0
@@ -0,0 +1,422 @@
1
+ ---
2
+ name: react-testing
3
+ description: Use when writing or fixing tests for React components, hooks, or pages — React Testing Library query priority, userEvent, async assertions, MSW network mocking, accessibility assertions with axe, and the RTL-vs-Playwright decision boundary.
4
+ ---
5
+
6
+ # React Testing
7
+
8
+ Comprehensive React testing patterns for behavior-focused component tests, custom hook tests, accessibility assertions, and network-level mocking.
9
+
10
+ ## When to Activate
11
+
12
+ - Writing tests for React components, custom hooks, or pages
13
+ - Adding test coverage to legacy untested components
14
+ - Migrating from Enzyme or class-component-era patterns to React Testing Library
15
+ - Setting up Vitest or Jest for a new React project
16
+ - Mocking HTTP requests in tests
17
+ - Asserting accessibility violations
18
+ - Deciding which tests belong in RTL vs Playwright Component Testing vs full E2E
19
+
20
+ ## Core Principle
21
+
22
+ Test what the user sees and does, not implementation details.
23
+
24
+ A test should:
25
+
26
+ - Render the component with the same providers it has in production
27
+ - Interact with it via accessible queries (role, label) and `userEvent`
28
+ - Assert visible output and observable side effects (callback fired, request sent)
29
+
30
+ A test should NOT:
31
+
32
+ - Inspect component state, props passed to children, or which hooks were called
33
+ - Mock React itself or framework hooks
34
+ - Assert on the number of renders or DOM structure beyond what affects users
35
+
36
+ ## Library Choice
37
+
38
+ | Runner | When | Note |
39
+ |---|---|---|
40
+ | **Vitest** | Vite, Remix, modern setups | Faster, native ESM, Jest-compatible API |
41
+ | **Jest** | Next.js, CRA, established repos | Default for many React projects |
42
+ | **Playwright Component Testing** | Real browser engine needed | Use when JSDOM lacks the required feature |
43
+ | **Cypress Component Testing** | Real browser, Cypress already in use | Alternative to Playwright CT |
44
+
45
+ Pick one. Do not run RTL + Vitest AND Playwright CT in the same repo unless you have a clear lane separation.
46
+
47
+ ## Query Priority
48
+
49
+ React Testing Library exposes queries in three tiers — use top-down:
50
+
51
+ 1. **Accessible to everyone**: `getByRole`, `getByLabelText`, `getByPlaceholderText`, `getByText`, `getByDisplayValue`
52
+ 2. **Semantic**: `getByAltText`, `getByTitle`
53
+ 3. **Test IDs (escape hatch)**: `getByTestId`
54
+
55
+ ```tsx
56
+ // Best
57
+ screen.getByRole("button", { name: /save/i });
58
+
59
+ // OK for inputs
60
+ screen.getByLabelText("Email");
61
+
62
+ // Last resort
63
+ screen.getByTestId("save-btn");
64
+ ```
65
+
66
+ Variants:
67
+
68
+ - `getBy*` — throws if no match
69
+ - `queryBy*` — returns `null` (use for "assert absence")
70
+ - `findBy*` — async, returns a Promise (use for elements that appear after async work)
71
+
72
+ ## User Interaction with `userEvent`
73
+
74
+ ```tsx
75
+ import userEvent from "@testing-library/user-event";
76
+
77
+ test("submits the form", async () => {
78
+ const user = userEvent.setup();
79
+ const onSubmit = vi.fn();
80
+ render(<UserForm onSubmit={onSubmit} />);
81
+
82
+ await user.type(screen.getByLabelText("Email"), "user@example.com");
83
+ await user.click(screen.getByRole("button", { name: /save/i }));
84
+
85
+ expect(onSubmit).toHaveBeenCalledWith({ email: "user@example.com" });
86
+ });
87
+ ```
88
+
89
+ - Always `await` userEvent calls
90
+ - Call `userEvent.setup()` once per test, reuse the returned `user`
91
+ - `userEvent` simulates a real browser sequence; `fireEvent` dispatches a single synthetic event — prefer `userEvent`
92
+
93
+ ## Async Patterns
94
+
95
+ ```tsx
96
+ // Element that appears after async work
97
+ expect(await screen.findByText("Loaded")).toBeInTheDocument();
98
+
99
+ // Side effect assertion
100
+ await waitFor(() => expect(saveSpy).toHaveBeenCalled());
101
+
102
+ // Element that should disappear
103
+ await waitForElementToBeRemoved(() => screen.queryByText("Loading"));
104
+ ```
105
+
106
+ Never `setTimeout` + assertion — flaky. Use the matchers above.
107
+
108
+ ## Network Mocking with MSW
109
+
110
+ Mock Service Worker mocks at the network layer. The component, hooks, and fetch library all behave exactly as in production.
111
+
112
+ ### Setup
113
+
114
+ ```ts
115
+ // test/setup.ts
116
+ import { setupServer } from "msw/node";
117
+ import { http, HttpResponse } from "msw";
118
+
119
+ export const handlers = [
120
+ http.get("/api/users/:id", ({ params }) =>
121
+ HttpResponse.json({ id: params.id, name: "Alice" }),
122
+ ),
123
+ http.post("/api/users", async ({ request }) => {
124
+ const body = await request.json();
125
+ return HttpResponse.json({ id: "new-id", ...body }, { status: 201 });
126
+ }),
127
+ ];
128
+
129
+ export const server = setupServer(...handlers);
130
+
131
+ beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
132
+ afterEach(() => server.resetHandlers());
133
+ afterAll(() => server.close());
134
+ ```
135
+
136
+ Configure `onUnhandledRequest: "error"` so any unmocked request fails the test loudly — silent passes are worse than red.
137
+
138
+ ### Per-test override
139
+
140
+ ```tsx
141
+ test("renders error on 500", async () => {
142
+ server.use(
143
+ http.get("/api/users/:id", () => new HttpResponse(null, { status: 500 })),
144
+ );
145
+ render(<UserPage id="1" />);
146
+ expect(await screen.findByText(/something went wrong/i)).toBeInTheDocument();
147
+ });
148
+ ```
149
+
150
+ ## Provider Wrapping
151
+
152
+ Wrap providers once in a `test-utils.tsx`:
153
+
154
+ ```tsx
155
+ // test-utils.tsx
156
+ import { render, RenderOptions } from "@testing-library/react";
157
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
158
+
159
+ export function renderWithProviders(
160
+ ui: React.ReactElement,
161
+ options?: RenderOptions,
162
+ ) {
163
+ const queryClient = new QueryClient({
164
+ defaultOptions: { queries: { retry: false } },
165
+ });
166
+
167
+ return render(
168
+ <QueryClientProvider client={queryClient}>
169
+ <ThemeProvider theme={lightTheme}>
170
+ <MemoryRouter>{ui}</MemoryRouter>
171
+ </ThemeProvider>
172
+ </QueryClientProvider>,
173
+ options,
174
+ );
175
+ }
176
+
177
+ export * from "@testing-library/react";
178
+ ```
179
+
180
+ Then `import { renderWithProviders, screen } from "test-utils"` in every test file.
181
+
182
+ ## Custom Hook Testing
183
+
184
+ ```tsx
185
+ import { renderHook, act } from "@testing-library/react";
186
+
187
+ test("useCounter increments and decrements", () => {
188
+ const { result } = renderHook(() => useCounter(0));
189
+
190
+ expect(result.current.count).toBe(0);
191
+
192
+ act(() => result.current.increment());
193
+ expect(result.current.count).toBe(1);
194
+
195
+ act(() => result.current.decrement());
196
+ expect(result.current.count).toBe(0);
197
+ });
198
+
199
+ test("useCounter accepts initial value", () => {
200
+ const { result } = renderHook(() => useCounter(10));
201
+ expect(result.current.count).toBe(10);
202
+ });
203
+
204
+ test("useUser fetches user data", async () => {
205
+ // Instantiate QueryClient ONCE per test outside the wrapper so it survives re-renders.
206
+ // Creating it inside the wrapper closure resets cache state on every render, producing flaky tests.
207
+ const queryClient = new QueryClient({
208
+ defaultOptions: { queries: { retry: false } },
209
+ });
210
+ const wrapper = ({ children }: { children: React.ReactNode }) => (
211
+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
212
+ );
213
+
214
+ const { result } = renderHook(() => useUser("1"), { wrapper });
215
+
216
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
217
+ expect(result.current.data).toEqual({ id: "1", name: "Alice" });
218
+ });
219
+ ```
220
+
221
+ - Wrap state-changing calls in `act`
222
+ - Test through the hook's public API only
223
+ - For hooks that use context, pass a `wrapper`
224
+
225
+ ## Accessibility Assertions
226
+
227
+ ```tsx
228
+ import { axe, toHaveNoViolations } from "jest-axe"; // or vitest-axe
229
+ expect.extend(toHaveNoViolations);
230
+
231
+ test("UserCard has no a11y violations", async () => {
232
+ const { container } = render(<UserCard user={mockUser} />);
233
+ expect(await axe(container)).toHaveNoViolations();
234
+ });
235
+ ```
236
+
237
+ Run axe in component tests for every interactive component. Catches:
238
+
239
+ - Missing labels on form inputs
240
+ - Invalid ARIA usage
241
+ - Poor color contrast (limited — JSDOM has no real CSS engine, so this works for inline styles only; visual contrast belongs in Playwright)
242
+ - Missing alt text on images
243
+ - Heading order violations
244
+
245
+ Cross-link: [skills/accessibility/SKILL.md](../accessibility/SKILL.md) for the broader a11y testing playbook.
246
+
247
+ ## When NOT to Use Snapshot Tests
248
+
249
+ Snapshots of rendered output:
250
+
251
+ - Break on every styling change
252
+ - Get rubber-stamped during review
253
+ - Test implementation detail (DOM structure), not behavior
254
+
255
+ Acceptable snapshot uses:
256
+
257
+ - Pure data serialization functions (`formatInvoice(invoice)` -> stable string)
258
+ - Generated config files (e.g., webpack config output)
259
+
260
+ For visual regression on components, use Playwright/Cypress screenshots or Percy/Chromatic — actual visual diffs, not DOM strings.
261
+
262
+ ## When to Reach for Playwright / Cypress
263
+
264
+ JSDOM (used by Vitest/Jest) cannot:
265
+
266
+ - Render real layout (flexbox, grid, viewport queries)
267
+ - Run native browser animation, CSS transitions
268
+ - Test scrolling behavior, drag-and-drop, paste from clipboard
269
+ - Handle iframes, popups, downloads, cross-origin flows
270
+ - Run real network in a controlled environment with full DevTools support
271
+
272
+ For any of those, use Playwright Component Testing (component test in real browser) or full E2E. See [e2e-testing skill](../e2e-testing/SKILL.md).
273
+
274
+ Decision boundary:
275
+
276
+ - A hook, a presentational component, a form with logic -> RTL
277
+ - A component whose layout matters or that uses browser APIs not in JSDOM -> Playwright CT
278
+ - A full user flow across multiple pages -> Playwright/Cypress E2E
279
+
280
+ ## Coverage Targets
281
+
282
+ | Layer | Target |
283
+ |---|---|
284
+ | Pure utilities | >=90% |
285
+ | Custom hooks | >=85% |
286
+ | Presentational components | >=80% — behavior, not lines |
287
+ | Container components | >=70% — golden paths + error states |
288
+ | Pages | E2E covered separately; smoke test minimum |
289
+
290
+ Configure via `vitest.config.ts` / `jest.config.js`:
291
+
292
+ ```ts
293
+ // vitest.config.ts
294
+ test: {
295
+ coverage: {
296
+ provider: "v8",
297
+ reporter: ["text", "html", "lcov"],
298
+ thresholds: {
299
+ lines: 80,
300
+ functions: 80,
301
+ branches: 70,
302
+ statements: 80,
303
+ },
304
+ },
305
+ }
306
+ ```
307
+
308
+ ## Anti-Patterns
309
+
310
+ - `container.querySelector("...")` — bypasses accessibility queries, lets tests pass when real users would fail
311
+ - Asserting on number of renders — implementation detail
312
+ - `jest.mock("react", ...)` — never mock React. Refactor the component instead
313
+ - Mocking child components by default — tests the integration, not isolation. Mock only when the child has heavy side effects
314
+ - Ignoring `act()` warnings — they signal real bugs (state update after unmount, missing async wrapping)
315
+ - Sharing mutable state across tests — flakes when test order changes
316
+ - Tests that pass with `it.skip()` removed — your test does not actually assert what you think
317
+
318
+ ## TDD Workflow
319
+
320
+ ```
321
+ RED -> Write failing test for the next requirement
322
+ GREEN -> Write minimal component code to pass
323
+ REFACTOR -> Improve the component, tests stay green
324
+ REPEAT -> Next requirement
325
+ ```
326
+
327
+ For new components:
328
+
329
+ 1. Define the component's prop type and signature
330
+ 2. Write the first test for the simplest case
331
+ 3. Verify it fails for the right reason
332
+ 4. Implement just enough to pass
333
+ 5. Add the next test case
334
+ 6. Refactor when the third similar test reveals a pattern
335
+
336
+ ## Test Commands
337
+
338
+ ```bash
339
+ # Vitest
340
+ vitest # watch
341
+ vitest run # one-shot
342
+ vitest run --coverage # with coverage
343
+ vitest run path/to/file.test.tsx # single file
344
+
345
+ # Jest
346
+ jest --watch
347
+ jest --coverage
348
+ jest path/to/file.test.tsx
349
+
350
+ # CI mode
351
+ CI=true vitest run --coverage
352
+ ```
353
+
354
+ ## Related
355
+
356
+ - Rules: [rules/react/testing.md](../../rules/react/testing.md)
357
+ - Skills: [react-patterns](../react-patterns/SKILL.md), [accessibility](../accessibility/SKILL.md), [e2e-testing](../e2e-testing/SKILL.md), [tdd-workflow](../tdd-workflow/SKILL.md)
358
+ - Agents: `react-reviewer` (reviews test quality during code review), `tdd-guide` (enforces TDD process)
359
+ - Commands: `/react-test`, `/react-review`
360
+
361
+ ## Examples
362
+
363
+ ### Form submission with MSW and userEvent
364
+
365
+ ```tsx
366
+ test("submits user form and shows success", async () => {
367
+ server.use(
368
+ http.post("/api/users", () =>
369
+ HttpResponse.json({ id: "1", name: "Alice" }, { status: 201 }),
370
+ ),
371
+ );
372
+
373
+ const user = userEvent.setup();
374
+ renderWithProviders(<UserForm />);
375
+
376
+ await user.type(screen.getByLabelText("Name"), "Alice");
377
+ await user.type(screen.getByLabelText("Email"), "alice@example.com");
378
+ await user.click(screen.getByRole("button", { name: /save/i }));
379
+
380
+ expect(await screen.findByText(/saved successfully/i)).toBeInTheDocument();
381
+ });
382
+ ```
383
+
384
+ ### Testing an error boundary
385
+
386
+ ```tsx
387
+ function Broken() {
388
+ throw new Error("boom");
389
+ }
390
+
391
+ test("error boundary renders fallback", () => {
392
+ // Suppress React's console.error noise for the expected throw, then restore so
393
+ // the spy does not leak across tests and hide real errors elsewhere.
394
+ const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
395
+ try {
396
+ render(
397
+ <ErrorBoundary fallback={<div>Something went wrong</div>}>
398
+ <Broken />
399
+ </ErrorBoundary>,
400
+ );
401
+
402
+ expect(screen.getByText("Something went wrong")).toBeInTheDocument();
403
+ } finally {
404
+ errorSpy.mockRestore();
405
+ }
406
+ });
407
+ ```
408
+
409
+ ### Testing a Suspense boundary
410
+
411
+ ```tsx
412
+ test("shows loading then content", async () => {
413
+ renderWithProviders(
414
+ <Suspense fallback={<div>Loading...</div>}>
415
+ <UserDetail id="1" />
416
+ </Suspense>,
417
+ );
418
+
419
+ expect(screen.getByText("Loading...")).toBeInTheDocument();
420
+ expect(await screen.findByText("Alice")).toBeInTheDocument();
421
+ });
422
+ ```