Back to Cheat SheetsAutomation · Beginner

Cypress cheat sheet

Command chaining, assertions, network stubbing and custom commands.

Commands

Visit and click

cy.visit('/login'); cy.get('#submit').click();

Type

cy.get('[name=email]').type('qa@test.io');

Contains

cy.contains('button', 'Save').click();

Assertions

Should

cy.get('.toast').should('be.visible').and('contain', 'Saved');

Length

cy.get('tr').should('have.length', 5);

Network and reuse

Intercept

cy.intercept('GET','/api/users',{ fixture:'users.json' }).as('users');

Wait alias

cy.wait('@users').its('response.statusCode').should('eq', 200);

Custom command

Cypress.Commands.add('login', (u,p) => { ... });

Go beyond the reference

Book a free demo class and apply these commands on live project work.