DK
Size: a a a
DK
O
OS
O
OS
OS
OK
OS
O
assertWindowAlert() {
cy.on('window:alert', (str) => {
console.log("DEBUG_TEST", str[0]);
expect(str[0]).to.equal("Not valid")
})
}
O
OS
OK
OS
Cypress.on('window:before:load', win => {
cy.stub(win, 'alert').as('windowAlert');
})
cy.get('@windowAlert').should('be.calledWithExactly', 'SOMESTRING');
OS
const stub = cy.stub();
cy.on('window:alert', stub);
... some other commands ...
cy.click('CLICK ME!');
cy.wrap(stub).should('be.calledWithExactly', 'str2');
O
Cypress.on('window:before:load', win => {
cy.stub(win, 'alert').as('windowAlert');
})
cy.get('@windowAlert').should('be.calledWithExactly', 'SOMESTRING');
OS
Cypress.Commands.add('stubAlert', () => {test.spec.js
const stub = cy.stub();
cy.on('window:alert', stub);
cy.wrap(stub).as('windowAlert');
});
cy.stubAlert();
cy.click('CLICK ME!');
cy.get('@windowAlert').should('be.calledWithExactly', 'str2');
OS
cy.wrap(stub)
и называть алиасом уже в тесте cy.stubAlert().as('alertForClickMe')
OS
O
D