DEV Community

Discussion on: How to use stub multiple API requests dynamically in Cypress

Collapse
 
dxcjbeck profile image
Jonathan Matthew Beck • Edited

What I meant to say is can you do away with the external dependency of xhook and use the cypress api instead:

beforeEach(() => {
cy.server({ method: 'POST' })
cy.route({
method: 'POST',
url: '**/articles',
onResponse: (xhr) => {
// insert your JSON filtering code here
}
})
})

docs.cypress.io/api/commands/route...

Thread Thread
 
digitaledawn profile image
Aurore T • Edited

That was the first thing I tried but that didn't work for this use case. I wish it did.