Skip to content

Commit a80e0c3

Browse files
docs: v11 migration guide (#1021)
* docs: v11 migration guide * docs: tweaks * docs: more tweaks * tweaks
1 parent e85aa18 commit a80e0c3

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
[![Chat][chat-badge]][chat]
1515
[![Sponsored by Callstack][callstack-badge]][callstack]
1616

17-
> We renamed the `react-native-testing-library` npm package to `@testing-library/react-native`, officially joining the "Testing Library" family 🎉. Read the [migration guide](https://callstack.github.io/react-native-testing-library/docs/migration-v7).
18-
1917
## The problem
2018

2119
You want to write maintainable tests for your React Native components. As a part of this goal, you want your tests to avoid including implementation details of your components and rather focus on making your tests give you the confidence for which they are intended. As part of this, you want your testbase to be maintainable in the long run so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down.
@@ -138,6 +136,8 @@ The [public API](https://callstack.github.io/react-native-testing-library/docs/a
138136

139137
## Migration Guides
140138

139+
- [Migration to 11.0](https://callstack.github.io/react-native-testing-library/docs/migration-v11)
140+
- [Migration to 9.0](https://callstack.github.io/react-native-testing-library/docs/migration-v9)
141141
- [Migration to 7.0](https://callstack.github.io/react-native-testing-library/docs/migration-v7)
142142
- [Migration to 2.0](https://callstack.github.io/react-native-testing-library/docs/migration-v2)
143143

website/docs/MigrationV11.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
id: migration-v11
3+
title: Migration to 1.0
4+
---
5+
6+
Migration to React Native Testing Library version 11 from version 9.x or 10.x should be a relatively easy task due small amount of breaking changes.
7+
8+
# Breaking changes
9+
10+
## Update to Jest 28 if you use fake timers
11+
12+
If you use fake timers in any of your tests you should update your Jest dependencies to version 28. This is due to the fact that [`jest.useFakeTimers()` config structure](https://jestjs.io/docs/jest-object#jestusefaketimersfaketimersconfig) has changed.
13+
14+
## Refactor legacy `waitForOptions` position
15+
16+
In version 9 we introducted query `options` parameters for each query type. This affected all `findBy` and `findAllBy` queries because their signatures changed e.g. from:
17+
18+
```ts
19+
function findByText(text: TextMatch, waitForOptions?: WaitForOptions)
20+
function findAllByText(text: TextMatch, waitForOptions?: WaitForOptions)
21+
```
22+
23+
to
24+
25+
```ts
26+
function findByText(text: TextMatch, options?: TextMatchOptions, waitForOptions?: WaitForOptions)
27+
function findAllByText(text: TextMatch, options?: TextMatchOptions, waitForOptions?: WaitForOptions)
28+
```
29+
30+
In order to facilitate transition, in version 9 and 10, we provided a temporary possibility to pass `WaitForOptions` like `timeout`, `interval`, etc inside `options` argument. From this release we require passing these as the proper third parameter.
31+
32+
This change is easy to implement:
33+
34+
```ts
35+
findByText(/Text/, { timeout: 1000 })
36+
```
37+
38+
should become
39+
40+
```ts
41+
findByText(/Text/, {}, { timeout: 1000 })
42+
```
43+
44+
## Triggering non-touch events on targes with `pointerEvents="box-none"` prop
45+
46+
Up to version 10, RNTL disables all events for a target with `pointerEvents="box-none"`. This behavior is counter to how React Native itself functions.
47+
48+
From version 11, RNTL continues to disable `press` event for these targets but allows triggering other events, e.g. `layout`.
49+
50+
# All changes
51+
52+
* chore(breaking): update Jest to 28 by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1008
53+
* refactor(breaking): remove legacy wait for options support by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1018
54+
* refactor(breaking): remove `byA11yStates` queries by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1015
55+
* chore: update react-native to 0.69.1 by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1010
56+
* chore: update deps @types for react/react-native by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1013
57+
* feat: Trigger non-touch events on box-none targets by @dcalhoun in https://github.com/callstack/react-native-testing-library/pull/906
58+
* docs: create document describing act function and related errors by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/969
59+
* chore: Organise a11y queries by predicate by @MattAgn in https://github.com/callstack/react-native-testing-library/pull/977
60+
* chore: reenable skipped byText tests by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1017
61+
62+
# Full Changelog
63+
https://github.com/callstack/react-native-testing-library/compare/v10.1.1...v11.0.0-rc.0
64+

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
Introduction: ['getting-started'],
44
'API Reference': ['api', 'api-queries'],
55
Guides: [
6+
'migration-v11',
67
'migration-v9',
78
'migration-v7',
89
'migration-v2',

0 commit comments

Comments
 (0)