web analytics
end to end testing

Whenever an application flow is tested from start to finish, it is known as end to end testing. It ensures that the application works the same as the user wants and that there is no bug present. End-to-end testing ensures that there is no break in any part of the application that current or new users cannot access. 

Why Cypress? 

Cypress is easy to use as compared to other tools like TestCafe, Selenium, and Puppeteer. Cypress is a widely used tool, which means that solution to the problems that occur in Cypress is available easily. The syntax used in Cypress is easy to learn and use. The other features of cypress are:

  1. Time travel.
  2. Debuggability.
  3. Automatic waits.
  4. Consistent results.
  5. Web & API testing.
  6. Screenshots & and videos.
  7. Cross-browser testing – locally or remotely.

Setting up or Installing the cypress.

The first step is the installation of JavaScript, as Cypress only supports JavaScript. To install, search node js on Google click on the first link, and download and install the latest version as per your OS. 

1

After installing NodeJS, check whether the path in environment variables is present or not. 

2

Now install Visual Studio code and install it. Choose OS according to your system. 

software testing

Create a folder in your system and open that folder in Visual Studio Code by right-clicking 

4

Open the terminal in VS code by clicking Terminal>New Terminal and run the command npm -I init to create a package.json file. As you can see after running the command, the terminal will look like image 1. Now just press enter until you get the image 2. Type YES and press enter. We are creating the package file to install any plugin in the future. 

5

Now we have to install cypress on the same folder we have created by entering the command npm install cypress    –save-dev. After running the command, the window will look like image 3. 

6

Open the cypress by using the command npx cypress open in the same Terminal. The Cypress window will open. Choose End-to-End(E2E) testing, click on continue, and choose the browser in which you want to test. 

7

After selecting the browser, click on Create New Spec give a name to the file, and click on Create Spec button.

software testing

Creating test cases 

To create test cases, go to the VS code click on the test file you have created, and write the code.

9

In the above picture, three test cases have been written: – 

First test: visiting the site ‘https://qacraft.com/ 

10

Second test: Verifying the title for a positive case. In this test case, the title of the website should be equal to India’s Best Software Testing Services Provider – QACraft.

11

Third test: Verifying the title for negative case. In this test case, the title should not be matched and the test case should fail and give an assertion error. 

12

Now open the cypress and run the test file test.cy.js by clicking on it. As you can see in the below image, the first two test cases are passed but the third test case failed because of the wrong assertion we had provided. 

13

Limitations of cypress: 
  1. Can’t automate Windows-based / mobile apps.
  2. Limited support of browsers.
  3. Only support two languages JavaScript and TypeScript.
  4. Reading/writing data into files is difficult.
  5. For the best report format, we must use dashboard features that are paid. Any other third-party report feature can’t be used.

 Conclusion 

Cypress can be a great tool to test web-based applications. And who want to create test cases in an easy way and want consistent results. The debugging and analyzing of test cases through screenshots and videos is very easy. However, the limitations of cypress make it unsuitable for most of the projects. 

Related Post

Leave a Comment