From 49204583336103b8cb76ccb63de217b8006479c1 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 13:02:51 +0200 Subject: [PATCH 1/5] Added migration docs section --- website/docs/MigrationTo20.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 website/docs/MigrationTo20.md diff --git a/website/docs/MigrationTo20.md b/website/docs/MigrationTo20.md new file mode 100644 index 000000000..7843455fe --- /dev/null +++ b/website/docs/MigrationTo20.md @@ -0,0 +1,11 @@ +# Migration to 2.0 + +### Some `byTestId` queries behavior changes + +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). + +If you relied on setting `testID` for your custom components, you should probably set them on the root element of the returned JSX. + +:::caution +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. `byTest`, `byPlaceholder`, etc) or accessability queries (e.g. `byA11yHint`, `byA11yLabel`, etc). +::: From 900bf301f311965fbd1ad9d1165f25d197f40d6b Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 14:31:58 +0200 Subject: [PATCH 2/5] Added to docosaurus side bar --- website/docs/{MigrationTo20.md => Migration20.md} | 9 +++++++-- website/sidebars.js | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) rename website/docs/{MigrationTo20.md => Migration20.md} (74%) diff --git a/website/docs/MigrationTo20.md b/website/docs/Migration20.md similarity index 74% rename from website/docs/MigrationTo20.md rename to website/docs/Migration20.md index 7843455fe..bb0abc0e9 100644 --- a/website/docs/MigrationTo20.md +++ b/website/docs/Migration20.md @@ -1,6 +1,11 @@ -# Migration to 2.0 +--- +id: migration20 +title: Migration to 2.0 +--- -### Some `byTestId` queries behavior changes +This guides describes major steps involved in migrating your testing code from using React Native Testing Library version `1.x` to version `2.0`. + +## Some `byTestId` queries behavior changes 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). diff --git a/website/sidebars.js b/website/sidebars.js index 67b9b5d86..d3c764e26 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -2,6 +2,7 @@ module.exports = { docs: { Introduction: ['getting-started'], 'API Reference': ['api', 'api-queries'], + Guides: ['migration20'], Examples: ['react-navigation', 'redux-integration'], }, }; From 176fd0ca1c659cf6a78e6fef16c6767fa7de9699 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 14:35:28 +0200 Subject: [PATCH 3/5] Updated README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bf662c11..72655a7a7 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,9 @@ The [public API](https://callstack.github.io/react-native-testing-library/docs/a - [`within`](https://callstack.github.io/react-native-testing-library/docs/api#within) - creates a queries object scoped for given element. - [`flushMicrotasksQueue`](https://callstack.github.io/react-native-testing-library/docs/api#flushmicrotasksqueue) - waits for microtasks queue to flush. -**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. +## Migration Guides + +- [Migration to 2.0](https://callstack.github.io/react-native-testing-library/docs/migration20) ## Made with ❤️ at Callstack From 556e7108f479f69b420aa8307f0cf7621d1d96e6 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 18 May 2020 14:47:52 +0200 Subject: [PATCH 4/5] Increased async test timeout --- src/__tests__/findByApi.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/findByApi.test.js b/src/__tests__/findByApi.test.js index 3f15c7840..191003010 100644 --- a/src/__tests__/findByApi.test.js +++ b/src/__tests__/findByApi.test.js @@ -55,4 +55,4 @@ test('findBy queries work asynchronously', async () => { ); await expect(findByDisplayValue('Display Value')).resolves.toBeTruthy(); await expect(findAllByDisplayValue('Display Value')).resolves.toHaveLength(1); -}, 10000); +}, 20000); From 77ca8ebe419045bb13bbde306d4a70fc02cc9cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 18 May 2020 16:02:47 +0200 Subject: [PATCH 5/5] Update website/docs/Migration20.md --- website/docs/Migration20.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/Migration20.md b/website/docs/Migration20.md index bb0abc0e9..6bd994919 100644 --- a/website/docs/Migration20.md +++ b/website/docs/Migration20.md @@ -12,5 +12,5 @@ In version `1.x` `getByTestId` and `queryByTestId` could return non-native eleme If you relied on setting `testID` for your custom components, you should probably set them on the root element of the returned JSX. :::caution -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. `byTest`, `byPlaceholder`, etc) or accessability queries (e.g. `byA11yHint`, `byA11yLabel`, etc). +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). :::