Setup & Teardown

BeforeEach

It is executed before each test. In our case this method is in charge of opening the view to test.

example.spec.ts
beforeEach(() => {
    cy.openExampleView();
});

The function openExampleView must be declared in the command.js file in the support folder. An example of this type of function is the following:

support/Commands.js
Cypress.Commands.add('openExampleView', () => {
  cy.visit('');
  cy.get('app-root > nav > ul > li:nth-child(1)').click();
});

Last updated