Тёмный

Conditionally Clear Items In A Cypress Test 

gleb bahmutov
Подписаться 7 тыс.
Просмотров 4,8 тыс.
50% 1

In this example, we clear the items in the application by clicking the delete button on each item. But we have to be careful about writing this test to avoid the default assertions built inside Cypress commands like cy.get.
cy.visit('/').wait(100)
cy.get('.todo')
.should('have.length.gte', 0)
.then(function ($todos) {
if (!$todos.length) {
cy.log('nothing to delete')
return
}
cy.wrap($todos)
.find('.destroy')
.click({ force: true, multiple: true })
})
// confirm there are no items
cy.get('.todo', { timeout: 100 }).should('have.length', 0)
See the full source code in github.com/bah...

Опубликовано:

 

18 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 10   
@joecaruso3756
@joecaruso3756 2 года назад
Very clever!
@t2hv33
@t2hv33 3 года назад
Very useful
@locnguyenthe3302
@locnguyenthe3302 3 года назад
i think i will subscribe and like your vids more :D . you should buy better micro Gleb :D nice vid
@Risekhalsa
@Risekhalsa 2 года назад
Can we use switch case in cypress instead of if else else if ????
@gleb
@gleb 2 года назад
You should not
@Risekhalsa
@Risekhalsa 2 года назад
@@gleb thanks
@Risekhalsa
@Risekhalsa 2 года назад
@@gleb multiple windows are supported in cypress ?
@Bergermeister99
@Bergermeister99 2 года назад
Very un-useful. I would pay money to find the absolute easiest, If else statement with out any aliases, functions or anything else other than "if this element exists do this, if not do that". I have spent days looking for this on the web but for some reason 100% of all examples add extra crap that make it more difficult to understand. If I was a programmer I wouldn't have an issue understanding this, but I am not a programmer. Seriously the code should be about 4-5 line long but you never find it. And the Cypress IO page is horrible in their examples as well.
@gleb
@gleb 2 года назад
I get it - you want tests to be non-deterministic and work differently every time you run them, you never want to know what exactly to expect on the page. I mean life is boring, might as well surprise yourself with random test failures. Ok, seriously - having the tests without conditional is the best practice. Cypress makes it simple, and that's why I love it. You might want to study how to write good solid tests, and even review the video ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-X8iIoTxu_8k.html and take a programming / Cypress fundamentals course. Then it will all "click", I promise.
Далее
Holding Bigger And Bigger Dogs
00:18
Просмотров 27 млн
С чего всё началось?
00:42
Просмотров 78 тыс.
Cypress Quiz With Yevhen Laichenkov
37:16
Просмотров 448
Required Input Attributes
7:26
Просмотров 633
Cypress Unit Testing In React Application
21:16
Просмотров 20 тыс.