Skip to content

Commit 421e9cd

Browse files
committed
docs: including testing-library prefix in all rules
1 parent 30f8d5b commit 421e9cd

24 files changed

+34
-34
lines changed

docs/rules/await-async-query.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Enforce promises from async queries to be handled (await-async-query)
1+
# Enforce promises from async queries to be handled (`testing-library/await-async-query`)
22

33
Ensure that promises returned by async queries are handled properly.
44

docs/rules/await-async-utils.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Enforce promises from async utils to be handled (await-async-utils)
1+
# Enforce promises from async utils to be handled (`testing-library/await-async-utils`)
22

33
Ensure that promises returned by async utils are handled properly.
44

docs/rules/await-fire-event.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Enforce promises from fire event methods to be handled (await-fire-event)
1+
# Enforce promises from fire event methods to be handled (`testing-library/await-fire-event`)
22

33
Ensure that promises returned by `fireEvent` methods are handled
44
properly.

docs/rules/consistent-data-testid.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Enforces consistent naming for the data-testid attribute (consistent-data-testid)
1+
# Enforces consistent naming for the data-testid attribute (`testing-library/consistent-data-testid`)
22

33
Ensure `data-testid` values match a provided regex. This rule is un-opinionated, and requires configuration.
44

docs/rules/no-await-sync-events.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow unnecessary `await` for sync events (no-await-sync-events)
1+
# Disallow unnecessary `await` for sync events (`testing-library/no-await-sync-events`)
22

33
Ensure that sync simulated events are not awaited unnecessarily.
44

docs/rules/no-await-sync-query.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow unnecessary `await` for sync queries (no-await-sync-query)
1+
# Disallow unnecessary `await` for sync queries (`testing-library/no-await-sync-query`)
22

33
Ensure that sync queries are not awaited unnecessarily.
44

docs/rules/no-container.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow the use of `container` methods (no-container)
1+
# Disallow the use of `container` methods (`testing-library/no-container`)
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

docs/rules/no-debug.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow the use of `debug` (no-debug)
1+
# Disallow the use of `debug` (`testing-library/no-debug`)
22

33
Just like `console.log` statements pollutes the browser's output, debug statements also pollutes the tests if one of your teammates forgot to remove it. `debug` statements should be used when you actually want to debug your tests but should not be pushed to the codebase.
44

docs/rules/no-dom-import.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow importing from DOM Testing Library
1+
# Disallow importing from DOM Testing Library (`testing-library/no-dom-import`)
22

33
Ensure that there are no direct imports from `@testing-library/dom` or
44
`dom-testing-library` when using some testing library framework
@@ -7,18 +7,18 @@ wrapper.
77
## Rule Details
88

99
Testing Library framework wrappers as React Testing Library already
10-
re-exports everything from DOM Testing Library so you always have to
11-
import DOM Testing Library utils from corresponding framework wrapper
10+
re-exports everything from DOM Testing Library, so you always have to
11+
import Testing Library utils from corresponding framework wrapper
1212
module to:
1313

1414
- use proper extended version of some of those methods containing
1515
additional functionality related to specific framework (e.g.
1616
`fireEvent` util)
1717
- avoid importing from extraneous dependencies (similar to
18-
eslint-plugin-import)
18+
`eslint-plugin-import`)
1919

2020
This rule aims to prevent users from import anything directly from
21-
`@testing-library/dom` (or `dom-testing-library`) and it's useful for
21+
`@testing-library/dom`, which is useful for
2222
new starters or when IDEs autoimport from wrong module.
2323

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

docs/rules/no-manual-cleanup.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow the use of `cleanup` (no-manual-cleanup)
1+
# Disallow the use of `cleanup` (`testing-library/no-manual-cleanup`)
22

33
`cleanup` is performed automatically if the testing framework you're using supports the `afterEach` global (like mocha, Jest, and Jasmine). In this case, it's unnecessary to do manual cleanups after each test unless you skip the auto-cleanup with environment variables such as `RTL_SKIP_AUTO_CLEANUP` for React.
44

docs/rules/no-node-access.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow direct Node access (no-node-access)
1+
# Disallow direct Node access (`testing-library/no-node-access`)
22

33
The Testing Library already provides methods for querying DOM elements.
44

docs/rules/no-promise-in-fire-event.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow the use of promises passed to a `fireEvent` method (no-promise-in-fire-event)
1+
# Disallow the use of promises passed to a `fireEvent` method (`testing-library/no-promise-in-fire-event`)
22

33
Methods from `fireEvent` expect to receive a DOM element. Passing a promise will end up in an error, so it must be prevented.
44

docs/rules/no-render-in-setup.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow the use of `render` in setup functions (no-render-in-setup)
1+
# Disallow the use of `render` in setup functions (`testing-library/no-render-in-setup`)
22

33
## Rule Details
44

docs/rules/no-wait-for-empty-callback.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Empty callbacks inside `waitFor` and `waitForElementToBeRemoved` are not preferred (no-wait-for-empty-callback)
1+
# Empty callbacks inside `waitFor` and `waitForElementToBeRemoved` are not preferred (`testing-library/no-wait-for-empty-callback`)
22

33
## Rule Details
44

docs/rules/no-wait-for-multiple-assertions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Multiple assertions inside `waitFor` are not preferred (no-wait-for-multiple-assertions)
1+
# Disallow the use of multiple expect inside `waitFor` (`testing-library/no-wait-for-multiple-assertions`)
22

33
## Rule Details
44

docs/rules/no-wait-for-side-effects.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Side effects inside `waitFor` are not preferred (no-wait-for-side-effects)
1+
# Disallow the use of side effects inside `waitFor` (`testing-library/no-wait-for-side-effects`)
22

33
## Rule Details
44

docs/rules/no-wait-for-snapshot.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Ensures no snapshot is generated inside of a `wait` call' (no-wait-for-snapshot)
1+
# Ensures no snapshot is generated inside a `waitFor` call (`testing-library/no-wait-for-snapshot`)
22

33
Ensure that no calls to `toMatchSnapshot` or `toMatchInlineSnapshot` are made from within a `waitFor` method (or any of the other async utility methods).
44

55
## Rule Details
66

77
The `waitFor()` method runs in a timer loop. So it'll retry every n amount of time.
8-
If a snapshot is generated inside the wait condition, jest will generate one snapshot per loop.
8+
If a snapshot is generated inside the wait condition, jest will generate one snapshot per each loop.
99

10-
The problem then is the amount of loop ran until the condition is met will vary between different computers (or CI machines). This leads to tests that will regenerate a lot of snapshots until the condition is matched when devs run those tests locally updating the snapshots; e.g devs cannot run `jest -u` locally or it'll generate a lot of invalid snapshots who'll fail during CI.
10+
The problem then is the amount of loop ran until the condition is met will vary between different computers (or CI machines). This leads to tests that will regenerate a lot of snapshots until the condition is matched when devs run those tests locally updating the snapshots; e.g. devs cannot run `jest -u` locally, or it'll generate a lot of invalid snapshots which will fail during CI.
1111

1212
Note that this lint rule prevents from generating a snapshot from within any of the [async utility methods](https://testing-library.com/docs/dom-testing-library/api-async).
1313

docs/rules/prefer-explicit-assert.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Suggest using explicit assertions rather than just `getBy*` queries (prefer-explicit-assert)
1+
# Suggest using explicit assertions rather than just `getBy*` queries (`testing-library/prefer-explicit-assert`)
22

33
Testing Library `getBy*` queries throw an error if the element is not
44
found. Some users like this behavior to use the query itself as an

docs/rules/prefer-find-by.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries (prefer-find-by)
1+
# Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries (`testing-library/prefer-find-by`)
22

33
findBy* queries are a simple combination of getBy* queries and waitFor. The findBy\* queries accept the waitFor options as the last argument. (i.e. screen.findByText('text', queryOptions, waitForOptions))
44

55
## Rule details
66

7-
This rule aims to use `findBy*` or `findAllBy*` queries to wait for elements, rather than using `waitFor`, or the deprecated methods `waitForElement` and `wait`.
8-
This rules analyzes those cases where `waitFor` is used with just one query method, in the form of an arrow function with only one statement (that is, without a block of statements). Given the callback could be more complex, this rule does not consider function callbacks or arrow functions with blocks of code
7+
This rule aims to use `findBy*` or `findAllBy*` queries to wait for elements, rather than using `waitFor`, or the deprecated methods `waitForElement` and `wait`.
8+
This rule analyzes those cases where `waitFor` is used with just one query method, in the form of an arrow function with only one statement (that is, without a block of statements). Given the callback could be more complex, this rule does not consider function callbacks or arrow functions with blocks of code
99

1010
Examples of **incorrect** code for this rule
1111

docs/rules/prefer-presence-queries.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Enforce specific queries when checking element is present or not (prefer-presence-queries)
1+
# Enforce specific queries when checking element is present or not (`testing-library/prefer-presence-queries`)
22

33
The (DOM) Testing Library allows to query DOM elements using different types of queries such as `get*` and `query*`. Using `get*` throws an error in case the element is not found, while `query*` returns null instead of throwing (or empty array for `queryAllBy*` ones). These differences are useful in some situations:
44

docs/rules/prefer-screen-queries.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Suggest using screen while using queries (prefer-screen-queries)
1+
# Suggest using `screen` while using queries (`testing-library/prefer-screen-queries`)
22

33
## Rule Details
44

docs/rules/prefer-user-event.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Use [userEvent](https://github.com/testing-library/user-event) over using `fireEvent` for user interactions (prefer-user-event)
1+
# Suggest using `userEvent` library instead of `fireEvent` for simulating user interaction (`testing-library/prefer-user-event`)
22

33
From
44
[testing-library/dom-testing-library#107](https://github.com/testing-library/dom-testing-library/issues/107):
@@ -97,8 +97,8 @@ When you don't want to use `userEvent`, such as if a legacy codebase is still us
9797

9898
## Further Reading
9999

100-
- [userEvent repository](https://github.com/testing-library/user-event)
101-
- [userEvent in the react-testing-library docs](https://testing-library.com/docs/ecosystem-user-event)
100+
- [`user-event` repository](https://github.com/testing-library/user-event)
101+
- [`userEvent` in the Testing Library docs](https://testing-library.com/docs/ecosystem-user-event)
102102

103103
## Appendix
104104

docs/rules/prefer-wait-for.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Use `waitFor` instead of deprecated wait methods (prefer-wait-for)
1+
# Use `waitFor` instead of deprecated wait methods (`testing-library/prefer-wait-for`)
22

33
`dom-testing-library` v7 released a new async util called `waitFor` which satisfies the use cases of `wait`, `waitForElement`, and `waitForDomChange` making them deprecated.
44

docs/rules/render-result-naming-convention.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Enforce a valid naming for return value from `render` (render-result-naming-convention)
1+
# Enforce a valid naming for return value from `render` (`testing-library/render-result-naming-convention`)
22

33
> The name `wrapper` is old cruft from `enzyme` and we don't need that here. The return value from `render` is not "wrapping" anything. It's simply a collection of utilities that you should actually not often need anyway.
44

0 commit comments

Comments
 (0)