Skip to content

Any way to alias fixture and also use in intercept (see examples)? #20275

Discussion options

You must be logged in to vote

I just realized there's a way around this aliasing the intercepts and using cy.wait:

beforeEach(() => {
  // The order of intercept is important
  cy.intercept("**/some/path?q1=foo", { fixture: `my-${parameterized}-filename.json` }).as("interceptAlias1");
  cy.intercept("**/some/path?q1=foo&q2=bar", { fixture: `my-${parameterized2}-filename.json` }).as("interceptAlias2");
  cy.intercept("**/some/path?q1=foo&q2=bar&q3=baz", { fixture: "my-simple-filename.json" } )
});

it("is a test", function() {
  cy.wait("@interceptAlias1").then(interception => {
    cy.get("thing").should("have.length", interception.response.body.nestedArray.length);
  });
  cy.wait("@interceptAlias2").then(interception 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Josh68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant