Any post on testing libraries will be incomplete without Mike Cohn’s Test Pyramid diagram, so here it is:
Image source: https://martinfowler.com/bliki/TestPyramid.html
We need more unit tests, lesser integration tests, and even lesser end-to-end tests, why? as it costs time and money to write more integration and end-to-end tests. Also, unit tests are faster compared to other test siblings. And not to mention, no one wants to wait for hours for the CI-CD pipeline execution.
Before, we dive deep in, here is the image that nicely illustrates the testing libraries per test tool abilities like test framework, assertion, test runner, mocking, code coverage (from left to right).
Jest is one of the libraries that provide various capabilities, which is shown in the above comparison. Jest (4 million weekly downloads) is a powerful tool for writing unit tests for pure functions. However, for more complex scenarios, especially when working with React apps, React Testing Library (1 million weekly downloads) is an excellent choice.
React Testing Library is built on top of DOM Testing Library, which helps writing tests using selectors. In places where you can’t use the React Testing Library, Enzyme library can rescue you (though Enzyme is the competitor).
So, with the help of Jest, React Testing Library, and Enzyme, one can pretty much cover any unit and integration test case scenarios. So, what about end-to-end testing? Well! Cypress library is the best of the best choice.
Awesome documentation, ease of implementation, less learning curve, I can’t even think of Selenium or any other library. Cypress has a nice interface where one can see the test execution with minimal test writing effort.
So, with this are we done? of course not, with the growing popularity of microservice architecture, contract testing is an essential part of it. And Pact is the consumer-driven contract testing library that provides assurance that consumer application or provider service can be deployed to production without breaking each other’s trust or in other terms the contract.
If you have reached here, then I did a satisfactory effort to keep you reading. Please be kind to leave any comment or ask for any correction. Happy Coding!