[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7594Z2DN5QJNK1GRRVK6M70":3,"skill-same:01M7594Z2DN5QJNK1GRRVK6M70":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":51,"ownerHtmlUrl":52,"ownerBlogUrl":6,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M7594Z2DN5QJNK1GRRVK6M70","react-component-testing",null,"React component testing patterns — mocking UI libraries (recharts), React Query, MSW with direct fetch, file upload flows, browser API stubs that don't break jsdom\u002FReact, vitest hoisting, and state-vs-data pitfalls.","lukemcqueen\u002Fsteadfaste-fleet","lukemcqueen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F405240?v=4","01M757MHPAGRXTJAT46SKZP98R","Luke McQueen","01M757MHPZ573KP8DT9GB8SBQ7",4,"MIT","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fsoftware-development\u002Freact-component-testing\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: react-component-testing\ndescription: \"React component testing patterns — mocking UI libraries (recharts), React Query, MSW with direct fetch, file upload flows, browser API stubs that don't break jsdom\u002FReact, vitest hoisting, and state-vs-data pitfalls.\"\nversion: 1.0.0\nauthor: Hermes Agent\nlicense: MIT\nplatforms: [linux, macos, windows]\nmetadata:\n  hermes:\n    tags: [react, testing, vitest, recharts, react-query, msw, jsdom, browser-apis, file-upload, fetch]\n    related_skills: [test-driven-development, react-best-practices]\n---\n\n# React Component Testing Patterns\n\n## Overview\n\nTesting React components that use third-party chart libraries (recharts), data-fetching (React Query), and internal state requires specific mocking strategies because these libraries don't render properly in jsdom. This skill captures proven patterns and common pitfalls, distilled from real test suites that fought every one of these battles.\n\n## When to Use\n\n- Testing components that render recharts or other SVG-based chart libraries\n- Testing components using `useQuery` from React Query\n- Testing components with MSW-intercepted `fetch` calls\n- Testing file upload flows\n- Testing components that touch browser APIs (ResizeObserver, matchMedia, scrollTo, IntersectionObserver)\n- Any vitest + jsdom setup hitting \"not implemented\" errors\n- Debugging flaky component tests\n\n## Core Principles\n\n### 1. Test behavior, not implementation\n\nAssert on what the user sees and does — rendered text, roles, calls to\nhandlers — not on internal function calls or DOM structure. If a test must\nreach into internals, that's a signal the component is over-coupling.\n\n### 2. One mock layer, not three\n\nMock the **boundary** — the network (MSW), the third-party library (recharts),\nthe browser API (ResizeObserver). Don't mock your own API modules AND the\nfetch layer AND the component's props. Choose the outermost layer that keeps\nthe test deterministic.\n\n### 3. retry: false everywhere in tests\n\nReact Query retries failed queries by default. In tests, a transient failure\nbecomes a 3× retry loop that makes `waitFor` flaky or hangs:\n\n```tsx\nconst queryClient = new QueryClient({\n  defaultOptions: { queries: { retry: false } },\n});\n```\n\n## Pattern 1 — Mocking recharts\n\nrecharts uses ResizeObserver + SVG rendering that breaks in jsdom. Mock the\nlibrary itself. This is the ONLY reliable way — trying to make recharts\nrender in jsdom is a rabbit hole:\n\n```tsx\n\u002F\u002F __mocks__\u002Frecharts.tsx\nexport const ResponsiveContainer = ({ children }: any) => \u003Cdiv>{children}\u003C\u002Fdiv>;\nexport const BarChart = ({ children }: any) => \u003Cdiv data-testid=\"bar-chart\">{children}\u003C\u002Fdiv>;\nexport const Bar = () => \u003Cdiv \u002F>;\nexport const XAxis = () => \u003Cdiv \u002F>;\nexport const YAxis = () => \u003Cdiv \u002F>;\nexport const Tooltip = () => \u003Cdiv \u002F>;\nexport const CartesianGrid = () => \u003Cdiv \u002F>;\nexport const Legend = () => \u003Cdiv \u002F>;\n```\n\n```tsx\n\u002F\u002F in the test\nvi.mock(\"recharts\");\n```\n\nAssert on the wrapper testid, not SVG internals:\n\n```tsx\nexpect(screen.getByTestId(\"bar-chart\")).toBeInTheDocument();\nexpect(screen.getByTestId(\"bar-chart\")).toHaveTextContent(\"Expected Label\");\n```\n\n### If the chart must show real data\n\nRender the data through the mock's children — pass the same data props and\nassert the mock receives them:\n\n```tsx\nconst { container } = render(\u003CBarChart data={mockData} \u002F>);\n\u002F\u002F The mock renders children; assert labels appear\n```\n\n## Pattern 2 — React Query\n\n### Wrapper\n\n```tsx\nfunction renderWithClient(ui: React.ReactElement) {\n  const queryClient = new QueryClient({\n    defaultOptions: { queries: { retry: false } },\n  });\n  return render(\n    \u003CQueryClientProvider client={queryClient}>{ui}\u003C\u002FQueryClientProvider>\n  );\n}\n```\n\n### Async data resolution\n\n```tsx\nawait waitFor(() => {\n  expect(screen.getByText(\"Loaded data\")).toBeInTheDocument();\n});\n```\n\n### Loading state\n\n```tsx\n\u002F\u002F Initial render shows loading\nexpect(screen.getByTestId(\"loading\")).toBeInTheDocument();\n\u002F\u002F After resolution\nawait waitFor(() => expect(screen.queryByTestId(\"loading\")).not.toBeInTheDocument());\n```\n\n### Error state\n\n```tsx\nserver.use(\n  http.get(\"\u002Fapi\u002Fitems\", () => HttpResponse.json({ message: \"boom\" }, { status: 500 }))\n);\nawait waitFor(() => expect(screen.getByText(\u002Ferror\u002Fi)).toBeInTheDocument());\n```\n\n### Invalidation after mutation\n\n```tsx\nawait userEvent.click(screen.getByRole(\"button\", { name: \u002Fsave\u002Fi }));\nawait waitFor(() => expect(mockFn).toHaveBeenCalled());\n```\n\n## Pattern 3 — MSW with direct fetch\n\nMSW intercepts at the network boundary, so your components exercise their\nREAL fetch\u002Faxios code — no mocking of your own API layer:\n\n```ts\n\u002F\u002F mocks\u002Fserver.ts\nimport { setupServer } from \"msw\u002Fnode\";\nimport { http, HttpResponse } from \"msw\";\n\nexport const server = setupServer(\n  http.get(\"\u002Fapi\u002Fitems\", () => HttpResponse.json([{ id: 1, name: \"alpha\" }])),\n  http.post(\"\u002Fapi\u002Fitems\", async ({ request }) => {\n    const body = await request.json();\n    return HttpResponse.json({ id: 2, ...body }, { status: 201 });\n  })\n);\n```\n\n```ts\n\u002F\u002F vitest.setup.ts\nimport { server } from \".\u002Fmocks\u002Fserver\";\n\nbeforeAll(() => server.listen());\nafterEach(() => server.resetHandlers());\nafterAll(() => server.close());\n```\n\n### Per-test overrides\n\n```tsx\nserver.use(\n  http.get(\"\u002Fapi\u002Fitems\", () => HttpResponse.json([], { status: 200 }))\n);\n```\n\n### Why MSW over module mocks\n\n- Your API module's real code runs — URL building, error mapping, response\n  parsing all get tested.\n- No drift between \"what the mock returns\" and \"what the API really returns\".\n- Adding a new endpoint to a component test is a one-line handler, not a\n  new module mock.\n\n## Pattern 4 — File upload flows\n\n```tsx\nimport userEvent from \"@testing-library\u002Fuser-event\";\n\nit(\"shows the uploaded file name\", async () => {\n  const file = new File([\"name,value\\n1,2\"], \"data.csv\", { type: \"text\u002Fcsv\" });\n  const input = screen.getByLabelText(\u002Fupload\u002Fi) as HTMLInputElement;\n\n  await userEvent.upload(input, file);\n\n  expect(screen.getByText(\"data.csv\")).toBeInTheDocument();\n});\n```\n\n### Multiple files\n\n```tsx\nconst files = [\n  new File([\"a\"], \"a.csv\", { type: \"text\u002Fcsv\" }),\n  new File([\"b\"], \"b.csv\", { type: \"text\u002Fcsv\" }),\n];\nawait userEvent.upload(input, files);\n```\n\n### Drag-and-drop\n\n```tsx\nconst dropzone = screen.getByTestId(\"dropzone\");\nawait userEvent.upload(dropzone, file);\n```\n\n## Pattern 5 — Browser API stubs\n\njsdom doesn't implement ResizeObserver, matchMedia, scrollTo,\nIntersectionObserver, or URL.createObjectURL. Stub them in a setup file —\nminimally, so you don't mask real behavior:\n\n```ts\n\u002F\u002F vitest.setup.ts\nclass ResizeObserverMock {\n  observe() {}\n  unobserve() {}\n  disconnect() {}\n}\nglobal.ResizeObserver = ResizeObserverMock as unknown as typeof ResizeObserver;\n\nObject.defineProperty(window, \"matchMedia\", {\n  writable: true,\n  value: (query: string) => ({\n    matches: false,\n    media: query,\n    addEventListener: () => {},\n    removeEventListener: () => {},\n    dispatchEvent: () => false,\n  }),\n});\n\nObject.defineProperty(window, \"scrollTo\", {\n  writable: true,\n  value: () => {},\n});\n```\n\n### URL.createObjectURL \u002F revokeObjectURL\n\nUsed by file-preview components. jsdom has neither:\n\n```ts\nglobal.URL.createObjectURL = vi.fn(() => \"blob:mock-url\");\nglobal.URL.revokeObjectURL = vi.fn();\n```\n\n## Pattern 6 — vitest hoisting\n\n`vi.mock` calls are hoisted above imports. You CANNOT reference variables\ndeclared after the imports inside the factory — the reference is undefined\nat hoist time. Use `vi.hoisted`:\n\n```tsx\nconst { mockFn } = vi.hoisted(() => ({ mockFn: vi.fn() }));\n\nvi.mock(\"..\u002Fapi\", () => ({ fetchData: mockFn }));\n```\n\nWithout `vi.hoisted`, the classic error is `ReferenceError: Cannot access\n'mockFn' before initialization`.\n\n### Mocking a hook module\n\n```tsx\nconst { useUser } = vi.hoisted(() => ({ useUser: vi.fn() }));\n\nvi.mock(\"..\u002Fhooks\u002Fuse-user\", () => ({ useUser }));\n\nuseUser.mockReturnValue({ id: 1, name: \"Ada\" });\n```\n\n## State-vs-Data Pitfall\n\nA component re-renders for **state changes** (interaction) AND **data\nchanges** (query refetch). When a test fails, classify first:\n\n| Symptom | Likely cause | Fix |\n|---------|-------------|-----|\n| Text updates after click, but fetch mock never called | State path only — the click doesn't refetch | Assert on state-driven render; the test is correct as written |\n| Data renders but interaction assertions fail | The interaction triggers a refetch that resets state | Mock the refetch (return cached data), assert state after |\n| `waitFor` times out | retry: true, or the query never resolves | retry: false; check the MSW handler matches the URL |\n| Flaky across runs | Shared module state \u002F no cleanup | Reset handlers + clear QueryClient between tests |\n\n**Never conflate the two:** a passing interaction test with a broken fetch\nmock tells you nothing about data rendering. Write separate tests for\nstate-driven and data-driven behavior.\n\n## Async Utils — waitFor vs findBy\n\n- `screen.findByText()` — waits for an element; prefer over\n  `waitFor(() => screen.getByText())` when asserting existence.\n- `waitFor` — use when the condition isn't a single element (e.g., a mock\n  was called, a count changed).\n\n```tsx\n\u002F\u002F Prefer\nexpect(await screen.findByText(\"Loaded\")).toBeInTheDocument();\n\n\u002F\u002F Over\nawait waitFor(() => expect(screen.getByText(\"Loaded\")).toBeInTheDocument());\n```\n\n## Pitfalls Checklist\n\n- ❌ **Full recharts render** — SVG in jsdom is not layout; always mock the library\n- ❌ **`retry: true` in tests** — failed queries retry and make `waitFor` flaky\n- ❌ **No cleanup between tests** — stale DOM\u002Fquery cache leaks across tests\n- ❌ **Mocking your own API module instead of MSW** — locks in implementation details\n- ❌ **`vi.mock` factory referencing outer variables** — use `vi.hoisted`\n- ❌ **Asserting on SVG internals** — brittle; assert on testids\u002Ftext\n- ❌ **Not resetting MSW handlers** — per-test overrides leak into later tests\n- ❌ **`userEvent` not awaited** — unawaited userEvent causes act warnings and flakiness\n- ❌ **Testing library not installed** — `@testing-library\u002Freact` + `@testing-library\u002Fjest-dom` + `@testing-library\u002Fuser-event` are required; `user-event` needs a setup entry\n\n## Verification\n\n```bash\n# Run the component test suite\npnpm vitest run --reporter=verbose\n\n# Confirm zero failures and zero act() warnings\n# Act warnings hide real bugs — don't suppress them with console.error mocks\n```\n\n## Related\n- `test-driven-development` — RED-GREEN-REFACTOR discipline\n- `react-best-practices` — performance\u002Fquality rules\n- `react-composition-patterns` — component structure that makes testing easier\n- `storybook-setup` — Storybook for component documentation\n- `change-test-loop` — small changes, verified\n","# React Component Testing Patterns\n\n## Overview\n\nTesting React components that use third-party chart libraries (recharts), data-fetching (React Query), and internal state requires specific mocking strategies because these libraries don't render properly in jsdom. This skill captures proven patterns and common pitfalls, distilled from real test suites that fought every one of these battles.\n\n## When to Use\n\n- Testing components that render recharts or other SVG-based chart libraries\n- Testing components using `useQuery` from React Query\n- Testing components with MSW-intercepted `fetch` calls\n- Testing file upload flows\n- Testing components that touch browser APIs (ResizeObserver, matchMedia, scrollTo, IntersectionObserver)\n- Any vitest + jsdom setup hitting \"not implemented\" errors\n- Debugging flaky component tests\n\n## Core Principles\n\n### 1. Test behavior, not implementation\n\nAssert on what the user sees and does — rendered text, roles, calls to\nhandlers — not on internal function calls or DOM structure. If a test must\nreach into internals, that's a signal the component is over-coupling.\n\n### 2. One mock layer, not three\n\nMock the **boundary** — the network (MSW), the third-party library (recharts),\nthe browser API (ResizeObserver). Don't mock your own API modules AND the\nfetch layer AND the component's props. Choose the outermost layer that keeps\nthe test deterministic.\n\n### 3. retry: false everywhere in tests\n\nReact Query retries failed queries by default. In tests, a transient failure\nbecomes a 3× retry loop that makes `waitFor` flaky or hangs:\n\n```tsx\nconst queryClient = new QueryClient({\n  defaultOptions: { queries: { retry: false } },\n});\n```\n\n## Pattern 1 — Mocking recharts\n\nrecharts uses ResizeObserver + SVG rendering that breaks in jsdom. Mock the\nlibrary itself. This is the ONLY reliable way — trying to make recharts\nrender in jsdom is a rabbit hole:\n\n```tsx\n\u002F\u002F __mocks__\u002Frecharts.tsx\nexport const ResponsiveContainer = ({ children }: any) => \u003Cdiv>{children}\u003C\u002Fdiv>;\nexport const BarChart = ({ children }: any) => \u003Cdiv data-testid=\"bar-chart\">{children}\u003C\u002Fdiv>;\nexport const Bar = () => \u003Cdiv \u002F>;\nexport const XAxis = () => \u003Cdiv \u002F>;\nexport const YAxis = () => \u003Cdiv \u002F>;\nexport const Tooltip = () => \u003Cdiv \u002F>;\nexport const CartesianGrid = () => \u003Cdiv \u002F>;\nexport const Legend = () => \u003Cdiv \u002F>;\n```\n\n```tsx\n\u002F\u002F in the test\nvi.mock(\"recharts\");\n```\n\nAssert on the wrapper testid, not SVG internals:\n\n```tsx\nexpect(screen.getByTestId(\"bar-chart\")).toBeInTheDocument();\nexpect(screen.getByTestId(\"bar-chart\")).toHaveTextContent(\"Expected Label\");\n```\n\n### If the chart must show real data\n\nRender the data through the mock's children — pass the same data props and\nassert the mock receives them:\n\n```tsx\nconst { container } = render(\u003CBarChart data={mockData} \u002F>);\n\u002F\u002F The mock renders children; assert labels appear\n```\n\n## Pattern 2 — React Query\n\n### Wrapper\n\n```tsx\nfunction renderWithClient(ui: React.ReactElement) {\n  const queryClient = new QueryClient({\n    defaultOptions: { queries: { retry: false } },\n  });\n  return render(\n    \u003CQueryClientProvider client={queryClient}>{ui}\u003C\u002FQueryClientProvider>\n  );\n}\n```\n\n### Async data resolution\n\n```tsx\nawait waitFor(() => {\n  expect(screen.getByText(\"Loaded data\")).toBeInTheDocument();\n});\n```\n\n### Loading state\n\n```tsx\n\u002F\u002F Initial render shows loading\nexpect(screen.getByTestId(\"loading\")).toBeInTheDocument();\n\u002F\u002F After resolution\nawait waitFor(() => expect(screen.queryByTestId(\"loading\")).not.toBeInTheDocument());\n```\n\n### Error state\n\n```tsx\nserver.use(\n  http.get(\"\u002Fapi\u002Fitems\", () => HttpResponse.json({ message: \"boom\" }, { status: 500 }))\n);\nawait waitFor(() => expect(screen.getByText(\u002Ferror\u002Fi)).toBeInTheDocument());\n```\n\n### Invalidation after mutation\n\n```tsx\nawait userEvent.click(screen.getByRole(\"button\", { name: \u002Fsave\u002Fi }));\nawait waitFor(() => expect(mockFn).toHaveBeenCalled());\n```\n\n## Pattern 3 — MSW with direct fetch\n\nMSW intercepts at the network boundary, so your components exercise their\nREAL fetch\u002Faxios code — no mocking of your own API layer:\n\n```ts\n\u002F\u002F mocks\u002Fserver.ts\nimport { setupServer } from \"msw\u002Fnode\";\nimport { http, HttpResponse } from \"msw\";\n\nexport const server = setupServer(\n  http.get(\"\u002Fapi\u002Fitems\", () => HttpResponse.json([{ id: 1, name: \"alpha\" }])),\n  http.post(\"\u002Fapi\u002Fitems\", async ({ request }) => {\n    const body = await request.json();\n    return HttpResponse.json({ id: 2, ...body }, { status: 201 });\n  })\n);\n```\n\n```ts\n\u002F\u002F vitest.setup.ts\nimport { server } from \".\u002Fmocks\u002Fserver\";\n\nbeforeAll(() => server.listen());\nafterEach(() => server.resetHandlers());\nafterAll(() => server.close());\n```\n\n### Per-test overrides\n\n```tsx\nserver.use(\n  http.get(\"\u002Fapi\u002Fitems\", () => HttpResponse.json([], { status: 200 }))\n);\n```\n\n### Why MSW over module mocks\n\n- Your API module's real code runs — URL building, error mapping, response\n  parsing all get tested.\n- No drift between \"what the mock returns\" and \"what the API really returns\".\n- Adding a new endpoint to a component test is a one-line handler, not a\n  new module mock.\n\n## Pattern 4 — File upload flows\n\n```tsx\nimport userEvent from \"@testing-library\u002Fuser-event\";\n\nit(\"shows the uploaded file name\", async () => {\n  const file = new File([\"name,value\\n1,2\"], \"data.csv\", { type: \"text\u002Fcsv\" });\n  const input = screen.getByLabelText(\u002Fupload\u002Fi) as HTMLInputElement;\n\n  await userEvent.upload(input, file);\n\n  expect(screen.getByText(\"data.csv\")).toBeInTheDocument();\n});\n```\n\n### Multiple files\n\n```tsx\nconst files = [\n  new File([\"a\"], \"a.csv\", { type: \"text\u002Fcsv\" }),\n  new File([\"b\"], \"b.csv\", { type: \"text\u002Fcsv\" }),\n];\nawait userEvent.upload(input, files);\n```\n\n### Drag-and-drop\n\n```tsx\nconst dropzone = screen.getByTestId(\"dropzone\");\nawait userEvent.upload(dropzone, file);\n```\n\n## Pattern 5 — Browser API stubs\n\njsdom doesn't implement ResizeObserver, matchMedia, scrollTo,\nIntersectionObserver, or URL.createObjectURL. Stub them in a setup file —\nminimally, so you don't mask real behavior:\n\n```ts\n\u002F\u002F vitest.setup.ts\nclass ResizeObserverMock {\n  observe() {}\n  unobserve() {}\n  disconnect() {}\n}\nglobal.ResizeObserver = ResizeObserverMock as unknown as typeof ResizeObserver;\n\nObject.defineProperty(window, \"matchMedia\", {\n  writable: true,\n  value: (query: string) => ({\n    matches: false,\n    media: query,\n    addEventListener: () => {},\n    removeEventListener: () => {},\n    dispatchEvent: () => false,\n  }),\n});\n\nObject.defineProperty(window, \"scrollTo\", {\n  writable: true,\n  value: () => {},\n});\n```\n\n### URL.createObjectURL \u002F revokeObjectURL\n\nUsed by file-preview components. jsdom has neither:\n\n```ts\nglobal.URL.createObjectURL = vi.fn(() => \"blob:mock-url\");\nglobal.URL.revokeObjectURL = vi.fn();\n```\n\n## Pattern 6 — vitest hoisting\n\n`vi.mock` calls are hoisted above imports. You CANNOT reference variables\ndeclared after the imports inside the factory — the reference is undefined\nat hoist time. Use `vi.hoisted`:\n\n```tsx\nconst { mockFn } = vi.hoisted(() => ({ mockFn: vi.fn() }));\n\nvi.mock(\"..\u002Fapi\", () => ({ fetchData: mockFn }));\n```\n\nWithout `vi.hoisted`, the classic error is `ReferenceError: Cannot access\n'mockFn' before initialization`.\n\n### Mocking a hook module\n\n```tsx\nconst { useUser } = vi.hoisted(() => ({ useUser: vi.fn() }));\n\nvi.mock(\"..\u002Fhooks\u002Fuse-user\", () => ({ useUser }));\n\nuseUser.mockReturnValue({ id: 1, name: \"Ada\" });\n```\n\n## State-vs-Data Pitfall\n\nA component re-renders for **state changes** (interaction) AND **data\nchanges** (query refetch). When a test fails, classify first:\n\n| Symptom | Likely cause | Fix |\n|---------|-------------|-----|\n| Text updates after click, but fetch mock never called | State path only — the click doesn't refetch | Assert on state-driven render; the test is correct as written |\n| Data renders but interaction assertions fail | The interaction triggers a refetch that resets state | Mock the refetch (return cached data), assert state after |\n| `waitFor` times out | retry: true, or the query never resolves | retry: false; check the MSW handler matches the URL |\n| Flaky across runs | Shared module state \u002F no cleanup | Reset handlers + clear QueryClient between tests |\n\n**Never conflate the two:** a passing interaction test with a broken fetch\nmock tells you nothing about data rendering. Write separate tests for\nstate-driven and data-driven behavior.\n\n## Async Utils — waitFor vs findBy\n\n- `screen.findByText()` — waits for an element; prefer over\n  `waitFor(() => screen.getByText())` when asserting existence.\n- `waitFor` — use when the condition isn't a single element (e.g., a mock\n  was called, a count changed).\n\n```tsx\n\u002F\u002F Prefer\nexpect(await screen.findByText(\"Loaded\")).toBeInTheDocument();\n\n\u002F\u002F Over\nawait waitFor(() => expect(screen.getByText(\"Loaded\")).toBeInTheDocument());\n```\n\n## Pitfalls Checklist\n\n- ❌ **Full recharts render** — SVG in jsdom is not layout; always mock the library\n- ❌ **`retry: true` in tests** — failed queries retry and make `waitFor` flaky\n- ❌ **No cleanup between tests** — stale DOM\u002Fquery cache leaks across tests\n- ❌ **Mocking your own API module instead of MSW** — locks in implementation details\n- ❌ **`vi.mock` factory referencing outer variables** — use `vi.hoisted`\n- ❌ **Asserting on SVG internals** — brittle; assert on testids\u002Ftext\n- ❌ **Not resetting MSW handlers** — per-test overrides leak into later tests\n- ❌ **`userEvent` not awaited** — unawaited userEvent causes act warnings and flakiness\n- ❌ **Testing library not installed** — `@testing-library\u002Freact` + `@testing-library\u002Fjest-dom` + `@testing-library\u002Fuser-event` are required; `user-event` needs a setup entry\n\n## Verification\n\n```bash\n# Run the component test suite\npnpm vitest run --reporter=verbose\n\n# Confirm zero failures and zero act() warnings\n# Act warnings hide real bugs — don't suppress them with console.error mocks\n```\n\n## Related\n- `test-driven-development` — RED-GREEN-REFACTOR discipline\n- `react-best-practices` — performance\u002Fquality rules\n- `react-composition-patterns` — component structure that makes testing easier\n- `storybook-setup` — Storybook for component documentation\n- `change-test-loop` — small changes, verified\n",{"name":5,"author":24,"license":15,"version":25,"metadata":26,"platforms":42,"description":7},"Hermes Agent","1.0.0",{"hermes":27},{"tags":28,"related_skills":39},[29,30,31,32,33,34,35,36,37,38],"react","testing","vitest","recharts","react-query","msw","jsdom","browser-apis","file-upload","fetch",[40,41],"test-driven-development","react-best-practices",[43,44,45],"linux","macos","windows","main","2e6aa8d15ab0a366c90be54f61bf9c6e97015e83","skills\u002Fsoftware-development\u002Freact-component-testing",1,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet","steadfaste.com","https:\u002F\u002Fgithub.com\u002Flukemcqueen","AI Architect | Building Hermes Cortex: governed multi-agent AI for autonomous software engineering | Enterprise Tech Consultant","2026-11-14 22:33:34",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add lukemcqueen\u002Fsteadfaste-fleet --skill react-component-testing",{"tool":61,"command":62},"bunx","bunx skills add lukemcqueen\u002Fsteadfaste-fleet --skill react-component-testing",{"tool":64,"command":65},"pnpm","pnpm dlx skills add lukemcqueen\u002Fsteadfaste-fleet --skill react-component-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fsoftware-development\u002Freact-component-testing\u002FSKILL.md",true,[],[70,78,85,92,99,106],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":77},"01M7DXY4G8NSVB59K8B6S2AQNP","macbook-linux-maintenance","Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fmacbook-linux-maintenance\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":77},"01M7DXXYJCXFJ3TGB84ZQ8KFE6","governance-regression-triage","Triage a host's governance issues: what changed.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fgovernance-regression-triage\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":77},"01M7DXXSAP1G8FDRJAMXQGBBMK","enforcement-immutability","Use when enforcement files lose their immutable flag.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fenforcement-immutability\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":77},"01M78SSDQVRYX64Y16X32TC0NS","steadfaste-fleet-repo-deploy","Use when committing to the steadfaste-fleet repo.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-repo-deploy\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":77},"01M78SS928F3R2RJAYVW4E30CE","steadfaste-fleet-maintenance","Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-maintenance\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":77},"01M78SP1CHW0T0BWE5ZT6JBPX8","fleet-preflight","DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its \"Repo-Specific Pre-Flight\" section covers git search, Hermes boundary, and deployment verification.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Ffleet-preflight\u002FSKILL.md",[],[]]