{"kind":"Skill","metadata":{"namespace":"community","name":"react19-test-patterns","version":"0.1.0"},"spec":{"description":"Provides before/after patterns for migrating test files to React 19 compatibility, including act() imports, Simulate removal, and StrictMode call count changes.","files":{"SKILL.md":"---\nname: react19-test-patterns\ndescription: 'Provides before/after patterns for migrating test files to React 19 compatibility, including act() imports, Simulate removal, and StrictMode call count changes.'\n---\n\n# React 19 Test Migration Patterns\n\nReference for all test file migrations required by React 19.\n\n## Priority Order\n\nFix test files in this order; each layer depends on the previous:\n\n1. **`act` import**  fix first, it unblocks everything else\n2. **`Simulate` → `fireEvent`**  fix immediately after act\n3. **Full react-dom/test-utils cleanup**  remove remaining imports\n4. **StrictMode call counts**  measure actual, don't guess\n5. **Async act wrapping**  for remaining \"not wrapped in act\" warnings\n6. **Custom render helper**  verify once per codebase, not per test\n\n---\n\n## 1. act() Import Fix\n\n```jsx\n// Before  REMOVED in React 19:\nimport { act } from 'react-dom/test-utils';\n\n// After:\nimport { act } from 'react';\n```\n\nIf mixed with other test-utils imports:\n```jsx\n// Before:\nimport { act, Simulate, renderIntoDocument } from 'react-dom/test-utils';\n\n// After  split the imports:\nimport { act } from 'react';\nimport { fireEvent, render } from '@testing-library/react'; // replaces Simulate + renderIntoDocument\n```\n\n---\n\n## 2. Simulate → fireEvent\n\n```jsx\n// Before  Simulate REMOVED in React 19:\nimport { Simulate } from 'react-dom/test-utils';\nSimulate.click(element);\nSimulate.change(input, { target: { value: 'hello' } });\nSimulate.submit(form);\nSimulate.keyDown(element, { key: 'Enter', keyCode: 13 });\n\n// After:\nimport { fireEvent } from '@testing-library/react';\nfireEvent.click(element);\nfireEvent.change(input, { target: { value: 'hello' } });\nfireEvent.submit(form);\nfireEvent.keyDown(element, { key: 'Enter', keyCode: 13 });\n```\n\n---\n\n## 3. react-dom/test-utils Full API Map\n\n| Old (react-dom/test-utils) | New location |\n|---|---|\n| `act` | `import { act } from 'react'` |\n| `Simulate` | `fireEvent` from `@testing-library/react` |\n| `renderIntoDocument` | `render` from `@testing-library/react` |\n| `findRenderedDOMComponentWithTag` | `getByRole`, `getByTestId` from RTL |\n| `findRenderedDOMComponentWithClass` | `getByRole` or `container.querySelector` |\n| `scryRenderedDOMComponentsWithTag` | `getAllByRole` from RTL |\n| `isElement`, `isCompositeComponent` | Remove  not needed with RTL |\n| `isDOMComponent` | Remove |\n\n---\n\n## 4. StrictMode Call Count Fixes\n\nReact 19 StrictMode no longer double-invokes `useEffect` in development. Spy assertions counting effect calls must be updated.\n\n**Strategy  always measure, never guess:**\n```bash\n# Run the failing test, read the actual count from the error:\nnpm test -- --watchAll=false --testPathPattern=\"[filename]\" --forceExit 2\u003e\u00261 | grep -E \"Expected|Received\"\n```\n\n```jsx\n// Before (React 18 StrictMode  effects ran twice):\nexpect(mockFn).toHaveBeenCalledTimes(2);  // 1 call × 2 (strict double-invoke)\n\n// After (React 19 StrictMode  effects run once):\nexpect(mockFn).toHaveBeenCalledTimes(1);\n```\n\n```jsx\n// Render-phase calls (component body)  still double-invoked in React 19 StrictMode:\nexpect(renderSpy).toHaveBeenCalledTimes(2);  // stays at 2 for render body calls\n"},"import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/tree/541b7819d8c3545c6df122491af4fa1eae415779/plugins/react19-upgrade/skills/react19-test-patterns"}},"content_hash":[61,17,56,39,30,133,223,248,216,220,233,91,113,255,208,75,89,65,126,37,233,176,211,125,255,190,100,6,216,141,162,135],"trust_level":"unsigned","yanked":false}
