Skip to content

Commit 0f1cd36

Browse files
docs(no-node-access): update examples
1 parent 9415c3b commit 0f1cd36

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

docs/rules/no-node-access.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ screen.getByText('Submit').closest('button'); // chaining with Testing Library m
1414

1515
```js
1616
const buttons = screen.getAllByRole('button');
17-
const buttonA = buttons[1]; // getting the element directly from the array
18-
19-
expect(buttonA.lastChild).toBeInTheDocument();
17+
expect(buttons[1].lastChild).toBeInTheDocument();
2018
```
2119

2220
```js
@@ -31,8 +29,8 @@ document.getElementById('submit-btn').closest('button');
3129
Examples of **correct** code for this rule:
3230

3331
```js
34-
const buttonText = screen.getByRole('button');
35-
expect(buttonText.textContent).toBe('Submit');
32+
const button = screen.getByRole('button');
33+
expect(button).toHaveTextContent('submit');
3634
```
3735

3836
## Further Reading

0 commit comments

Comments
 (0)