From a80e0c338b29928d42e4b1537081d71aca2d2c18 Mon Sep 17 00:00:00 2001 From: Maciej Jastrzebski Date: Mon, 25 Jul 2022 16:23:57 +0200 Subject: [PATCH] docs: v11 migration guide (#1021) * docs: v11 migration guide * docs: tweaks * docs: more tweaks * tweaks --- README.md | 4 +-- website/docs/MigrationV11.md | 64 ++++++++++++++++++++++++++++++++++++ website/sidebars.js | 1 + 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 website/docs/MigrationV11.md diff --git a/README.md b/README.md index 31868d79b..cef41cdd8 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,6 @@ [![Chat][chat-badge]][chat] [![Sponsored by Callstack][callstack-badge]][callstack] -> 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). - ## The problem 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 ## Migration Guides +- [Migration to 11.0](https://callstack.github.io/react-native-testing-library/docs/migration-v11) +- [Migration to 9.0](https://callstack.github.io/react-native-testing-library/docs/migration-v9) - [Migration to 7.0](https://callstack.github.io/react-native-testing-library/docs/migration-v7) - [Migration to 2.0](https://callstack.github.io/react-native-testing-library/docs/migration-v2) diff --git a/website/docs/MigrationV11.md b/website/docs/MigrationV11.md new file mode 100644 index 000000000..01751500c --- /dev/null +++ b/website/docs/MigrationV11.md @@ -0,0 +1,64 @@ +--- +id: migration-v11 +title: Migration to 1.0 +--- + +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. + +# Breaking changes + +## Update to Jest 28 if you use fake timers + +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. + +## Refactor legacy `waitForOptions` position + +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: + +```ts +function findByText(text: TextMatch, waitForOptions?: WaitForOptions) +function findAllByText(text: TextMatch, waitForOptions?: WaitForOptions) +``` + +to + +```ts +function findByText(text: TextMatch, options?: TextMatchOptions, waitForOptions?: WaitForOptions) +function findAllByText(text: TextMatch, options?: TextMatchOptions, waitForOptions?: WaitForOptions) +``` + +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. + +This change is easy to implement: + +```ts +findByText(/Text/, { timeout: 1000 }) +``` + +should become + +```ts +findByText(/Text/, {}, { timeout: 1000 }) +``` + +## Triggering non-touch events on targes with `pointerEvents="box-none"` prop + +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. + +From version 11, RNTL continues to disable `press` event for these targets but allows triggering other events, e.g. `layout`. + +# All changes + +* chore(breaking): update Jest to 28 by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1008 +* refactor(breaking): remove legacy wait for options support by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1018 +* refactor(breaking): remove `byA11yStates` queries by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1015 +* chore: update react-native to 0.69.1 by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1010 +* chore: update deps @types for react/react-native by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1013 +* feat: Trigger non-touch events on box-none targets by @dcalhoun in https://github.com/callstack/react-native-testing-library/pull/906 +* docs: create document describing act function and related errors by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/969 +* chore: Organise a11y queries by predicate by @MattAgn in https://github.com/callstack/react-native-testing-library/pull/977 +* chore: reenable skipped byText tests by @mdjastrzebski in https://github.com/callstack/react-native-testing-library/pull/1017 + +# Full Changelog +https://github.com/callstack/react-native-testing-library/compare/v10.1.1...v11.0.0-rc.0 + diff --git a/website/sidebars.js b/website/sidebars.js index ac4f90137..d35d024aa 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -3,6 +3,7 @@ module.exports = { Introduction: ['getting-started'], 'API Reference': ['api', 'api-queries'], Guides: [ + 'migration-v11', 'migration-v9', 'migration-v7', 'migration-v2',