Cypress Tutorial
Introduction To Cypress
What Is Cypress ?
Cypress is an open source JavaScript All-in-one-end-to-end web testing tool. It was specifically developed for front-end developers by front-end developers.
It was built on Node.js and comes in the form of package as a npm module. As Cypress is based on Node.js, it uses JavaScript for writing tests.
So,we can say that Cypress is a solution that aims to enable front-end developers and test automation engineers to write web tests in the de-facto web language that is JavaScript.
What libraries does Cypress use ?
Cypress basically uses 3 main libraries :
> Mocha for BDD test framework,
> Chai for assertions, and
> Sinon for mocking and stubbing purposes.
Why Cypress is different ?
Supports JavaScript only - Unlike Selenium,Cypress allows us to write tests in JavaScript only. So, for writing cypress tests you need to know about JavaScript concepts and its uses.
Doesn't need Selenium - Cypress has its own library and framework for testing and doesn't use selenium for automation.Cypress run within your browser just the way you're running your web-application.
Dev & QA friendly - In Cypress, tests run extremely fast and changes are reflected in real-time. So it's easy for a developer to write a Cypress test and if it fails then simply code it to get succeeded. And its syntax is too simple that makes QAs to write tests in Cypress efficiently.
What features Cypress does have ?
Automatic waits - Cypress has smart wait for commands as they run within browser and we will barely have to use waits when using cypress.
Consistent Results - Cypress directly communicates with browser, so it is fast, consistent and more reliable.
Supports multiple browsers - Now supports multiple browsers, e.g. chrome, firefox and so on.
Stubbing - Application behaviour and server responses can be stubbed easily using Cypress.
Screenshots & Videos - It captures screenshots on failure or records videos of the entire suite when running from CLI.