This guide describes the migration to React Native Testing Library version 13 from version 12.x.
Overall, the v13 release is relatively small, focusing on removing deprecated queries and improving the developer experience.
This version supports only React 18+ and corresponding React Native versions (0.71+). If you use React 16 or 17, please use the latest of v12 versions.
Note: currently, stable React Native is unavailable for React 19, which is still in the RC phase, so we test against React Native nightly builds.
This version introduces concurrent rendering by default. This change should not affect regular tests, but it might affect your tests if you use React Suspense or similar.
You can revert to legacy rendering by passing concurrentRoot: false to render or configure methods.
Note: in React 19, concurrent rendering is the only supported rendering mode.
You can remove import '@testing-library/react-native/extend-expect' imports, as now Jest matchers are extended by default when you import anything from @testing-library/react-native.
You can avoid the automatic extending of Jest matchers by importing @testing-library/react-native/pure instead.
*ByAccessibilityState queriesWe have removed this deprecated query as it is typically too general to give meaningful results. Use one of the following options:
disabled, selected, checked, expanded and busy*ByAccessibilityValue queriesWe have removed this deprecated query as it is typically too general to give meaningful results. Use one of the following options:
value optionWe have removed RNTL Jest preset, so you should change you jest.config.js accordingly.
Replace:
debug.shallowWe didn't support shallow rendering for the time being. Now, we are removing the last remains of it: debug.shallow(). If you are interested in shallow rendering see here.
Explicit labels:
accessiblityLabelledByaccessiblityLabelaria-labelledbyaria-labelnow take strict priority over implicit labels derived from the element's text content.
This change should not break any tests, it should also make RNTL tests run 10-20% faster.
act instead of React Test Renderer oneThis change should not break any tests.
flushMicroTasks internal methodThis change should not break any tests.
https://github.com/callstack/react-native-testing-library/compare/v12.8.1...v13.0.0