TIL about Cypress Custom Commands
POSTED ON:
I really like Cypress as a testing suite. It's really pwowerful and has a lot of features.
Today I learned adding custom commands to Cypress to abstract common patterns:
Cypress.Commands.add('login', () => {
cy.visit('/login');
cy.get('input[name=email]').type('foo@bar.com');
cy.get('input[name=password]').type('password');
cy.get('form').submit();
});
// Anywhere else
cy.login();
via Cypress or how I learned to stop worrying and love E2E
Related TILs
Tagged: testing