Replies: 1 comment 2 replies
-
Hi @jwm01cg! 👋 One way to get some more information on what is expensive is to run a profiler on the tests to see where it spends most time. It is possible to start the debug tool in Chrome dev tools and run the profiler from there. Looking at the test in the example, I believe that You have some options:
Happy DOM should probably look into what exactly Testing Library is doing that takes time and optimize it. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! I'm looking at happy-dom as a replacement for jsdom for unit testing my React app with @testing-library/react and vitest. I've managed to integrate it and get some of my tests to start passing.
However, I've noticed so far that the tests are significantly slower when running with happy-dom. One particular test file that took 2m42s to run under jsdom now takes 15m6s with happy-dom. This is confusing to me as all I have read online suggests that happy-dom is more lightweight than jsdom and focuses more on performance.
I am relying heavily on byRole queries which can apparently be problematic according to this discussion in the testing-library repository. However, my app has fairly strict accessibility requirements so I'm not sure I'd really want to start ripping those out in favour of
byText
.I did notice in a small test app with vitest and happy-dom that happy-dom takes the lead there, so maybe it is something to do with my app. Which leads me to my main question: is there any data I can collect to work out what is taking so long during my tests? Perhaps also there is some common wisdom about patterns that tend to slow down happy-dom?
Beta Was this translation helpful? Give feedback.
All reactions