Skip to content

Commit 0366d4f

Browse files
authored
feat: use supportFile by testingType (#19364)
* feat: use supportFile by testingType * Fix defaults * Start renaming files, and updating system-tests * Fix some tests * Fix some tests * Fix more tests * Try to fix CI * Fix more tests * Fix some tests * Revert changes * Revert supportFile defaultValue * Fix some tests * Fix some tests * Fix some tests * Fix some tests * Update supportFile example * Update snapshots * Remove scaffold support * Handle config errors * Remove scaffold * Fix tests * Fix test * Update test * Fix test * Update supportFile template * Fix template
1 parent 59703a6 commit 0366d4f

File tree

191 files changed

+567
-493
lines changed

Some content is hidden

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

191 files changed

+567
-493
lines changed

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ system-tests/projects/**/static/*
2222
system-tests/projects/**/*.jsx
2323
system-tests/projects/**/fail.js
2424
system-tests/lib/scaffold/plugins/index.js
25-
system-tests/lib/scaffold/support/index.js
25+
system-tests/lib/scaffold/support/e2e.js
26+
system-tests/lib/scaffold/support/component.js
2627
system-tests/lib/scaffold/support/commands.js
2728
system-tests/test/support/projects/e2e/cypress/
2829
system-tests/projects/e2e/cypress/integration/stdout_exit_early_failing_spec.js

circle.yml

+20-4
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,13 @@ commands:
813813
rm -rf cypress.json
814814
echo 'module.exports = {}' > cypress.config.js
815815
fi
816+
- run:
817+
name: Rename support file
818+
working_directory: /tmp/<<parameters.repo>>
819+
command: |
820+
if [[ -f cypress/support/index.js ]]; then
821+
mv cypress/support/index.js cypress/support/e2e.js
822+
fi
816823
- run:
817824
name: Print Cypress version
818825
working_directory: /tmp/<<parameters.repo>>
@@ -1681,7 +1688,7 @@ jobs:
16811688
steps:
16821689
- clone-repo-and-checkout-branch:
16831690
repo: cypress-example-kitchensink
1684-
pull_request_id: 510
1691+
pull_request_id: 523
16851692
- install-required-node
16861693
- run:
16871694
name: Remove cypress.json
@@ -1933,6 +1940,10 @@ jobs:
19331940
},
19341941
},
19351942
}" > cypress.config.ts
1943+
- run:
1944+
name: Rename support file
1945+
working_directory: <<parameters.wd>>
1946+
command: mv cypress/support/index.ts cypress/support/e2e.js
19361947
- run:
19371948
name: Run project tests 🗳
19381949
working_directory: <<parameters.wd>>
@@ -2003,14 +2014,15 @@ jobs:
20032014
- test-binary-against-repo:
20042015
repo: cypress-example-kitchensink
20052016
browser: "electron"
2006-
pull_request_id: 510
2017+
pull_request_id: 523
20072018

20082019
test-binary-against-awesome-typescript-loader:
20092020
<<: *defaults
20102021
steps:
20112022
- test-binary-against-repo:
20122023
repo: cypress-test-awesome-typescript-loader
20132024
browser: "electron"
2025+
pull_request_id: 7
20142026

20152027
test-binary-against-kitchensink-firefox:
20162028
<<: *defaults
@@ -2019,7 +2031,7 @@ jobs:
20192031
- test-binary-against-repo:
20202032
repo: cypress-example-kitchensink
20212033
browser: firefox
2022-
pull_request_id: 510
2034+
pull_request_id: 523
20232035

20242036
test-binary-against-kitchensink-chrome:
20252037
<<: *defaults
@@ -2028,7 +2040,7 @@ jobs:
20282040
- test-binary-against-repo:
20292041
repo: cypress-example-kitchensink
20302042
browser: chrome
2031-
pull_request_id: 510
2043+
pull_request_id: 523
20322044

20332045
test-binary-against-todomvc-firefox:
20342046
<<: *defaults
@@ -2120,6 +2132,10 @@ jobs:
21202132
command: |
21212133
rm -rf cypress.json
21222134
echo 'module.exports = {}' > cypress.config.js
2135+
- run:
2136+
name: Rename support file
2137+
working_directory: test-binary
2138+
command: mv cypress/support/index.js cypress/support/e2e.js
21232139
- run:
21242140
name: Verify Cypress binary
21252141
working_directory: test-binary

cli/schema/cypress.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
"string",
148148
"boolean"
149149
],
150-
"default": "cypress/support/index.js",
150+
"default": "cypress/support/e2e.js",
151151
"description": "Path to file to load before test files load. This file is compiled and bundled. (Pass false to disable)"
152152
},
153153
"videosFolder": {

cli/types/cypress.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2742,7 +2742,7 @@ declare namespace Cypress {
27422742
screenshotsFolder: string | false
27432743
/**
27442744
* Path to file to load before test files load. This file is compiled and bundled. (Pass false to disable)
2745-
* @default "cypress/support/index.js"
2745+
* @default "cypress/support/{e2e|component}.js"
27462746
*/
27472747
supportFile: string | false
27482748
/**
@@ -5476,7 +5476,7 @@ declare namespace Cypress {
54765476
```
54775477
// likely want to do this in a support file
54785478
// so it's applied to all spec files
5479-
// cypress/support/index.js
5479+
// cypress/support/{e2e|component}.js
54805480
54815481
Cypress.on('uncaught:exception', (err, runnable) => {
54825482
// returning false here prevents Cypress from

npm/angular/README.md

+2-2

npm/angular/cypress.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default defineConfig({
88
'projectId': 'nf7zag',
99
'component': {
1010
'specPattern': 'src/app/**/*cy-spec.ts',
11+
'supportFile': 'cypress/support/component.ts',
1112
setupNodeEvents (on, config) {
1213
return require('./cypress/plugins')(on, config)
1314
},
File renamed without changes.

npm/create-cypress-tests/__snapshots__/init-component-testing.test.ts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ module.exports = (on, config) => {
4040
4141
`
4242

43-
exports['Injected overridden webpack template support/index.js'] = `
43+
exports['Injected overridden webpack template support/component.js'] = `
4444
import "./commands.js";
4545
`

npm/create-cypress-tests/src/component-testing/init-component-testing.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('init component tests script', () => {
7171
)
7272

7373
const supportFile = fs.readFileSync(
74-
path.join(e2eTestOutputPath, 'cypress', 'support', 'index.js'),
74+
path.join(e2eTestOutputPath, 'cypress', 'support', 'component.js'),
7575
{ encoding: 'utf-8' },
7676
)
7777

@@ -81,9 +81,9 @@ describe('init component tests script', () => {
8181
}
8282

8383
snapshot(
84-
`${name} support/index.js`,
84+
`${name} support/component.js`,
8585
fs.readFileSync(
86-
path.join(e2eTestOutputPath, 'cypress', 'support', 'index.js'),
86+
path.join(e2eTestOutputPath, 'cypress', 'support', 'component.js'),
8787
{ encoding: 'utf-8' },
8888
),
8989
)
@@ -92,7 +92,7 @@ describe('init component tests script', () => {
9292
it('determines more presumable configuration to suggest', async () => {
9393
createTempFiles({
9494
'/cypress.config.ts': 'export default {}',
95-
'/cypress/support/index.js': '',
95+
'/cypress/support/component.js': '',
9696
'/cypress/plugins/index.js': 'module.exports = (on, config) => {}',
9797
// For next.js user will have babel config, but we want to suggest to use the closest config for the application code
9898
'/babel.config.js': 'module.exports = { }',
@@ -115,7 +115,7 @@ describe('init component tests script', () => {
115115
it('automatically suggests to the user which config to use', async () => {
116116
createTempFiles({
117117
'/cypress.config.ts': 'export default {}',
118-
'/cypress/support/index.js': 'import "./commands.js";',
118+
'/cypress/support/component.js': 'import "./commands.js";',
119119
'/cypress/plugins/index.js': 'module.exports = () => {}',
120120
'/package.json': JSON.stringify({
121121
dependencies: {

npm/cypress-schematic/src/schematics/ng-add/files/cypress.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig } from 'cypress'
22

33
export default defineConfig({
44
'integrationFolder': '<%= root%>cypress/integration',
5-
'supportFile': '<%= root%>cypress/support/index.ts',
5+
'supportFile': '<%= root%>cypress/support/component.ts',
66
'videosFolder': '<%= root%>cypress/videos',
77
'screenshotsFolder': '<%= root%>cypress/screenshots',
88
'pluginsFile': '<%= root%>cypress/plugins/index.ts',

npm/cypress-schematic/src/schematics/ng-add/files/cypress/support/index.ts npm/cypress-schematic/src/schematics/ng-add/files/cypress/support/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ***********************************************************
2-
// This example support/index.js is processed and
2+
// This example support/component.ts is processed and
33
// loaded automatically before your test files.
44
//
55
// This is a great place to put global configuration and

npm/cypress-schematic/src/schematics/ng-add/index.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('@cypress/schematic: ng-add', () => {
3232
})
3333

3434
it('should create cypress files', async () => {
35-
const files = ['cypress/integration/spec.ts', 'cypress/plugins/index.ts', 'cypress/support/commands.ts', 'cypress/support/index.ts', 'cypress/tsconfig.json', 'cypress.config.ts']
35+
const files = ['cypress/integration/spec.ts', 'cypress/plugins/index.ts', 'cypress/support/commands.ts', 'cypress/tsconfig.json', 'cypress.config.ts']
3636
const homePath = '/projects/sandbox/'
3737

3838
return schematicRunner.runSchematicAsync('ng-add', {}, appTree).toPromise().then((tree) => {

npm/react/cypress/support/index.js npm/react/cypress/support/component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ***********************************************************
2-
// This example support/index.js is processed and
2+
// This example support/component.js is processed and
33
// loaded automatically before your test files.
44
//
55
// This is a great place to put global configuration and
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/component.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

npm/react/examples/find-webpack/cypress.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default defineConfig({
55
'projectId': 'jq5xpp',
66
'component': {
77
'specPattern': 'src/**/*.spec.{js,ts,jsx,tsx}',
8+
'supportFile': 'cypress/support/component.ts',
89
devServer (cypressConfig) {
910
const findReactScriptsWebpackConfig = require('@cypress/react/plugins/react-scripts/findReactScriptsWebpackConfig')
1011
const { startDevServer } = require('@cypress/webpack-dev-server')

npm/react/examples/react-scripts-typescript/cypress.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
'viewportWidth': 500,
44
'viewportHeight': 800,
55
'component': {
6+
'supportFile': 'cypress/support/component.ts',
67
'specPattern': 'src/**/*cy-spec.tsx',
78
setupNodeEvents (on, config) {
89
const devServer = require('@cypress/react/plugins/react-scripts')

npm/react/examples/tailwind/cypress.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
'env': {
77
'coverage': true,
88
},
9-
config: {
9+
component: {
1010
'specPattern': 'src/**/*cy-spec.js',
1111
setupNodeEvents (on, config) {
1212
// load file devServer that comes with this plugin

npm/vite-dev-server/cypress.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default defineConfig({
55
'video': false,
66
'fixturesFolder': false,
77
'component': {
8+
'supportFile': 'cypress/support.js',
89
'specPattern': 'cypress/components/**/*.spec.*',
910
devServer (cypressConfig) {
1011
const path = require('path')

npm/vue/cypress.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default defineConfig({
99
'experimentalFetchPolyfill': true,
1010
'e2e': {
1111
'specPattern': 'cypress/integration/**/*',
12+
'supportFile': false,
1213
},
1314
'component': {
1415
'specPattern': 'cypress/component/**/*spec.{js,ts,tsx}',
File renamed without changes.

npm/vue/docs/manual-install.md

+1-1

npm/vue/examples/code-coverage/README.md

+1-1

system-tests/projects/config-with-invalid-browser/cypress/support/index.js npm/webpack-preprocessor/cypress/support/e2e.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ***********************************************************
2-
// This example support/index.js is processed and
2+
// This example support/e2e.js is processed and
33
// loaded automatically before your test files.
44
//
55
// This is a great place to put global configuration and
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module.exports = {
22
'baseUrl': 'http://localhost:3000',
33
'fixturesFolder': false,
4-
'supportFile': false,
54
'viewportWidth': 600,
5+
'e2e': {
6+
'supportFile': false,
7+
},
68
}

npm/webpack-preprocessor/examples/use-babelrc/cypress.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
'fixturesFolder': false,
3-
'supportFile': false,
43
'e2e': {
4+
'supportFile': false,
55
'specPattern': 'cypress/integration/**/*',
66
setupNodeEvents (on, config) {
77
const webpackPreprocessor = require('../..')

npm/webpack-preprocessor/examples/use-ts-loader/cypress.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { defineConfig } from 'cypress'
22

33
export default defineConfig({
44
'fixturesFolder': false,
5-
'supportFile': false,
65
'e2e': {
6+
'supportFile': false,
77
async setupNodeEvents (on, config) {
88
const webpackPreprocessor = await import('../..')
99

packages/app/cypress/component/support/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { registerMountFn } from '@packages/frontend-shared/cypress/support/common'
22
// ***********************************************************
3-
// This example support/index.js is processed and
3+
// This example support/index.ts is processed and
44
// loaded automatically before your test files.
55
//
66
// This is a great place to put global configuration and

packages/config/__snapshots__/index_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ exports['src/index .getDefaultValues returns list of public config keys 1'] = {
5757
"screenshotsFolder": "cypress/screenshots",
5858
"slowTestThreshold": 10000,
5959
"scrollBehavior": "top",
60-
"supportFile": "cypress/support",
60+
"supportFile": "cypress/support/e2e.js",
6161
"supportFolder": false,
6262
"taskTimeout": 60000,
6363
"trashAssetsBeforeRuns": true,

0 commit comments

Comments
 (0)