Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

_Released 11/18/2025 (PENDING)_

**Features:**

- The `experimentalRunAllSpecs` option can now be used for component testing as well as e2e testing. Addresses [#25636](https://github.com/cypress-io/cypress/issues/25636).

**Bugfixes:**

- Fixed an issue where top changes on test retries could cause attempt numbers to show up more than one time in the reporter and cause attempts to be lost in Test Replay. Addressed in [#32888](https://github.com/cypress-io/cypress/pull/32888).
Expand Down
50 changes: 36 additions & 14 deletions npm/vite-dev-server/client/initCypressTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,42 @@ if (supportFile) {
})
}

// Using relative path wouldn't allow to load tests outside Vite project root folder
// So we use the "@fs" bit to load the test file using its absolute path
// Normalize path to not include a leading slash (different on Win32 vs Unix)
const normalizedAbsolutePath = CypressInstance.spec.absolute.replace(/^\//, '')
const testFileAbsolutePathRoute = `${devServerPublicPathBase}/@fs/${normalizedAbsolutePath}`

/* Spec file import logic */
// We need a slash before /src/my-spec.js, this does not happen by default.
importsToLoad.push({
load: () => import(testFileAbsolutePathRoute),
absolute: CypressInstance.spec.absolute,
relative: CypressInstance.spec.relative,
relativeUrl: testFileAbsolutePathRoute,
})
const specPath = new URLSearchParams(document.location.search).get('specPath')

if (specPath === '__all' || CypressInstance.spec.relative === '__all') {
const runAllSpecs = window.parent.__RUN_ALL_SPECS__ || []
const allSpecs = window.parent.__RUN_MODE_SPECS__ || []

runAllSpecs.forEach((specRelative) => {
const specObj = allSpecs.find((s) => s.relative === specRelative)

if (specObj) {
const normalizedPath = specObj.absolute.replace(/^\//, '')
const specRoute = `${devServerPublicPathBase}/@fs/${normalizedPath}`

importsToLoad.push({
load: () => import(specRoute),
absolute: specObj.absolute,
relative: specObj.relative,
relativeUrl: specRoute,
})
}
})
} else {
// Using relative path wouldn't allow to load tests outside Vite project root folder
// So we use the "@fs" bit to load the test file using its absolute path
// Normalize path to not include a leading slash (different on Win32 vs Unix)
const normalizedAbsolutePath = CypressInstance.spec.absolute.replace(/^\//, '')
const testFileAbsolutePathRoute = `${devServerPublicPathBase}/@fs/${normalizedAbsolutePath}`

// We need a slash before /src/my-spec.js, this does not happen by default.
importsToLoad.push({
load: () => import(testFileAbsolutePathRoute),
absolute: CypressInstance.spec.absolute,
relative: CypressInstance.spec.relative,
relativeUrl: testFileAbsolutePathRoute,
})
}

if (!CypressInstance) {
throw new Error('Tests cannot run without a reference to Cypress!')
Expand Down
5 changes: 4 additions & 1 deletion npm/webpack-dev-server/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const makeImport = (file: Cypress.Cypress['spec'], filename: string, chunkName:
const magicComments = chunkName ? `/* webpackChunkName: "${chunkName}" */` : ''

return `"${filename}": {
shouldLoad: () => new URLSearchParams(document.location.search).get("specPath") === "${file.absolute}",
shouldLoad: () => {
const specPath = new URLSearchParams(document.location.search).get("specPath")
return specPath === "__all" || specPath === "${file.absolute}"
},
load: () => import("${file.absolute}" ${magicComments}),
absolute: "${file.absolute.split(path.sep).join(path.posix.sep)}",
relative: "${file.relative.split(path.sep).join(path.posix.sep)}",
Expand Down
6 changes: 2 additions & 4 deletions packages/app/src/store/run-all-specs-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@ export const useRunAllSpecsStore = defineStore('runAllSpecs', () => {
directoryChildrenRef.value = directoryChildren
}

const query = useQuery({ query: RunAllSpecsDataDocument, pause: isRunMode || window.__CYPRESS_TESTING_TYPE__ === 'component' })
const query = useQuery({ query: RunAllSpecsDataDocument, pause: isRunMode })

const isRunAllSpecsAllowed = computed(() => {
const isE2E = query.data.value?.currentProject?.currentTestingType === 'e2e'

const config: ResolvedConfig = query.data.value?.currentProject?.config || []
const hasExperiment = config.some(({ field, value }) => field === 'experimentalRunAllSpecs' && value === true)

return (isE2E && hasExperiment)
return hasExperiment
})

return {
Expand Down
10 changes: 0 additions & 10 deletions packages/config/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,6 @@ export const breakingRootOptions: Array<BreakingOption> = [
errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG',
isWarning: false,
testingTypes: ['e2e'],
}, {
name: 'experimentalRunAllSpecs',
errorKey: 'EXPERIMENTAL_RUN_ALL_SPECS_E2E_ONLY',
isWarning: false,
testingTypes: ['e2e'],
},
{
name: 'experimentalOriginDependencies',
Expand Down Expand Up @@ -724,11 +719,6 @@ export const testingTypeBreakingOptions: { e2e: Array<BreakingOption>, component
errorKey: 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT',
isWarning: false,
},
{
name: 'experimentalRunAllSpecs',
errorKey: 'EXPERIMENTAL_RUN_ALL_SPECS_E2E_ONLY',
isWarning: false,
},
{
name: 'experimentalOriginDependencies',
errorKey: 'EXPERIMENTAL_ORIGIN_DEPENDENCIES_E2E_ONLY',
Expand Down
1 change: 0 additions & 1 deletion packages/data-context/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,6 @@ enum ErrorTypeEnum {
EXPERIMENTAL_JIT_COMPILE_REMOVED
EXPERIMENTAL_ORIGIN_DEPENDENCIES_E2E_ONLY
EXPERIMENTAL_PROMPT_COMMAND_E2E_ONLY
EXPERIMENTAL_RUN_ALL_SPECS_E2E_ONLY
EXPERIMENTAL_SESSION_AND_ORIGIN_REMOVED
EXPERIMENTAL_SINGLE_TAB_RUN_MODE
EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED
Expand Down
1 change: 1 addition & 0 deletions packages/data-context/src/sources/HtmlDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export class HtmlDataSource {
<body>
<script>
window.__RUN_MODE_SPECS__ = ${JSON.stringify(this.ctx.project.specs)}
window.__RUN_ALL_SPECS__ = ${JSON.stringify(this.ctx.project.runAllSpecs)}
window.__CYPRESS_MODE__ = ${JSON.stringify(this.ctx.isRunMode && !process.env.CYPRESS_INTERNAL_SIMULATE_OPEN_MODE ? 'run' : 'open')};
window.__CYPRESS_CONFIG__ = ${JSON.stringify(serveConfig)};
window.__CYPRESS_TESTING_TYPE__ = '${this.ctx.coreData.currentTestingType}'
Expand Down
15 changes: 0 additions & 15 deletions packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1228,21 +1228,6 @@ export const AllCypressErrors = {

You can safely remove this option from your config.`
},
EXPERIMENTAL_RUN_ALL_SPECS_E2E_ONLY: () => {
const code = errPartial`
{
e2e: {
experimentalRunAllSpecs: true
},
}`

return errTemplate`\
The ${fmt.highlight(`experimentalRunAllSpecs`)} experiment is currently only supported for End to End Testing and must be configured as an e2e testing type property: ${fmt.highlightSecondary(`e2e.experimentalRunAllSpecs`)}.

${fmt.code(code)}

If you have feedback about the experiment, please join the discussion here: http://on.cypress.io/run-all-specs`
},
EXPERIMENTAL_ORIGIN_DEPENDENCIES_E2E_ONLY: () => {
const code = errPartial`
{
Expand Down
6 changes: 0 additions & 6 deletions packages/errors/test/visualSnapshotErrors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1064,12 +1064,6 @@ describe('visual error templates', () => {
}
},

EXPERIMENTAL_RUN_ALL_SPECS_E2E_ONLY: () => {
return {
default: [],
}
},

BROWSER_UNSUPPORTED_LAUNCH_OPTION: () => {
return {
default: ['electron', ['env']],
Expand Down
34 changes: 0 additions & 34 deletions packages/launchpad/cypress/e2e/config-warning.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const THIRTY_SECONDS = 1000 * 30

describe('baseUrl', () => {
it('should show baseUrl warning if Cypress cannot connect to provided baseUrl', () => {
cy.scaffoldProject('config-with-base-url-warning')
Expand Down Expand Up @@ -90,38 +88,6 @@ describe('experimentalSingleTabRunMode', () => {
})
})

describe('experimentalRunAllSpecs', () => {
it('is a valid config for e2e testing', { defaultCommandTimeout: THIRTY_SECONDS }, () => {
cy.scaffoldProject('run-all-specs')
cy.openProject('run-all-specs')

cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.findByTestId('launchpad-Choose a browser')
cy.get('h1').contains('Choose a browser')
})

it('is not a valid config for component testing', () => {
cy.scaffoldProject('run-all-specs')
cy.openProject('run-all-specs', ['--config-file', 'cypress-invalid-component.config.js'])

cy.visitLaunchpad()
cy.get('[data-cy-testingtype="component"]').click()
cy.findByTestId('error-header')
cy.contains('The experimentalRunAllSpecs experiment is currently only supported for End to End Testing')
})

it('is not valid config when specified at root', { defaultCommandTimeout: THIRTY_SECONDS }, () => {
cy.scaffoldProject('run-all-specs')
cy.openProject('run-all-specs', ['--config-file', 'cypress-invalid-root.config.js'])

cy.visitLaunchpad()
cy.get('[data-cy-testingtype="e2e"]').click()
cy.findByTestId('error-header')
cy.contains('The experimentalRunAllSpecs experiment is currently only supported for End to End Testing')
})
})

describe('experimentalOriginDependencies', () => {
it('is a valid config for e2e testing', () => {
cy.scaffoldProject('session-and-origin-e2e-specs')
Expand Down
19 changes: 15 additions & 4 deletions packages/server/lib/socket-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { openExternal } from './gui/links'
import type { Socket } from '@packages/socket'

import type { RunState, CachedTestState, ProtocolManagerShape, AutomationCommands } from '@packages/types'
import { RUN_ALL_SPECS_KEY } from '@packages/types'
import memory from './browsers/memory'
import { privilegedCommandsManager } from './privileged-commands/privileged-commands-manager'
import type { StudioInitOptions } from './types/studio'
Expand Down Expand Up @@ -409,10 +410,20 @@ export class SocketBase {
const ctx = await getCtx()
const devServer = await ctx._apis.projectApi.getDevServer()

// update the dev server with the spec running
debug(`updating CT dev-server with spec: ${spec.relative}`)
// @ts-expect-error
await devServer.updateSpecs([spec], { neededForJustInTimeCompile: true })
if (spec.relative === RUN_ALL_SPECS_KEY) {
const specsToCompile = ctx.project.runAllSpecs.map((relPath) => {
return ctx.project.specs.find((s) => s.relative === relPath)
}).filter(Boolean) as Cypress.Spec[]

debug(`updating CT dev-server with ${specsToCompile.length} specs`)
// @ts-expect-error
await devServer.updateSpecs(specsToCompile, { neededForJustInTimeCompile: true })
} else {
// update the dev server with the spec running
debug(`updating CT dev-server with spec: ${spec.relative}`)
// @ts-expect-error
await devServer.updateSpecs([spec], { neededForJustInTimeCompile: true })
}

return socket.emit('dev-server:on-spec-updated')
})
Expand Down