-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Conversation
29 flaky tests on run #52339 ↗︎
Details:
cypress/e2e/e2e/origin/commands/assertions.cy.ts • 1 flaky test • 5x-driver-firefox
|
@@ -7,7 +7,7 @@ const _isBrowser = (browser, matcher, errPrefix) => { | |||
let exclusive = false | |||
|
|||
const matchWithExclusion = (objValue, srcValue) => { | |||
if (srcValue.startsWith('!')) { | |||
if (_.isString(srcValue) && srcValue.startsWith('!')) { |
There was a problem hiding this comment.
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".
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
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
cypress-documentation
?type definitions
?