-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is your average running time for React Testing Library tests? #819
Comments
JSDOM can be fairly slow, and some parts of testing library can be slow, but it's hard to tell without seeing the test. Could you post code for testing library and Cypress in comparison? |
I'll add to what @nickmccurdy said by saying that you might consider using https://github.com/bahmutov/cypress-react-unit-test + https://github.com/testing-library/cypress-testing-library and you'll get basically the same experience just running in a real browser. Hard to tell whether it'll be faster though. The overhead of loading a real browser and the challenge of running in parallel is pretty significant. |
Stick console.times throughout your test suite and you can get an idea of which are the slow parts. I've found Make sure you are using fake timers and not waiting for any realtime timers. Also if using jest and running suites in parallel, I've found setting the max workers to 50% knocked 20% of our test suite run time, that could depend on the hardware you are using though and wouldn't affect running a single suite. |
Perhaps you could try disabling the isInaccessible checks on local environments and only running it on CI. Unsure how much that would help though. If there is a specific component that takes too long to render and it is unrelated to your test, you could try mocking that. As long as it is tested somewhere else the tradeoff might be worth it. |
You might want to check the comments in this thread: |
Closing in favor of #820 where we discuss performance of |
@lpaulger It's this issue 820 (for dom-testing-library). @dougbacelar had linked it earlier, but when the issue was referenced in a subsequent comment by number it was linked to an issue in this repo. |
We have just started using React Testing Library. The biggest issue that we are facing right now is the test takes very long to run. One simple integration test (testing the behavior of several components on a container) takes about 80s to 100s. The test running speed is equal or worse than our Cypress tests now.
What are the recommended ways to troubleshoot the running speed of the react testing library?
Also, what are the main culprits of slowness? Could it be component re-rendering issues?
What are your average test running speed?
The text was updated successfully, but these errors were encountered: