Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use best practices in our test suites #635

Open
chanceaclark opened this issue Oct 13, 2021 · 0 comments
Open

Use best practices in our test suites #635

chanceaclark opened this issue Oct 13, 2021 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@chanceaclark
Copy link
Contributor

Is your feature request related to a problem? Please describe.
There's a few best practices we have been shirking on. First of all we should be using the screen.*By queries rather than using the const { findBy* } = render() to get elements and whatnot. We also shouldn't be using container to search for elements*. We should go through our test suites and clean up some of these inefficiencies.

*some conditions may apply

Describe the solution, feature, or improvement you'd like
Pulling some common mistakes we initially made from Kent C. Dodds article.

// From this
const { container, getByText } = render(<Table {...} />);

const rows = container.querySelectorAll('tbody > tr');
const nextPageButton = getByText('Next page');
// ...

// To this
render(<Table {...} />);

const rows = await screen.findAllByRole('row');
const nextPageButton = screen.getByRole('button', { name: /next page/i });
// ....

Describe alternatives you've considered
N/A

Additional context
N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Development

No branches or pull requests

1 participant