Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
213454b
fix: make error on integration folder point to e2e
elevatebart Mar 30, 2022
3c36a19
fix: add context for testing type to the errors
elevatebart Mar 30, 2022
6e696e0
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Mar 31, 2022
bd41322
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 4, 2022
7465696
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 8, 2022
ce4efb1
fix: pass testnigtype to errors
elevatebart Apr 9, 2022
d0a2af4
add testingType where needed
elevatebart Apr 9, 2022
855140c
show setupNodeEvent when error
elevatebart Apr 9, 2022
10c2cd1
fix some unit tests
elevatebart Apr 9, 2022
a6c6b66
update snapshot
elevatebart Apr 9, 2022
65509e3
update snapshot
elevatebart Apr 9, 2022
a4c4fdc
test: add test for stupNodeEvents
elevatebart Apr 11, 2022
f29ea89
fix: add name for config error
elevatebart Apr 11, 2022
76819e5
fix: use distinct errors for root and e2e failures
elevatebart Apr 11, 2022
01d5907
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 11, 2022
7404dc4
test: update 2 snapshots
elevatebart Apr 11, 2022
4401169
snapshot update again
elevatebart Apr 11, 2022
3d56fd1
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 11, 2022
53d4d52
update snapshots again normally this time
elevatebart Apr 11, 2022
cac9de3
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 12, 2022
4393a9e
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 12, 2022
dafa48a
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 13, 2022
fceb83e
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 13, 2022
45f73d6
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 13, 2022
896db64
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 14, 2022
bfd8e6f
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 14, 2022
c42b3d3
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 14, 2022
db37d07
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 14, 2022
7ea279d
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 15, 2022
16262fe
Merge branch '10.0-release' into elevatebart/fix/plugins-config-error…
Apr 15, 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
6 changes: 3 additions & 3 deletions packages/config/__snapshots__/index.spec.ts.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [
"blacklistHosts",
"componentFolder",
"integrationFolder",
"testFiles",
"ignoreTestFiles",
"pluginsFile",
"experimentalComponentTesting",
"blacklistHosts",
"experimentalGetCookiesSameSite",
"experimentalNetworkStubbing",
"experimentalRunEvents",
"experimentalShadowDomSupport",
"experimentalStudio",
"firefoxGcInterval",
"nodeVersion",
"nodeVersion",
"pluginsFile"
"nodeVersion"
]

exports['src/index .getDefaultValues returns list of public config keys 1'] = {
Expand Down
16 changes: 10 additions & 6 deletions packages/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'lodash'
import Debug from 'debug'
import { defaultSpecPattern, options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions, additionalOptionsToResolveConfig } from './options'
import type { BreakingOption, BreakingOptionErrorKey } from './options'
import type { TestingType } from '@packages/types'

// this export has to be done in 2 lines because of a bug in babel typescript
import * as validation from './validation'
Expand Down Expand Up @@ -43,14 +44,15 @@ export type BreakingErrResult = {
newName?: string
value?: any
configFile: string
testingType?: TestingType
}

type ErrorHandler = (
key: BreakingOptionErrorKey,
options: BreakingErrResult
) => void

const validateNoBreakingOptions = (breakingCfgOptions: BreakingOption[], cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => {
const validateNoBreakingOptions = (breakingCfgOptions: BreakingOption[], cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler, testingType?: TestingType) => {
breakingCfgOptions.forEach(({ name, errorKey, newName, isWarning, value }) => {
if (_.has(cfg, name)) {
if (value && cfg[name] !== value) {
Expand All @@ -71,6 +73,7 @@ const validateNoBreakingOptions = (breakingCfgOptions: BreakingOption[], cfg: an
newName,
value,
configFile: cfg.configFile,
testingType,
})
}

Expand All @@ -79,6 +82,7 @@ const validateNoBreakingOptions = (breakingCfgOptions: BreakingOption[], cfg: an
newName,
value,
configFile: cfg.configFile,
testingType,
})
}
})
Expand Down Expand Up @@ -145,12 +149,12 @@ export const validate = (cfg: any, onErr: (property: string) => void) => {
})
}

export const validateNoBreakingConfigRoot = (cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => {
return validateNoBreakingOptions(breakingRootOptions, cfg, onWarning, onErr)
export const validateNoBreakingConfigRoot = (cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler, testingType: TestingType) => {
return validateNoBreakingOptions(breakingRootOptions, cfg, onWarning, onErr, testingType)
}

export const validateNoBreakingConfig = (cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => {
return validateNoBreakingOptions(breakingOptions, cfg, onWarning, onErr)
export const validateNoBreakingConfig = (cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler, testingType: TestingType) => {
return validateNoBreakingOptions(breakingOptions, cfg, onWarning, onErr, testingType)
}

export const validateNoBreakingConfigLaunchpad = (cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => {
Expand All @@ -160,7 +164,7 @@ export const validateNoBreakingConfigLaunchpad = (cfg: any, onWarning: ErrorHand
export const validateNoBreakingTestingTypeConfig = (cfg: any, testingType: keyof typeof testingTypeBreakingOptions, onWarning: ErrorHandler, onErr: ErrorHandler) => {
const options = testingTypeBreakingOptions[testingType]

return validateNoBreakingOptions(options, cfg, onWarning, onErr)
return validateNoBreakingOptions(options, cfg, onWarning, onErr, testingType)
}

export const validateNoReadOnlyConfig = (config: any, onErr: (property: string) => void) => {
Expand Down
16 changes: 9 additions & 7 deletions packages/config/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,6 @@ export const additionalOptionsToResolveConfig = [
*/
export const breakingOptions: Array<BreakingOption> = [
{
name: 'blacklistHosts',
errorKey: 'RENAMED_CONFIG_OPTION',
newName: 'blockHosts',
}, {
name: 'componentFolder',
errorKey: 'COMPONENT_FOLDER_REMOVED',
isWarning: false,
Expand All @@ -564,10 +560,19 @@ export const breakingOptions: Array<BreakingOption> = [
errorKey: 'TEST_FILES_RENAMED',
newName: 'excludeSpecPattern',
isWarning: false,
}, {
name: 'pluginsFile',
errorKey: 'PLUGINS_FILE_CONFIG_OPTION_REMOVED',
isWarning: false,
}, {
name: 'experimentalComponentTesting',
errorKey: 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED',
isWarning: false,
}, {
name: 'blacklistHosts',
errorKey: 'RENAMED_CONFIG_OPTION',
newName: 'blockHosts',
isWarning: false,
}, {
name: 'experimentalGetCookiesSameSite',
errorKey: 'EXPERIMENTAL_SAMESITE_REMOVED',
Expand Down Expand Up @@ -603,9 +608,6 @@ export const breakingOptions: Array<BreakingOption> = [
value: 'bundled',
errorKey: 'NODE_VERSION_DEPRECATION_BUNDLED',
isWarning: true,
}, {
name: 'pluginsFile',
errorKey: 'PLUGINS_FILE_CONFIG_OPTION_REMOVED',
},
]

Expand Down
7 changes: 5 additions & 2 deletions packages/config/test/unit/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ describe('src/index', () => {
configUtil.validateNoBreakingConfig({
'experimentalNetworkStubbing': 'should break',
configFile: 'config.js',
}, warningFn, errorFn)
}, warningFn, errorFn, 'e2e')

expect(warningFn).to.have.been.calledOnceWith('EXPERIMENTAL_NETWORK_STUBBING_REMOVED', {
name: 'experimentalNetworkStubbing',
newName: undefined,
value: undefined,
testingType: 'e2e',
configFile: 'config.js',
})

Expand All @@ -153,13 +154,14 @@ describe('src/index', () => {
configUtil.validateNoBreakingConfig({
'blacklistHosts': 'should break',
configFile: 'config.js',
}, warningFn, errorFn)
}, warningFn, errorFn, 'e2e')

expect(warningFn).to.have.been.callCount(0)
expect(errorFn).to.have.been.calledOnceWith('RENAMED_CONFIG_OPTION', {
name: 'blacklistHosts',
newName: 'blockHosts',
value: undefined,
testingType: 'e2e',
configFile: 'config.js',
})
})
Expand All @@ -179,6 +181,7 @@ describe('src/index', () => {
name: 'experimentalStudio',
newName: undefined,
value: undefined,
testingType: undefined,
configFile: 'config.js',
})

Expand Down
7 changes: 4 additions & 3 deletions packages/data-context/src/data/ProjectConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class ProjectConfigManager {
const cypressEnv = await this.loadCypressEnvFile()
const fullConfig = await this.buildBaseFullConfig(loadConfigReply.initialConfig, cypressEnv, this.options.ctx.modeOptions)

const finalConfig = this._cachedFullConfig = this.options.ctx._apis.configApi.updateWithPluginValues(fullConfig, result.setupConfig ?? {})
const finalConfig = this._cachedFullConfig = this.options.ctx._apis.configApi.updateWithPluginValues(fullConfig, result.setupConfig ?? {}, this._testingType ?? 'e2e')

await this.options.onFinalConfigLoaded(finalConfig)

Expand Down Expand Up @@ -332,7 +332,7 @@ export class ProjectConfigManager {
return w
}

private validateConfigRoot (config: Cypress.ConfigOptions) {
private validateConfigRoot (config: Cypress.ConfigOptions, testingType: TestingType) {
return validateNoBreakingConfigRoot(
config,
(type, obj) => {
Expand All @@ -341,6 +341,7 @@ export class ProjectConfigManager {
(type, obj) => {
throw getError(type, obj)
},
testingType,
)
}

Expand All @@ -359,7 +360,7 @@ export class ProjectConfigManager {

private async buildBaseFullConfig (configFileContents: Cypress.ConfigOptions, envFile: Cypress.ConfigOptions, options: Partial<AllModeOptions>, withBrowsers = true) {
assert(this._testingType, 'Cannot build base full config without a testing type')
this.validateConfigRoot(configFileContents)
this.validateConfigRoot(configFileContents, this._testingType)

const testingTypeOverrides = configFileContents[this._testingType] ?? {}
const optionsOverrides = options.config?.[this._testingType] ?? {}
Expand Down
2 changes: 1 addition & 1 deletion packages/data-context/src/data/ProjectLifecycleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface InjectedConfigApi {
cypressVersion: string
validateConfig<T extends Cypress.ConfigOptions>(config: Partial<T>, onErr: (errMsg: ConfigValidationFailureInfo | string) => never): T
allowedConfig(config: Cypress.ConfigOptions): Cypress.ConfigOptions
updateWithPluginValues(config: FullConfig, modifiedConfig: Partial<Cypress.ConfigOptions>): FullConfig
updateWithPluginValues(config: FullConfig, modifiedConfig: Partial<Cypress.ConfigOptions>, testingType: TestingType): FullConfig
setupFullConfigWithDefaults(config: SetupFullConfigOptions): Promise<FullConfig>
}

Expand Down

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.

8 changes: 2 additions & 6 deletions packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 28 additions & 16 deletions packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1409,20 +1409,32 @@ export const AllCypressErrors = {
const stackTrace = err ? fmt.stackTrace(err) : null

const newName = errShape.newName || '<unknown>'
const code = errPartial`
{
e2e: {
specPattern: '...',
},
component: {
specPattern: '...',
},
}`

return errTemplate`\
The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}.

It is now renamed to ${fmt.highlight(newName)} and configured separately as a testing type property: ${fmt.highlightSecondary(`e2e.${newName}`)} and ${fmt.highlightSecondary(`component.${newName}`)}
const testingTypedHelpMessage = errShape.testingType
? errPartial`${fmt.highlightSecondary(`${errShape.testingType}.${newName}`)}`
: errPartial`${fmt.highlightSecondary(`e2e.${newName}`)} or ${fmt.highlightSecondary(`component.${newName}`)}`

const code = errShape.testingType
? errPartial`
{
${fmt.off(errShape.testingType)}: {
specPattern: '...',
},
}`
: errPartial`
{
e2e: {
specPattern: '...',
},
component: {
specPattern: '...',
},
}`

return errTemplate`\
The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}.

It is now renamed to ${fmt.highlight(newName)} and configured separately as a testing type property: ${testingTypedHelpMessage}
${fmt.code(code)}

https://on.cypress.io/migration-guide
Expand All @@ -1442,7 +1454,7 @@ export const AllCypressErrors = {
}`

return errTemplate`\
The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}.
The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}.

It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a component testing property: ${fmt.highlightSecondary('component.specPattern')}
${fmt.code(code)}
Expand All @@ -1464,9 +1476,9 @@ export const AllCypressErrors = {
}`

return errTemplate`\
The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}.
The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}.

It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a component testing property: ${fmt.highlightSecondary('component.specPattern')}
It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a end to end testing property: ${fmt.highlightSecondary('e2e.specPattern')}
${fmt.code(code)}

https://on.cypress.io/migration-guide
Expand Down
Loading