Member-only story
Getting Started With Cypress: Write Your First Angular Test
Write robust E2E tests
On 24th April, Angular announced the deprecation of their E2E testing tool protractor. It was unclear if there will be a successor or if Angular is delegating this to the users themselves. At the time of this writing, WebDriver.IO, TestCafé, and Cypress have provided schematics for the Angular CLI.
This is the second part which is about the first steps in Cypress. The first part is about E2E frameworks in general.
You find the source files here. If you prefer watching over reading, then this recording of my talk is for you.
Basics
Cypress is extremely easy to use. Starting from Angular 12, you just need to run the schematics like npx ng add @cypress/schematic
and voilá, done. If you are on Nx, which is what I recommend, Cypress is already preinstalled.
Cypress tests are written like most of the other tests in JavaScript. describe
defines a new test suite and contains multiple test cases, where each one is defined by it
. They are located in the folder /cypress/integration.
E2E tests do the same things a human tester would do. They are looking, clicking, and typing. Each of these three actions has its own command in Cypress. Actually, they are methods…