Skip to content
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

chore: experimental retries cfg override #28045

Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions packages/driver/src/cy/testConfigOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ export class TestConfigOverride {
unverifiedTestConfig: [],
}

// TODO: remove when experimental overriding is supported
const experimentalRetryCfgKeys = [
'experimentalStrategy', 'experimentalOptions',
]

const experimentalRetryConfigAttempted = Object.keys(resolvedTestConfig.unverifiedTestConfig?.retries || {})
.some((v) => experimentalRetryCfgKeys.includes(v))

if (experimentalRetryConfigAttempted) {
throw new Error('Cannot set experimental retries on individual tests')
}

if (Object.keys(resolvedTestConfig.unverifiedTestConfig).length > 0) {
this.restoreTestConfigFn = mutateConfiguration(resolvedTestConfig, config, env)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
e2e: {
supportFile: false,
setupNodeEvents (on, config) {
// in the case the tests needed to be debugged:

// on('before:browser:launch', (browser, launchOptions) => {
// launchOptions.args.push('--auto-open-devtools-for-tabs')

// return launchOptions
// })
},
},
retries: {
experimentalStrategy: 'detect-flake-and-pass-on-threshold',
runMode: true,
openMode: true,
experimentalOptions: {
maxRetries: 3,
passesRequired: 1,
},
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
e2e: {
supportFile: false,
setupNodeEvents (on, config) {
// in the case the tests needed to be debugged:

// on('before:browser:launch', (browser, launchOptions) => {
// launchOptions.args.push('--auto-open-devtools-for-tabs')

// return launchOptions
// })
},
},
retries: {
runMode: 0,
openMode: 0,
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
describe('overriding legacy retries with experimental retries', () => {
const experimentalStrategy = 'detect-flake-and-pass-on-threshold'
const openMode = false
const runMode = true
const maxRetries = 3
const passesRequired = 1

describe('at the describe level', {
retries: {
experimentalStrategy,
openMode,
runMode,
experimentalOptions: {
maxRetries,
passesRequired,
},
},
}, () => {
it('sets the config', () => {
const retries = Cypress.config('retries')

expect(retries.experimentalStrategy).to.eq(experimentalStrategy)
expect(retries.experimentalOptions?.maxRetries).to.eq(maxRetries)
expect(retries.experimentalOptions?.passesRequired).to.eq(passesRequired)
expect(retries.runMode).to.eq(runMode)
expect(retries.openMode).to.eq(openMode)
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe('overriding experimental retries with legacy retries', () => {
const openMode = 1
const runMode = 3

it('sets the config', {
retries: {
openMode,
runMode,
},
}, () => {
const retries = Cypress.config('retries')

expect(retries.runMode).to.eq(runMode)
expect(retries.openMode).to.eq(openMode)
})
})
18 changes: 18 additions & 0 deletions system-tests/test/testConfigOverrides_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,22 @@ describe('testConfigOverrides', () => {
expectedExitCode: 1,
})
})

describe('experimental retries specific behavior', () => {
systemTests.it('fails when attempting to set experimental retries as override', {
spec: 'override-with-experimental-retries.cy.js',
project: 'experimental-retries',
configFile: 'cypress-legacy-retries.config.js',
expectedExitCode: 1,
browser: '!webkit',
})

systemTests.it('succeeds when setting legacy retries as an override to experimental retries', {
spec: 'override-with-legacy-retries.cy.js',
project: 'experimental-retries',
configFile: 'cypress-experimental-retries.config.js',
expectedExitCode: 0,
browser: '!webkit',
})
})
})
Loading