Introduction to Cypress

‘Cypress can test anything that runs in a browser’

Cypress supports faster End-to End(E2E) testing. Cypress gives devs access to all of the browser environments in which the site/app runs.

What is End to End Testing?

End to end testing is one of the testings in which the entire flow of the application is tested. is it working as per requirement or not. It validates the whole software from start to end along with integration and external interfaces.

What is cypress?

Cypress is an open source and automation testing tool. It can be used for front end and application programming interface (API) test automation.

Cypress tests are implemented on Mocha and Chai.

How to install it?

Cypress desktop application can be installed over windows 7, ubuntu, and macOS.

We can install cypress using npm with this command

cd project/path
Npm install cypress--save-dev ./node_modules/.bin/cypress open

cypress is installed locally with dev dependencies.

We can see cypress folder inside our project root directory.

Start cypress

With this command, we can open the folder structure for cypress inside that some tests are already written

./node_modules/.bin/cypress open

Open project

Under cypress/integration folder we can write test cases for our application.

Create file with extension .js

Example: demo.js

✢ Visit the website inside the browser

cy.visit() — it is used to visit the particular URL.

✢ Validating contains

cy.contains() — it is used to validate the contains present over website.

✢ Button or link click

.click() — This function is used to click over the link we found so we can proceed further. This is a child command.

✢ Adding Assertion

.should() — it is used to add assertion. This is a child command.

This above .should() function checks for 3 input text-box are present over web-page.

.and() is similar to .should() which is also used to add assertions.

‘and’ command is an assertion command chained up with other assertions. ‘should’ command is also an assertion command chained up with the selector.

we can’t write like this
cy.should() or cy.add()

✢ .Check()

.check() — This function is used to check the checkbox or radio-buttons.

✢ .Clear()

.clear() — This function is used to clear data.

with help of this command, we can clear the content inside the text area and write the text ‘Hello, World’.

Who uses Cypress?

Cypress is most probably used by QA engineers and developers using javascript framework.

Why do I like Cypress?

  1. Fast, easy, and reliable.
  2. No need of a selenium server.
  3. Provide assertions.
  4. Simple and easy to set up.
  5. Javascript based tasting framework.

Browsers Support

  • Chrome, Firefox, Edge, Brave, Electron

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.