Exploring Cypress: how we tested the testing framework
Tags: testing, cypress, framework
Published: 2020-03-25 16:52:47

<i>Our QA Engineer Mikhail Levashov talks about what Cypress is, what are the features of this framework, and also about the February update.</i>

Today we’ll discuss Cypress automated testing platform, which we met last October. While we continue to discover its functionality we still want to share our first experience with this framework. And at the same time praise the February update, which expanded the capabilities of cross-browser testing.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cn8mu2ta720ccpne32qr.png)

Sometimes people pay attention to Cypress since there is no tester on their project and they want to transfer all its functions to this platform. We took a different path and handed the “new toy” to the testers themselves, stepped aside and looked at what would happen.

<b>What do we think now?</b> Cypress provides really interesting technical solutions. The developers were able to optimize many routine processes, so they accelerated testing and made it enjoyable, without unnecessary fatigue. Also, the framework has wide functionality, a low entry threshold, and intuitive accessibility.

Cypress is a very promising platform that is being actively developed. We think that in the near future, the number of IT companies around the world using Cypress will only grow. So, we wanted to be proactive and explore it as soon as possible! 

<h1>What does Cypress offer?</h1>

Cypress.io is a multifunctional platform for automatic testing of web interfaces, which provides effective tools for writing tests of any complexity - from small modular (unit) to end-to-end (e2e). Any components and the process of their interaction can be tracked in detail, having previously described the scenario.

The advantage of this environment is comprehensive documentation. This is one of the most important arguments for Cypress - if you wish, you can start to learn this framework from scratch, even if you have no automation experience.

The intuitive interface of the application allows you to start launching the first unit tests right out of the box. Cypress is an independent all-in-one framework. Unlike Selenium, a regular connection of libraries and modules is not necessary in this case; it greatly simplifies the work and saves time, allowing you to start testing without any troubles.

After installing and running Cypress, we immediately see code examples with relevant commands (cypress / integration / examples), where the main functions are clearly implemented. To connect your integration tests, you only need to place the files in the appropriate directory.

The structure of tests within Cypress is an algorithm consisting of sequential commands interconnected by the logic described by us. A convenient step-by-step scenario is achieved due to the possibility of accessing any element in the DOM. The principle is based on the identification of an element or group by a common or special name / selector / property and many other parameters, depending on the scenario. This feature allows you to specify the process of navigation and access to the selected component without any difficulties.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zhqcss79w06qoy8ju5hr.gif)

The Cypress platform has an embedded browser (Google Chrome, Firefox) to run tests. It integrates seamlessly into any project and can control traffic. As a result, we have free space for creativity and a powerful tool for teamwork, in which everything is at hand.

<h1>What did we get in February?</h1>

And now let's pay attention to the feedback of our testers. According to them, the long-awaited February update of the platform expanded the capabilities of cross-browser testing, the implementation of which worried the community for a long time. Cypress developers say this time the team is focused on one of the most anticipated releases - adding new runtimes.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/r6jhwvexoi9nqvaa4bkl.png)

In the latest patch, we get support for Firefox and Edge and the ability to set tests space, order and priority of execution, depending on the selected browser. The developers pampered us with new optimization solutions that are worth it to pay attention to them.

Now we can define scripts for running tests in a strictly defined environment using shortcuts, and access them using a special flag. The framework itself determines the browsers available in the system and provides the ability to work with them immediately after installation.

It is also noteworthy that in a situation where there is no need to test everything written in one environment, we always have the opportunity to assign their place to each conditional scenario. The general array of tests can be divided into subsets by writing the dependencies of browser execution in scripts. The described tool allows us to easily optimize the time costs and rationally distribute the load in the testing process. The variability of use is impressive.

The function of skipping / ignoring tests in the context was added: the tool allows you to minimize costs over distances, leaving only the necessary tests in the session. From now on, we can focus on the actual and not waste time checking the extra context. For example, if it is necessary, we can turn to small unit tests, bypassing multi-level end-to-end tests. An important feature is that <b>skip</b> and <b>ignore</b> are not identical and have different mechanics. The first function does not exclude the tests indicated in itself from the final reporting but makes the browser bypass their execution. Ignoring works differently because it completely deactivates the script and excluding it from test reports.

Test scenarios can now be started, previously distributed into groups, and run in parallel on different computers (tests are compiled by the specified browser). This function is universal because it allows you to distribute a given amount of CI resources for the browser. The advantage of the parallelization method is the variability of test execution. Now we can minimize the cost of CI, or vice versa, increase the duration of testing.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/o76oslg97879yvh99wfs.png)

<h1>Summary</h1>

Cypress.io is a great example of the fact that truly complex and multifunctional platforms consist of many simple and affordable tools. It is equipped with everything necessary, the documentation allows you to find all the information if you wish, and the ability to perceive it is already dictated by the skills and knowledge of a particular specialist. We will definitely continue to explore it: firstly, it is convenient and efficient, and secondly, this is a plus for customers, because we own technologies, the popularity of which is growing.