Testing Interception object itself in Cypress #28220
Eprince-hub
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am setting up a Cypress test for CSP violations, and I want to confirm the method I am using to ensure I am not doing anything crazy!
Most of the interception checks I have seen on the internet (Blog posts, Documentation) have been testing the request or the response body or other properties of the interception, like the example below.
In my case, though, I don't care about the response or the request body because I just want to ensure no CSP violations. So whenever there is no CSP violation, the
interception
returns null (logCSP Violations: null
). Only when there is a CSP violation does the interception return the request body in my case, but in this case, I want to throw an error immediately.So this is how my interception is set up.
I am trying to make documentation for this approach with some documented proof that I am not doing anything wrong here, but I can't find anything.
Is this my approach okay, and would it not be flaky? And if not, what could be the best way to make this kind of check in Cypress?
Is there any example of a similar use case that I can refer to in my documentation?
I will be happy for any information please.
Beta Was this translation helpful? Give feedback.
All reactions