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

feat: add testIsolation option and support describe-only overrides #23040

Merged
merged 46 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
28380a5
feat: add testIsolation config option and add support for varying con…
emilyrohrbough Jul 29, 2022
8677ec7
clean up based on tests
emilyrohrbough Jul 29, 2022
174b50c
fix unit tests & types
emilyrohrbough Jul 29, 2022
3ca878d
system tests
emilyrohrbough Jul 29, 2022
819f71f
and fix
emilyrohrbough Jul 29, 2022
41fb01b
fix tests & align runTime with runtime value passed to the dashboard
emilyrohrbough Jul 31, 2022
6226550
fix snapshots
emilyrohrbough Aug 1, 2022
7b62033
add types
emilyrohrbough Aug 1, 2022
68fd5b1
Merge branch 'develop' into test-isolation-config-opt-2
emilyrohrbough Aug 1, 2022
15ec8d8
fix
emilyrohrbough Aug 1, 2022
dec1da8
Update cli/types/cypress.d.ts
emilyrohrbough Aug 2, 2022
9de9028
Merge branch 'develop' into test-isolation-config-opt-2
emilyrohrbough Aug 3, 2022
191105b
typescript changes per lachlan's review
emilyrohrbough Aug 3, 2022
92d5bc8
change testIsolation's defaultValue from default to legacy
emilyrohrbough Aug 3, 2022
fd510a9
add issues in comments and update missed default->legacy changes
emilyrohrbough Aug 3, 2022
fe3bcca
Merge branch 'develop' into test-isolation-config-opt-2
emilyrohrbough Aug 8, 2022
d0c1a0d
add missing todo
emilyrohrbough Aug 8, 2022
9848dab
break out driver config validation
emilyrohrbough Aug 8, 2022
840d2bc
whoops. fix types
emilyrohrbough Aug 8, 2022
88aa9e5
reduce specificity of event override levels
emilyrohrbough Aug 8, 2022
2c47a14
legacy -> lax
emilyrohrbough Aug 8, 2022
16125cd
nit
emilyrohrbough Aug 8, 2022
c8cd668
fix
emilyrohrbough Aug 8, 2022
c036d64
Merge branch 'develop' into test-isolation-config-opt-2
emilyrohrbough Aug 8, 2022
66c5c16
Merge branch 'develop' into test-isolation-config-opt-2
emilyrohrbough Aug 9, 2022
86f4e62
Update packages/server/test/unit/config_spec.js
emilyrohrbough Aug 10, 2022
06766ab
Update packages/server/lib/config.ts
emilyrohrbough Aug 10, 2022
5c48123
Update packages/server/test/unit/config_spec.js
emilyrohrbough Aug 10, 2022
d823396
Merge branch 'develop' into test-isolation-config-opt-2
emilyrohrbough Aug 11, 2022
7005a0e
remove err workarounds that were fixed in https://github.com/cypress…
emilyrohrbough Aug 11, 2022
f60dd05
Merge branch 'test-isolation-config-opt-2' of https://github.com/cypr…
emilyrohrbough Aug 11, 2022
9bfc380
Update packages/driver/cypress/e2e/util/config.cy.js
emilyrohrbough Aug 11, 2022
e3e5dde
Update packages/config/src/options.ts
emilyrohrbough Aug 11, 2022
aa97c9a
Update packages/driver/cypress/e2e/commands/sessions/sessions.cy.js
emilyrohrbough Aug 11, 2022
8446984
fix failing test
emilyrohrbough Aug 11, 2022
3248797
fix snapshot
emilyrohrbough Aug 11, 2022
073de5a
overruled....changing lax back to legacy
emilyrohrbough Aug 11, 2022
623ef3b
Merge branch 'develop' into test-isolation-config-opt-2
emilyrohrbough Aug 11, 2022
28a7140
fix
emilyrohrbough Aug 11, 2022
fb14105
Merge branch 'test-isolation-config-opt-2' of https://github.com/cypr…
emilyrohrbough Aug 11, 2022
2b94621
change code -> fileLoad
emilyrohrbough Aug 11, 2022
586ca74
okayyyy another round of feedback applied
emilyrohrbough Aug 11, 2022
9449f40
Update cli/types/cypress.d.ts
emilyrohrbough Aug 12, 2022
368ff71
Merge branch 'develop' into test-isolation-config-opt-2
emilyrohrbough Aug 12, 2022
f34fdb3
Update packages/server/lib/util/spec_writer.ts
emilyrohrbough Aug 12, 2022
2291a29
Merge branch 'develop' into test-isolation-config-opt-2
emilyrohrbough Aug 12, 2022
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
11 changes: 7 additions & 4 deletions packages/config/__snapshots__/index.spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys 1
"supportFile": "cypress/support/e2e.{js,jsx,ts,tsx}",
"supportFolder": false,
"taskTimeout": 60000,
"testIsolation": "default",
"trashAssetsBeforeRuns": true,
"userAgent": null,
"video": true,
Expand All @@ -77,6 +78,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys 1
"viewportWidth": 1000,
"waitForAnimations": true,
"watchForFileChanges": true,
"specPattern": "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}",
"additionalIgnorePattern": [],
"autoOpen": false,
"browsers": [],
Expand Down Expand Up @@ -146,6 +148,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys f
"supportFile": "cypress/support/e2e.{js,jsx,ts,tsx}",
"supportFolder": false,
"taskTimeout": 60000,
"testIsolation": "default",
"trashAssetsBeforeRuns": true,
"userAgent": null,
"video": true,
Expand All @@ -156,6 +159,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys f
"viewportWidth": 1000,
"waitForAnimations": true,
"watchForFileChanges": true,
"specPattern": "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}",
"additionalIgnorePattern": [],
"autoOpen": false,
"browsers": [],
Expand All @@ -172,8 +176,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys f
"socketId": null,
"socketIoCookie": "__socket",
"socketIoRoute": "/__socket",
"xhrRoute": "/xhrs/",
"specPattern": "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}"
"xhrRoute": "/xhrs/"
}

exports['config/src/index .getPublicConfigKeys returns list of public config keys 1'] = [
Expand Down Expand Up @@ -221,6 +224,7 @@ exports['config/src/index .getPublicConfigKeys returns list of public config key
"supportFile",
"supportFolder",
"taskTimeout",
"testIsolation",
"trashAssetsBeforeRuns",
"userAgent",
"video",
Expand All @@ -235,6 +239,5 @@ exports['config/src/index .getPublicConfigKeys returns list of public config key
"browsers",
"hosts",
"isInteractive",
"modifyObstructiveCode",
"specPattern"
"modifyObstructiveCode"
]
50 changes: 37 additions & 13 deletions packages/config/src/browser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import _ from 'lodash'
import Debug from 'debug'
import { defaultSpecPattern, options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions, additionalOptionsToResolveConfig } from './options'
import type { BreakingOption, BreakingOptionErrorKey } from './options'
import {
defaultSpecPattern,
options,
ALL_OVERRIDE_LEVELS,
breakingOptions,
breakingRootOptions,
testingTypeBreakingOptions,
} from './options'

import type { BreakingOption, BreakingOptionErrorKey, OverrideLevel, OverrideLevels } from './options'
import type { TestingType } from '@packages/types'

// this export has to be done in 2 lines because of a bug in babel typescript
Expand All @@ -21,10 +29,12 @@ const debug = Debug('cypress:config:browser')
const dashesOrUnderscoresRe = /^(_-)+/

// takes an array and creates an index object of [keyKey]: [valueKey]
function createIndex<T extends Record<string, any>> (arr: Array<T>, keyKey: keyof T, valueKey: keyof T) {
function createIndex<T extends Record<string, any>> (arr: Array<T>, keyKey: keyof T, valueKey: keyof T, defaultValueFallback?: any) {
return _.reduce(arr, (memo: Record<string, any>, item) => {
if (item[valueKey] !== undefined) {
memo[item[keyKey] as string] = item[valueKey]
} else {
memo[item[keyKey] as string] = defaultValueFallback
emilyrohrbough marked this conversation as resolved.
Show resolved Hide resolved
}

return memo
Expand All @@ -33,13 +43,19 @@ function createIndex<T extends Record<string, any>> (arr: Array<T>, keyKey: keyo

const breakingKeys = _.map(breakingOptions, 'name')
const defaultValues = createIndex(options, 'name', 'defaultValue')
const publicConfigKeys = _([...options, ...additionalOptionsToResolveConfig]).reject({ isInternal: true }).map('name').value()
const publicConfigKeys = _(options).reject({ isInternal: true }).map('name').value()
const validationRules = createIndex(options, 'name', 'validation')
const testConfigOverrideOptions = createIndex(options, 'name', 'canUpdateDuringTestTime')
const testOverrideLevels = createIndex(options, 'name', 'overrideLevels', 'never')
const restartOnChangeOptionsKeys = _.filter(options, 'requireRestartOnChange')

const issuedWarnings = new Set()

export type InvalidTestOverrideResult = {
invalidConfigKey: string
overrideLevel: string
supportedOverrideLevels: OverrideLevels
}

export type BreakingErrResult = {
name: string
newName?: string
Expand Down Expand Up @@ -172,16 +188,24 @@ export const validateNoBreakingTestingTypeConfig = (cfg: any, testingType: keyof
return validateNoBreakingOptions(options, cfg, onWarning, onErr, testingType)
}

export const validateNoReadOnlyConfig = (config: any, onErr: (property: string) => void) => {
let errProperty
export const validateOverridableAtTestTest = (config: any, overrideLevel: Exclude<OverrideLevel, 'never'>, onErr: (result: InvalidTestOverrideResult) => void) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const validateOverridableAtTestTest = (config: any, overrideLevel: Exclude<OverrideLevel, 'never'>, onErr: (result: InvalidTestOverrideResult) => void) => {
export const validateOverridableAtTestTime = (config: any, overrideLevel: Exclude<OverrideLevel, 'never'>, onErr: (result: InvalidTestOverrideResult) => void) => {

Or validateOverridableAtRuntime?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes. good call out. I wanted to call this testTime, since that's what it in in my head, but I went with runtime to align with the resolve level of 'runtime' we use to pass to the cloud

Object.keys(config).some((configKey) => {
const runtimeValidation = ALL_OVERRIDE_LEVELS.includes(overrideLevel)
const overrideLevels = testOverrideLevels[configKey] as OverrideLevels

Object.keys(config).some((option) => {
return errProperty = testConfigOverrideOptions[option] === false ? option : undefined
})
if (!overrideLevels) {
// non-cypress configuration option. skip validation
return
}

if (errProperty) {
return onErr(errProperty)
}
if (runtimeValidation && (overrideLevels === 'never' || !overrideLevels.includes(overrideLevel))) {
onErr({
invalidConfigKey: configKey,
overrideLevel,
supportedOverrideLevels: overrideLevels,
})
}
})
}

export const validateNeedToRestartOnChange = (cachedConfig: any, updatedConfig: any) => {
Expand Down
Loading