From 82ace4946fca958698adcc367ba3e8fa9ab070a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Sun, 28 Mar 2021 20:01:43 +0200 Subject: [PATCH] refactor: cleanup after migrating all rules to v4 (#303) * docs: update rule description * test: improve current cases * refactor: use new rule creator * feat: avoid reporting type and keyboard with 0 delay * refactor: use new helpers for detection * test: split fire and user events cases * test: improve errors location asserts * feat: detect user-event import properly * test: add cases for increasing coverage up to 100% * test: assert error message data * test: set final threshold for node-utils * chore: extract semantic release config to its own file * docs: including testing-library prefix in all rules * docs: including testing-library rule prefix in README --- .releaserc.json | 17 ++++++ README.md | 52 +++++++++---------- docs/rules/await-async-query.md | 2 +- docs/rules/await-async-utils.md | 2 +- docs/rules/await-fire-event.md | 2 +- docs/rules/consistent-data-testid.md | 2 +- docs/rules/no-await-sync-events.md | 2 +- docs/rules/no-await-sync-query.md | 2 +- docs/rules/no-container.md | 2 +- docs/rules/no-debug.md | 2 +- docs/rules/no-dom-import.md | 10 ++-- docs/rules/no-manual-cleanup.md | 2 +- docs/rules/no-node-access.md | 2 +- docs/rules/no-promise-in-fire-event.md | 2 +- docs/rules/no-render-in-setup.md | 2 +- docs/rules/no-wait-for-empty-callback.md | 2 +- docs/rules/no-wait-for-multiple-assertions.md | 2 +- docs/rules/no-wait-for-side-effects.md | 2 +- docs/rules/no-wait-for-snapshot.md | 6 +-- docs/rules/prefer-explicit-assert.md | 2 +- docs/rules/prefer-find-by.md | 6 +-- docs/rules/prefer-presence-queries.md | 2 +- docs/rules/prefer-screen-queries.md | 2 +- docs/rules/prefer-user-event.md | 6 +-- docs/rules/prefer-wait-for.md | 2 +- docs/rules/render-result-naming-convention.md | 2 +- jest.config.js | 3 +- package.json | 17 ------ 28 files changed, 78 insertions(+), 79 deletions(-) create mode 100644 .releaserc.json diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 00000000..dd5a8466 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,17 @@ +{ + "pkgRoot": "dist", + "branches": [ + "+([0-9])?(.{+([0-9]),x}).x", + "main", + "next", + "next-major", + { + "name": "beta", + "prerelease": true + }, + { + "name": "alpha", + "prerelease": true + } + ] +} diff --git a/README.md b/README.md index e89fc02a..3261e7e9 100644 --- a/README.md +++ b/README.md @@ -125,32 +125,32 @@ To enable this configuration use the `extends` property in your ## Supported Rules -| Rule | Description | Configurations | Fixable | -| -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ------------------ | -| [await-async-query](docs/rules/await-async-query.md) | Enforce promises from async queries to be handled | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | -| [await-async-utils](docs/rules/await-async-utils.md) | Enforce async utils to be awaited properly | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | -| [await-fire-event](docs/rules/await-fire-event.md) | Enforce promises from fire event methods to be handled | ![vue-badge][] | | -| [consistent-data-testid](docs/rules/consistent-data-testid.md) | Ensure `data-testid` values match a provided regex. | | | -| [no-await-sync-events](docs/rules/no-await-sync-events.md) | Disallow unnecessary `await` for sync events | | | -| [no-await-sync-query](docs/rules/no-await-sync-query.md) | Disallow unnecessary `await` for sync queries | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | -| [no-container](docs/rules/no-container.md) | Disallow the use of `container` methods | ![angular-badge][] ![react-badge][] ![vue-badge][] | | -| [no-debug](docs/rules/no-debug.md) | Disallow the use of `debug` | ![angular-badge][] ![react-badge][] ![vue-badge][] | | -| [no-dom-import](docs/rules/no-dom-import.md) | Disallow importing from DOM Testing Library | ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] | -| [no-manual-cleanup](docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | | | -| [no-node-access](docs/rules/no-node-access.md) | Disallow direct Node access | ![angular-badge][] ![react-badge][] ![vue-badge][] | | -| [no-promise-in-fire-event](docs/rules/no-promise-in-fire-event.md) | Disallow the use of promises passed to a `fireEvent` method | | | -| [no-render-in-setup](docs/rules/no-render-in-setup.md) | Disallow the use of `render` in setup functions | | | -| [no-wait-for-empty-callback](docs/rules/no-wait-for-empty-callback.md) | Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved` | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | -| [no-wait-for-multiple-assertions](docs/rules/no-wait-for-multiple-assertions.md) | Disallow the use of multiple expect inside `waitFor` | | | -| [no-wait-for-side-effects](docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects inside `waitFor` | | | -| [no-wait-for-snapshot](docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | | -| [prefer-explicit-assert](docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than just `getBy*` queries | | | -| [prefer-find-by](docs/rules/prefer-find-by.md) | Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] | -| [prefer-presence-queries](docs/rules/prefer-presence-queries.md) | Enforce specific queries when checking element is present or not | | | -| [prefer-user-event](docs/rules/prefer-user-event.md) | Suggest using `userEvent` library instead of `fireEvent` for simulating user interaction | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | -| [prefer-screen-queries](docs/rules/prefer-screen-queries.md) | Suggest using screen while using queries | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | -| [prefer-wait-for](docs/rules/prefer-wait-for.md) | Use `waitFor` instead of deprecated wait methods | | ![fixable-badge][] | -| [render-result-naming-convention](docs/rules/render-result-naming-convention.md) | Enforce a valid naming for return value from `render` | ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| Rule | Description | Configurations | Fixable | +| ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ------------------ | +| [testing-library/await-async-query](docs/rules/await-async-query.md) | Enforce promises from async queries to be handled | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| [testing-library/await-async-utils](docs/rules/await-async-utils.md) | Enforce async utils to be awaited properly | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| [testing-library/await-fire-event](docs/rules/await-fire-event.md) | Enforce promises from fire event methods to be handled | ![vue-badge][] | | +| [testing-library/consistent-data-testid](docs/rules/consistent-data-testid.md) | Ensure `data-testid` values match a provided regex. | | | +| [testing-library/no-await-sync-events](docs/rules/no-await-sync-events.md) | Disallow unnecessary `await` for sync events | | | +| [testing-library/no-await-sync-query](docs/rules/no-await-sync-query.md) | Disallow unnecessary `await` for sync queries | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| [testing-library/no-container](docs/rules/no-container.md) | Disallow the use of `container` methods | ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| [testing-library/no-debug](docs/rules/no-debug.md) | Disallow the use of `debug` | ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| [testing-library/no-dom-import](docs/rules/no-dom-import.md) | Disallow importing from DOM Testing Library | ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] | +| [testing-library/no-manual-cleanup](docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | | | +| [testing-library/no-node-access](docs/rules/no-node-access.md) | Disallow direct Node access | ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| [testing-library/no-promise-in-fire-event](docs/rules/no-promise-in-fire-event.md) | Disallow the use of promises passed to a `fireEvent` method | | | +| [testing-library/no-render-in-setup](docs/rules/no-render-in-setup.md) | Disallow the use of `render` in setup functions | | | +| [testing-library/no-wait-for-empty-callback](docs/rules/no-wait-for-empty-callback.md) | Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved` | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| [testing-library/no-wait-for-multiple-assertions](docs/rules/no-wait-for-multiple-assertions.md) | Disallow the use of multiple expect inside `waitFor` | | | +| [testing-library/no-wait-for-side-effects](docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects inside `waitFor` | | | +| [testing-library/no-wait-for-snapshot](docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | | +| [testing-library/prefer-explicit-assert](docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than just `getBy*` queries | | | +| [testing-library/prefer-find-by](docs/rules/prefer-find-by.md) | Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] | +| [testing-library/prefer-presence-queries](docs/rules/prefer-presence-queries.md) | Enforce specific queries when checking element is present or not | | | +| [testing-library/prefer-user-event](docs/rules/prefer-user-event.md) | Suggest using `userEvent` library instead of `fireEvent` for simulating user interaction | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| [testing-library/prefer-screen-queries](docs/rules/prefer-screen-queries.md) | Suggest using screen while using queries | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | +| [testing-library/prefer-wait-for](docs/rules/prefer-wait-for.md) | Use `waitFor` instead of deprecated wait methods | | ![fixable-badge][] | +| [testing-library/render-result-naming-convention](docs/rules/render-result-naming-convention.md) | Enforce a valid naming for return value from `render` | ![angular-badge][] ![react-badge][] ![vue-badge][] | | [build-badge]: /~https://github.com/testing-library/eslint-plugin-testing-library/actions/workflows/pipeline.yml/badge.svg [build-url]: /~https://github.com/testing-library/eslint-plugin-testing-library/actions/workflows/pipeline.yml diff --git a/docs/rules/await-async-query.md b/docs/rules/await-async-query.md index 162acd2e..c0f8081f 100644 --- a/docs/rules/await-async-query.md +++ b/docs/rules/await-async-query.md @@ -1,4 +1,4 @@ -# Enforce promises from async queries to be handled (await-async-query) +# Enforce promises from async queries to be handled (`testing-library/await-async-query`) Ensure that promises returned by async queries are handled properly. diff --git a/docs/rules/await-async-utils.md b/docs/rules/await-async-utils.md index d1772aaf..9d23ab41 100644 --- a/docs/rules/await-async-utils.md +++ b/docs/rules/await-async-utils.md @@ -1,4 +1,4 @@ -# Enforce promises from async utils to be handled (await-async-utils) +# Enforce promises from async utils to be handled (`testing-library/await-async-utils`) Ensure that promises returned by async utils are handled properly. diff --git a/docs/rules/await-fire-event.md b/docs/rules/await-fire-event.md index cff4509c..65e28594 100644 --- a/docs/rules/await-fire-event.md +++ b/docs/rules/await-fire-event.md @@ -1,4 +1,4 @@ -# Enforce promises from fire event methods to be handled (await-fire-event) +# Enforce promises from fire event methods to be handled (`testing-library/await-fire-event`) Ensure that promises returned by `fireEvent` methods are handled properly. diff --git a/docs/rules/consistent-data-testid.md b/docs/rules/consistent-data-testid.md index 4afc6860..9b03f2ae 100644 --- a/docs/rules/consistent-data-testid.md +++ b/docs/rules/consistent-data-testid.md @@ -1,4 +1,4 @@ -# Enforces consistent naming for the data-testid attribute (consistent-data-testid) +# Enforces consistent naming for the data-testid attribute (`testing-library/consistent-data-testid`) Ensure `data-testid` values match a provided regex. This rule is un-opinionated, and requires configuration. diff --git a/docs/rules/no-await-sync-events.md b/docs/rules/no-await-sync-events.md index df95afd4..58206373 100644 --- a/docs/rules/no-await-sync-events.md +++ b/docs/rules/no-await-sync-events.md @@ -1,4 +1,4 @@ -# Disallow unnecessary `await` for sync events (no-await-sync-events) +# Disallow unnecessary `await` for sync events (`testing-library/no-await-sync-events`) Ensure that sync simulated events are not awaited unnecessarily. diff --git a/docs/rules/no-await-sync-query.md b/docs/rules/no-await-sync-query.md index b84f117c..09424258 100644 --- a/docs/rules/no-await-sync-query.md +++ b/docs/rules/no-await-sync-query.md @@ -1,4 +1,4 @@ -# Disallow unnecessary `await` for sync queries (no-await-sync-query) +# Disallow unnecessary `await` for sync queries (`testing-library/no-await-sync-query`) Ensure that sync queries are not awaited unnecessarily. diff --git a/docs/rules/no-container.md b/docs/rules/no-container.md index 2089fad5..c764c641 100644 --- a/docs/rules/no-container.md +++ b/docs/rules/no-container.md @@ -1,4 +1,4 @@ -# Disallow the use of `container` methods (no-container) +# Disallow the use of `container` methods (`testing-library/no-container`) 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. diff --git a/docs/rules/no-debug.md b/docs/rules/no-debug.md index e3278738..1b3167fd 100644 --- a/docs/rules/no-debug.md +++ b/docs/rules/no-debug.md @@ -1,4 +1,4 @@ -# Disallow the use of `debug` (no-debug) +# Disallow the use of `debug` (`testing-library/no-debug`) 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. diff --git a/docs/rules/no-dom-import.md b/docs/rules/no-dom-import.md index e6e9e000..a7ba4e1b 100644 --- a/docs/rules/no-dom-import.md +++ b/docs/rules/no-dom-import.md @@ -1,4 +1,4 @@ -# Disallow importing from DOM Testing Library +# Disallow importing from DOM Testing Library (`testing-library/no-dom-import`) Ensure that there are no direct imports from `@testing-library/dom` or `dom-testing-library` when using some testing library framework @@ -7,18 +7,18 @@ wrapper. ## Rule Details Testing Library framework wrappers as React Testing Library already -re-exports everything from DOM Testing Library so you always have to -import DOM Testing Library utils from corresponding framework wrapper +re-exports everything from DOM Testing Library, so you always have to +import Testing Library utils from corresponding framework wrapper module to: - use proper extended version of some of those methods containing additional functionality related to specific framework (e.g. `fireEvent` util) - avoid importing from extraneous dependencies (similar to - eslint-plugin-import) + `eslint-plugin-import`) This rule aims to prevent users from import anything directly from -`@testing-library/dom` (or `dom-testing-library`) and it's useful for +`@testing-library/dom`, which is useful for new starters or when IDEs autoimport from wrong module. Examples of **incorrect** code for this rule: diff --git a/docs/rules/no-manual-cleanup.md b/docs/rules/no-manual-cleanup.md index cfdd84d8..4b63f88f 100644 --- a/docs/rules/no-manual-cleanup.md +++ b/docs/rules/no-manual-cleanup.md @@ -1,4 +1,4 @@ -# Disallow the use of `cleanup` (no-manual-cleanup) +# Disallow the use of `cleanup` (`testing-library/no-manual-cleanup`) `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. diff --git a/docs/rules/no-node-access.md b/docs/rules/no-node-access.md index 78d775dd..638f06eb 100644 --- a/docs/rules/no-node-access.md +++ b/docs/rules/no-node-access.md @@ -1,4 +1,4 @@ -# Disallow direct Node access (no-node-access) +# Disallow direct Node access (`testing-library/no-node-access`) The Testing Library already provides methods for querying DOM elements. diff --git a/docs/rules/no-promise-in-fire-event.md b/docs/rules/no-promise-in-fire-event.md index 2c8c238c..3bd5dd5f 100644 --- a/docs/rules/no-promise-in-fire-event.md +++ b/docs/rules/no-promise-in-fire-event.md @@ -1,4 +1,4 @@ -# Disallow the use of promises passed to a `fireEvent` method (no-promise-in-fire-event) +# Disallow the use of promises passed to a `fireEvent` method (`testing-library/no-promise-in-fire-event`) Methods from `fireEvent` expect to receive a DOM element. Passing a promise will end up in an error, so it must be prevented. diff --git a/docs/rules/no-render-in-setup.md b/docs/rules/no-render-in-setup.md index 0cdf4cc7..91ec364f 100644 --- a/docs/rules/no-render-in-setup.md +++ b/docs/rules/no-render-in-setup.md @@ -1,4 +1,4 @@ -# Disallow the use of `render` in setup functions (no-render-in-setup) +# Disallow the use of `render` in setup functions (`testing-library/no-render-in-setup`) ## Rule Details diff --git a/docs/rules/no-wait-for-empty-callback.md b/docs/rules/no-wait-for-empty-callback.md index 629d3ffa..2754f710 100644 --- a/docs/rules/no-wait-for-empty-callback.md +++ b/docs/rules/no-wait-for-empty-callback.md @@ -1,4 +1,4 @@ -# Empty callbacks inside `waitFor` and `waitForElementToBeRemoved` are not preferred (no-wait-for-empty-callback) +# Empty callbacks inside `waitFor` and `waitForElementToBeRemoved` are not preferred (`testing-library/no-wait-for-empty-callback`) ## Rule Details diff --git a/docs/rules/no-wait-for-multiple-assertions.md b/docs/rules/no-wait-for-multiple-assertions.md index 5b836dbf..efe376ca 100644 --- a/docs/rules/no-wait-for-multiple-assertions.md +++ b/docs/rules/no-wait-for-multiple-assertions.md @@ -1,4 +1,4 @@ -# Multiple assertions inside `waitFor` are not preferred (no-wait-for-multiple-assertions) +# Disallow the use of multiple expect inside `waitFor` (`testing-library/no-wait-for-multiple-assertions`) ## Rule Details diff --git a/docs/rules/no-wait-for-side-effects.md b/docs/rules/no-wait-for-side-effects.md index ccb3dd95..6f81179d 100644 --- a/docs/rules/no-wait-for-side-effects.md +++ b/docs/rules/no-wait-for-side-effects.md @@ -1,4 +1,4 @@ -# Side effects inside `waitFor` are not preferred (no-wait-for-side-effects) +# Disallow the use of side effects inside `waitFor` (`testing-library/no-wait-for-side-effects`) ## Rule Details diff --git a/docs/rules/no-wait-for-snapshot.md b/docs/rules/no-wait-for-snapshot.md index 8f35f2ab..65b3683f 100644 --- a/docs/rules/no-wait-for-snapshot.md +++ b/docs/rules/no-wait-for-snapshot.md @@ -1,13 +1,13 @@ -# Ensures no snapshot is generated inside of a `wait` call' (no-wait-for-snapshot) +# Ensures no snapshot is generated inside a `waitFor` call (`testing-library/no-wait-for-snapshot`) Ensure that no calls to `toMatchSnapshot` or `toMatchInlineSnapshot` are made from within a `waitFor` method (or any of the other async utility methods). ## Rule Details The `waitFor()` method runs in a timer loop. So it'll retry every n amount of time. -If a snapshot is generated inside the wait condition, jest will generate one snapshot per loop. +If a snapshot is generated inside the wait condition, jest will generate one snapshot per each loop. -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. +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. 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). diff --git a/docs/rules/prefer-explicit-assert.md b/docs/rules/prefer-explicit-assert.md index 136c3b29..03338517 100644 --- a/docs/rules/prefer-explicit-assert.md +++ b/docs/rules/prefer-explicit-assert.md @@ -1,4 +1,4 @@ -# Suggest using explicit assertions rather than just `getBy*` queries (prefer-explicit-assert) +# Suggest using explicit assertions rather than just `getBy*` queries (`testing-library/prefer-explicit-assert`) Testing Library `getBy*` queries throw an error if the element is not found. Some users like this behavior to use the query itself as an diff --git a/docs/rules/prefer-find-by.md b/docs/rules/prefer-find-by.md index 18b344b6..d85b296f 100644 --- a/docs/rules/prefer-find-by.md +++ b/docs/rules/prefer-find-by.md @@ -1,11 +1,11 @@ -# Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries (prefer-find-by) +# Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries (`testing-library/prefer-find-by`) 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)) ## Rule details -This rule aims to use `findBy*` or `findAllBy*` queries to wait for elements, rather than using `waitFor`, or the deprecated methods `waitForElement` and `wait`. -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 +This rule aims to use `findBy*` or `findAllBy*` queries to wait for elements, rather than using `waitFor`, or the deprecated methods `waitForElement` and `wait`. +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 Examples of **incorrect** code for this rule diff --git a/docs/rules/prefer-presence-queries.md b/docs/rules/prefer-presence-queries.md index f66dff91..05ef773a 100644 --- a/docs/rules/prefer-presence-queries.md +++ b/docs/rules/prefer-presence-queries.md @@ -1,4 +1,4 @@ -# Enforce specific queries when checking element is present or not (prefer-presence-queries) +# Enforce specific queries when checking element is present or not (`testing-library/prefer-presence-queries`) 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: diff --git a/docs/rules/prefer-screen-queries.md b/docs/rules/prefer-screen-queries.md index 79978017..081d7283 100644 --- a/docs/rules/prefer-screen-queries.md +++ b/docs/rules/prefer-screen-queries.md @@ -1,4 +1,4 @@ -# Suggest using screen while using queries (prefer-screen-queries) +# Suggest using `screen` while using queries (`testing-library/prefer-screen-queries`) ## Rule Details diff --git a/docs/rules/prefer-user-event.md b/docs/rules/prefer-user-event.md index a4f539b3..dda1aca0 100644 --- a/docs/rules/prefer-user-event.md +++ b/docs/rules/prefer-user-event.md @@ -1,4 +1,4 @@ -# Use [userEvent](/~https://github.com/testing-library/user-event) over using `fireEvent` for user interactions (prefer-user-event) +# Suggest using `userEvent` library instead of `fireEvent` for simulating user interaction (`testing-library/prefer-user-event`) From [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 ## Further Reading -- [userEvent repository](/~https://github.com/testing-library/user-event) -- [userEvent in the react-testing-library docs](https://testing-library.com/docs/ecosystem-user-event) +- [`user-event` repository](/~https://github.com/testing-library/user-event) +- [`userEvent` in the Testing Library docs](https://testing-library.com/docs/ecosystem-user-event) ## Appendix diff --git a/docs/rules/prefer-wait-for.md b/docs/rules/prefer-wait-for.md index cf607e72..ee82769c 100644 --- a/docs/rules/prefer-wait-for.md +++ b/docs/rules/prefer-wait-for.md @@ -1,4 +1,4 @@ -# Use `waitFor` instead of deprecated wait methods (prefer-wait-for) +# Use `waitFor` instead of deprecated wait methods (`testing-library/prefer-wait-for`) `dom-testing-library` v7 released a new async util called `waitFor` which satisfies the use cases of `wait`, `waitForElement`, and `waitForDomChange` making them deprecated. diff --git a/docs/rules/render-result-naming-convention.md b/docs/rules/render-result-naming-convention.md index ffd6ec8f..f9e2e4fe 100644 --- a/docs/rules/render-result-naming-convention.md +++ b/docs/rules/render-result-naming-convention.md @@ -1,4 +1,4 @@ -# Enforce a valid naming for return value from `render` (render-result-naming-convention) +# Enforce a valid naming for return value from `render` (`testing-library/render-result-naming-convention`) > 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. diff --git a/jest.config.js b/jest.config.js index 2385b99d..a355a05e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -11,9 +11,8 @@ module.exports = { lines: 100, statements: 100, }, - // TODO drop this custom threshold after v4 './lib/node-utils.ts': { - branches: 85, + branches: 90, functions: 90, lines: 90, statements: 90, diff --git a/package.json b/package.json index e98fd824..dfae46ea 100644 --- a/package.json +++ b/package.json @@ -20,23 +20,6 @@ "bugs": { "url": "/~https://github.com/testing-library/eslint-plugin-testing-library/issues" }, - "release": { - "pkgRoot": "dist", - "branches": [ - "+([0-9])?(.{+([0-9]),x}).x", - "main", - "next", - "next-major", - { - "name": "beta", - "prerelease": true - }, - { - "name": "alpha", - "prerelease": true - } - ] - }, "main": "index.js", "scripts": { "build": "tsc",