Performance issues #1144
Unanswered
alexkuchun
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Greetings community,
We're using
user-event
library extensively for our project. Recently, in one of new tests, I've noticed that it often overcomes the default Jest timeout limit of 5s per test. After investigating for a while, I've discovered that the performance decrease was unfortunately caused by using userEvent instead of fireEvent. An example: a simple test with 3 navigation menu button clicks takes 3603 ms withawait userEvent.click()
and only 724 ms withfireEvent.click()
, even though I've setuserEvent
with the fake timers and reduced adelay
tonull
(with real timers the results were almost twice as worse). Another test with just 2 clicks (toggle switching) runs 3260ms onuserEvent
vs 856 onfireEvent
. Locally it's still under the 5s limit, however within the CI pipeline the duration increases.I've also had a look at the other tests we have and tried measuring it there. The difference is still there, but is not as dramatic - ex. x2 with 2 clicks.
I understand that
userEvent
is obviously more complex, however I still find the performance difference quite odd (even after looking at this thread). Are there any other settings which might help to increase the performance? Or perhaps there are any less obvious external factors which might play part (ex. onHover styles changes)? Or is it expected that the userEvent performance gradually decreases inversely to the overall components size/logics?Beta Was this translation helpful? Give feedback.
All reactions