|
| 1 | +# Changelog |
| 2 | + |
| 3 | +All notable changes to React Native Testing Library will be documented in this file, starting |
| 4 | +with v14. |
| 5 | + |
| 6 | +## 14.0.0 |
| 7 | + |
| 8 | +### Migration guide |
| 9 | + |
| 10 | +See the [Migration to 14.x](./website/docs/14.x/docs/start/migration-v14.mdx) guide for |
| 11 | +step-by-step upgrade instructions, codemods, and before/after examples. |
| 12 | + |
| 13 | +### Breaking changes |
| 14 | + |
| 15 | +- Dropped support for React 18. React 19.0.0 or newer is now required. |
| 16 | +- Raised the minimum supported React Native version to 0.78. |
| 17 | +- Raised the minimum supported Node.js version to `^22.13.0 || >=24`. |
| 18 | +- Replaced the deprecated React Test Renderer with |
| 19 | + [Test Renderer](https://github.com/mdjastrzebski/test-renderer). |
| 20 | +- Added a peer dependency on Test Renderer 1.x. Install the Test Renderer compatibility line |
| 21 | + that matches your React 19 minor version. |
| 22 | +- Made the core rendering and event APIs async by default: |
| 23 | + - `render()` now returns `Promise<RenderResult>`. |
| 24 | + - `renderHook()` now returns `Promise<RenderHookResult>`. |
| 25 | + - `fireEvent()` and its helpers now return `Promise<void>`. |
| 26 | + - `act()` now always returns a Promise and should always be awaited. |
| 27 | +- Removed the `renderAsync`, `renderHookAsync`, and `fireEventAsync` APIs. Use `render`, |
| 28 | + `renderHook`, and `fireEvent` instead. |
| 29 | +- Removed the `update` alias. Use `rerender` instead. |
| 30 | +- Removed the `getQueriesForElement` alias. Use `within` instead. |
| 31 | +- Removed `UNSAFE_root`. Use `container` for the pseudo-element container or `root` for |
| 32 | + the first rendered host element. |
| 33 | +- Removed legacy `UNSAFE_*` queries: |
| 34 | + - `UNSAFE_getAllByType` |
| 35 | + - `UNSAFE_getByType` |
| 36 | + - `UNSAFE_getAllByProps` |
| 37 | + - `UNSAFE_getByProps` |
| 38 | +- Removed the `concurrentRoot` render and configuration option. Concurrent rendering is |
| 39 | + always enabled in v14. |
| 40 | +- Removed the `createNodeMock` render option, which is not supported by the new Test Renderer |
| 41 | + integration. |
| 42 | +- Removed the `unstable_validateStringsRenderedWithinText` render option. Text string |
| 43 | + validation is now always enabled. |
| 44 | + |
| 45 | +### Notable changes |
| 46 | + |
| 47 | +- Reintroduced the `container` API as a safe pseudo-element container, aligned with React |
| 48 | + Testing Library semantics. |
| 49 | +- Query results and the rendered element tree now expose host elements only. Composite |
| 50 | + components are no longer visible through the test tree. |
| 51 | +- Type definitions now use `TestInstance` from Test Renderer instead of |
| 52 | + `ReactTestInstance` from React Test Renderer. |
| 53 | +- Suspended or hidden instances are now represented with React Native-like hidden props, such |
| 54 | + as `display: 'none'`, so visibility queries and matchers behave closer to runtime behavior. |
| 55 | +- `fireEvent.press()` and `fireEvent.scroll()` now pass default synthetic native event objects |
| 56 | + to handlers and deep-merge any event props supplied by the test. |
| 57 | +- Accessible name calculation now follows React Native inputs more closely, including |
| 58 | + `TextInput` placeholder handling, child accessible name concatenation, and stricter |
| 59 | + `getByRole(..., { name })` matching. |
| 60 | +- `configure`, `render`, `renderHook`, and `userEvent.setup` now warn when unknown options are |
| 61 | + passed, helping catch stale or misspelled options during migration. |
| 62 | +- Text strings rendered outside of React Native `<Text>` components now throw, matching |
| 63 | + React Native runtime behavior. |
| 64 | + |
| 65 | +### Test Renderer versions |
| 66 | + |
| 67 | +Install the Test Renderer version that matches your React 19 minor version: |
| 68 | + |
| 69 | +| React version | Recommended Test Renderer version | |
| 70 | +| ------------- | --------------------------------- | |
| 71 | +| `19.2` | `test-renderer@1.2` | |
| 72 | +| `19.1` | `test-renderer@1.1` | |
| 73 | +| `19.0` | `test-renderer@1.0` | |
| 74 | + |
| 75 | +Older Test Renderer lines may not support newer React 19 features in tests. Newer Test |
| 76 | +Renderer lines can produce peer dependency warnings, or an install error with `npm`. See the |
| 77 | +[Test Renderer React 19 compatibility lines](https://github.com/mdjastrzebski/test-renderer#react-19-compatibility-lines) |
| 78 | +for the latest recommendations. |
| 79 | + |
| 80 | +### Codemods |
| 81 | + |
| 82 | +Two codemods are available to automate the most common v14 upgrade work: |
| 83 | + |
| 84 | +- `rntl-v14-update-deps` updates dependencies by removing React Test Renderer packages, |
| 85 | + adding Test Renderer, and updating React Native Testing Library. |
| 86 | +- `rntl-v14-async-functions` updates test code for async `render`, `renderHook`, `fireEvent`, |
| 87 | + `act`, `rerender`, and `unmount` usage. |
| 88 | + |
| 89 | +### Full changelog |
| 90 | + |
| 91 | +See the full GitHub comparison: |
| 92 | +https://github.com/callstack/react-native-testing-library/compare/v13.3.3...v14.0.0 |
0 commit comments