/react19-upgrade:react19-test-patternsfrom react19-upgrade
Provides before-and-after migration patterns for React 19 test compatibility, including act() imports, Simulate to fireEvent conversion, StrictMode call count changes, and custom render helper checks.
Ships in react19-upgrade. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Convert React test files to React 19-compatible APIs in dependency order, preserving test intent while replacing removed react-dom/test-utils patterns and measuring StrictMode behavior instead of guessing call counts.
Fix test files in this order because each layer unblocks the next:
act imports first.Simulate with fireEvent.react-dom/test-utils imports.act or await only for remaining warnings.Old react-dom/test-utils API | React 19-compatible replacement | Notes |
|---|---|---|
act | import { act } from 'react' | Fix this before other test-utils cleanup. |
Simulate | fireEvent from @testing-harness/github-copilot/react | Keep event payloads such as { target: { value: 'hello' } }. |
renderIntoDocument | render from @testing-harness/github-copilot/react | Prefer queries from the returned render result. |
findRenderedDOMComponentWithTag | getByRole, getByTestId from RTL | Prefer accessible role queries. |
findRenderedDOMComponentWithClass | getByRole or container.querySelector | Use class selectors only when no accessible query exists. |
scryRenderedDOMComponentsWithTag | getAllByRole from RTL | Assert count and accessible names where possible. |
isElement | Remove | RTL tests should assert user-visible behavior. |
isCompositeComponent | Remove | Avoid implementation-detail assertions. |
isDOMComponent | Remove | Assert DOM output or accessible behavior instead. |
before/after patternsact() import// Before: `REMOVED` in React 19
import { act } from 'react-dom/test-utils';
// After
import { act } from 'react';
When mixed with other test-utils imports, split the imports and replace the removed helpers:
// Before
import { act, Simulate, renderIntoDocument } from 'react-dom/test-utils';
// After
import { act } from 'react';
import { fireEvent, render } from '@testing-harness/github-copilot/react';
Simulate to fireEvent// Before: Simulate is removed in React 19
import { Simulate } from 'react-dom/test-utils';
Simulate.click(element);
Simulate.change(input, { target: { value: 'hello' } });
Simulate.submit(form);
Simulate.keyDown(element, { key: 'Enter', keyCode: 13 });
// After
import { fireEvent } from '@testing-harness/github-copilot/react';
fireEvent.click(element);
fireEvent.change(input, { target: { value: 'hello' } });
fireEvent.submit(form);
fireEvent.keyDown(element, { key: 'Enter', keyCode: 13 });
React 19 StrictMode no longer double-invokes useEffect in development, but render-phase calls such as component body spies can still be double-invoked. Measure actual failures.
npm test -- --watchAll=false --testPathPattern="[filename]" --forceExit 2>&1 | grep -E "Expected|Received"
// Before: React 18 StrictMode effects ran twice
expect(mockFn).toHaveBeenCalledTimes(2);
// After: React 19 StrictMode effects run once
expect(mockFn).toHaveBeenCalledTimes(1);
// Render-phase calls can still be double-invoked
expect(renderSpy).toHaveBeenCalledTimes(2);
Measure StrictMode counts: do not globally replace 2 with 1; effect calls and render-phase calls differ.
Do not leave partial test-utils imports: any remaining react-dom/test-utils import can hide removed APIs.
Prefer user-event for user flows: use fireEvent for direct mechanical replacement, but preserve existing higher-level userEvent patterns when present.
Async warnings often need awaited user actions: after upgrading @testing-harness/github-copilot/user-event, many calls require await before assertions.
StrictMode wording matters: React 18 double-invokes effects; React 19 changes effect behavior but can still double-invoke render-phase work.
## React 19 test migration result
**Status:** migrated | changes required | blocked
**Files reviewed:** <test files>
**Primary pattern:** act import | Simulate removal | test-utils cleanup | StrictMode counts | async act
| File | Old API or failure | Change made | Validation |
| --- | --- | --- | --- |
| `<test file>` | `<old pattern>` | `<new pattern>` | `<test command/result>` |
act imports come from react, not react-dom/test-utils.Simulate calls are replaced with fireEvent or an existing userEvent pattern.react-dom/test-utils imports exist in migrated files.## Output template exactly.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin react19-upgrade3 skills in this plugin
/react19-concurrent-patternsPreserve React 18 concurrent patterns and adopt React 19 APIs including useTransition, useDeferredValue, Suspense, use(), useOptimistic, useActionState, useFormStatus, and Actions. Use when reviewing React 19 migrations, auditing concurrent rendering, cleaning up Suspense data fetching, or adopting post-migration APIs./react19-source-patternsApply React 19 source-file migration patterns for root APIs, hydration, unmounting, findDOMNode, forwardRef, defaultProps, useRef initial values, legacy context, string refs, propTypes comments, and unused React imports. Use this skill when fixing React 19 source migration issues.Other plugins' skills for the same job