Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Ensure cypress tab is active before any command runs #28334

Merged
merged 14 commits into from
Nov 16, 2023

Conversation

chrisbreiding
Copy link
Contributor

@chrisbreiding chrisbreiding commented Nov 14, 2023

Additional details

Ensures the main Cypress tab is active (i.e. the tab on top and shown by the browser) before any command is run and at the end of a test. This is in anticipation of support for testing multiple tabs/windows with the future @cypress/puppeteer plugin. It's only implemented in Chromium for now, as that's what the puppeteer plugin will support. It's not necessary for Electron because it doesn't have tabs.

It uses the extension to accomplish activating the tab, since it's the only way to do it without the browser stealing focus from other apps (like CDP Page.bringToFront would do).

Steps to test

Run any test in open mode and open a new tab while the test is running. You'll see the active tab switch back to the Cypress tab before the next command starts running. It will also switch back at the end of a test, including if a command fails.

PR Tasks

Copy link

cypress bot commented Nov 15, 2023

29 flaky tests on run #52339 ↗︎

0 28283 1346 0 Flakiness 29

Details:

Merge remote-tracking branch 'origin/develop' into crb/cy-puppeteer-return-focus
Project: cypress Commit: a6542aba05
Status: Passed Duration: 18:59 💡
Started: Nov 16, 2023 4:52 PM Ended: Nov 16, 2023 5:11 PM
Flakiness  cypress/e2e/e2e/origin/commands/assertions.cy.ts • 1 flaky test • 5x-driver-firefox

View Output

Test Artifacts
cy.origin assertions > #consoleProps > .should() and .and()
    </td>
  </tr></table>
Flakiness  cypress/e2e/cypress/cypress.cy.js • 3 flaky tests • 5x-driver-firefox

View Output

Test Artifacts
... > correctly returns currentRetry
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <a href="https://cloud.cypress.io/projects/ypt4pf/runs/52339/overview/53b08136-83db-444a-a12e-c7601fd1e175?reviewViewBy=FLAKY&utm_source=github&utm_medium=flaky&utm_campaign=view%20test">
        ... > correctly returns currentRetry
      </a>
    </td>
    <td>
      
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <a href="https://cloud.cypress.io/projects/ypt4pf/runs/52339/overview/c68a5a63-ef3c-4a21-a61c-fc45183c0c8a?reviewViewBy=FLAKY&utm_source=github&utm_medium=flaky&utm_campaign=view%20test">
        ... > correctly returns currentRetry
      </a>
    </td>
    <td>
      
    </td>
  </tr></table>
Flakiness  cypress/e2e/project-setup.cy.ts • 1 flaky test • launchpad-e2e

View Output

Test Artifacts
... > can reconfigure config after CT has been set up Test Replay Screenshots
Flakiness  cypress/e2e/global-mode.cy.ts • 1 flaky test • launchpad-e2e

View Output

Test Artifacts
... > can be opened Test Replay Screenshots
Flakiness  src/debug/empty/DebugEmptyStates.cy.tsx • 1 flaky test • app-ct

View Output

Test Artifacts
... > renders slideshow Test Replay Screenshots

The first 5 flaky specs are shown, see all 17 specs in Cypress Cloud.

Review all test suite changes for PR #28334 ↗︎

@@ -7,7 +7,7 @@ const _isBrowser = (browser, matcher, errPrefix) => {
let exclusive = false

const matchWithExclusion = (objValue, srcValue) => {
if (srcValue.startsWith('!')) {
if (_.isString(srcValue) && srcValue.startsWith('!')) {
Copy link
Contributor Author

@chrisbreiding chrisbreiding Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a drive-by fix that I needed for the browser check. I didn't see any open issues about this, but it does seem like it wasn't working as documented, where Cypress.isBrowser({ isHeadless: true }) would fail with "startsWith is not a function".

@chrisbreiding chrisbreiding merged commit 06b5ca2 into develop Nov 16, 2023
80 of 82 checks passed
@chrisbreiding chrisbreiding deleted the crb/cy-puppeteer-return-focus branch November 16, 2023 18:09
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 21, 2023

Released in 13.6.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.6.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants