So say I've got a cypress test with a spy on window.fetch like so:
describe('My test', () => {
beforeEach(() => {
cy.visit('http://localhost:3000', {
onBeforeLoad(win) {
cy.spy(win, 'fetch')
},
})
I can assert that POST request has a certain URL like so:
cy.window().its('fetch').should('be.calledWith', 'http://whatever.com/stuff')
but I can't figure out how to assert against the body of that request.
How would I assert, for instance, that it contains my_param=10?
Thanks!
Nobody eh? Well, if anyone else stumbles across this, I figured it out and here's how you do it:
Remember to import sinon as a separate dependency.
You can use this line multiple times to assert against multiple variables.