cy.intercept() unable to mock the same url multiple times

Viewed 290

cy.intercept() mocks the response first time. But, if I try again second time with a different response, it does not work.

cy.intercept(
  {
    method: 'GET',
    url: `get/note`,
  },

  {
    body: {
      statusCode: 200,
      message: 'Request successful',
      result: [],
    },
  }
).as('loadComments1');

cy.intercept(
  {
    method: 'GET',
    url: `get/note`,
  },

  {
    body: {
      statusCode: 200,
      message: 'Request successful',
      result: seededNoteComments,
    },
  }
).as('loadComments2');
0 Answers
Related