Cypress and It’s Features

Anshita Bhasin
4 min readOct 5, 2022

--

Cypress is a nodeJS-based test automation testing tool that is built basically on top of Mocha JS. One can automate the front end (web) and back end (API)both with cypress. Cypress has some super amazing features which make it a favorite choice of QA and Dev when it comes to automation these days.

Below are some of the advantages which make it unique from other leading automation tools in the market:

  1. Easy Installation. (Just 1 line, npm install cypress --save-dev)
  2. No extra dependency is required for opening browsers like chrome and firefox. We just have to mention in the package.json about the browser name.

Example: npx cypress run -e — e2e — browser chrome

3. Easy Debug: It captures snapshots at the time of test execution. This allows QAs or developers to hover over a specific command in the Command Log to see exactly what happened at that particular step.

No need to go to logs and check the error when one can view it on the browser with each action as highlighted.

4. In-built waits ( By default, cypress has amazing support for the waits). One doesn’t need to add explicit or implicit wait commands in test scripts. We can configure the timeout as per our requirement in cypress.config.js if we want.

5. Fast test execution, as It runs inside the browser which makes the execution super fast.

6. Reloading on every change in the script. Cypress reloads your test case whenever you make any changes to your script. You do not need to execute it explicitly. It is handled by default in cypress.

7. Retry Code. By default, cypress has an in-built retry logic configured. We just have to change the configuration as per our requirement in cypress.config.js.

Cypress will retry tests up to ‘n’ additional times (for a total of n+1 attempts) before potentially being marked as a failed test.

n= number of retries you have provided in cypress.config.js

8. Test Status: One can view it on Test Status Menu about how many tests failed and passed and how long they took to execute.

9. ViewPort Sizing. One can check the responsiveness layout by changing the viewport.

10. By default, cypress comes with a common base class (Command.js) in which we can write the common functions and use them in our framework using the syntax “cy.commandName()”.

11. Folder Structure: Cypress provides the basic folder structure with respect to the automation framework.

Test Data: There is a folder named “fixtures” in which you can add your test data files like “test.json”.

e2e/Integration: You can add your test cases here.

support/command.js: You can add your common methods in this class.

cypress.config.js: You can configure base URL and configurations like timeouts, retry count here.

12. We do not need to create a property file or class for storing the data like URL. By default, Cypress has cypress.config.js in which you can add common configurations like baseUrl, timeouts, retries, etc.

13. Great support for Assertions.

Example:

cy.get(locator).should(‘be.visible’)

cy.get(locator).should(‘be.enabled’)

cy.get(locator).should(‘have.value’)

14. Amazing Documentation. Most of the solutions to the error, we can find on cypress's official website.

15. Cypress Dashboard: This is paid if the total users are more than 3, but it has some super cool features like —

a. It provides you the view of the flaky test (which is the most painful part for QA to find out flaky test)

b. Integration with Jenkins

c. Parallel Execution

Conclusion:

Based on all the above-listed features, Cypress is becoming the number one choice for test automation in most of the leading companies. It has great community support and very well-written documentation. If you haven’t tried it yet, then I would suggest you install and run 1 test case and you will realize how amazing this tool is.

Hope you enjoyed the article. Happy learning! — AB

Thanks, Naveen AutomationLabs for the support and guidance.

Ref: https://docs.cypress.io/guides/overview/why-cypress

Anshita Bhasin
Sr. Automation Engineer

GitHub | LinkedIn | Twitter | Youtube

--

--

Anshita Bhasin

QA Chapter Lead at Proptech company in Dubai.. Here to share and learn new things! Youtube => ABAutomationHub