question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance regression: hasPointerEvents increases click time

See original GitHub issue
  • @testing-library/user-event version: 13.2.1
  • Testing Framework and version: jest@27.0.2
  • DOM Environment: jest-environment-jsdom@26.6.2

Relevant code or config


import userEvent from "@testing-library/user-event";
userEvent.click(await app.findByText("Test"));

What you did:

Clicked an element using @testing-library/user-event

What happened:

Went slower than expected

Problem description:

I upgraded to a newer version of this library that contains the following PR: https://github.com/testing-library/user-event/pull/631

More specifically it contains the following LOC: https://github.com/testing-library/user-event/blob/673c2257ef63f69dd46b9fe2d4bbc3146db1426b/src/utils/misc/hasPointerEvents.ts#L11

If I understand correctly it loops over the tree and using window.getComputedStyle(el) on every one. In our tests this seems to be quite costly depending on what you are clicking and how much you are rendering.

Below is an earlier version of user-event (13.0.0, before the PR had been merged). We do a bunch of clicks and every click clocks in about 10-40ms. The aggregated time for this specific test lands in about 500ms. Screenshot 2021-10-01 at 10 02 34

Below is the version we are using: 13.2.1. As you can see every click has increased and differs a bit of course but around 150-200ms for each click. And it is because of the checking of pointer-events. In my case over a large set of tests it adds minutes. Screenshot 2021-10-01 at 10 05 52

Solution description:

I do not know how to solve this. The pointer-events check is a good check to have but is there a more effecient way to check it?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kentcdoddscommented, Oct 1, 2021

I think we should add a flag as well as a global configuration option which someone could flip on/off manually to make sure things are good and then switch back to have faster tests

0reactions
ph-fritschecommented, Oct 3, 2021

@jesperorb A PR would be great.

https://github.com/testing-library/user-event/blob/673c2257ef63f69dd46b9fe2d4bbc3146db1426b/src/click.ts#L116-L120

The third parameter could be extended to clickOptions & PointerOptions.

interface PointerOptions {
  skipPointerEventsCheck?: boolean
}

PointerOptions should then be used by all our pointer APIs.

For the configuration across multiple calls: This should be handled when resolving #714 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Towards Continuous Performance Regression Testing
Pause times are worse, directly impacting the application's latency, and the largely increased GC volume means the production environment will ...
Read more >
ionic-v1.x - Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Regression Testing of Performance - Alexandr Gubarev
Time is money. And sometimes bugs related to application hangs and performance degradations dissatisfy customers and businesses lose money.
Read more >
3 Ways to Improve Your Regression - YouTube
Linear regression plays a big part in the everyday life of a data analyst, but the results aren't always satisfactory.
Read more >
Performance-Regression Pitfalls Every Project Should Avoid
With proper planning and execution, continuous performance-regression testing can be a powerful tool for hardware and software projects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found