https://cypress.io logo
question on multiple `cy.intercept()`s: - our app ...
# e2e-testing
p
question on multiple `cy.intercept()`s: - our app makes multiple different requests to a
/graphql
endpoint - each request has the same method (POST) and endpoint url; they differ only in their request bodies, in particular the
operationName
. so the naive
cy.intercept('POST', '/endpoint')
matches all of them, and i have to implement the aliasing methods from https://docs.cypress.io/guides/end-to-end-testing/working-with-graphql to have a hope of disambiguating them - i would like to stub all of these requests inside the same test, replacing their responses with mock data stored as fixtures is this even possible? gleb's blog post https://glebbahmutov.com/blog/cypress-intercept-problems/#multiple-matchers seems to suggest there's no way for me to
cy.wait()
on more than one `cy.intercept()`s with the same method and endpoint in the same test context, and that my only solution is to not have tests that require more than one of the intercepts.
(the page under test assembles its contents from three different graphql requests -- roughly, one request serves the page header contents, the second serves the sidebar contents, and the third serves the main pane contents)
g
The simplest way we use is to add a custom request header with that operation name,

https://www.youtube.com/watch?v=AcU5mkedchM&feature=youtu.be▾