cypress-plugin-api icon indicating copy to clipboard operation
cypress-plugin-api copied to clipboard

Calls to cy.request after cy.api is called show up in the new UI view

Open elylucas opened this issue 2 years ago • 3 comments

Version: 2.6.0

Not sure if this is intentional or not, but felt like a bug. After you call cy.api for the first time, calls to cy.request also show up in the new UI to view api requests. It would be nice if only cy.api calls showed up in the UI.

beforeEach(() => {
    cy.request({
      log: false,
      method: 'POST',
      url: '/missions/reset',
      headers: {
        Authorization: 'resetcreds',
      },
    });
    cy.log('seeding db');
  });

  it('can delete mission', () => {
    cy.api('DELETE', '/missions/1').as('response');
    cy.get('@response').its('status').should('equal', 204);
  });
image

elylucas avatar Nov 26 '22 17:11 elylucas

Hey @elylucas I haven’t been able to replicate this. The image you show is a behavior that would be normal if you had requestOnly mode enabled in your config. Is that the case by any chance?

filiphric avatar Nov 26 '22 19:11 filiphric

Hmm no, only thing I modified in the config was the baseUrl. I tried creating a new repo to reproduce the issue but the problem didn't happen there. So I threw up the app im working on in the api-request-reproduction branch if you want to take a look. The API app is in the cy-heroes-api folder.

BTW, loving the plugin. The repo above is a talk I'm preparing on building an API and using the plugin to test it.

elylucas avatar Nov 27 '22 17:11 elylucas

Oh thanks for the additional info, I was able to figure this out. I need to do a little bit of refactoring I believe. It seems that the way I handle registering the plugin is less than ideal. besides the code being messy, it creates this bug.

When cy.api() is called, it will overwrite cy.request() command in the background. All the upcoming cy.request() calls become cy.api() I thought I tested this properly when I implemented it, but apparently not 🙁 I will think of a fix and make it happen

filiphric avatar Nov 28 '22 14:11 filiphric

:tada: This issue has been resolved in version 2.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Dec 20 '22 09:12 github-actions[bot]