Cypress intercepts flakes
# i-need-help
f
Hey, I have recently swapped from arbitrary waits to intercepts. This shaved about 30 percent of my testing time off which is awesome. Sadly i do experience more dom related flakes. Especially in my search components. I do wait for the request to be fetched but in about 20 percent of runs the table is not rerendered yet and cypress will therefore find multiple matching elements. Now i can just put another assertion like cy.contains() but first of all i dont like the idea of a "useless" assertion which is true anyway and also that wont work if i have an inline editable input which has to be invoked. Any ideas are welcome !
g
a) it is hard to help without a reproducible example b) there might be delay between the app getting the data and re-rendering, so adding a UI assertion is always a good idea c) for any network testing issues I have a paid course https://cypress.tips/courses/network-testing
f
It is a hundred percent a delay between re render ! It is not the biggest issue since it will most certainly retry and work but UI assertion is probably the way to go... Just thought maybe one of you guys had a similiar issue
I will now when possible do a UI assertion that within the table atleast the element searched for is displayed. This could still flake theoretically since my table could already render the first 5 of 15 elements which contains the searched one and just over go the assertion but the small delay plus the cases where the element is not displayed should now be fine ^^
g
You could write an assertion to ensure the search results either change after the search or all items have the search value
f
This is what i started to do 🙂 I check if a element is not existing in the table after query. This is one of the elements which is a hundred percent in the table due to seeding and if i search it should not be part^^
Copy code
cy.dataCy('searchable-addon__string-input').type('COMPANY');
    cy.wait('@SearchQuery');
    cy.dataCy('datacy-table__table').contains('TEST').should('not.exist');
I think that should do it 🙂 Thanks btw for the support!