What is Cypress ? A Beginner’s Guide to Cypress Testing and Automation

Cypress Automation Tool

What is cypress Used For ?

Cypress Automation Tool is a UI Automation tool used for automating web applications that run in browser. Its an open source and locally installed tool for with lot of salient features.

  1. ScreenShots – Takes Screenshots for all steps either passed or failed.
  2. In-built Waits – Cypress automatically waits for commands and assertions there is no need for any implicit and explicit waits.

It helps automating different kind of testing as follows :-

  1. Unit Tests
  2. Component Tests
  3. Acceptance Tests
  4. E2E Tests
  5. Regression Tests

Cypress Architecture Explained

Cypress Architecture works on the concept of client-server architecture. Here Client(Browser) and Server(Node.js) interact with each other via HTTP Requests and HTTP responses executing the cypress command with the help of a proxy server and reacting with DOM elements within the browser tp perform desired flows for given web application.

Cypress vs Selenium: Key Differences

TraitsCypressSelenium
Tech StackJavaScript & TypeScriptMultiple languages (Java, Python, C# etc.)
BrowsersChrome, Edge, Firefox, ElectronChrome, IE, Safari,Edge,Firefox,Opera
FrameworksSupports only Mocha JS and Chai JSSupports multiple framweorks depending on which language is used
SetupSetup is wasy with multiple options including command line options Setup is required as external dependencies are required to run
Se vs Cy

Installing Cypress

Pre – Requsites

There are multiple ways in which cypress can be installed

Installation via Command Line

Cypress via a build file(package.json)

In most of the Enterprise testing setup cypress is installed at run time via a build file. Here and in our framework we will discuss the 3rd option for installation.

Installation via package.json

Package.JSON will act as a build file and dependency manager. It manages all the dependencies for building the project and all build scripts with different options.

Understanding package.json in Cypress Projects

  1. Name – Name of you Project
  2. Dependencies & Dev Dependencies – dependencies and corresponding version.
  3. Scripts – Build and Different Run configuration

We have multiple options to choose from. Below table shows the most important ones you are using.

OptionDescription
--browser-bRun Cypress in the browser with the given name.
–e2eRun end to end tests(default)
--env-eSpecify Environment variables
--headlessHide the browser instead of running headed(default cypress run)
--recordWhether to record the test run
--tag-tIdentify a run with a tag or tags

Running Cypress Tests

Cypress gets install usually inside ./node_modules/bin/cypress

cd to bin
cypress open

Comments

One response to “What is Cypress ? A Beginner’s Guide to Cypress Testing and Automation”

  1. […] thedevopsguy.co.in in Test Automation, Blog Previous Post […]

Leave a Reply

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