filiphric / cypress-plugin-api

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

Cypress App preview is stuck on API calls screen #60

Closed vlcekr closed 1 year ago

vlcekr commented 2 years ago

Hi Filip, we use cypress-plugin-api v2.3.3 + Cypress v 11.0.1 and there is issue of Cypress App preview not switching back to tested application after making api calls.

We have tests for application front-end, it just simulates user behavior but at some point we make api calls to make something happen on the background. After these api calls, test should continue in testing application front-end. Unfortunately, in Cypress App preview, the screen is stuck on API calls view and doesn't go back to tested APP and fails.

Could you please take a look at it? Thanks!

lucasdonato commented 2 years ago

The same problem happened to me. In my E2E tests, sometimes the screen gets stuck with the request preview. I can't always reproduce the error. it's random

filiphric commented 2 years ago

Sure, I'll make sure to fix this once I identify the issue. A reproducible example would really help here. If you are able to provide this, that would be great 👍

vlcekr commented 2 years ago

You can reproduce it easily with this test

describe('test', () => {
    it('doesnt switch back to app', () => {
        cy.visit('https://www.typescriptlang.org/docs/');
        cy.api('https://api.publicapis.org/entries');
        cy.contains('TS for the New Programmer').click(); // this will fail because there is api screen displayed and it doesn't switch back to website
    });
});
filiphric commented 2 years ago

@vlcekr are you using snapshotOnly in your test? I can replicate the issue with the code you sent me, but only when snapshotOnly is set to false (which is default)

filiphric commented 2 years ago

@lucasdonato does this happen when snapshotOnly mode is set to true?

tester-at-bmi commented 2 years ago

We also have simular issues with both settings to true.

{
   requestMode: true, 
   snapshotOnly: true  
}

and also with

{
   requestMode: true, 
   snapshotOnly: false  
}

The tests are working when both settings are set to false.

filiphric commented 1 year ago

Hey! I’m still unable to replicate this issue. I found some minor errors that I’m going to fix, but as far as the described issue goes, I’m not able to help. I tried this:

describe('test', { env: { snapshotOnly: true} }, () => {
    it('doesnt switch back to app', () => {
        cy.visit('https://www.typescriptlang.org/docs/');
        cy.api('https://api.publicapis.org/entries');
        cy.contains('TS for the New Programmer').click();
    });
});

when snapshotOnly mode is set, all works as intended, UI view hides. when it is not set, it’s false by default, so you are not able to select elements on visited page (as expected).

Closing this for now, feel free to reopen