Refactor A Test Part 4: A Better Delete Method

Publié le: 02 mars 2024
sur la chaîne: gleb bahmutov
581
23

In this video, I refactor the page object method that deletes a customer.
add a log message
use cy.contains(selector, text) rather than the longer cy.get(selector).contains(text)
explicit "confirm" stub and check that the stub was called with expected argument
confirm the application routes to the correct URL after deleting
delete() {
cy.log('**deleting the customer**');
cy.on(
'window:confirm',
cy
.stub()
.returns(true)
// @ts-expect-error
.as('confirm')
);
cy.contains('button', 'Delete').click();
cy.get('@confirm').should('have.been.calledOnceWith', 'Really delete?');
cy.location('pathname').should('eq', '/customer');
}
Find the original code at https://github.com/bahmutov/basta-spr...


Sur cette page du site, vous pouvez voir la vidéo en ligne Refactor A Test Part 4: A Better Delete Method durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur gleb bahmutov 02 mars 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 581 fois et il a aimé 23 téléspectateurs. Bon visionnage!