|
| 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 | + |
0 commit comments