Skip to content

Commit 081dd19

Browse files
feat: Use .config files (#18578)
Co-authored-by: Tim Griesser <tgriesser10@gmail.com>
1 parent 469b228 commit 081dd19

File tree

351 files changed

+2252
-1094
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+2252
-1094
lines changed

circle.yml

+60-18
Original file line numberDiff line numberDiff line change
@@ -516,20 +516,34 @@ commands:
516516
steps:
517517
- run: yarn verify:mocha:results <<parameters.expectedResultCount>>
518518

519-
clone-repo-and-checkout-release-branch:
519+
clone-repo-and-checkout-branch:
520520
description: |
521521
Clones an external repo and then checks out the branch that matches the next version otherwise uses 'master' branch.
522522
parameters:
523523
repo:
524524
description: "Name of the github repo to clone like: cypress-example-kitchensink"
525525
type: string
526+
pull_request_id:
527+
description: Pull request number to check out before installing and testing
528+
type: integer
529+
default: 0
526530
steps:
527531
- restore_cached_binary
528532
- run:
529533
name: "Cloning test project: <<parameters.repo>>"
530534
command: |
531535
git clone --depth 1 --no-single-branch https://github.com/cypress-io/<<parameters.repo>>.git /tmp/<<parameters.repo>>
532536
cd /tmp/<<parameters.repo>> && (git checkout $(node ./scripts/get-next-version) || true)
537+
- when:
538+
condition: <<parameters.pull_request_id>>
539+
steps:
540+
- run:
541+
name: Check out PR <<parameters.pull_request_id>>
542+
working_directory: /tmp/<<parameters.repo>>
543+
command: |
544+
git fetch origin pull/<<parameters.pull_request_id>>/head:pr-<<parameters.pull_request_id>>
545+
git checkout pr-<<parameters.pull_request_id>>
546+
git log -n 2
533547
534548
test-binary-against-rwa:
535549
description: |
@@ -571,7 +585,7 @@ commands:
571585
type: string
572586
default: "CI=true yarn start"
573587
steps:
574-
- clone-repo-and-checkout-release-branch:
588+
- clone-repo-and-checkout-branch:
575589
repo: <<parameters.repo>>
576590
- when:
577591
condition: <<parameters.pull_request_id>>
@@ -701,18 +715,9 @@ commands:
701715
type: string
702716
default: "npm start --if-present"
703717
steps:
704-
- clone-repo-and-checkout-release-branch:
718+
- clone-repo-and-checkout-branch:
705719
repo: <<parameters.repo>>
706-
- when:
707-
condition: <<parameters.pull_request_id>>
708-
steps:
709-
- run:
710-
name: Check out PR <<parameters.pull_request_id>>
711-
working_directory: /tmp/<<parameters.repo>>
712-
command: |
713-
git fetch origin pull/<<parameters.pull_request_id>>/head:pr-<<parameters.pull_request_id>>
714-
git checkout pr-<<parameters.pull_request_id>>
715-
git log -n 2
720+
pull_request_id: <<parameters.pull_request_id>>
716721
- run:
717722
# Install deps + Cypress binary with yarn if yarn.lock present
718723
command: |
@@ -724,6 +729,16 @@ commands:
724729
CYPRESS_INSTALL_BINARY=~/cypress/cypress.zip npm install ~/cypress/cypress.tgz
725730
fi
726731
working_directory: /tmp/<<parameters.repo>>
732+
- run:
733+
name: Scaffold new config file
734+
working_directory: /tmp/<<parameters.repo>>
735+
environment:
736+
CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1"
737+
command: |
738+
if [[ -f cypress.json ]]; then
739+
rm -rf cypress.json
740+
echo 'module.exports = {}' > cypress.config.js
741+
fi
727742
- run:
728743
name: Print Cypress version
729744
working_directory: /tmp/<<parameters.repo>>
@@ -1610,9 +1625,17 @@ jobs:
16101625
test-kitchensink:
16111626
<<: *defaults
16121627
steps:
1613-
- clone-repo-and-checkout-release-branch:
1628+
- clone-repo-and-checkout-branch:
16141629
repo: cypress-example-kitchensink
1630+
pull_request_id: 510
16151631
- install-required-node
1632+
- run:
1633+
name: Remove cypress.json
1634+
description: Remove cypress.json in case it exists
1635+
working_directory: /tmp/cypress-example-kitchensink
1636+
environment:
1637+
CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1"
1638+
command: rm -rf cypress.json
16161639
- run:
16171640
name: Install prod dependencies
16181641
command: yarn --production
@@ -1637,7 +1660,7 @@ jobs:
16371660
<<: *defaults
16381661
resource_class: medium
16391662
steps:
1640-
- clone-repo-and-checkout-release-branch:
1663+
- clone-repo-and-checkout-branch:
16411664
repo: cypress-example-kitchensink
16421665
- run:
16431666
name: Install prod dependencies
@@ -1662,7 +1685,7 @@ jobs:
16621685
<<: *defaults
16631686
resource_class: medium
16641687
steps:
1665-
- clone-repo-and-checkout-release-branch:
1688+
- clone-repo-and-checkout-branch:
16661689
repo: cypress-test-tiny
16671690
- run:
16681691
name: Run test project
@@ -1846,7 +1869,7 @@ jobs:
18461869
environment:
18471870
CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1"
18481871
command: |
1849-
echo '{}' > cypress.json
1872+
echo 'module.exports = {}' > cypress.config.js
18501873
npx cypress run
18511874
18521875
test-full-typescript-project:
@@ -1878,6 +1901,14 @@ jobs:
18781901
name: Scaffold full TypeScript project 🏗
18791902
working_directory: <<parameters.wd>>
18801903
command: npx @bahmutov/cly@1 init --typescript
1904+
- run:
1905+
name: Scaffold new config file
1906+
working_directory: <<parameters.wd>>
1907+
environment:
1908+
CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1"
1909+
command: |
1910+
rm -rf cypress.json
1911+
echo 'export default {}' > cypress.config.ts
18811912
- run:
18821913
name: Run project tests 🗳
18831914
working_directory: <<parameters.wd>>
@@ -1888,7 +1919,7 @@ jobs:
18881919
<<: *defaults
18891920
steps:
18901921
- restore_workspace_binaries
1891-
- clone-repo-and-checkout-release-branch:
1922+
- clone-repo-and-checkout-branch:
18921923
repo: cypress-test-tiny
18931924
- run:
18941925
name: Install Cypress
@@ -1940,6 +1971,7 @@ jobs:
19401971
- test-binary-against-repo:
19411972
repo: cypress-example-kitchensink
19421973
browser: "electron"
1974+
pull_request_id: 510
19431975

19441976
test-binary-against-awesome-typescript-loader:
19451977
<<: *defaults
@@ -1955,6 +1987,7 @@ jobs:
19551987
- test-binary-against-repo:
19561988
repo: cypress-example-kitchensink
19571989
browser: firefox
1990+
pull_request_id: 510
19581991

19591992
"test-binary-against-kitchensink-chrome":
19601993
<<: *defaults
@@ -1963,6 +1996,7 @@ jobs:
19631996
- test-binary-against-repo:
19641997
repo: cypress-example-kitchensink
19651998
browser: chrome
1999+
pull_request_id: 510
19662000

19672001
"test-binary-against-todomvc-firefox":
19682002
<<: *defaults
@@ -2056,6 +2090,14 @@ jobs:
20562090
name: Add Cypress demo
20572091
working_directory: test-binary
20582092
command: npx @bahmutov/cly init
2093+
- run:
2094+
name: Scaffold new config file
2095+
working_directory: test-binary
2096+
environment:
2097+
CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1"
2098+
command: |
2099+
rm -rf cypress.json
2100+
echo 'module.exports = {}' > cypress.config.js
20592101
- run:
20602102
name: Verify Cypress binary
20612103
working_directory: test-binary

cli/__snapshots__/cli_spec.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ exports['shows help for open --foo 1'] = `
2121
--component runs component tests
2222
-c, --config <config> sets configuration values. separate multiple
2323
values with a comma. overrides any value in
24-
cypress.json.
24+
cypress.config.{ts|js}.
2525
-C, --config-file <config-file> path to JSON file where configuration values
26-
are set. defaults to "cypress.json". pass
27-
"false" to disable.
26+
are set. defaults to
27+
"cypress.config.{ts|js}". pass "false" to
28+
disable.
2829
-d, --detached [bool] runs Cypress application in detached mode
2930
--e2e runs end to end tests
3031
-e, --env <env> sets environment variables. separate
3132
multiple values with a comma. overrides any
32-
value in cypress.json or cypress.env.json
33+
value in cypress.config.{ts|js} or
34+
cypress.env.json
3335
--global force Cypress into global mode as if its
3436
globally installed
3537
-p, --port <port> runs Cypress on a specific port. overrides
36-
any value in cypress.json.
38+
any value in cypress.config.{ts|js}.
3739
-P, --project <project-path> path to the project
3840
--dev runs cypress in development and bypasses
3941
binary check
@@ -67,17 +69,17 @@ exports['shows help for run --foo 1'] = `
6769
-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.
6870
--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
6971
--component runs component tests
70-
-c, --config <config> sets configuration values. separate multiple values with a comma. overrides any value in cypress.json.
71-
-C, --config-file <config-file> path to JSON file where configuration values are set. defaults to "cypress.json". pass "false" to disable.
72+
-c, --config <config> sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{ts|js}.
73+
-C, --config-file <config-file> path to JSON file where configuration values are set. defaults to "cypress.config.{ts|js}". pass "false" to disable.
7274
--e2e runs end to end tests
73-
-e, --env <env> sets environment variables. separate multiple values with a comma. overrides any value in cypress.json or cypress.env.json
75+
-e, --env <env> sets environment variables. separate multiple values with a comma. overrides any value in cypress.config.{ts|js} or cypress.env.json
7476
--group <name> a named group for recorded runs in the Cypress Dashboard
7577
-k, --key <record-key> your secret Record Key. you can omit this if you set a CYPRESS_RECORD_KEY environment variable.
7678
--headed displays the browser instead of running headlessly
7779
--headless hide the browser instead of running headed (default for cypress run)
7880
--no-exit keep the browser open after tests finish
7981
--parallel enables concurrent runs and automatic load balancing of specs across multiple machines or processes
80-
-p, --port <port> runs Cypress on a specific port. overrides any value in cypress.json.
82+
-p, --port <port> runs Cypress on a specific port. overrides any value in cypress.config.{ts|js}.
8183
-P, --project <project-path> path to the project
8284
-q, --quiet run quietly, using only the configured reporter
8385
--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
@@ -107,12 +107,12 @@ const descriptions = {
107107
cacheSize: 'Used with the list command to show the sizes of the cached folders',
108108
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',
109109
component: 'runs component tests',
110-
config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.json.',
111-
configFile: 'path to JSON file where configuration values are set. defaults to "cypress.json". pass "false" to disable.',
110+
config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{ts|js}.',
111+
configFile: 'path to JSON file where configuration values are set. defaults to "cypress.config.{ts|js}". pass "false" to disable.',
112112
detached: 'runs Cypress application in detached mode',
113113
dev: 'runs cypress in development and bypasses binary check',
114114
e2e: 'runs end to end tests',
115-
env: 'sets environment variables. separate multiple values with a comma. overrides any value in cypress.json or cypress.env.json',
115+
env: 'sets environment variables. separate multiple values with a comma. overrides any value in cypress.config.{ts|js} or cypress.env.json',
116116
exit: 'keep the browser open after tests finish',
117117
forceInstall: 'force install the Cypress binary',
118118
global: 'force Cypress into global mode as if its globally installed',
@@ -121,7 +121,7 @@ const descriptions = {
121121
headless: 'hide the browser instead of running headed (default for cypress run)',
122122
key: 'your secret Record Key. you can omit this if you set a CYPRESS_RECORD_KEY environment variable.',
123123
parallel: 'enables concurrent runs and automatic load balancing of specs across multiple machines or processes',
124-
port: 'runs Cypress on a specific port. overrides any value in cypress.json.',
124+
port: 'runs Cypress on a specific port. overrides any value in cypress.config.{ts|js}.',
125125
project: 'path to the project',
126126
quiet: 'run quietly, using only the configured reporter',
127127
record: 'records the run. sends test results, screenshots and videos to your Cypress Dashboard.',

cli/schema/cypress.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
"includeShadowDom": {
283283
"type": "boolean",
284284
"default": false,
285-
"description": "Enables including elements within the shadow DOM when using querying commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.json, per-suite or per-test in the test configuration object, or programmatically with Cypress.config()"
285+
"description": "Enables including elements within the shadow DOM when using querying commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.config.{ts|js}, per-suite or per-test in the test configuration object, or programmatically with Cypress.config()"
286286
},
287287
"clientCertificates": {
288288
"description": "Defines client certificates to use when sending requests to the specified URLs",

cli/test/lib/cypress_spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ describe('cypress', function () {
234234
})
235235
})
236236

237-
it('coerces --config-file cypress.json to string', async () => {
238-
const args = 'cypress run --config-file cypress.json'.split(' ')
237+
it('coerces --config-file cypress.config.js to string', async () => {
238+
const args = 'cypress run --config-file cypress.config.js'.split(' ')
239239
const options = await cypress.cli.parseRunArguments(args)
240240

241241
expect(options).to.deep.equal({
242-
configFile: 'cypress.json',
242+
configFile: 'cypress.config.js',
243243
})
244244
})
245245

cli/test/lib/exec/open_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ describe('exec open', function () {
6666
})
6767

6868
it('spawns with --config-file set', function () {
69-
return open.start({ configFile: 'special-cypress.json' })
69+
return open.start({ configFile: 'special-cypress.config.js' })
7070
.then(() => {
7171
expect(spawn.start).to.be.calledWith(
72-
['--config-file', 'special-cypress.json'],
72+
['--config-file', 'special-cypress.config.js'],
7373
)
7474
})
7575
})

cli/test/lib/exec/run_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ describe('exec run', function () {
150150
})
151151

152152
it('spawns with --config-file set', function () {
153-
return run.start({ configFile: 'special-cypress.json' })
153+
return run.start({ configFile: 'special-cypress.config.js' })
154154
.then(() => {
155155
expect(spawn.start).to.be.calledWith(
156-
['--run-project', process.cwd(), '--config-file', 'special-cypress.json'],
156+
['--run-project', process.cwd(), '--config-file', 'special-cypress.config.js'],
157157
)
158158
})
159159
})

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ declare namespace CypressCommandLine {
144144
*
145145
* If `false` is passed, no config file will be used.
146146
*
147-
* @default "cypress.json"
147+
* @default "cypress.config.{ts|js}"
148148
*/
149149
configFile: string | false
150150
/**

cli/types/cypress.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ declare namespace Cypress {
353353

354354
// no real way to type without generics
355355
/**
356-
* Returns all environment variables set with CYPRESS_ prefix or in "env" object in "cypress.json"
356+
* Returns all environment variables set with CYPRESS_ prefix or in "env" object in "cypress.config.{ts|js}"
357357
*
358358
* @see https://on.cypress.io/env
359359
*/
@@ -362,7 +362,7 @@ declare namespace Cypress {
362362
* Returns specific environment variable or undefined
363363
* @see https://on.cypress.io/env
364364
* @example
365-
* // cypress.json
365+
* // cypress.config.js
366366
* { "env": { "foo": "bar" } }
367367
* Cypress.env("foo") // => bar
368368
*/
@@ -2756,7 +2756,7 @@ declare namespace Cypress {
27562756
retries: Nullable<number | { runMode?: Nullable<number>, openMode?: Nullable<number> }>
27572757
/**
27582758
* Enables including elements within the shadow DOM when using querying
2759-
* commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.json,
2759+
* commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.config.{ts|js},
27602760
* per-suite or per-test in the test configuration object, or programmatically
27612761
* with Cypress.config()
27622762
* @default false
@@ -2894,7 +2894,7 @@ declare namespace Cypress {
28942894

28952895
interface PluginConfigOptions extends ResolvedConfigOptions {
28962896
/**
2897-
* Absolute path to the config file (default: <projectRoot>/cypress.json) or false
2897+
* Absolute path to the config file (default: <projectRoot>/cypress.config.{ts|js}) or false
28982898
*/
28992899
configFile: string | false
29002900
/**

npm/angular/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ require('core-js/es7/reflect');
2222
require('@cypress/angular/support');
2323
```
2424

25-
Enable component testing in `cypress.json`.
25+
Enable component testing in `cypress.config.js`.
2626

27-
```json
28-
{
27+
```js
28+
module.exports = {
2929
"component": {
3030
"componentFolder": "src/app",
3131
"testFiles": "**/*cy-spec.ts"

npm/angular/cypress.config.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'cypress'
2+
3+
export default defineConfig({
4+
'experimentalFetchPolyfill': true,
5+
'fixturesFolder': false,
6+
'includeShadowDom': true,
7+
'fileServerFolder': 'src',
8+
'projectId': 'nf7zag',
9+
'component': {
10+
'componentFolder': 'src/app',
11+
'testFiles': '**/*cy-spec.ts',
12+
},
13+
})

0 commit comments

Comments
 (0)