8. 12. 2023

Automatic testing of web applications using Cypress

The complexity of web applications increases over time, and with it the risk of possible errors. Especially with long-term projects, which are gradually evolving, we may find that something that once worked will suddenly stop working for us. It’s definitely a good idea to have apps covered in & nbsp; UNIT tests that give us some success and can test specific functionalities of the app. However, for some things, UNIT tests are also short, especially when it comes to the frontend – and & nbsp; Cypress , which allows & nbsp; end to end testing (integration tests) , will help us with that.

For many years, Selenium has been here with us & nbsp; However, its use is no longer pleasant and fully sufficient. Cypress, on the other hand, has taken everything to a new level and, unlike other competing tools, does not use Selenium as its core, but was created completely “on a green field”. This allows you to go your own way and offer a sophisticated UI and test writing.

In this introductory article, we’ll show you how to install and run cypress. In the next chapters of this series, we will look at the actual writing of tests and show how to use Cypress practically in our web application so that it is a great help to us.

Install Cypress using npm

There are several ways to install Cypress. Since I’m a fronted player and use npm to manage packages on almost every project, I’ll go this way. & Nbsp; Install Cypress & nbsp; we can simply use the following command in the console (similarly, we can install Cypress using Yarn).

This will install Cypress locally for our project and we can use it happily. Now all we have to do is run it and enjoy it to the fullest. The easiest way is to run it directly with the following command:

After running this command, a beautiful UI will run with an overview of tests that we can run. After selecting the test we want to run, the test will run in the Electron browser, which is built on Chromium. & Nbsp; What pleasantly surprised me is the smoothness and speed of the environment, which works really well.

We’ll talk about how to write your own tests in the next article in this series.


Leave a Reply

Your email address will not be published. Required fields are marked *