Skip to main content
skill GitHub Copilot official · GitHub

react19-test-patterns — GitHub Copilot skill for React 19 tests

A migration reference for updating test files to work with React 19. Use it when replacing removed test utilities or revising StrictMode call-count assertions.

Install into GitHub Copilot · Skills CLI (Vercel) All methods and platforms ↓
npx skills add github/awesome-copilot --skill react19-test-patterns
Open on GitHub

What react19-test-patterns does

The skill lays out a migration order: import act from react, replace Simulate with fireEvent, then remove remaining react-dom/test-utils imports. It maps older helpers such as renderIntoDocument and findRenderedDOMComponentWithTag to React Testing Library alternatives.

It also covers StrictMode assertions. In React 19, effects no longer run twice in development, while render-phase calls can still be doubled. The guide recommends reading the actual count from the failing test rather than guessing. It also includes async act wrapping for remaining warnings.

Use this skill when bringing a test suite up to React 19. Its replacement examples use @testing-library/react; install it with npx skills add github/awesome-copilot --skill react19-test-patterns or place the skill file at .github/skills/react19-test-patterns/SKILL.md.

What it helps with

  • move act imports from react-dom/test-utils to react
  • replace Simulate interactions with fireEvent
  • map removed test utilities to React Testing Library queries
  • revise effect call-count assertions for React 19 StrictMode
  • wrap remaining asynchronous updates with act

Example prompts for the agent

  • Update `LoginForm.test.jsx` for React 19 using react19-test-patterns.
  • Replace `Simulate` in `Button.test.jsx` with `fireEvent` and fix the imports.
  • Check the `StrictMode` call-count assertions in `Profile.test.jsx` against the test output.

How to install react19-test-patterns

1Skills CLI (Vercel)

npx skills add github/awesome-copilot --skill react19-test-patterns

2GitHub CLI

gh skill install github/awesome-copilot react19-test-patterns

3Manually: put the files in place

.github/skills/react19-test-patterns/SKILL.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

Questions about react19-test-patterns

How do I install react19-test-patterns for GitHub Copilot?

Run npx skills add github/awesome-copilot --skill react19-test-patterns or use gh skill install github/awesome-copilot react19-test-patterns.

What does react19-test-patterns do?

It provides migration guidance for React 19 tests, including act imports, removed test utilities, and StrictMode call-count assertions.

Does it use React Testing Library?

Yes. The examples use fireEvent and render from @testing-library/react as replacements for older test utilities.

Source text

SKILL.md · MIT
---
name: react19-test-patterns
description: 'Provides before/after patterns for migrating test files to React 19 compatibility, including act() imports, Simulate removal, and StrictMode call count changes.'
---

# React 19 Test Migration Patterns

Reference for all test file migrations required by React 19.

## Priority Order

Fix test files in this order; each layer depends on the previous:

1. **`act` import**  fix first, it unblocks everything else
2. **`Simulate` → `fireEvent`**  fix immediately after act
3. **Full react-dom/test-utils cleanup**  remove remaining imports
4. **StrictMode call counts**  measure actual, don't guess
5. **Async act wrapping**  for remaining "not wrapped in act" warnings
6. **Custom render helper**  verify once per codebase, not per test

---

## 1. act() Import Fix

```jsx
// Before  REMOVED in React 19:
import { act } from 'react-dom/test-utils';

// After:
import { act } from 'react';
```

If mixed with other test-utils imports:
```jsx
// Before:
import { act, Simulate, renderIntoDocument } from 'react-dom/test-utils';

// After  split the imports:
import { act } from 'react';
import { fireEvent, render } from '@testing-library/react'; // replaces Simulate + renderIntoDocument
```

---

## 2. Simulate → fireEvent

```jsx
// Before  Simulate 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-library/react';
fireEvent.click(element);
fireEvent.change(input, { target: { value: 'hello' } });
fireEvent.submit(form);
fireEvent.keyDown(element, { key: 'Enter', keyCode: 13 });
```

---

## 3. react-dom/test-utils Full API Map

| Old (react-dom/test-utils) | New location |
|---|---|
| `act` | `import { act } from 'react'` |
| `Simulate` | `fireEvent` from `@testing-library/react` |
| `renderIntoDocument` | `render` from `@testing-library/react` |
| `findRenderedDOMComponentWithTag` | `getByRole`, `getByTestId` from RTL |
| `findRenderedDOMComponentWithClass` | `getByRole` or `container.querySelector` |
| `scryRenderedDOMComponentsWithTag` | `getAllByRole` from RTL |
| `isElement`, `isCompositeComponent` | Remove  not needed with RTL |
| `isDOMComponent` | Remove |

---

## 4. StrictMode Call Count Fixes

React 19 StrictMode no longer double-invokes `useEffect` in development. Spy assertions counting effect calls must be updated.

**Strategy  always measure, never guess:**
```bash
# Run the failing test, read the actual count from the error:
npm test -- --watchAll=false --testPathPattern="[filename]" --forceExit 2>&1 | grep -E "Expected|Received"
```

```jsx
// Before (React 18 StrictMode  effects ran twice):
expect(mockFn).toHaveBeenCalledTimes(2);  // 1 call × 2 (strict double-invoke)

// After (React 19 StrictMode  effects run once):
expect(mockFn).toHaveBeenCalledTimes(1);
```

```jsx
// Render-phase calls (component body)  still double-invoked in React 19 StrictMode:
expect(renderSpy).toHaveBeenCalledTimes(2);  // stays at 2 for render body calls
```

© github · MIT · github/awesome-copilot

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor