简体   繁体   中英

Integration test with Cypress or React Testing Library?

I'm new to testing and as I understand, integration tests are aimed to test a bunch of components and how they interact with each other.

But if in a project we use both Cypress for E2E and React testing library for unit testing, which one to use for integration tests, and what are the pros and cons?

I would recommend using React testing library (RTL) since integration testing is more granular and does not require the entire application to run.

The main benefit of Cypress is that it tests against real browsers which makes it great for ensuring your E2E flows work as intended. While Cypress is fast, it has to do a lot of additional work compared to RTL. I do think Cypress is best for just E2E testing, specifically the high value paths in your application.

Cypress recently introduced component testing, https://docs.cypress.io/guides/component-testing/introduction

Running test in the browser environment makes it easier to understand what's going on within the test thanks to visual feedback from the browser.

Such approach also allows to tests things like drag and drop, which is difficult to achieve with JSDom.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM