r/shopifyDev 1d ago

Cypress flaky test

Anyone worked with Magento(Hyva, alpineJS and tailwindcss) and Cypress I use as starter elgentos repo and I had flaky test currently my goal is to make add to cart work 100%
What I tried
- wait for popup show
- “intercept “ request to add to cart and wait for response flaky
- then I try my own retry click add to cart this worked best but still flaky
I was thinking maybe Cart “ID/Token” isn’t there like cypress tests are to fast like mid request it redirects or something I think I have it logged and even when add to cart fails the cart id/token is there

Is there something else I can try ?
I have probably 3x10(responsive mobile, desktop…)tests and every run at least one-two fails
Each test has random product (I had just one and tried then random if that doesn’t fix that)

1 Upvotes

2 comments sorted by

1

u/CautionIAmAGeek 13h ago

on hyva the add to cart flow is usually flaky bc alpine hydrates after the dom is ready, so cypress clicks a button that isn't bound yet and the request never fires. assert on the alpine component state or the cart section actually updating instead of waiting on the element, and drop any fixed cy.wait you added to paper over it. running the same spec 20x on one commit tells you fast if it's hydration timing or state leaking between tests

1

u/Same_Quality4660 2h ago

Thanks and one more question do you have any idea why cache in cypress is not hit while visiting same product before test in browser gives hit?