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

feat: add flag to skip pointer-events check #731

Merged
merged 4 commits into from
Oct 10, 2021
Merged

feat: add flag to skip pointer-events check #731

merged 4 commits into from
Oct 10, 2021

Conversation

jesperorb
Copy link
Contributor

@jesperorb jesperorb commented Oct 3, 2021

What:

This PR adds a new flag called skipPointerEventsCheck which makes it possible to skip checking for pointer-events: "none" when using different user events like click or dblclick.

This PR does not add a global config flag as per discussion in: #729

Why:

As per discussion in: #729

Adding the check for hasPointerEvents increase the time to execute each click and hover or anything that relies on pointer-events. The increased time for each click can be quite drastic depending on how large of a DOM-tree you are rendering in your tests as it checks if any parent has the property set.

Making it optional can speed up tests. If you for example know that the property is not set in the code your are testing. Or if you want to disable it momentarily when developing and the run it later on in the CI.

How:

Adding a common interface for pointer events that has the property skipPointerEventsCheck and using this flag anywhere the check hasPointerEvents is being used.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

Feedback and questions

  • What counts as Documentation in the checklist?

Add a flag to skip the check for pointer-events set to none.

The check is costly to check and this flag makes it possible to skip it.
@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 3, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f733425:

Sandbox Source
userEvent-PR-template Configuration

@codecov
Copy link

codecov bot commented Oct 3, 2021

Codecov Report

Merging #731 (f733425) into main (a4943d5) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #731   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           50        50           
  Lines          946       958   +12     
  Branches       371       385   +14     
=========================================
+ Hits           946       958   +12     
Impacted Files Coverage Δ
src/utils/misc/hasPointerEvents.ts 100.00% <ø> (ø)
src/click.ts 100.00% <100.00%> (ø)
src/hover.ts 100.00% <100.00%> (ø)
src/select-options.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4943d5...f733425. Read the comment docs.

src/click.ts Outdated Show resolved Hide resolved
@ph-fritsche
Copy link
Member

ph-fritsche commented Oct 7, 2021

@jesperorb Would you be so kind to file a PR documenting this flag in https://github.com/testing-library/testing-library-docs/blob/main/docs/ecosystem-user-event.mdx ?

@ph-fritsche ph-fritsche linked an issue Oct 7, 2021 that may be closed by this pull request
@jesperorb
Copy link
Contributor Author

@jesperorb Would you be so kind to file a PR documenting this flag in https://github.com/testing-library/testing-library-docs/blob/main/docs/ecosystem-user-event.mdx ?

@ph-fritsche Yes, will do 👍🏽

@ph-fritsche ph-fritsche merged commit 26b7d0b into testing-library:main Oct 10, 2021
@github-actions
Copy link

🎉 This PR is included in version 13.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ph-fritsche
Copy link
Member

@all-contributors add @jesperorb code

@allcontributors
Copy link
Contributor

@ph-fritsche

I've put up a pull request to add @jesperorb! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance regression: hasPointerEvents increases click time
2 participants