tgriesser / cypress-graphql-mock

Adds commands for executing a mocked GraphQL server using only the client
171 stars 43 forks source link

Intercept request #26

Open sarink opened 5 years ago

sarink commented 5 years ago

How can I intercept the stubbed fetch call to inspect the request body?

nicangeli commented 2 years ago

It's a bit clunky, but you can do something like:

cy.get("@fetchStub").then((stub) => {
  const mutation = JSON.parse(stub.getCall(0).args[1].body);

  expect(mutation.variables).to.deep.eql(expectedVariables);
});