Cypress: Fail tests that have unexpected API requests

Created on 14 Nov 2017  路  2Comments  路  Source: cypress-io/cypress

Is this a Feature or Bug?

Feature

Desired behavior:

I'd like a way to fail a test for any XHR calls that are not expected (ie. that no cy.route() has been set for). Current there's a force404, but that's not enough to be able to actually cause a test to fail

I had thought of using the onResponse option but it gets bypassed for the requests that force404 handles.

cy.server({
  force404: true,
  onResponse: xhr => {
    if (xhr.status === 404) {
      expect(true).to.equal(false);
    }
  }
});
ready for work feature

Most helpful comment

Any news about this, I'd love to see this happen. Is there a lot of work ? I can work on if not

All 2 comments

Still wasn't able to find a way to cause a test to fail if the force404:true is invoked, any updates on this issue?

Any news about this, I'd love to see this happen. Is there a lot of work ? I can work on if not

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igorpavlov picture igorpavlov  路  3Comments

SecondFlight picture SecondFlight  路  3Comments

dkreft picture dkreft  路  3Comments

jennifer-shehane picture jennifer-shehane  路  3Comments

rbung picture rbung  路  3Comments