-
Notifications
You must be signed in to change notification settings - Fork 718
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
docs: add query ByRole performance notes #1349
docs: add query ByRole performance notes #1349
Conversation
✅ Deploy Preview for testing-library ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -462,3 +462,20 @@ You can query a specific element like this | |||
```js | |||
getByRole('alertdialog', {description: 'Your session is about to expire'}) | |||
``` | |||
|
|||
## Performance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, but I'd like to keep it open for second reviewer.
One additional comment we might encourage is to use happy-dom as that should be faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'd be happy to add a note about happy-dom as I agree it is likely the best option if it works for people (I've seen some users report it isn't a viable option for them yet).
What do we think about adding something like this?
"Firstly, if you are using jsdom we'd encourage trying happy-dom as it is much more efficient. If this works for you it is your best option, improving performance while keeping test confidence.
Otherwise the suggestions below may help."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it like this for now, as this will likely break something.
We can always revisit it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my research, happy-dom
is faster but lacks the fetureset of JSDOM
, and that is reason folks often revert back to JSDOM
after attempting a migration.
@all-contributors please add @agentdylan for docs |
I've put up a pull request to add @agentdylan! 🎉 |
Adds notes about performance of *ByRole queries to the Queries > ByRole page.
getByRole
and the likes are known to be slow at times and documentation has been requested123 to help make this more visible.This has been known for several years1 and performance remains a concern4 so I believe it is worthwhile adding to the docs.
I think it's important to have a balance of conveying the importance of
getByRole
while still sharing this information about the performance so users can make an informed decision if performance is a problem.This relates to issues
These issues have great discussion around this topic, which I've attempted to consolidate.
Footnotes
https://github.com/testing-library/dom-testing-library/issues/820#issuecomment-726812393 ↩ ↩2
https://github.com/testing-library/dom-testing-library/issues/820#issuecomment-726980009 ↩
https://github.com/testing-library/dom-testing-library/issues/820#issuecomment-726994803 ↩
https://github.com/testing-library/dom-testing-library/issues/698 ↩