When comparing Jest vs Cypress, the Slant community recommends Jest for most people. In the question“What are the best JavaScript unit testing frameworks?” Jest is ranked 2nd while Cypress is ranked 4th. The most important reason people chose Jest is:
One of Jest's philosophies is to provide an integrated “zero-configuration” experience. Eg: it provides assertion library by default.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Easy to use
One of Jest's philosophies is to provide an integrated “zero-configuration” experience.
Eg: it provides assertion library by default.
Pro Well documented
Pro Recommended for React testing
Jest is the recommended unit testing framework by Facebook. It's also the one used by Facebook developers when working with React projects.
Pro Snapshot testing is convinient
It's great for testing UI.
It is also convenient for asserting complex data objects, as it doesn't require developers to manually compose the expected value.
Pro Web UI to develop tests quickly
You can edit your test code in the browser and instantly see it run as you change the code.
Pro Easy to record a video
It can easily record a video so you can understand what happened when a test failed in your CI.
Pro Amazing dashboard to view reports and recordings
The Cypress dashboard allows you to see every run on a great UI linked to commits and gitflow.
Pro Cross Browser testing
https://docs.cypress.io/guides/guides/cross-browser-testing.html
Chrome
Firefox
Edge
Electron
Brave
Cons
Con Not beginner-friendly
If you're new to unit testing and are trying to understand unit testing within the React ecosystem, specifically ReactNative, it is going to be a challenge. The Jest doc dives right into making tests without any primer on how to go from concept to implementation.
Con Doesn't support Safari
Con Single tab only
Does not and will not support multiple tabs or multiple simultaneous browsers.
See https://docs.cypress.io/guides/references/trade-offs.html#Permanent-trade-offs-1
Con Heavy in setup
Do not add Cypress in the main repo. Have a specific test repo for it or you will be sorry when the CI/CD flow takes 5-6 min longer every build due to installation time of Cypress.
