Refactor A Test Part 4: A Better Delete Method

Опубликовано: 02 Март 2024
на канале: gleb bahmutov
551
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...


Смотрите видео Refactor A Test Part 4: A Better Delete Method онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал gleb bahmutov 02 Март 2024. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 551 раз и оно понравилось 23 посетителям.