-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Changes from 23 commits
2ecdd91
7d52188
1b473df
918997e
b5574b5
5c760d4
ff28d69
48c637d
7cf8da9
3adcb40
adfd7ce
ca5a16c
58efbac
9861034
0dcfe74
4c99b4d
84f0d8a
33b9d43
805bcdc
646857d
3747bc8
1d1df2e
81a3a0c
293a0f4
d7aa638
e83e56c
bc430a9
7453063
cb609e6
3cb9ab3
785e1ae
80cd48a
56bf522
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import type { Socket } from '@packages/socket/lib/browser' | |
import * as cors from '@packages/network/lib/cors' | ||
import { automation, useRunnerUiStore } from '../store' | ||
import { useScreenshotStore } from '../store/screenshot-store' | ||
import { getAutIframeModel } from '.' | ||
|
||
export type CypressInCypressMochaEvent = Array<Array<string | Record<string, any>>> | ||
|
||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing, nice idea. Done: 3cb9ab3 |
||
|
||
constructor ( | ||
// import '@packages/driver' | ||
|
@@ -337,6 +340,14 @@ export class EventManager { | |
rerun() | ||
}) | ||
|
||
this.ws.on('aut:destroy:init', () => { | ||
const autIframe = getAutIframeModel() | ||
|
||
autIframe.destroy() | ||
this.ws.emit('aut:destroy:complete') | ||
this.autDestroyedCount++ | ||
}) | ||
|
||
// @ts-ignore | ||
const $window = this.$CypressDriver.$(window) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,28 +4,34 @@ import path from 'path' | |
import * as validate from './validation' | ||
// @ts-ignore | ||
import pkg from '@packages/root' | ||
import type { AllCypressErrorNames } from '@packages/errors' | ||
|
||
export type BreakingOptionErrorKey = | ||
| 'COMPONENT_FOLDER_REMOVED' | ||
| 'INTEGRATION_FOLDER_REMOVED' | ||
| 'CONFIG_FILE_INVALID_ROOT_CONFIG' | ||
| 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' | ||
| 'CONFIG_FILE_INVALID_ROOT_CONFIG_COMPONENT' | ||
| 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' | ||
| 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_E2E' | ||
| 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED' | ||
| 'EXPERIMENTAL_SAMESITE_REMOVED' | ||
| 'EXPERIMENTAL_NETWORK_STUBBING_REMOVED' | ||
| 'EXPERIMENTAL_RUN_EVENTS_REMOVED' | ||
| 'EXPERIMENTAL_SESSION_SUPPORT_REMOVED' | ||
| 'EXPERIMENTAL_SHADOW_DOM_REMOVED' | ||
| 'EXPERIMENTAL_STUDIO_REMOVED' | ||
| 'FIREFOX_GC_INTERVAL_REMOVED' | ||
| 'NODE_VERSION_DEPRECATION_SYSTEM' | ||
| 'NODE_VERSION_DEPRECATION_BUNDLED' | ||
| 'PLUGINS_FILE_CONFIG_OPTION_REMOVED' | ||
| 'RENAMED_CONFIG_OPTION' | ||
| 'TEST_FILES_RENAMED' | ||
const BREAKING_OPTION_ERROR_KEY: Readonly<AllCypressErrorNames[]> = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just making things a bit more strict - now you cannot add a breaking key without an associated error message defined in |
||
'COMPONENT_FOLDER_REMOVED', | ||
'INTEGRATION_FOLDER_REMOVED', | ||
'CONFIG_FILE_INVALID_ROOT_CONFIG', | ||
'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E', | ||
'CONFIG_FILE_INVALID_ROOT_CONFIG_COMPONENT', | ||
'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT', | ||
'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_E2E', | ||
'EXPERIMENTAL_COMPONENT_TESTING_REMOVED', | ||
'EXPERIMENTAL_SAMESITE_REMOVED', | ||
'EXPERIMENTAL_NETWORK_STUBBING_REMOVED', | ||
'EXPERIMENTAL_RUN_EVENTS_REMOVED', | ||
'EXPERIMENTAL_SESSION_SUPPORT_REMOVED', | ||
'EXPERIMENTAL_SINGLE_TAB_RUN_MODE', | ||
'EXPERIMENTAL_SHADOW_DOM_REMOVED', | ||
'EXPERIMENTAL_STUDIO_REMOVED', | ||
'EXPERIMENTAL_STUDIO_REMOVED', | ||
'FIREFOX_GC_INTERVAL_REMOVED', | ||
'NODE_VERSION_DEPRECATION_SYSTEM', | ||
'NODE_VERSION_DEPRECATION_BUNDLED', | ||
'PLUGINS_FILE_CONFIG_OPTION_REMOVED', | ||
'RENAMED_CONFIG_OPTION', | ||
'TEST_FILES_RENAMED', | ||
] as const | ||
|
||
export type BreakingOptionErrorKey = typeof BREAKING_OPTION_ERROR_KEY[number] | ||
|
||
type TestingType = 'e2e' | 'component' | ||
|
||
|
@@ -224,6 +230,13 @@ const resolvedOptions: Array<ResolvedConfigOption> = [ | |
isExperimental: true, | ||
canUpdateDuringTestTime: false, | ||
requireRestartOnChange: 'server', | ||
}, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our config isn't in the greatest state given we don't validate against this list.. As is, e2e testers could set these even if the server didn't honor it. it'd be better to add this to the list of breaking e2e test configuration changes that are lower in this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
name: 'experimentalSingleTabRunMode', | ||
defaultValue: false, | ||
validation: validate.isBoolean, | ||
isExperimental: true, | ||
canUpdateDuringTestTime: false, | ||
requireRestartOnChange: 'server', | ||
}, { | ||
name: 'fileServerFolder', | ||
defaultValue: '', | ||
|
@@ -569,7 +582,7 @@ export const additionalOptionsToResolveConfig = [ | |
/** | ||
* Values not allowed in 10.X+ in the root, e2e and component config | ||
*/ | ||
export const breakingOptions: Array<BreakingOption> = [ | ||
export const breakingOptions: Readonly<BreakingOption[]> = [ | ||
{ | ||
name: 'blacklistHosts', | ||
errorKey: 'RENAMED_CONFIG_OPTION', | ||
|
@@ -641,7 +654,7 @@ export const breakingOptions: Array<BreakingOption> = [ | |
newName: 'specPattern', | ||
isWarning: false, | ||
}, | ||
] | ||
] as const | ||
|
||
export const breakingRootOptions: Array<BreakingOption> = [ | ||
{ | ||
|
@@ -689,6 +702,12 @@ export const breakingRootOptions: Array<BreakingOption> = [ | |
|
||
export const testingTypeBreakingOptions: { e2e: Array<BreakingOption>, component: Array<BreakingOption> } = { | ||
e2e: [ | ||
{ | ||
name: 'experimentalSingleTabRunMode', | ||
errorKey: 'EXPERIMENTAL_SINGLE_TAB_RUN_MODE', | ||
isWarning: false, | ||
testingTypes: ['e2e'], | ||
}, | ||
{ | ||
name: 'indexHtmlFile', | ||
errorKey: 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_E2E', | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1085,6 +1085,12 @@ export const AllCypressErrors = { | |
|
||
You can safely remove the ${fmt.highlight(`experimentalStudio`)} configuration option from your config.` | ||
}, | ||
EXPERIMENTAL_SINGLE_TAB_RUN_MODE: () => { | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}, | ||
FIREFOX_GC_INTERVAL_REMOVED: () => { | ||
return errTemplate`\ | ||
The ${fmt.highlight(`firefoxGcInterval`)} configuration option was removed in ${fmt.cypressVersion(`8.0.0`)}. It was introduced to work around a bug in Firefox 79 and below. | ||
|
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