DEV Community

Raphaël Badia
Raphaël Badia

Posted on

A stupid reason why cy.intercept() doesn't work when you reload Cypress tests

When trying to intercept a search api of my website, a strange bug almost drove me crazy : the first time I ran the test, it worked, but then failed once I tried to reload the test !

It turned out that there was a cache on the api side, so the browser is not doing an actual request once it's cached in the disk :
CleanShot 2021-04-28 at 15.09.54@2x

So from now on, I know that when I want to work with intercepted api responses that are cached, I must tick the "disable cache" checkbox.
CleanShot 2021-04-28 at 15.13.07@2x

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay