You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/MigrationV12.md
+8-3Lines changed: 8 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,12 @@ React Native Testing Library 12 introduces a handful of breaking changes compare
7
7
8
8
# Breaking changes
9
9
10
-
## 1. `*ByRole` queries now return only accessibility elements
10
+
## 1. All queries exclude elements hidden from accessibility by default
11
+
Elements that are hidden from accessiblity, e.g. elements on non-active screen when using React Navigation, now will not be matched by default by all queries. This the effect of switch default value for global config option `defaultIncludeHiddenElements`(api#defaultincludehiddenelements-option) to `false`.
12
+
13
+
Previous behaviour of matching hidden elements can be enabled on query level using [includeHiddenElements](api-queries#includehiddenelements-option) query options or globally using `defaultIncludeHiddenElements`(api#defaultincludehiddenelements-option) configuration option.
14
+
15
+
## 2. `*ByRole` queries now return only accessibility elements
11
16
`*ByRole` queries now return only accessibility elements, either explicitly marked with `accessible` prop or implicit ones where this status is derrived from component type itself (e.g `Text`, `TextInput`, `Switch`, but not `View`).
12
17
13
18
You may need to adjust relevant components under test to make sure they pass `isAccessibilityElement` check.
@@ -38,14 +43,14 @@ While following elements will not match:
## 2. `*ByText`, `*ByDisplayValue`, `*ByPlaceholderText` queries now return host elements
46
+
## 3. `*ByText`, `*ByDisplayValue`, `*ByPlaceholderText` queries now return host elements
42
47
`*ByText`, `*ByDisplayValue`, `*ByPlaceholderText` queries now return [host elements](testing-env#host-and-composite-components), which is consistent with other queries.
43
48
44
49
While potentially breaking, this should not cause issues in tests if you are using recommended queries and Jest Matchers from Jest Native package.
45
50
46
51
Problematic cases may include: directly checking some prop values (without using Jest Native matchers), referencing other nodes using `parent` or `children` props, examining `type` property of `ReactTestInstance`, etc.
47
52
48
-
## 3. `container` API has been renamed to `UNSAFE_root`.
53
+
## 4. `container` API has been renamed to `UNSAFE_root`.
49
54
50
55
Historically `container` was supposed to mimic the [RTL's container](https://testing-library.com/docs/react-testing-library/api/#container). However it turned out not so relevant in RNTL's environment, where we actually used it to return React Test Renderer's root instance.
0 commit comments