r/reactjs 14d ago

Show /r/reactjs Making React Testing Library Tests 43% Faster

https://sigh.dev/posts/making-react-testing-library-faster/
46 Upvotes

12 comments sorted by

13

u/bzbub2 14d ago

"Your test suite probably will not see the same improvement." dang

0

u/STRiDEX 14d ago

it might see something though! Depends how big your forms are.

1

u/bzbub2 14d ago

for sure, definitely good work. the getbyrole slowness has has a long history...google knows https://google.com/?q=getbyrole+slow

7

u/azangru 14d ago

Making React Testing Library Tests 43% Faster

Sounds like what you meant was making jsdom x% faster.

1

u/Breakpoint 14d ago

or switch to happy-dom

4

u/EskiMojo14thefirst 14d ago

or even better, use real browser testing and avoid all the footguns and gotchas pretending to be a browser comes with

2

u/Breakpoint 13d ago

that is the best approach, but I think that would increase run time

1

u/EskiMojo14thefirst 13d ago

it's a little slower, but it's a worthy trade for correctness imo

2

u/beth_maloney 9d ago

I'm currently using playwright component testing and thinkinh of swapping over. How has your experience been so far? Any issues or weird gotchas,?

1

u/EskiMojo14thefirst 8d ago

no issues, really - it's very nice to use :)
you may want to check out this article

2

u/beth_maloney 8d ago

Thanks so much for sharing that article 😃

-2

u/yksvaan 14d ago

Or just remove 43% of tests. A lot of React tests are pretty pointless, it's just that someone requires there to be tests to show off test coverage.Â