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: docs/rules/no-node-access.md
+14-2Lines changed: 14 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@
4
4
5
5
<!-- end auto-generated rule header -->
6
6
7
-
The Testing Library already provides methods for querying DOM elements.
7
+
Disallow direct access or manipulation of DOM nodes in favor of Testing Library's user-centric APIs.
8
8
9
9
## Rule Details
10
10
11
-
This rule aims to disallow DOM traversal using native HTML methods and properties, such as `closest`, `lastChild` and all that returns another Node element from an HTML tree.
11
+
This rule aims to disallow direct access and manipulation of DOM nodes using native HTML properties and methods — including traversal (e.g. `closest`, `lastChild`) as well as direct actions (e.g. `click()`, `focus()`). Use Testing Library’s queries and userEvent APIs instead.
12
12
13
13
Examples of **incorrect** code for this rule:
14
14
@@ -21,6 +21,12 @@ screen.getByText('Submit').closest('button'); // chaining with Testing Library m
0 commit comments