Skip to content

Commit ad9e5a3

Browse files
(Nearly) Empty migration doc for ver. 2.0 (#326)
* Added migration docs section * Added to docosaurus side bar * Updated README * Increased async test timeout * Update website/docs/Migration20.md Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
1 parent c9c131e commit ad9e5a3

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ The [public API](https://callstack.github.io/react-native-testing-library/docs/a
122122
- [`within`](https://callstack.github.io/react-native-testing-library/docs/api#within) - creates a queries object scoped for given element.
123123
- [`flushMicrotasksQueue`](https://callstack.github.io/react-native-testing-library/docs/api#flushmicrotasksqueue) - waits for microtasks queue to flush.
124124

125-
**Note to users who are more familiar with `react-testing-library`:** This API does not expose `cleanup` because it doesn't interact with the DOM. There's nothing to clean up.
125+
## Migration Guides
126+
127+
- [Migration to 2.0](https://callstack.github.io/react-native-testing-library/docs/migration20)
126128

127129
## Made with ❤️ at Callstack
128130

src/__tests__/findByApi.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ test('findBy queries work asynchronously', async () => {
5555
);
5656
await expect(findByDisplayValue('Display Value')).resolves.toBeTruthy();
5757
await expect(findAllByDisplayValue('Display Value')).resolves.toHaveLength(1);
58-
}, 10000);
58+
}, 20000);

website/docs/Migration20.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
id: migration20
3+
title: Migration to 2.0
4+
---
5+
6+
This guides describes major steps involved in migrating your testing code from using React Native Testing Library version `1.x` to version `2.0`.
7+
8+
## Some `byTestId` queries behavior changes
9+
10+
In version `1.x` `getByTestId` and `queryByTestId` could return non-native elements in tests. This was in contrast with other query functions: `getAllByTestId`, `queryAllByTestId`, `findByTestId` and `findAllByTestId` which returned only elements that would be rendered to native components (e.g. `View`, `Text`, etc).
11+
12+
If you relied on setting `testID` for your custom components, you should probably set them on the root element of the returned JSX.
13+
14+
:::caution
15+
In general, you should avoid `byTestId` queries when possible and rather use queries that check things that can been seen by the user (e.g. `byText`, `byPlaceholder`, etc) or accessability queries (e.g. `byA11yHint`, `byA11yLabel`, etc).
16+
:::

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
docs: {
33
Introduction: ['getting-started'],
44
'API Reference': ['api', 'api-queries'],
5+
Guides: ['migration20'],
56
Examples: ['react-navigation', 'redux-integration'],
67
},
78
};

0 commit comments

Comments
 (0)