Skip to content

Commit

Permalink
Revert docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingItWrong committed Mar 18, 2024
1 parent c06a0a2 commit 796274f
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions docs/rules/no-container.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
# Disallow the use of `container` methods (`testing-library/no-container`)

💼 This rule is enabled in the following configs: `angular`, `marko`, `react`,
`vue`.
💼 This rule is enabled in the following configs: `angular`, `marko`, `react`, `vue`.

<!-- end auto-generated rule header -->

By using `container` methods like `.querySelector` and properties like
`.innerHTML`, you may lose a lot of the confidence that the user can really
interact with your UI. Also, the test becomes harder to read, and it will break
more frequently.
By using `container` methods like `.querySelector` you may lose a lot of the confidence that the user can really interact with your UI. Also, the test becomes harder to read, and it will break more frequently.

This applies to Testing Library frameworks built on top of **DOM Testing
Library**
This applies to Testing Library frameworks built on top of **DOM Testing Library**

## Rule Details

This rule aims to disallow the use of `container` methods and properties in your
tests.
This rule aims to disallow the use of `container` methods in your tests.

Examples of **incorrect** code for this rule:

```js
const { container } = render(<Example />);
const button = container.querySelector('.btn-primary');
const html = container.innerHTML;
```

```js
const { container: alias } = render(<Example />);
const button = alias.querySelector('.btn-primary');
const html = alias.innerHTML;
```

```js
const view = render(<Example />);
const button = view.container.getElementsByClassName('.btn-primary');
const html = view.container.innerHTML;
```

Examples of **correct** code for this rule:
Expand Down

0 comments on commit 796274f

Please sign in to comment.