filiphric / cypress-plugin-api

Cypress plugin to show your API information in the Cypress UI runner
ISC License
264 stars 35 forks source link

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

Closed elylucas closed 1 year ago

elylucas commented 2 years ago

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
filiphric commented 2 years ago

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?

elylucas commented 2 years ago

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.

filiphric commented 2 years ago

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

github-actions[bot] commented 1 year ago

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

The release is available on:

Your semantic-release bot :package::rocket: