Skip to content

Commit 3274da7

Browse files
authored
fix: terminal error message for non migrated config (#21467)
* fix: terminal error message for non migrated config * fix: terminal error message for non migrated config
1 parent fbe6452 commit 3274da7

File tree

20 files changed

+44
-38
lines changed

20 files changed

+44
-38
lines changed

cli/__snapshots__/cli_spec.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ exports['shows help for open --foo 1'] = `
2323
--component runs component tests
2424
-c, --config <config> sets configuration values. separate multiple
2525
values with a comma. overrides any value in
26-
cypress.config.{ts|js}.
26+
cypress.config.{js,ts,mjs,cjs}.
2727
-C, --config-file <config-file> path to script file where configuration
2828
values are set. defaults to
29-
"cypress.config.{ts|js}".
29+
"cypress.config.{js,ts,mjs,cjs}".
3030
-d, --detached [bool] runs Cypress application in detached mode
3131
--e2e runs end to end tests
3232
-e, --env <env> sets environment variables. separate
3333
multiple values with a comma. overrides any
34-
value in cypress.config.{ts|js} or
34+
value in cypress.config.{js,ts,mjs,cjs} or
3535
cypress.env.json
3636
--global force Cypress into global mode as if its
3737
globally installed
3838
-p, --port <port> runs Cypress on a specific port. overrides
39-
any value in cypress.config.{ts|js}.
39+
any value in cypress.config.{js,ts,mjs,cjs}.
4040
-P, --project <project-path> path to the project
4141
--dev runs cypress in development and bypasses
4242
binary check
@@ -70,17 +70,17 @@ exports['shows help for run --foo 1'] = `
7070
-b, --browser <browser-name-or-path> runs Cypress in the browser with the given name. if a filesystem path is supplied, Cypress will attempt to use the browser at that path.
7171
--ci-build-id <id> the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers
7272
--component runs component tests
73-
-c, --config <config> sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{ts|js}.
74-
-C, --config-file <config-file> path to script file where configuration values are set. defaults to "cypress.config.{ts|js}".
73+
-c, --config <config> sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{js,ts,mjs,cjs}.
74+
-C, --config-file <config-file> path to script file where configuration values are set. defaults to "cypress.config.{js,ts,mjs,cjs}".
7575
--e2e runs end to end tests
76-
-e, --env <env> sets environment variables. separate multiple values with a comma. overrides any value in cypress.config.{ts|js} or cypress.env.json
76+
-e, --env <env> sets environment variables. separate multiple values with a comma. overrides any value in cypress.config.{js,ts,mjs,cjs} or cypress.env.json
7777
--group <name> a named group for recorded runs in the Cypress Dashboard
7878
-k, --key <record-key> your secret Record Key. you can omit this if you set a CYPRESS_RECORD_KEY environment variable.
7979
--headed displays the browser instead of running headlessly
8080
--headless hide the browser instead of running headed (default for cypress run)
8181
--no-exit keep the browser open after tests finish
8282
--parallel enables concurrent runs and automatic load balancing of specs across multiple machines or processes
83-
-p, --port <port> runs Cypress on a specific port. overrides any value in cypress.config.{ts|js}.
83+
-p, --port <port> runs Cypress on a specific port. overrides any value in cypress.config.{js,ts,mjs,cjs}.
8484
-P, --project <project-path> path to the project
8585
-q, --quiet run quietly, using only the configured reporter
8686
--record [bool] records the run. sends test results, screenshots and videos to your Cypress Dashboard.

cli/lib/cli.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ const descriptions = {
101101
cacheSize: 'Used with the list command to show the sizes of the cached folders',
102102
ciBuildId: 'the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers',
103103
component: 'runs component tests',
104-
config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{ts|js}.',
105-
configFile: 'path to script file where configuration values are set. defaults to "cypress.config.{ts|js}".',
104+
config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{js,ts,mjs,cjs}.',
105+
configFile: 'path to script file where configuration values are set. defaults to "cypress.config.{js,ts,mjs,cjs}".',
106106
detached: 'runs Cypress application in detached mode',
107107
dev: 'runs cypress in development and bypasses binary check',
108108
e2e: 'runs end to end tests',
109-
env: 'sets environment variables. separate multiple values with a comma. overrides any value in cypress.config.{ts|js} or cypress.env.json',
109+
env: 'sets environment variables. separate multiple values with a comma. overrides any value in cypress.config.{js,ts,mjs,cjs} or cypress.env.json',
110110
exit: 'keep the browser open after tests finish',
111111
forceInstall: 'force install the Cypress binary',
112112
global: 'force Cypress into global mode as if its globally installed',
@@ -115,7 +115,7 @@ const descriptions = {
115115
headless: 'hide the browser instead of running headed (default for cypress run)',
116116
key: 'your secret Record Key. you can omit this if you set a CYPRESS_RECORD_KEY environment variable.',
117117
parallel: 'enables concurrent runs and automatic load balancing of specs across multiple machines or processes',
118-
port: 'runs Cypress on a specific port. overrides any value in cypress.config.{ts|js}.',
118+
port: 'runs Cypress on a specific port. overrides any value in cypress.config.{js,ts,mjs,cjs}.',
119119
project: 'path to the project',
120120
quiet: 'run quietly, using only the configured reporter',
121121
record: 'records the run. sends test results, screenshots and videos to your Cypress Dashboard.',

cli/types/cypress-npm-api.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ declare namespace CypressCommandLine {
142142
/**
143143
* Path to the config file to be used.
144144
*
145-
* @default "cypress.config.{ts|js}"
145+
* @default "cypress.config.{js,ts,mjs,cjs}"
146146
*/
147147
configFile: string
148148
/**

cli/types/cypress.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ declare namespace Cypress {
398398

399399
// no real way to type without generics
400400
/**
401-
* Returns all environment variables set with CYPRESS_ prefix or in "env" object in "cypress.config.{ts|js}"
401+
* Returns all environment variables set with CYPRESS_ prefix or in "env" object in "cypress.config.{js,ts,mjs,cjs}"
402402
*
403403
* @see https://on.cypress.io/env
404404
*/
@@ -2855,7 +2855,7 @@ declare namespace Cypress {
28552855
retries: Nullable<number | { runMode?: Nullable<number>, openMode?: Nullable<number> }>
28562856
/**
28572857
* Enables including elements within the shadow DOM when using querying
2858-
* commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.config.{ts|js},
2858+
* commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.config.{js,ts,mjs,cjs},
28592859
* per-suite or per-test in the test configuration object, or programmatically
28602860
* with Cypress.config()
28612861
* @default false
@@ -2917,7 +2917,7 @@ declare namespace Cypress {
29172917
*/
29182918
interface RuntimeConfigOptions extends Partial<RuntimeServerConfigOptions> {
29192919
/**
2920-
* Absolute path to the config file (default: <projectRoot>/cypress.config.{ts|js})
2920+
* Absolute path to the config file (default: <projectRoot>/cypress.config.{js,ts,mjs,cjs})
29212921
*/
29222922
configFile: string
29232923
/**
@@ -3041,7 +3041,7 @@ declare namespace Cypress {
30413041
}
30423042

30433043
/**
3044-
* Config options that can be assigned on cypress.config.{ts|js} file
3044+
* Config options that can be assigned on cypress.config.{js,ts,mjs,cjs} file
30453045
*/
30463046
type UserConfigOptions<ComponentDevServerOpts = any> = Omit<ResolvedConfigOptions<ComponentDevServerOpts>, 'baseUrl' | 'excludeSpecPattern' | 'supportFile' | 'specPattern' | 'indexHtmlFile'>
30473047

npm/angular/src/app/assets-image/assets-image.component.cy.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('AssetsImageComponent', () => {
77
it.skip('should create', () => {
88
initEnv(AssetsImageComponent)
99
mount(AssetsImageComponent)
10-
// add "fileServerFolder": "src" in cypress.config.{ts|js}
10+
// add "fileServerFolder": "src" in cypress.config.{js,ts,mjs,cjs}
1111
cy.get('img#noSlash')
1212
.should('be.visible')
1313
.and(($img) => {
@@ -29,7 +29,7 @@ describe('AssetsImageComponent', () => {
2929
it.skip('should create with AppModule', () => {
3030
initEnv({ imports: [AppModule] })
3131
mount(AssetsImageComponent)
32-
// add "fileServerFolder": "src" in cypress.config.{ts|js}
32+
// add "fileServerFolder": "src" in cypress.config.{js,ts,mjs,cjs}
3333
cy.get('img#noSlash')
3434
.should('be.visible')
3535
.and(($img) => {

npm/angular/src/app/use-custom-element/use-custom-element.component.cy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
22
import { initEnv, mount } from '@cypress/angular'
33
// You have to import your custom element
4-
// And in cypress.config.{ts|js} activate "includeShadowDom" configuration
4+
// And in cypress.config.{js,ts,mjs,cjs} activate "includeShadowDom" configuration
55
import '../my-custom-element'
66
import { UseCustomElementComponent } from './use-custom-element.component'
77

npm/react/cypress/component/viewport.cy.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const viewportWidth = 200
22
const viewportHeight = 100
33

4-
describe('cypress.config.{ts|js} viewport',
4+
describe('cypress.config.{js,ts,mjs,cjs} viewport',
55
{ viewportWidth, viewportHeight },
66
() => {
77
it('should have the correct dimensions', () => {

packages/driver/src/cypress/mocha.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const setMochaProps = (specWindow, _mocha) => {
146146
// to the mocha instance for clarity
147147
m.Mocha = M
148148

149-
// this needs to be part of the configuration of cypress.config.{ts|js}
149+
// this needs to be part of the configuration of cypress.config.{js,ts,mjs,cjs}
150150
// we can't just forcibly use bdd
151151
return ui(specWindow, _mocha)
152152
}

packages/driver/src/cypress/shadow_dom_utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Order of preference for including shadow dom:
3-
* command-level > programmatic config > test-level > suite-level > cypress.config.{ts|js}
3+
* command-level > programmatic config > test-level > suite-level > cypress.config.{js,ts,mjs,cjs}
44
*/
55
export const resolveShadowDomInclusion = (Cypress: Cypress.Cypress, commandValue?: boolean): boolean => {
66
if (commandValue != null) return commandValue

packages/errors/__snapshot-html__/CONFIG_FILE_MIGRATION_NEEDED.html

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/errors/src/errors.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1183,9 +1183,11 @@ export const AllCypressErrors = {
11831183
return errTemplate`
11841184
There is a ${fmt.highlight(`cypress.json`)} file at the path: ${fmt.path(projectRoot)}
11851185
1186-
${fmt.cypressVersion('10.0.0')} no longer supports cypress.json.
1186+
${fmt.cypressVersion('10.0.0')} no longer supports ${fmt.highlight(`cypress.json`)}.
11871187
1188-
Please run ${fmt.highlightTertiary('cypress open')} to launch the migration tool to migrate to ${fmt.highlightSecondary('cypress.config.{ts|js}')}.
1188+
Please run ${fmt.highlightTertiary('cypress open')} to launch the migration tool to migrate to ${fmt.highlightSecondary('cypress.config.{js,ts,mjs,cjs}')}.
1189+
1190+
https://on.cypress.io/migration-guide
11891191
`
11901192
},
11911193

packages/graphql/schemas/schema.graphql

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ enum CodeLanguageEnum {
369369
}
370370

371371
"""
372-
The currently opened Cypress project, represented by a cypress.config.{ts|js} file
372+
The currently opened Cypress project, represented by a cypress.config.{js,ts,mjs,cjs} file
373373
"""
374374
type CurrentProject implements Node & ProjectLike {
375375
"""The currently selected browser for the project"""

packages/graphql/src/schemaTypes/objectTypes/gql-CurrentProject.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const PackageManagerEnum = enumType({
1515

1616
export const CurrentProject = objectType({
1717
name: 'CurrentProject',
18-
description: 'The currently opened Cypress project, represented by a cypress.config.{ts|js} file',
18+
description: 'The currently opened Cypress project, represented by a cypress.config.{js,ts,mjs,cjs} file',
1919
node: 'projectRoot',
2020
definition (t) {
2121
t.implements('ProjectLike')

packages/server/lib/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ export function parseEnv (cfg: Record<string, any>, envCLI: Record<string, any>,
586586
resolveFrom('env', envProc)
587587
resolveFrom('cli', envCLI)
588588

589-
// envCfg is from cypress.config.{ts|js}
589+
// envCfg is from cypress.config.{js,ts,mjs,cjs}
590590
// envFile is from cypress.env.json
591591
// envProc is from process env vars
592592
// envCLI is from CLI arguments

packages/server/lib/project-base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ export class ProjectBase<TServer extends Server> extends EE {
472472
return this._cfg
473473
}
474474

475-
// returns project config (user settings + defaults + cypress.config.{ts|js})
475+
// returns project config (user settings + defaults + cypress.config.{js,ts,mjs,cjs})
476476
// with additional object "state" which are transient things like
477477
// window width and height, DevTools open or not, etc.
478478
getConfig (): Cfg {

packages/server/lib/server-base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export abstract class ServerBase<TSocket extends SocketE2E | SocketCt> {
249249
const { morgan, clientRoute, namespace } = config
250250
const app = express()
251251

252-
// set the cypress config from the cypress.config.{ts|js} file
252+
// set the cypress config from the cypress.config.{js,ts,mjs,cjs} file
253253
app.set('view engine', 'html')
254254

255255
// since we use absolute paths, configure express-handlebars to not automatically find layouts

packages/server/test/unit/config_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe('lib/config', () => {
159159
it.skip('validates cypress.config.js', function () {
160160
this.setup({ reporter: 5 })
161161

162-
return this.expectValidationFails('cypress.config.{ts|js}')
162+
return this.expectValidationFails('cypress.config.{js,ts,mjs,cjs}')
163163
})
164164

165165
// NOTE: Validated in real use

packages/types/src/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export interface OpenProjectLaunchOptions {
6565
// spec pattern to use when launching from CLI
6666
spec?: string
6767

68-
// Callback to reload the Desktop GUI when cypress.config.{ts|js} is changed.
68+
// Callback to reload the Desktop GUI when cypress.config.{js,ts,mjs,cjs} is changed.
6969
onSettingsChanged?: false | (() => void)
7070
browsers?: FoundBrowser[]
7171

system-tests/__snapshots__/config_spec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,14 @@ There is a cypress.json file at the path: /foo/bar/.projects/pristine
187187
188188
Cypress version 10.0.0 no longer supports cypress.json.
189189
190-
Please run cypress open to launch the migration tool to migrate to cypress.config.{ts|js}.
190+
Please run cypress open to launch the migration tool to migrate to cypress.config.{js,ts,mjs,cjs}.
191+
192+
https://on.cypress.io/migration-guide
191193
192194
193195
`
194196

195-
exports['e2e config throws error when cypress.json is found in project and cypress.config.{ts|js} exists as well 1'] = `
197+
exports['e2e config throws error when cypress.json is found in project and cypress.config.{js,ts,mjs,cjs} exists as well 1'] = `
196198
There is both a cypress.config.js and a cypress.json file at the location below:
197199
198200
/foo/bar/.projects/multiple-config-files-with-json

system-tests/test/config_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('e2e config', () => {
104104
})
105105
})
106106

107-
it('throws error when cypress.json is found in project and cypress.config.{ts|js} exists as well', async function () {
107+
it('throws error when cypress.json is found in project and cypress.config.{js,ts,mjs,cjs} exists as well', async function () {
108108
await Fixtures.scaffoldProject('multiple-config-files-with-json')
109109

110110
return systemTests.exec(this, {

0 commit comments

Comments
 (0)