‘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.
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
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.
With this command, we can open the folder structure for cypress inside that some tests are already written
Under cypress/integration folder we can write test cases for our application.
Create file with extension .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() — This function is used to check the checkbox or radio-buttons.
.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?
Why do I like Cypress?
- Fast, easy, and reliable.
- No need of a selenium server.
- Provide assertions.
- Simple and easy to set up.
- Chrome, Firefox, Edge, Brave, Electron