52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
// ***********************************************
|
|
// This example commands.js shows you how to
|
|
// create various custom commands and overwrite
|
|
// existing commands.
|
|
//
|
|
// For more comprehensive examples of custom
|
|
// commands please read more here:
|
|
// https://on.cypress.io/custom-commands
|
|
// ***********************************************
|
|
//
|
|
//
|
|
// -- This is a parent command --
|
|
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
//
|
|
//
|
|
// -- This is a child command --
|
|
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
//
|
|
//
|
|
// -- This is a dual command --
|
|
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
//
|
|
//
|
|
// -- This will overwrite an existing command --
|
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
|
|
Cypress.Commands.add("goToSignInPage", () => {
|
|
cy.visit("/");
|
|
cy.contains("Sign In").click();
|
|
});
|
|
|
|
Cypress.Commands.add("login", (username, password) => {
|
|
cy.goToSignInPage();
|
|
|
|
cy.get('[data-cy="username"]').type(username);
|
|
cy.get('[data-cy="password"]').type(password);
|
|
cy.get('[data-cy="sign-in-button"]', { timeout: 2000 }).click();
|
|
});
|
|
|
|
Cypress.Commands.add("passwordReset", (email) => {
|
|
cy.goToSignInPage();
|
|
cy.get('[data-cy="reset-password"]').click();
|
|
cy.get('[data-cy="reset-password-email-input"]').type(email);
|
|
cy.get('[data-cy="reset-password-button"]').click();
|
|
});
|
|
|
|
Cypress.on("uncaught:exception", (err, runnable) => {
|
|
// returning false here prevents Cypress from
|
|
// failing the test
|
|
return false;
|
|
});
|