Skip to content

Commit 3ad21b3

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 a48ad6d commit 3ad21b3

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ Please note that in many cases `waitFor` call can be replaced by proper use of `
3636
:::
3737
3838
## Some `byTestId` queries behavior changes
39+
40+
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).
41+
42+
If you relied on setting `testID` for your custom components, you should probably set them on the root element of the returned JSX.
43+
44+
:::caution
45+
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).
46+
:::

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)