After getting to know and using Selenium, that famous and practical automating tool we love so much, it’s easy to believe that no better option exists. Well, at least that’s what I thought for a long time, always suggesting Selenium when it came to new projects. Undoubtedly, it is an excellent tool for test automation.
However, a few months back, I started hearing the word ‘Cypress’ more and more often in the quality assurance field. Although I already knew of its existence, I didn’t give it much importance until I saw that job interviews and job posts related to automation began requesting Cypress knowledge. After learning a bit more about the tool and working with it for a while, I now know why Cypress is increasingly required.
What is Cypress?
Cypress is a test automation framework with an architecture that’s different from the usual. Its ‘built-in tools’ is an all-in-one framework that includes all the necessary tools to start automating immediately.
Cypress has a lot of advantages/tools that really help with test automation, such as:
Time Travel: Cypress takes snapshots while tests are running. This way, we can easily identify what’s happening with our tests simply by moving the mouse across the command log.
Test Runner: Cypress uses an interactive ‘runner’ to run tests. This allows us to see the commands that are being executed while viewing the application that’s being tested.
Dashboard: This service gives us access to all tests performed. For example, in our continuous integration (CI) tool, Dashboard provides information about what happened during the tests by taking screenshots and recording videos of failed tests. Additionally, it allows us to organize our Cypress project from a single place, providing integration with other tools such as Github and Slack.
Headless: This Cypress functionality allows us to run tests in the background, hiding the browser.
The following are some of the main advantages of using Cypress:
- It’s easy to install and easy to start automating. Cypress has several built-in tools that allow us to begin automating immediately after installation.
- It registers all actions for better debugging of test cases.
- It takes screenshots and records videos. Dashboard provides lots of advantages for generating concrete and reliable reports of our test cases.
- Complete documentation with examples on the official website.
Cypress has a lot of advantages in comparison to other automation tools, but it also has some disadvantages that should be taken into consideration for a clear perspective of the tool. Among these we find:
- Cypress only allows interaction with a single tab of the application under testing (AUT) and this will not change. Given its architecture and how Cypress runs on the browser, there are ways to mitigate this situation.
- It’s not possible to do a ‘mouseover’ with Cypress. Currently, there’s a pending ticket regarding this matter that will surely be dealt with in future versions.
- Cypress is free! But the Dashboard service has certain restrictions. For 5 users or more, the cost is $100 per month, and the fee increases depending on the number of users.
- Although usable, the ‘Page Object Model’ pattern is not recommended by Cypress developers. From my perspective, this has to do with the way synchronicity/asynchronicity is used. This is a topic that could be discussed in more depth, but there’s no need for concern! It’s just a matter of having a little knowledge of the programming language and the way synchronicity is handled, then we’ll be able to keep using our favorite automation pattern.
I highly recommend learning to use Cypress due to the automation tool market evolution and because of how fun and quick it is to automate tests using this framework.