cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.85k stars 3.17k forks source link

Cypress runner should start up / reload as a background application (on Mac OS) #25600

Open PeterJayCruz opened 1 year ago

PeterJayCruz commented 1 year ago

What would you like?

When the Cypress runner first loads up or is reloaded (i.e. updating the cypress config file), it becomes the focused application [on Mac OS].

It would be nice if this happened in the background (as it once did prior to v10). currently it is taking over as the focused application and opening in a full screen. so it takes over the whole screen and disrupts workflow.

Why is this needed?

it is very disruptive to my workflow when writing code and the cypress runner becomes the active/focused window while i'm in the middle of typing something in my IDE or terminal for example.

Other

Seems to be a relatively recent change in behavior with an upgrade to Cypress v10.

Just want to say I have been loving the updates to the Cypress runner! This would be such an impactful quality of life kind of improvement! :)

SnowdenWintermute commented 1 year ago

This happens on Ubuntu 20.04 as well. Very frustrating because every time I make a change to the code cypress forces the test browser window into focus. Because of this I have to close cypress when I am editing and reopen it when I want to test.

marktnoonan commented 1 year ago

It sounds like we have a couple of different things reported here. @PeterJayCruz you seem to be speaking more about the experience when Cypress is expected to open - like after changing config or when opening for the first time. @SnowdenWintermute it sounds like you are describing a more general problem with Ubuntu where Cypress steals focus during any edits?

Some screen recordings showing the exact behavior would be great, from either of you, we may have a couple of different aspects of this to address.

SnowdenWintermute commented 1 year ago

I think Peter and I are describing the same thing. When I make edits to Cypress tests, it does not steal focus. It is when I make an edit to something that causes a reload, like cypress.config.json, that Cypress takes focus. You can see the example here: https://www.youtube.com/watch?v=gZ3hmbki8i4

marktnoonan commented 1 year ago

Thanks, that is helpful. I took your comment as a bit more broad.

Since the original issue was reported on Mac, I tried to reproduce there but I can't. Editing config file only refreshes the browser in certain situations (some values require a full relaunch of the browser).

Most values shouldn't do this though - like editing e2e.setupNodeEvents doesn't stop/start the browser for me, it just does a reload in place where we parse the modified config.

Maybe I'm missing something about how to reproduce. If you have the time, would you mind grabbing this template: https://github.com/cypress-io/cypress-test-tiny and verifying that you see the same problem?

That will isolate whether this is a bug in Cypress on your OS in general. The alternative is that some specific dependencies or something are leading to the incorrect behavior.

I do think we should change the behavior so the browser doesn't steal focus unless it was launched by user action in the app. That would probably fix this issue for you even if it doesn't actually explain why the behavior is not the same for me.

SnowdenWintermute commented 1 year ago

I tried to reproduce the behavior using the template, but I wasn't able to get Cypress to reload upon changing cypress.config.js like it does in my project. I looked at the version I was using in my project and saw I was using Cypress 11 so I upgraded to 12 (the same version I installed in the template) but my project still had the behavior. Then I thought maybe it was because I am using typescript so I configured the template for typescript but still I could not get Cypress to reload upon changing cypress.config.ts. I'm not sure exactly what it is about my project that causes reloads because there are a lot of dependencies. Since I'm unable to get Cypress to reload by changing the config file, I wasn't able to verify it if would steal focus if it did reload.

marktnoonan commented 1 year ago

@SnowdenWintermute this is difficult to speculate about, I wonder if you could share a video of the behavior you see?

Also getting a look at your dependencies and your config file would be great to help understand what is happening.

If you can share these without revealing private information, of course.

SnowdenWintermute commented 1 year ago

@marktnoonan

Hi Mark,

Here is a video of the behavior: https://www.youtube.com/watch?v=gZ3hmbki8i4

The project itself is here: https://github.com/SnowdenWintermute/lucella

public commented 1 month ago

This behaviour is so incredibly annoying. No application should ever steal focus.