Skip to content

Commit c6c5cdb

Browse files
committed
docs: update rule details and add Testing Library Guides section
1 parent 17f7322 commit c6c5cdb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/rules/no-node-access.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ Disallow direct access or manipulation of DOM nodes in favor of Testing Library'
88

99
## Rule Details
1010

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.
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()`, `select()`). Use Testing Library’s queries and userEvent APIs instead.
12+
13+
> [!NOTE]
14+
> This rule does not report usage of `focus()`, because imperative focus (e.g. `getByText('focus me').focus()`) is recommended over `fireEvent.focus()`.
15+
> If an element is not focusable, related assertions will fail, leading to more robust tests. See [Testing Library Events Guide](https://testing-library.com/docs/guide-events/) for more details.
1216
1317
Examples of **incorrect** code for this rule:
1418

@@ -104,3 +108,7 @@ expect(container.firstChild).toMatchSnapshot();
104108
- [`Document`](https://developer.mozilla.org/en-US/docs/Web/API/Document)
105109
- [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element)
106110
- [`Node`](https://developer.mozilla.org/en-US/docs/Web/API/Node)
111+
112+
### Testing Library Guides
113+
114+
- [Testing Library Events Guide](https://testing-library.com/docs/guide-events/)

0 commit comments

Comments
 (0)