Skip to content

Performance concern with jsdom and getByRole #390

Closed
@oliviertassinari

Description

@oliviertassinari
  • DOM Testing Library version: 6.8.1
  • node version: v12.6.0

I apologize in advance for not following the issue template; I'm not sure it serves performance discussion well.

We are in the progress of migrating the test suite of Material-UI from enzyme shallow + mount API to testing-library. However, we have hit a roadblock (we should consider what we do with this block, do we force our way in, move around it, etc?). While the test suite takes about 14s to run on v3, it now takes about 70s (on my machine). It's a x5 increase. Diving more into the issue, I could identify this problem:

Capture d’écran 2019-10-22 à 01 18 17

Once we aggregate all the data, we realize that we indeed spend most of our time in this function:

Capture d’écran 2019-10-22 à 01 26 21

So it seems that the numerous calls to window.getComputedStyle() are using +65% of the available CPU resources. If we run the same tests in a chrome headless, the performance are much better, about 20s instead of 70s.

So my question is, do we have a viable workaround? In the case of Material-UI, we have migrated about 28% of our tests. If I extrapolate, once we hit 100%, our unit tests will take about 4 minutes (to be compared with ~14s in v3). Should we do something about it? If yes, what options do we have? Thank you!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions