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

Cypress App preview is stuck on API calls screen

Open vlcekr opened this issue 2 years ago • 6 comments

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!

vlcekr avatar Nov 11 '22 05:11 vlcekr

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

lucasdonato avatar Nov 11 '22 09:11 lucasdonato

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 👍

filiphric avatar Nov 11 '22 10:11 filiphric

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
	});
});

vlcekr avatar Nov 11 '22 10:11 vlcekr

@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 avatar Nov 12 '22 09:11 filiphric

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

filiphric avatar Nov 12 '22 09:11 filiphric

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.

tester-at-bmi avatar Nov 28 '22 14:11 tester-at-bmi

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

filiphric avatar Dec 20 '22 09:12 filiphric