Skip to content

Commit 1c59122

Browse files
author
Mateus Felix
committed
docs(no-container): update
| add description about testing library frameworks | add link to container docs | remove recommended badge
1 parent d624bfe commit 1c59122

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ To enable this configuration use the `extends` property in your
140140
| [await-fire-event](docs/rules/await-fire-event.md) | Enforce async fire event methods to be awaited | ![vue-badge][] | |
141141
| [consistent-data-testid](docs/rules/consistent-data-testid.md) | Ensure `data-testid` values match a provided regex. | | |
142142
| [no-await-sync-query](docs/rules/no-await-sync-query.md) | Disallow unnecessary `await` for sync queries | ![recommended-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | |
143-
| [no-container](docs/rules/no-container.md) | Disallow the use of `container` methods | ![recommended-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | |
143+
| [no-container](docs/rules/no-container.md) | Disallow the use of `container` methods | ![angular-badge][] ![react-badge][] ![vue-badge][] | |
144144
| [no-debug](docs/rules/no-debug.md) | Disallow the use of `debug` | ![angular-badge][] ![react-badge][] ![vue-badge][] | |
145145
| [no-dom-import](docs/rules/no-dom-import.md) | Disallow importing from DOM Testing Library | ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] |
146146
| [no-manual-cleanup](docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | | |

docs/rules/no-container.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
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.
44

5+
This applies to Testing Library frameworks built on top of **DOM Testing Library**
6+
57
## Rule Details
68

79
This rule aims to disallow the use of `container` methods in your tests.
@@ -33,4 +35,5 @@ If you use [custom render functions](https://testing-library.com/docs/example-re
3335

3436
## Further Reading
3537

38+
- [about the `container` element](https://testing-library.com/docs/react-testing-library/api#container-1)
3639
- [querying with `screen`](https://testing-library.com/docs/dom-testing-library/api-queries#screen)

lib/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const recommendedRules = {
3636
'testing-library/await-async-query': 'error',
3737
'testing-library/await-async-utils': 'error',
3838
'testing-library/no-await-sync-query': 'error',
39-
'testing-library/no-container': 'error',
4039
'testing-library/no-wait-for-empty-callback': 'error',
4140
'testing-library/prefer-find-by': 'error',
4241
'testing-library/prefer-screen-queries': 'error',
@@ -53,6 +52,7 @@ export = {
5352
plugins: ['testing-library'],
5453
rules: {
5554
...recommendedRules,
55+
'testing-library/no-container': 'error',
5656
'testing-library/no-debug': 'warn',
5757
'testing-library/no-dom-import': ['error', 'angular'],
5858
},
@@ -61,6 +61,7 @@ export = {
6161
plugins: ['testing-library'],
6262
rules: {
6363
...recommendedRules,
64+
'testing-library/no-container': 'error',
6465
'testing-library/no-debug': 'warn',
6566
'testing-library/no-dom-import': ['error', 'react'],
6667
},
@@ -70,6 +71,7 @@ export = {
7071
rules: {
7172
...recommendedRules,
7273
'testing-library/await-fire-event': 'error',
74+
'testing-library/no-container': 'error',
7375
'testing-library/no-debug': 'warn',
7476
'testing-library/no-dom-import': ['error', 'vue'],
7577
},

tests/__snapshots__/index.test.ts.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ Object {
5353
"testing-library/await-async-query": "error",
5454
"testing-library/await-async-utils": "error",
5555
"testing-library/no-await-sync-query": "error",
56-
"testing-library/no-container": "error",
5756
"testing-library/no-wait-for-empty-callback": "error",
5857
"testing-library/prefer-find-by": "error",
5958
"testing-library/prefer-screen-queries": "error",

0 commit comments

Comments
 (0)