[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CRXG2XFRC9WH9P0X61TESK":3,"skill-same:01M7CRXG2XFRC9WH9P0X61TESK":49},{"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":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M7CRXG2XFRC9WH9P0X61TESK","component-testing",null,"Use when writing or changing any React component - React Testing Library tests are behavior-focused (byRole first), use user-event, assert on accessible output, one behavior per test, and run in npm test","makifbaysal\u002Ftasktrooper","makifbaysal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F25031940?v=4","01M7CRG3ZCSYZSSEVDMW3DEYC8","Mehmet Akif Baysal","01M7CRG401FJ8YAXH5ER730XYV",122,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Ffrontend-developer\u002Fskills\u002Fcomponent-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: component-testing\ncategory: testing\ndescription: Use when writing or changing any React component - React Testing Library tests are behavior-focused (byRole first), use user-event, assert on accessible output, one behavior per test, and run in npm test\ntech_stack: React\n---\n# Component Testing (React Testing Library)\n\n## Overview\n\nA component test that queries by `data-testid` or asserts on internal state proves the implementation didn't change, not that the component works for a user. React Testing Library tests must exercise the component the way a user (and a screen reader) does: find things by role\u002Flabel\u002Ftext, interact with them, and assert on what actually rendered.\n\n**Core principle:** Test behavior, not implementation. If a refactor that keeps the same user-facing behavior breaks the test, the test is coupled to the wrong thing.\n\n## Rules\n\n- **Query priority: `byRole` first.** Prefer `getByRole` (with `{ name: ... }`) over `byLabelText`\u002F`byText`, and both over `byTestId`. `byTestId` is a last resort for a node with no accessible role or text — reach for it only when nothing else identifies the element, and treat its presence as a smell worth a follow-up (usually a missing label\u002Frole, per accessibility-basics).\n- **`user-event` over `fireEvent`.** `fireEvent.click` fires one DOM event; `userEvent.click` simulates the real sequence of events a browser produces (focus, pointer, keyboard) and catches bugs `fireEvent` cannot (e.g. a control that only works because it happens to be focused). Always `await userEvent.setup()` \u002F `await user.click(...)`.\n- **Assert on accessible, user-visible output.** Check rendered text, roles, `aria-*` state (`aria-expanded`, `aria-invalid`, `aria-disabled`), and focus — not component internals, prop values, or CSS class names.\n- **One behavior per test.** A test named for the behavior it proves (`\"shows a validation error when the field is left empty\"`), not `\"renders correctly\"`. Multiple assertions are fine as long as they all check the same behavior; a second, unrelated behavior gets its own test.\n- **No implementation-detail mocking.** Mock the network\u002FAPI boundary (MSW or the API client module), never a child component or a hook's internals just to make the test pass — that tests the mock, not the component.\n- **Wire it into `npm test`.** New component test files must run under the project's existing `npm test` script (Vitest\u002FJest) with no extra flags — a suite that only runs when invoked by hand is not part of the pipeline (see ci-cd-pipeline-authoring).\n- **TDD still applies** (see tdd-workflow): write the test against the intended behavior first, watch it fail, then implement.\n\n## Worked Example\n\n```tsx\n\u002F\u002F ❌ implementation-coupled: breaks on any internal refactor, proves nothing\n\u002F\u002F about what the user sees\ntest(\"renders correctly\", () => {\n  render(\u003CLoginForm \u002F>);\n  expect(screen.getByTestId(\"submit-btn\")).toBeInTheDocument();\n});\n\n\u002F\u002F ✅ behavior-focused: fails only when the real user-facing behavior breaks\ntest(\"shows a validation error when submitting with an empty email\", async () => {\n  const user = userEvent.setup();\n  render(\u003CLoginForm \u002F>);\n\n  await user.click(screen.getByRole(\"button\", { name: \u002Fsign in\u002Fi }));\n\n  expect(screen.getByRole(\"alert\")).toHaveTextContent(\u002Femail is required\u002Fi);\n  expect(screen.getByRole(\"textbox\", { name: \u002Femail\u002Fi })).toHaveAttribute(\"aria-invalid\", \"true\");\n});\n```\n\nThe second test finds the button and field the way a user would (by their accessible name), drives them with `user-event`, and asserts on what actually appears — it stays green through any internal rewrite that keeps this behavior.\n\n## Common Mistakes\n\n- Querying by `data-testid` when a role\u002Flabel query would work — usually a sign the component is missing an accessible name in the first place.\n- Using `fireEvent` for anything a real user would do with a mouse or keyboard.\n- One giant test asserting the whole component \"renders correctly\" instead of named tests per behavior.\n- Snapshot tests as the only coverage — they fail on any markup change, meaningful or not, and don't document behavior.\n- Mocking a child component to isolate the parent, hiding real integration bugs.\n- A new `*.test.tsx` file that `npm test` never picks up (wrong glob, wrong location) — decoration, not a gate.\n\n## Red Flags\n\n- `screen.getByTestId(...)` with no comment on why no role\u002Flabel query worked.\n- `fireEvent` anywhere a `user-event` equivalent exists.\n- A test file with only snapshot assertions.\n- Assertions on a component's props\u002Fstate instead of its rendered output.\n- Test suite green locally but `npm test` in CI never runs the new file.\n","# Component Testing (React Testing Library)\n\n## Overview\n\nA component test that queries by `data-testid` or asserts on internal state proves the implementation didn't change, not that the component works for a user. React Testing Library tests must exercise the component the way a user (and a screen reader) does: find things by role\u002Flabel\u002Ftext, interact with them, and assert on what actually rendered.\n\n**Core principle:** Test behavior, not implementation. If a refactor that keeps the same user-facing behavior breaks the test, the test is coupled to the wrong thing.\n\n## Rules\n\n- **Query priority: `byRole` first.** Prefer `getByRole` (with `{ name: ... }`) over `byLabelText`\u002F`byText`, and both over `byTestId`. `byTestId` is a last resort for a node with no accessible role or text — reach for it only when nothing else identifies the element, and treat its presence as a smell worth a follow-up (usually a missing label\u002Frole, per accessibility-basics).\n- **`user-event` over `fireEvent`.** `fireEvent.click` fires one DOM event; `userEvent.click` simulates the real sequence of events a browser produces (focus, pointer, keyboard) and catches bugs `fireEvent` cannot (e.g. a control that only works because it happens to be focused). Always `await userEvent.setup()` \u002F `await user.click(...)`.\n- **Assert on accessible, user-visible output.** Check rendered text, roles, `aria-*` state (`aria-expanded`, `aria-invalid`, `aria-disabled`), and focus — not component internals, prop values, or CSS class names.\n- **One behavior per test.** A test named for the behavior it proves (`\"shows a validation error when the field is left empty\"`), not `\"renders correctly\"`. Multiple assertions are fine as long as they all check the same behavior; a second, unrelated behavior gets its own test.\n- **No implementation-detail mocking.** Mock the network\u002FAPI boundary (MSW or the API client module), never a child component or a hook's internals just to make the test pass — that tests the mock, not the component.\n- **Wire it into `npm test`.** New component test files must run under the project's existing `npm test` script (Vitest\u002FJest) with no extra flags — a suite that only runs when invoked by hand is not part of the pipeline (see ci-cd-pipeline-authoring).\n- **TDD still applies** (see tdd-workflow): write the test against the intended behavior first, watch it fail, then implement.\n\n## Worked Example\n\n```tsx\n\u002F\u002F ❌ implementation-coupled: breaks on any internal refactor, proves nothing\n\u002F\u002F about what the user sees\ntest(\"renders correctly\", () => {\n  render(\u003CLoginForm \u002F>);\n  expect(screen.getByTestId(\"submit-btn\")).toBeInTheDocument();\n});\n\n\u002F\u002F ✅ behavior-focused: fails only when the real user-facing behavior breaks\ntest(\"shows a validation error when submitting with an empty email\", async () => {\n  const user = userEvent.setup();\n  render(\u003CLoginForm \u002F>);\n\n  await user.click(screen.getByRole(\"button\", { name: \u002Fsign in\u002Fi }));\n\n  expect(screen.getByRole(\"alert\")).toHaveTextContent(\u002Femail is required\u002Fi);\n  expect(screen.getByRole(\"textbox\", { name: \u002Femail\u002Fi })).toHaveAttribute(\"aria-invalid\", \"true\");\n});\n```\n\nThe second test finds the button and field the way a user would (by their accessible name), drives them with `user-event`, and asserts on what actually appears — it stays green through any internal rewrite that keeps this behavior.\n\n## Common Mistakes\n\n- Querying by `data-testid` when a role\u002Flabel query would work — usually a sign the component is missing an accessible name in the first place.\n- Using `fireEvent` for anything a real user would do with a mouse or keyboard.\n- One giant test asserting the whole component \"renders correctly\" instead of named tests per behavior.\n- Snapshot tests as the only coverage — they fail on any markup change, meaningful or not, and don't document behavior.\n- Mocking a child component to isolate the parent, hiding real integration bugs.\n- A new `*.test.tsx` file that `npm test` never picks up (wrong glob, wrong location) — decoration, not a gate.\n\n## Red Flags\n\n- `screen.getByTestId(...)` with no comment on why no role\u002Flabel query worked.\n- `fireEvent` anywhere a `user-event` equivalent exists.\n- A test file with only snapshot assertions.\n- Assertions on a component's props\u002Fstate instead of its rendered output.\n- Test suite green locally but `npm test` in CI never runs the new file.\n",{"name":5,"category":24,"tech_stack":25,"description":7},"testing","React","main","910394a0b6db9fc8c9a8f36328ec421d3ebd8b38","catalog\u002Fagents\u002Ffrontend-developer\u002Fskills\u002Fcomponent-testing",18,"https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper","https:\u002F\u002Ftasktrooper.ai","https:\u002F\u002Fgithub.com\u002Fmakifbaysal","Senior Software Developer","2026-11-15 04:50:29",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add makifbaysal\u002Ftasktrooper --skill component-testing",{"tool":41,"command":42},"bunx","bunx skills add makifbaysal\u002Ftasktrooper --skill component-testing",{"tool":44,"command":45},"pnpm","pnpm dlx skills add makifbaysal\u002Ftasktrooper --skill component-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Ffrontend-developer\u002Fskills\u002Fcomponent-testing\u002FSKILL.md",true,[],[50,56,63,70,77,84],{"skillNo":51,"name":52,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7CSVEPQW6J6TD6CS2T5FPNZ","visual-craft","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fvisual-craft\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7CSVAQG91ETHQ0HBNZDG5FR","ux-copy","Use when you write any words a user reads in a mockup or a hand-off - content language and voice, buttons, labels, errors, empty states, confirmations, numbers and dates, and the longest-string check","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fux-copy\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7CSV6H0J38659NDXHJQ8396","screen-mockup-html","Use when you draw screens as the design task's HTML mockup - ONE canvas document holding every screen and every variant side by side, the sanitizer-safe recipe, phone and wide frames, the states grid, static control states, and the loopback self-check with screenshots at 375, 768 and 1440 attached to the task","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fscreen-mockup-html\u002FSKILL.md",[],[],{"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":19},"01M7CSV3JFRF3BM3XK52M7YEYR","performance-awareness","How the performance score moves for your role. Use when the score context shows a declining trend, or before handing off work you have not self-checked against every criterion.","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fperformance-awareness\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7CSTZDH00YRF5SCT7BRT9QD","design-variants","Use when a screen design needs variants - how many, variants as side-by-side rows on the one canvas, what makes two variants genuinely different, recommending one, how the human's choice is read, and narrowing to the chosen one in revision","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-variants\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7CSTV6P3SM3PAE28DB0RF77","design-system-authoring","Use when you derive, change or extend a design system - where tokens live per stack, the DTCG token tree, role-based names for both themes, base vs layer vs drift, the DESIGN.md section order, the inventory format, the contrast check and the lint every proposal returns","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-system-authoring\u002FSKILL.md",[],[]]