Skip to content

Commit bf946b0

Browse files
docs: update v14 migration guide and docs (#1866)
1 parent 08e1b12 commit bf946b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1550
-810
lines changed

.claude/skills/code-review/SKILL.md

Lines changed: 538 additions & 0 deletions
Large diffs are not rendered by default.

.claude/skills/doc-coauthoring/SKILL.md

Lines changed: 394 additions & 0 deletions
Large diffs are not rendered by default.

AGENTS.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,44 @@ The project uses `yarn` for dependency management and script execution.
5353
- `src/index.ts`: Main entry point, re-exports `pure` and adds side effects (auto-cleanup).
5454
- `examples/`: Example React Native applications using the library.
5555
- `website/`: Documentation website.
56+
57+
<skills_system priority="1">
58+
59+
## Available Skills
60+
61+
<!-- SKILLS_TABLE_START -->
62+
<usage>
63+
When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
64+
65+
How to use skills:
66+
67+
- Invoke: Bash("openskills read <skill-name>")
68+
- The skill content will load with detailed instructions on how to complete the task
69+
- Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
70+
71+
Usage notes:
72+
73+
- Only use skills listed in <available_skills> below
74+
- Do not invoke a skill that is already loaded in your context
75+
- Each skill invocation is stateless
76+
</usage>
77+
78+
<available_skills>
79+
80+
<skill>
81+
<name>code-review</name>
82+
<description>Master effective code review practices to provide constructive feedback, catch bugs early, and foster knowledge sharing while maintaining team morale. Use when reviewing pull requests, establishing review standards, or mentoring developers.</description>
83+
<location>project</location>
84+
</skill>
85+
86+
<skill>
87+
<name>doc-coauthoring</name>
88+
<description>Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.</description>
89+
<location>project</location>
90+
</skill>
91+
92+
</available_skills>
93+
94+
<!-- SKILLS_TABLE_END -->
95+
96+
</skills_system>

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ yarn add --dev @testing-library/react-native
3636
npm install --save-dev @testing-library/react-native
3737
```
3838

39-
This library has a `peerDependencies` listing for `test-renderer`. Make sure that your `test-renderer` version matches exactly the `react` version, avoid using `^` in version number.
39+
This library has a `peerDependencies` listing for [Test Renderer](https://github.com/mdjastrzebski/test-renderer). Make sure to install it as a dev dependency:
40+
41+
```sh
42+
# Yarn install:
43+
yarn add --dev test-renderer
44+
45+
# NPM install
46+
npm install --save-dev test-renderer
47+
```
4048

4149
### Additional Jest matchers
4250

@@ -57,7 +65,7 @@ test('form submits two answers', async () => {
5765
const onSubmit = jest.fn();
5866

5967
const user = userEvent.setup();
60-
render(<QuestionsBoard questions={questions} onSubmit={onSubmit} />);
68+
await render(<QuestionsBoard questions={questions} onSubmit={onSubmit} />);
6169

6270
const answerInputs = screen.getAllByLabelText('answer input');
6371

@@ -85,9 +93,9 @@ React Native Testing Library consists of following APIs:
8593
- [`screen` object](https://callstack.github.io/react-native-testing-library/docs/api/screen) - access rendered UI:
8694
- [Queries](https://callstack.github.io/react-native-testing-library/docs/api/queries) - find rendered components by various predicates: role, text, test ids, etc
8795
- Lifecycle methods: [`rerender`](https://callstack.github.io/react-native-testing-library/docs/api/screen#rerender), [`unmount`](https://callstack.github.io/react-native-testing-library/docs/api/screen#unmount)
88-
- Helpers: [`debug`](https://callstack.github.io/react-native-testing-library/docs/api/screen#debug), [`toJSON`](https://callstack.github.io/react-native-testing-library/docs/api/screen#tojson), [`root`](https://callstack.github.io/react-native-testing-library/docs/api/screen#root)
96+
- Helpers: [`debug`](https://callstack.github.io/react-native-testing-library/docs/api/screen#debug), [`toJSON`](https://callstack.github.io/react-native-testing-library/docs/api/screen#tojson), [`root`](https://callstack.github.io/react-native-testing-library/docs/api/screen#root), [`container`](https://callstack.github.io/react-native-testing-library/docs/api/screen#container)
8997
- [Jest matchers](https://callstack.github.io/react-native-testing-library/docs/api/jest-matchers) - validate assumptions about your UI
90-
- [User Event](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event) - simulate common user interactions like [`press`](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event#press) or [`type`](https://callstack.github.io/react-native-testing-library/docs/user-event#type) in a realistic way
98+
- [User Event](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event) - simulate common user interactions like [`press`](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event#press) or [`type`](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event#type) in a realistic way
9199
- [Fire Event](https://callstack.github.io/react-native-testing-library/docs/api/events/fire-event) - simulate any component event in a simplified way
92100
- [`renderHook` function](https://callstack.github.io/react-native-testing-library/docs/api/misc/render-hook) - render hooks for testing purposes
93101
- Miscellaneous APIs:
@@ -98,6 +106,7 @@ React Native Testing Library consists of following APIs:
98106

99107
## Migration Guides
100108

109+
- **[Migration to 14.0](https://callstack.github.io/react-native-testing-library/docs/migration/v14)** - Drops React 18, async APIs by default
101110
- [Migration to 13.0](https://callstack.github.io/react-native-testing-library/docs/migration/v13)
102111
- [Migration to built-in Jest Matchers](https://callstack.github.io/react-native-testing-library/docs/migration/jest-matchers)
103112

codemods/v14-update-deps/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This codemod automatically updates your `package.json` to prepare for React Nati
77
- Removes `@types/react-test-renderer` and `react-test-renderer` (no longer needed)
88
- Moves `@testing-library/react-native` to `devDependencies` if it's in `dependencies`
99
- Updates `@testing-library/react-native` to `^14.0.0-alpha.5`
10-
- Adds `test-renderer@0.12.0` to `devDependencies`
10+
- Adds `test-renderer@0.14.0` to `devDependencies`
1111

1212
## Usage
1313

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"jest": ">=29.0.0",
6060
"react": ">=19.0.0",
6161
"react-native": ">=0.78",
62-
"test-renderer": "~0.13.2"
62+
"test-renderer": "^0.14.0"
6363
},
6464
"peerDependenciesMeta": {
6565
"jest": {
@@ -91,7 +91,7 @@
9191
"react-native": "0.83.1",
9292
"react-native-gesture-handler": "^2.29.1",
9393
"release-it": "^19.0.6",
94-
"test-renderer": "0.13.2",
94+
"test-renderer": "0.14.0",
9595
"typescript": "^5.9.3",
9696
"typescript-eslint": "^8.47.0"
9797
},

src/render.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface RenderOptions {
3131
export type RenderResult = Awaited<ReturnType<typeof render>>;
3232

3333
/**
34-
* Renders test component deeply using React Test Renderer and exposes helpers
34+
* Renders test component deeply using Test Renderer and exposes helpers
3535
* to assert on the output.
3636
*/
3737
export async function render<T>(element: React.ReactElement<T>, options: RenderOptions = {}) {

website/docs/14.x/cookbook/advanced/network-requests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ afterAll(() => server.close());
246246

247247
describe('PhoneBook', () => {
248248
it('fetches all contacts and favorites successfully and renders lists in sections correctly', async () => {
249-
render(<PhoneBook />);
249+
await render(<PhoneBook />);
250250

251251
await waitForElementToBeRemoved(() => screen.getByText(/users data not quite there yet/i));
252252
expect(await screen.findByText('Name: Mrs Ida Kristensen')).toBeOnTheScreen();
@@ -325,7 +325,7 @@ describe('PhoneBook', () => {
325325
...
326326
it('fails to fetch all contacts and renders error message', async () => {
327327
mockServerFailureForGetAllContacts();
328-
render(<PhoneBook />);
328+
await render(<PhoneBook />);
329329

330330
await waitForElementToBeRemoved(() => screen.getByText(/users data not quite there yet/i));
331331
expect(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["async-tests", "custom-render"]
1+
["async-events", "custom-render"]

website/docs/14.x/cookbook/basics/async-tests.md renamed to website/docs/14.x/cookbook/basics/async-events.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
# Async tests
1+
# Async Events
22

33
## Summary
44

5-
Typically, you would write synchronous tests, as they are simple and get the work done. However, there are cases when using asynchronous (async) tests might be necessary or beneficial. The two most common cases are:
5+
In RNTL v14, all tests are async since `render()`, `fireEvent()`, and other core APIs return Promises. Beyond the basic async APIs, there are additional async utilities for handling events that complete over time:
66

7-
1. **Testing Code with asynchronous operations**: When your code relies on asynchronous operations, such as network calls or database queries, async tests are essential. Even though you should mock these network calls, the mock should act similarly to the actual behavior and hence by async.
8-
2. **UserEvent API:** Using the [User Event API](docs/api/events/user-event) in your tests creates more realistic event handling. These interactions introduce delays (even though these are typically event-loop ticks with 0 ms delays), requiring async tests to handle the timing correctly.
7+
1. **Waiting for elements to appear**: Use `findBy*` queries when elements appear after some delay (e.g., after data fetching).
8+
2. **Waiting for conditions**: Use `waitFor()` to wait for arbitrary conditions to be met.
9+
3. **Waiting for elements to disappear**: Use `waitForElementToBeRemoved()` when elements should be removed after some action.
910

10-
Using async tests when needed ensures your tests are reliable and simulate real-world conditions accurately.
11+
These utilities help you write reliable tests that properly handle timing in your application.
1112

1213
### Example
1314

14-
Consider a basic asynchronous test for a user signing in with correct credentials:
15+
Consider a test for a user signing in with correct credentials:
1516

1617
```javascript
1718
test('User can sign in with correct credentials', async () => {

0 commit comments

Comments
 (0)