-
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
feat: experimental single tab run mode for component testing #23104
feat: experimental single tab run mode for component testing #23104
Conversation
…al-single-tab-component-testing
…al-single-tab-component-testing
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ FlakinessThis comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
@@ -1105,6 +1111,16 @@ module.exports = { | |||
return this.currentSetScreenshotMetadata(data) | |||
} | |||
|
|||
if (options.experimentalSingleTabRunMode && options.testingType === 'component' && !options.isFirstSpec) { | |||
// reset browser state to match e2e behavior when opening/closing a new tab | |||
return openProject.resetBrowserState().then(() => { |
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.
We reset the state here, much like we do between tabs, so this minimizes the chance of negatively impacting spec isolation.
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.
maybe this doesn't matter since this is experimental, but if something goes wrong, this loses the test retries for CT.
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.
Oh true, this seems like a problem - something we will definitely need to highlight in the notes, unless we can find a fix prior to releasing this experiment (if that's even acceptable, will need to update the tech brief with this drawback... good point).
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.
Actually @emilyrohrbough I don't get it - I tried to use retries
but it works okay: 4c99b4d#diff-ff7a203eea50ba8d34ac184c54310e07e4f279447a923ba9bec878e643b9e289R699-R700
Is there another way to configuring this or an edge case that I'm missing?
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.
The retries are only for the initial browser launch right? I'm not sure we'd need retries for when we're navigating in this new way
…al-single-tab-component-testing
@@ -35,6 +35,14 @@ export class AutIframe { | |||
return $iframe | |||
} | |||
|
|||
destroy () { |
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 new for single tab - we tear down the AUT between specs, right after we stop recording, but before we start the next spec.
For comparison of before/after, see: https://whimsical.com/spec-isolation-XiJyCyVUJmWQYRQbysgpP1
packages/errors/src/errors.ts
Outdated
return errTemplate`\ | ||
The ${fmt.highlight(`experimentalSingleTabRunMode`)} experiment is currently only supported for Component Testing. | ||
|
||
If you are enjoying the experiment with Component Testing, please join the discussion here: http://on.cypress.io/experimental-single-tab-run-mode` |
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.
Maybe have a more open ended message? They may be enjoying it, but they may not be? Either way we would want feedback.
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.
packages/server/lib/modes/run.js
Outdated
@@ -1218,6 +1234,12 @@ module.exports = { | |||
.catch(warnVideoRecordingFailed) | |||
} | |||
|
|||
const usingExperimentalSingleTabMode = testingType === 'component' && config.experimentalSingleTabRunMode | |||
|
|||
if (usingExperimentalSingleTabMode) { |
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.
Any reason we're doing this here rather than at line 1269? Seems like it might make sense to destroy the Aut at the same place that we were previously closing the tab.
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.
Good point, I'll move it down near there, near where we close/change tab. e83e56c
Running the CT specs in launchpad with this experiment went from ~46s to ~28s on my machine 👍🏻 |
f193fec
to
bc430a9
Compare
@ryanthemanuel thanks for the quick review! Updated. Did some manual QA on the video recording, seems to be working as expected. |
@@ -54,6 +55,8 @@ export class EventManager { | |||
studioRecorder: any | |||
selectorPlaygroundModel: any | |||
cypressInCypressMochaEvents: CypressInCypressMochaEvent[] = [] | |||
// Used for testing the experimentalSingleTabRunMode experiment. Ensures AUT is correctly destroyed between specs. | |||
autDestroyedCount = 0 |
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.
Any way we can setup this up in the e2e/ct support files so we don't have this hanging around in prod code?
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.
Sure thing, nice idea. Done: 3cb9ab3
0c9341e
to
3cb9ab3
Compare
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.
Looks good. Nice work!
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
@lmiller1990 can you upload a screenshot of what the settings UI looks like for E2E vs CT that indicate which experiments are available? I would expect that Currently the UI looks like this: Notice that there isn't a place where it explains where to set the experimental flags. Since we now are building support for |
User facing changelog
Introduce a new Cypress experiment,
experimentalSingleTabRunMode
, for Component Testing. All specs will execute in a single tab, similar to the Component Testing alpha in Cypress 9.Additional details
Useful Linkd
In this PR, I added an experimental flag that will reverted back to the Cypress 9 behavior, which will run all the specs for CT in a single tab. It's much faster (see the associated issue for numbers). There are some trade-offs, as noted in the technical brief, which is why this is behind an experimental flag.
This experiment was driven by feedback in #22353, and also from our dashboard users, noting running all CT specs was up to 50% slower.
Ideally, when we work on the Run All specs feature, we will explore and find out how to best isolate specs running in a single tab. This work will likely make this experiment obsolete, and we'd just deprecate it, in favor of the new run all specs feature. This is a significant project and unlikely to land anytime soon, thus this experiment.
Steps to test
packages/launchpad
, which enables the experimentyarn cypress:run:ct --browser chrome --config video=false
. 55s on my machine. ⚡--headed
to see it running in a single tab.cypress.config.ts
yarn cypress:run:ct --browser chrome --config video=false
. 91.9s on my machine. 🐌How has the user experience changed?
Component Tests run much more quickly with this experiment enabled.
PR Tasks
cypress-documentation
?type definitions
?