Skip to content

docs: Add more info about slow tests in the FE #6584

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

Merged
merged 1 commit into from
Mar 14, 2023

Conversation

BrunoQuaresma
Copy link
Collaborator

Screen Shot 2023-03-13 at 13 55 38

@BrunoQuaresma BrunoQuaresma requested review from rodrimaia, Kira-Pilot and a team March 13, 2023 17:03
@BrunoQuaresma BrunoQuaresma self-assigned this Mar 13, 2023
@BrunoQuaresma BrunoQuaresma enabled auto-merge (squash) March 14, 2023 13:46
```tsx
const form = screen.getByTestId("form")
user.click(within(form).getByRole("button"))
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit surprised to see this section in our README instead of in our wiki; however, I'm not opposed to having it here. I'm curious how this section would scale - I imagine there are all sorts of testing strategies and pitfalls we could elaborate on; which ones will we deem important enough to stick in our README? Should we eventually have an externally-facing wiki? Should we just link to a list of SO articles and Kent C Dodd's blogs we find insightful? Just some food for thought. I really appreciate the clarity of the writeup!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to have things on docs as markdown so it is also added to the website docs improving SEO as a side effect.

- https://stackoverflow.com/questions/69711888/react-testing-library-getbyrole-is-performing-extremely-slowly
- https://github.com/testing-library/dom-testing-library/issues/552#issuecomment-625172052

Even with `ByRole` having performance issues we still want to use it but for that, we have to scope the "querying" area by using the `within` command. So instead of using `screen.getByRole("button")` directly we could do `within(form).getByRole("button")`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Even with `ByRole` having performance issues we still want to use it but for that, we have to scope the "querying" area by using the `within` command. So instead of using `screen.getByRole("button")` directly we could do `within(form).getByRole("button")`.
Despite its performance issues, `ByRole` is still a valuable selector. When using it, we should scope the "querying" area by using the `within` command. So instead of using `screen.getByRole("button")` directly we could do `within(form).getByRole("button")`.

@BrunoQuaresma BrunoQuaresma merged commit e376849 into main Mar 14, 2023
@BrunoQuaresma BrunoQuaresma deleted the bq/add-test-info-docs branch March 14, 2023 13:54
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants