diff --git a/cli/types/cypress.d.ts b/cli/types/cypress.d.ts index 3531a5ef34..66222d514f 100644 --- a/cli/types/cypress.d.ts +++ b/cli/types/cypress.d.ts @@ -3043,7 +3043,7 @@ declare namespace Cypress { viteConfig?: Omit, undefined>, 'base' | 'root'> } - interface ComponentConfigOptions extends Omit { + interface ComponentConfigOptions extends Omit { devServer: DevServerFn | DevServerConfigOptions devServerConfig?: ComponentDevServerOpts } diff --git a/packages/app/cypress/e2e/runner/sessions.ui.cy.ts b/packages/app/cypress/e2e/runner/sessions.ui.cy.ts index 2b5e6165bb..628922e43f 100644 --- a/packages/app/cypress/e2e/runner/sessions.ui.cy.ts +++ b/packages/app/cypress/e2e/runner/sessions.ui.cy.ts @@ -39,7 +39,8 @@ describe('runner/cypress sessions.ui.spec', { it('creates new session', () => { loadSpec({ - filePath: 'sessions/new_session.cy.js', + projectName: 'runner-session-e2e-specs', + filePath: 'new_session.cy.js', }) validateSessionsInstrumentPanel(['blank_session']) @@ -62,7 +63,8 @@ describe('runner/cypress sessions.ui.spec', { it('creates new session with validation', () => { loadSpec({ - filePath: 'sessions/new_session_with_validation.cy.js', + projectName: 'runner-session-e2e-specs', + filePath: 'new_session_with_validation.cy.js', }) validateSessionsInstrumentPanel(['blank_session']) @@ -95,7 +97,8 @@ describe('runner/cypress sessions.ui.spec', { it('creates new session and fails validation', () => { loadSpec({ - filePath: 'sessions/new_session_and_fails_validation.cy.js', + projectName: 'runner-session-e2e-specs', + filePath: 'new_session_and_fails_validation.cy.js', }) validateSessionsInstrumentPanel(['blank_session']) @@ -127,7 +130,8 @@ describe('runner/cypress sessions.ui.spec', { it('restores saved session', () => { loadSpec({ - filePath: 'sessions/restores_saved_session.cy.js', + projectName: 'runner-session-e2e-specs', + filePath: 'restores_saved_session.cy.js', }) cy.get('.test').each(($el) => cy.wrap($el).click()) @@ -180,7 +184,8 @@ describe('runner/cypress sessions.ui.spec', { it('recreates session', () => { loadSpec({ - filePath: 'sessions/recreates_session.cy.js', + projectName: 'runner-session-e2e-specs', + filePath: 'recreates_session.cy.js', }) cy.get('.test').each(($el) => cy.wrap($el).click()) @@ -241,7 +246,8 @@ describe('runner/cypress sessions.ui.spec', { it('recreates session and fails validation', () => { loadSpec({ - filePath: 'sessions/recreates_session_and_fails_validation.cy.js', + projectName: 'runner-session-e2e-specs', + filePath: 'recreates_session_and_fails_validation.cy.js', }) cy.get('.test').each(($el) => cy.wrap($el).click()) @@ -298,7 +304,8 @@ describe('runner/cypress sessions.ui.spec', { it('multiple sessions in a test', () => { loadSpec({ - filePath: 'sessions/multiple_sessions.cy.js', + projectName: 'runner-session-e2e-specs', + filePath: 'multiple_sessions.cy.js', }) validateSessionsInstrumentPanel(['user1', 'user2']) diff --git a/packages/app/cypress/e2e/runner/support/spec-loader.ts b/packages/app/cypress/e2e/runner/support/spec-loader.ts index 9d953f7d2f..52a20150c7 100644 --- a/packages/app/cypress/e2e/runner/support/spec-loader.ts +++ b/packages/app/cypress/e2e/runner/support/spec-loader.ts @@ -19,6 +19,7 @@ export type LoadSpecOptions = { failCount?: number | string pendingCount?: number | string hasPreferredIde?: boolean + projectName?: 'runner-e2e-specs' | 'runner-session-e2e-specs' } export function loadSpec (options: LoadSpecOptions) { @@ -29,10 +30,11 @@ export function loadSpec (options: LoadSpecOptions) { failCount = '--', hasPreferredIde = false, pendingCount, + projectName = 'runner-e2e-specs', } = options - cy.scaffoldProject('runner-e2e-specs') - cy.openProject('runner-e2e-specs') + cy.scaffoldProject(projectName) + cy.openProject(projectName) cy.startAppServer() cy.withCtx((ctx, options) => { diff --git a/packages/config/src/options.ts b/packages/config/src/options.ts index 48e9b98416..92400c1eb6 100644 --- a/packages/config/src/options.ts +++ b/packages/config/src/options.ts @@ -209,7 +209,7 @@ const resolvedOptions: Array = [ defaultValue: false, validation: validate.isBoolean, isExperimental: true, - canUpdateDuringTestTime: true, + canUpdateDuringTestTime: false, }, { name: 'experimentalSourceRewriting', defaultValue: false, @@ -637,6 +637,11 @@ export const breakingRootOptions: Array = [ errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E', isWarning: false, testingTypes: ['e2e'], + }, { + name: 'experimentalSessionAndOrigin', + errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E', + isWarning: false, + testingTypes: ['e2e'], }, { name: 'excludeSpecPattern', errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG', @@ -684,5 +689,10 @@ export const testingTypeBreakingOptions: { e2e: Array, component errorKey: 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT', isWarning: false, }, + { + name: 'experimentalSessionAndOrigin', + errorKey: 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT', + isWarning: false, + }, ], } diff --git a/packages/data-context/__snapshots__/codegen.spec.ts.js b/packages/data-context/__snapshots__/codegen.spec.ts.js index ec8c9a3194..d1d32f441c 100644 --- a/packages/data-context/__snapshots__/codegen.spec.ts.js +++ b/packages/data-context/__snapshots__/codegen.spec.ts.js @@ -28,6 +28,7 @@ module.exports = defineConfig({ return require('./cypress/plugins/index.js')(on, config) }, baseUrl: 'localhost:3000', + experimentalSessionAndOrigin: true, }, component: { setupNodeEvents(on, config) {}, @@ -68,6 +69,7 @@ module.exports = defineConfig({ }, retries: 2, baseUrl: 'localhost:300', + experimentalSessionAndOrigin: true, slowTestThreshold: 500, }, component: { diff --git a/packages/data-context/src/sources/migration/codegen.ts b/packages/data-context/src/sources/migration/codegen.ts index 7033103aa5..feb7d8c344 100644 --- a/packages/data-context/src/sources/migration/codegen.ts +++ b/packages/data-context/src/sources/migration/codegen.ts @@ -434,6 +434,7 @@ export function reduceConfig (cfg: LegacyCypressConfigJson, options: CreateConfi e2e: { ...acc.e2e, supportFile: val }, } case 'baseUrl': + case 'experimentalSessionAndOrigin': return { ...acc, e2e: { ...acc.e2e, [key]: val }, diff --git a/packages/data-context/test/unit/sources/migration/codegen.spec.ts b/packages/data-context/test/unit/sources/migration/codegen.spec.ts index 61b68ec2f3..783a0ad25a 100644 --- a/packages/data-context/test/unit/sources/migration/codegen.spec.ts +++ b/packages/data-context/test/unit/sources/migration/codegen.spec.ts @@ -60,6 +60,7 @@ describe('cypress.config.js generation', () => { const config: Partial = { e2e: { baseUrl: 'localhost:3000', + experimentalSessionAndOrigin: true, }, } @@ -126,6 +127,7 @@ describe('cypress.config.js generation', () => { const config = { viewportWidth: 300, baseUrl: 'localhost:300', + experimentalSessionAndOrigin: true, slowTestThreshold: 500, e2e: { retries: 2, diff --git a/packages/server/test/integration/cypress_spec.js b/packages/server/test/integration/cypress_spec.js index f7031fe85c..79acb6a4c9 100644 --- a/packages/server/test/integration/cypress_spec.js +++ b/packages/server/test/integration/cypress_spec.js @@ -1653,9 +1653,9 @@ describe('lib/cypress', () => { // this should be overriden by the env argument json.baseUrl = 'http://localhost:8080' - const { supportFile, specPattern, excludeSpecPattern, baseUrl, slowTestThreshold, ...rest } = json + const { supportFile, specPattern, excludeSpecPattern, baseUrl, experimentalSessionAndOrigin, slowTestThreshold, ...rest } = json - return settings.writeForTesting(this.todosPath, { ...rest, e2e: { baseUrl, supportFile, specPattern, excludeSpecPattern } }) + return settings.writeForTesting(this.todosPath, { ...rest, e2e: { baseUrl, experimentalSessionAndOrigin, supportFile, specPattern, excludeSpecPattern } }) }).then(() => { return cypress.start([ '--port=2121', @@ -1684,6 +1684,7 @@ describe('lib/cypress', () => { expect(cfg.pageLoadTimeout).to.eq(1000) expect(cfg.port).to.eq(2121) expect(cfg.baseUrl).to.eq('http://localhost') + expect(cfg.experimentalSessionAndOrigin).to.be.false expect(cfg.watchForFileChanges).to.be.false expect(cfg.responseTimeout).to.eq(5555) expect(cfg.env.baz).to.eq('baz') diff --git a/system-tests/__snapshots__/config_spec.js b/system-tests/__snapshots__/config_spec.js index 7c676a3d97..5016701848 100644 --- a/system-tests/__snapshots__/config_spec.js +++ b/system-tests/__snapshots__/config_spec.js @@ -408,3 +408,18 @@ Please remove this option or add this as a component testing type property: comp https://on.cypress.io/migration-guide ` + +exports['e2e config throws an error if experimentalSessionAndOrigin is set on the component level 1'] = ` +The component.experimentalSessionAndOrigin configuration option is not valid for component testing. + +Please remove this option or add this as an e2e testing type property: e2e.experimentalSessionAndOrigin + +{ + e2e: { + experimentalSessionAndOrigin: '...', + } +} + +https://on.cypress.io/migration-guide + +` diff --git a/system-tests/projects/invalid-root-level-config/invalid-component-experimentalSessionAndOrigin-config.js b/system-tests/projects/invalid-root-level-config/invalid-component-experimentalSessionAndOrigin-config.js new file mode 100644 index 0000000000..2070a526c1 --- /dev/null +++ b/system-tests/projects/invalid-root-level-config/invalid-component-experimentalSessionAndOrigin-config.js @@ -0,0 +1,5 @@ +module.exports = { + component: { + experimentalSessionAndOrigin: true, + }, +} diff --git a/system-tests/projects/migration/cypress.json b/system-tests/projects/migration/cypress.json index 59a877e946..40f795147a 100644 --- a/system-tests/projects/migration/cypress.json +++ b/system-tests/projects/migration/cypress.json @@ -6,6 +6,7 @@ "componentFolder": "src", "testFiles": "**/*.spec.{tsx,js}", "pluginsFile": "cypress/plugins/index.js", + "experimentalSessionAndOrigin": true, "e2e": { "defaultCommandTimeout": 10000, "slowTestThreshold": 5000 diff --git a/system-tests/projects/migration/expected-cypress.config.js b/system-tests/projects/migration/expected-cypress.config.js index 0baad99c3c..8f03e935d4 100644 --- a/system-tests/projects/migration/expected-cypress.config.js +++ b/system-tests/projects/migration/expected-cypress.config.js @@ -15,6 +15,7 @@ module.exports = defineConfig({ slowTestThreshold: 5000, baseUrl: 'http://localhost:3000', specPattern: 'cypress/e2e/**/*.spec.{tsx,js}', + experimentalSessionAndOrigin: true, }, component: { setupNodeEvents (on, config) {}, diff --git a/system-tests/projects/runner-session-e2e-specs/cypress.config.js b/system-tests/projects/runner-session-e2e-specs/cypress.config.js new file mode 100644 index 0000000000..0f7fa65a14 --- /dev/null +++ b/system-tests/projects/runner-session-e2e-specs/cypress.config.js @@ -0,0 +1,8 @@ +module.exports = { + numTestsKeptInMemory: 0, + video: false, + e2e: { + supportFile: false, + experimentalSessionAndOrigin: true, + }, +} diff --git a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/blank_session.cy.js b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/blank_session.cy.js similarity index 58% rename from system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/blank_session.cy.js rename to system-tests/projects/runner-session-e2e-specs/cypress/e2e/blank_session.cy.js index 1e8bede8ba..dbf88726b8 100644 --- a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/blank_session.cy.js +++ b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/blank_session.cy.js @@ -1,5 +1,3 @@ -Cypress.config('experimentalSessionAndOrigin', true) - it('t1', () => { cy.session('blank_session', () => {}) assert(true) diff --git a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/multiple_sessions.cy.js b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/multiple_sessions.cy.js similarity index 78% rename from system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/multiple_sessions.cy.js rename to system-tests/projects/runner-session-e2e-specs/cypress/e2e/multiple_sessions.cy.js index 9ccde27c40..347eab320d 100644 --- a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/multiple_sessions.cy.js +++ b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/multiple_sessions.cy.js @@ -1,5 +1,3 @@ -Cypress.config('experimentalSessionAndOrigin', true) - it('t1', () => { cy.session('user1', () => { window.localStorage.foo = 'val' diff --git a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/new_session.cy.js b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/new_session.cy.js similarity index 69% rename from system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/new_session.cy.js rename to system-tests/projects/runner-session-e2e-specs/cypress/e2e/new_session.cy.js index 490a5fda26..c8acc81bfe 100644 --- a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/new_session.cy.js +++ b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/new_session.cy.js @@ -1,5 +1,3 @@ -Cypress.config('experimentalSessionAndOrigin', true) - it('t1', () => { const setupFn = cy.stub().as('runSetup') diff --git a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/new_session_and_fails_validation.cy.js b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/new_session_and_fails_validation.cy.js similarity index 78% rename from system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/new_session_and_fails_validation.cy.js rename to system-tests/projects/runner-session-e2e-specs/cypress/e2e/new_session_and_fails_validation.cy.js index 86ed76fc9b..27db500fa4 100644 --- a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/new_session_and_fails_validation.cy.js +++ b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/new_session_and_fails_validation.cy.js @@ -1,5 +1,3 @@ -Cypress.config('experimentalSessionAndOrigin', true) - it('t1', () => { const setupFn = cy.stub().as('runSetup') const validateFn = cy.stub().returns(false).as('runValidation') diff --git a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/new_session_with_validation.cy.js b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/new_session_with_validation.cy.js similarity index 79% rename from system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/new_session_with_validation.cy.js rename to system-tests/projects/runner-session-e2e-specs/cypress/e2e/new_session_with_validation.cy.js index 41c80d286c..9e16375511 100644 --- a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/new_session_with_validation.cy.js +++ b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/new_session_with_validation.cy.js @@ -1,5 +1,3 @@ -Cypress.config('experimentalSessionAndOrigin', true) - it('t1', () => { const setupFn = cy.stub().as('runSetup') const validateFn = cy.stub().as('runValidation') diff --git a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/recreated_session.cy.js b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/recreated_session.cy.js similarity index 89% rename from system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/recreated_session.cy.js rename to system-tests/projects/runner-session-e2e-specs/cypress/e2e/recreated_session.cy.js index f8e4785930..16fbebc804 100644 --- a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/recreated_session.cy.js +++ b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/recreated_session.cy.js @@ -1,5 +1,3 @@ -Cypress.config('experimentalSessionAndOrigin', true) - const stub = Cypress.sinon.stub().callsFake(() => { // The validation for t3 will fail, causing the // session to be recreated (rather than load from saved) diff --git a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/recreates_session.cy.js b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/recreates_session.cy.js similarity index 88% rename from system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/recreates_session.cy.js rename to system-tests/projects/runner-session-e2e-specs/cypress/e2e/recreates_session.cy.js index 7473e77703..3a5389920b 100644 --- a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/recreates_session.cy.js +++ b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/recreates_session.cy.js @@ -1,8 +1,6 @@ let setupFn let validateFn -Cypress.config('experimentalSessionAndOrigin', true) - before(() => { setupFn = cy.stub().as('runSetup') validateFn = cy.stub().callsFake(() => { diff --git a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/recreates_session_and_fails_validation.cy.js b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/recreates_session_and_fails_validation.cy.js similarity index 88% rename from system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/recreates_session_and_fails_validation.cy.js rename to system-tests/projects/runner-session-e2e-specs/cypress/e2e/recreates_session_and_fails_validation.cy.js index 25b5de76ca..11201aa6b3 100644 --- a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/recreates_session_and_fails_validation.cy.js +++ b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/recreates_session_and_fails_validation.cy.js @@ -1,8 +1,6 @@ let setupFn let validateFn -Cypress.config('experimentalSessionAndOrigin', true) - before(() => { setupFn = cy.stub().as('runSetup') validateFn = cy.stub().callsFake(() => { diff --git a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/restores_saved_session.cy.js b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/restores_saved_session.cy.js similarity index 86% rename from system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/restores_saved_session.cy.js rename to system-tests/projects/runner-session-e2e-specs/cypress/e2e/restores_saved_session.cy.js index c5ffb5a819..4640c687c0 100644 --- a/system-tests/projects/runner-e2e-specs/cypress/e2e/sessions/restores_saved_session.cy.js +++ b/system-tests/projects/runner-session-e2e-specs/cypress/e2e/restores_saved_session.cy.js @@ -1,8 +1,6 @@ let setupFn let validateFn -Cypress.config('experimentalSessionAndOrigin', true) - before(() => { setupFn = cy.stub().as('runSetup') validateFn = cy.stub().as('runValidation') diff --git a/system-tests/test/config_spec.js b/system-tests/test/config_spec.js index 511a2e25da..17bf745d0a 100644 --- a/system-tests/test/config_spec.js +++ b/system-tests/test/config_spec.js @@ -170,6 +170,18 @@ describe('e2e config', () => { }) }) + it('throws an error if experimentalSessionAndOrigin is set on the component level', async function () { + await Fixtures.scaffoldProject('invalid-root-level-config') + + return systemTests.exec(this, { + project: 'invalid-root-level-config', + configFile: 'invalid-component-experimentalSessionAndOrigin-config.js', + testingType: 'component', + expectedExitCode: 1, + snapshot: true, + }) + }) + it('throws an error if indexHtml is set on the root level', async function () { await Fixtures.scaffoldProject('invalid-root-level-config')