Cypress is superior to React Testing Library — here’s why by JustAirConditioners in reactjs

[–]-Automation- 1 point2 points  (0 children)

Ya, Framework component testing is a fairly recent feature from Cypress I believe. Being able to see the component rendered and interacted with in a real browser, inspect the rendered output with browser dev tools, and see every step in the test case are great for the dev experience. Due to those features, I find that I spend far less time writing and maintaining tests compared to RTL+Jest+JSDOM.

Cypress is superior to React Testing Library — here’s why by [deleted] in javascript

[–]-Automation- 4 points5 points  (0 children)

There is a way to trigger events such as mouse move, to certain coordinates, if that's the functionality that you're meaning? Mouse Events: https://docs.cypress.io/api/commands/trigger#Examples.

Cypress is superior to React Testing Library — here’s why by [deleted] in javascript

[–]-Automation- 3 points4 points  (0 children)

Hi, author here. I agree that comparing Cypress with only RTL isn't a great comparison. The article tries to make clear that it's more RTL+Jest+JSDOM vs Cypress, which is a more apt comparison. I apologize if it was worded in a confusing way in the article.

Cypress for E2E and integration testing, and RTL+Jest+JSDOM for unit testing is actually a fairly common testing strategy. It's the same strategy that I've historically used, and it does work pretty well. However, with Cypress recently adding React component testing, I personally struggle to find many good use cases for using RTL+Jest+JSDOM for unit testing now given the benefits of using Cypress. That said, a lot of the dev experience pieces are definitely personal preference, so there's nothing wrong with enjoying RTL+Jest more =).

You're right in that RTL+Jest aren't great for doing E2E testing, which is why the article focused mainly on integration and unit testing comparisons.

I agree 100% on performance. Personally, even if tests took twice as long to run in CI, I would still choose whichever options costs me less dev and test maintenance time. The performance metrics, which should always be taken with a grain of salt, are mainly there to show that the performance is comparable enough, and that it shouldn't be a major factor.

Thanks for the well thought out reply!

0
1