ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library
MIT License
Bot releases are hidden (Show)
Published by Belco90 over 4 years ago
Published by Belco90 over 4 years ago
Published by Belco90 over 4 years ago
await-async-utils
: reflect waitFor changes (#89)no-wait-for-empty-callback
(#94)prefer-wait-for
(#88)prefer-screen-queries
(#99)prefer-presence-queries
(#98)This new rule is fixable so it can help you migrating deprecated wait
, waitForElement
and waitForDomChange
to new waitFor
method.
From this:
import { render, wait, waitForElement, waitForDomChange } from '@testing-library/dom';
async () => {
render(<SomeComponent />);
await wait();
await wait(() => expect(screen.getByText('submit')).not.toBeInTheDocument());
await waitForElement(() => {});
await waitForDomChange();
await waitForDomChange({ timeout: 100 });
};
to this:
import { render, waitFor } from '@testing-library/dom';
async () => {
render(<SomeComponent />);
// `wait` without callback is replaced with `waitFor` with empty callback
await waitFor(() => {});
// `wait` with some callback is replaced with `waitFor` keeping same callback
await waitFor(() => expect(screen.getByText('submit')).not.toBeInTheDocument());
// same for `waitForElement`
await waitFor(() => {});
// same for `waitForDomChange`
await waitFor(() => {});
// `waitForDomChange` options are passed as 2nd arg to `waitFor`
await waitFor(() => {}, { timeout: 100 });
};
no-get-by-for-checking-element-not-present
removed in favor of new rule prefer-presence-queries
(#98)Published by Belco90 over 4 years ago