Skip to content

Commit 792980a

Browse files
feat: support specPattern, deprecate integrationFolder and componentFolder (#19319)
* use new specPattern API * remove projectApi.findSpecs * do not require integration folder * support --spec * support --spec * remove old code * remove old code * nuke old code * no appvetor * update * correct url for ct * work on migrating launchpad * update ct spec url * types * types * dead code * remove old endpiont * revert back circle.yml * update missing config * delete spec util * update config * update config * config again * update spec pattern * updated vue config * update spec pattern for ui components * update config for vite dev server * update snapshots * update config * update design system config * fix spec pattern in reporter * update default * update deprecated spec snapshots * update system tests * update run mode output * revert changes * lint * remove scaffold tests * update angular * fix CT * update circle yml * fix system tests for ct * fix tests * work on server unit tests * patch package * patch package again * update test * try not to rely on config async loading too much * normalize specPattern to array * update snapshot * use base name * deal with react-scripts later * update snapshot * hacky way to update snapshots * new hack to update snapshots * trying again * hacky fix * ci: snapshots * ci: snapshots * snapshots * mas updates * update spec API * fix test * fix test * update * update test * fix test * update plugin * update spec * webpack optinos * Update launchpad tests * fix screenshot paths * updated snapshot * change pattern * guard * fix smoke test * patch code coverage * update percy config * fix specs * try updating example project * update snapshots * remove old test * remove snapshot hack * add back appveyor * remove old code * update snapshot * Fix tests * wip * revert snapshot * reverted all snaps * remove only * remove commnet * remove old code * reverted file * lint * revert video compression spec * update snapshot * update spec path logic * update snap * updated snap * snaps * snaps * fix spec * rename ignoreTestFiles to ignoreSpecPattern * update screenshot dir for runner-ct * update deprecations * update * upate * fix test * update snaps * update snap * updating snap * added missing snaps * updated cypress run mode integration spec * electron snapshot * ensure newly scaffold specs are cached * fix launchpad spec * types * update test * transpile based on spec pattern * add back example * remove unnecessary async and nodeVersion * removed old test * update spec pattern and add defensive check around platform * remove unused feature flag * added tests * fix react example * update test * update config * fix spec finding in run mode * fix tests * fixing specs * fix switching between specs * remove invalid test * increase timeout Co-authored-by: estrada9166 <estrada9166@hotmail.com>
1 parent a744999 commit 792980a

File tree

129 files changed

+2415
-3664
lines changed

Some content is hidden

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

129 files changed

+2415
-3664
lines changed

circle.yml

-43
Original file line numberDiff line numberDiff line change
@@ -1882,46 +1882,6 @@ jobs:
18821882
echo "console.log('hello world')" > hello.ts
18831883
npx tsc hello.ts --noEmit
18841884
1885-
# testing scaffolding examples and running them
1886-
# against example.cypress.io
1887-
test-cypress-scaffold:
1888-
resource_class: medium
1889-
parameters:
1890-
executor:
1891-
description: Executor name to use
1892-
type: executor
1893-
default: cy-doc
1894-
wd:
1895-
description: Working directory, should be OUTSIDE cypress monorepo folder
1896-
type: string
1897-
default: /root/test-scaffold
1898-
<<: *defaults
1899-
steps:
1900-
- restore_workspace_binaries
1901-
- run: mkdir <<parameters.wd>>
1902-
- run:
1903-
name: Create new NPM package ⚗️
1904-
working_directory: <<parameters.wd>>
1905-
command: npm init -y
1906-
- run:
1907-
name: Install dependencies 📦
1908-
working_directory: <<parameters.wd>>
1909-
environment:
1910-
CYPRESS_INSTALL_BINARY: /root/cypress/cypress.zip
1911-
# let's install Cypress, Jest and any other package that might conflict
1912-
# https://github.com/cypress-io/cypress/issues/6690
1913-
command: |
1914-
npm install /root/cypress/cypress.tgz \
1915-
typescript jest @types/jest enzyme @types/enzyme
1916-
- run:
1917-
name: Scaffold and test examples 🏗
1918-
working_directory: <<parameters.wd>>
1919-
environment:
1920-
CYPRESS_INTERNAL_FORCE_SCAFFOLD: "1"
1921-
command: |
1922-
echo 'module.exports = {}' > cypress.config.js
1923-
npx cypress run
1924-
19251885
test-full-typescript-project:
19261886
parameters:
19271887
executor:
@@ -2390,9 +2350,6 @@ linux-workflow: &linux-workflow
23902350
- test-types-cypress-and-jest:
23912351
requires:
23922352
- create-build-artifacts
2393-
- test-cypress-scaffold:
2394-
requires:
2395-
- create-build-artifacts
23962353
- test-full-typescript-project:
23972354
requires:
23982355
- create-build-artifacts

cli/schema/cypress.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"description": "Any values to be set as environment variables. See https://on.cypress.io/environment-variables",
1616
"body": {}
1717
},
18-
"ignoreTestFiles": {
18+
"ignoreSpecPattern": {
1919
"type": [
2020
"string",
2121
"array"

cli/types/cypress.d.ts

+14
Original file line numberDiff line numberDiff line change
@@ -2616,8 +2616,14 @@ declare namespace Cypress {
26162616
/**
26172617
* A String or Array of glob patterns used to ignore test files that would otherwise be shown in your list of tests. Cypress uses minimatch with the options: {dot: true, matchBase: true}. We suggest using http://globtester.com to test what files would match.
26182618
* @default "*.hot-update.js"
2619+
* @deprecated use `ignoreSpecPattern` instead
26192620
*/
26202621
ignoreTestFiles: string | string[]
2622+
/**
2623+
* A String or Array of glob patterns used to ignore test files that would otherwise be shown in your list of tests. Cypress uses minimatch with the options: {dot: true, matchBase: true}. We suggest using http://globtester.com to test what files would match.
2624+
* @default "*.hot-update.js"
2625+
*/
2626+
ignoreSpecPattern: string | string[]
26212627
/**
26222628
* The number of tests for which snapshots and command data are kept in memory. Reduce this number if you are experiencing high memory consumption in your browser during a test run.
26232629
* @default 50
@@ -2691,6 +2697,7 @@ declare namespace Cypress {
26912697
/**
26922698
* Path to folder containing integration test files
26932699
* @default "cypress/integration"
2700+
* @deprecated
26942701
*/
26952702
integrationFolder: string
26962703
/**
@@ -2835,6 +2842,7 @@ declare namespace Cypress {
28352842
blockHosts: null | string | string[]
28362843
/**
28372844
* Path to folder containing component test files.
2845+
* @deprecated
28382846
*/
28392847
componentFolder: false | string
28402848
/**
@@ -2848,6 +2856,12 @@ declare namespace Cypress {
28482856
/**
28492857
* Glob pattern to determine what test files to load.
28502858
*/
2859+
specPattern: string | string[]
2860+
/**
2861+
* Glob pattern to determine what test files to load.
2862+
*
2863+
* @deprecated Use `specPattern` under `component` or `e2e`
2864+
*/
28512865
testFiles: string | string[]
28522866
/**
28532867
* The user agent the browser sends in all request headers.

npm/angular/cypress.config.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ export default defineConfig({
77
'fileServerFolder': 'src',
88
'projectId': 'nf7zag',
99
'component': {
10-
'componentFolder': 'src/app',
11-
'testFiles': '**/*cy-spec.ts',
10+
'specPattern': 'src/app/**/*cy-spec.ts',
1211
setupNodeEvents (on, config) {
1312
return require('./cypress/plugins')(on, config)
1413
},

npm/angular/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"app-start": "ng serve",
1414
"app-build": "ng build",
1515
"test": "yarn cy:run",
16-
"test-ci": "yarn cy:run"
16+
"test-ci": "yarn cy:run",
17+
"postinstall": "patch-package"
1718
},
1819
"dependencies": {
1920
"@cypress/mount-utils": "0.0.0-development",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
diff --git a/node_modules/@cypress/code-coverage/support-utils.js b/node_modules/@cypress/code-coverage/support-utils.js
2+
index 31e00ee..0c56908 100644
3+
--- a/node_modules/@cypress/code-coverage/support-utils.js
4+
+++ b/node_modules/@cypress/code-coverage/support-utils.js
5+
@@ -10,7 +10,7 @@ const filterSpecsFromCoverage = (totalCoverage, config = Cypress.config) => {
6+
const integrationFolder = config('integrationFolder')
7+
/** @type {string} Cypress run-time config has test files string pattern */
8+
// @ts-ignore
9+
- const testFilePattern = config('testFiles')
10+
+ const testFilePattern = config('specPattern')
11+
12+
// test files chould be:
13+
// wild card string "**/*.*" (default)
14+
diff --git a/node_modules/@cypress/code-coverage/support.js b/node_modules/@cypress/code-coverage/support.js
15+
index c99ceb2..f51ce4e 100644
16+
--- a/node_modules/@cypress/code-coverage/support.js
17+
+++ b/node_modules/@cypress/code-coverage/support.js
18+
@@ -37,7 +37,6 @@ const logMessage = (s) => {
19+
* If there are more files loaded from support folder, also removes them
20+
*/
21+
const filterSupportFilesFromCoverage = (totalCoverage) => {
22+
- const integrationFolder = Cypress.config('integrationFolder')
23+
const supportFile = Cypress.config('supportFile')
24+
25+
/** @type {string} Cypress run-time config has the support folder string */
26+
@@ -50,16 +49,9 @@ const filterSupportFilesFromCoverage = (totalCoverage) => {
27+
isSupportFile(filename)
28+
)
29+
30+
- // check the edge case
31+
- // if we have files from support folder AND the support folder is not same
32+
- // as the integration, or its prefix (this might remove all app source files)
33+
- // then remove all files from the support folder
34+
- if (!integrationFolder.startsWith(supportFolder)) {
35+
- // remove all covered files from support folder
36+
- coverage = Cypress._.omitBy(totalCoverage, (fileCoverage, filename) =>
37+
- filename.startsWith(supportFolder)
38+
- )
39+
- }
40+
+ coverage = Cypress._.omitBy(totalCoverage, (fileCoverage, filename) =>
41+
+ filename.startsWith(supportFolder)
42+
+ )
43+
return coverage
44+
}
45+

npm/design-system/cypress.config.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ module.exports = {
33
viewportHeight: 800,
44
video: false,
55
projectId: 'z9dxah',
6-
testFiles: '**/*spec.{js,jsx,ts,tsx}',
76
env: {
87
reactDevtools: true,
98
},
10-
ignoreTestFiles: [
9+
ignoreSpecPattern: [
1110
'**/__snapshots__/*',
1211
'**/__image_snapshots__/*',
1312
],
14-
componentFolder: 'src',
1513
fixturesFolder: false,
1614
component: {
15+
specPattern: 'src/**/*spec.{js,jsx,ts,tsx}',
1716
devServer (cypressConfig) {
1817
const { startDevServer } = require('@cypress/vite-dev-server')
1918

npm/react/cypress.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ module.exports = {
55
'viewportHeight': 400,
66
'video': false,
77
'projectId': 'z9dxah',
8-
'testFiles': '**/*spec.{js,jsx,ts,tsx}',
98
'env': {
109
'reactDevtools': true,
1110
},
12-
'ignoreTestFiles': [
11+
'ignoreSpecPattern': [
1312
'**/__snapshots__/*',
1413
'**/__image_snapshots__/*',
1514
],
1615
'experimentalFetchPolyfill': true,
1716
'component': {
17+
'specPattern': 'cypress/component/**/*spec.{js,jsx,ts,tsx}',
1818
devServer (cypressConfig, devServerConfig) {
1919
const { startDevServer } = require('@cypress/webpack-dev-server')
2020
const path = require('path')

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module.exports = {
22
'video': false,
33
'fixturesFolder': false,
4-
'testFiles': '**/*spec.js',
54
'viewportWidth': 500,
65
'viewportHeight': 500,
76
'component': {
7+
'specPattern': 'cypress/component/**/*spec.js',
88
setupNodeEvents (on, config) {
99
// load file devServer that comes with this plugin
1010
// https://github.com/bahmutov/cypress-react-unit-test#install

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module.exports = {
22
'component': {
3-
'testFiles': '**/*.test.{js,ts,jsx,tsx}',
4-
'componentFolder': 'src',
3+
'specPattern': 'cypress/component/**/*.test.{js,ts,jsx,tsx}',
54
setupNodeEvents (on, config) {
65
const cracoConfig = require('./craco.config.js')
76
const devServer = require('@cypress/react/plugins/craco')

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ export default defineConfig({
44
'video': true,
55
'projectId': 'jq5xpp',
66
'component': {
7-
'testFiles': '**/*.spec.{js,ts,jsx,tsx}',
8-
'componentFolder': 'src',
7+
'specPattern': 'src/**/*.spec.{js,ts,jsx,tsx}',
98
devServer (cypressConfig) {
109
const findReactScriptsWebpackConfig = require('@cypress/react/plugins/react-scripts/findReactScriptsWebpackConfig')
1110
const { startDevServer } = require('@cypress/webpack-dev-server')

npm/react/examples/nextjs-webpack-5/cypress.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module.exports = {
22
'video': false,
3-
'testFiles': '**/*.spec.{js,jsx}',
43
'viewportWidth': 500,
54
'viewportHeight': 800,
6-
'componentFolder': 'cypress/components',
75
'pluginsFile': 'cypress/plugins.js',
86
'component': {
7+
'specPattern': 'cypress/component/**/*.spec.{js,jsx}',
98
setupNodeEvents (on, config) {
109
const devServer = require('@cypress/react/plugins/next')
1110

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
module.exports = {
22
'video': false,
3-
'testFiles': '**/*.spec.{js,jsx}',
43
'viewportWidth': 500,
54
'viewportHeight': 800,
65
'experimentalFetchPolyfill': true,
7-
'componentFolder': 'cypress/components',
86
'env': {
97
'coverage': true,
108
},
119
'component': {
10+
'specPattern': 'cypress/components/**/*.spec.{js,jsx}',
1211
setupNodeEvents (on, config) {
1312
const devServer = require('@cypress/react/plugins/next')
1413

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module.exports = {
22
'video': false,
33
'fixturesFolder': false,
4-
'testFiles': '**/*cy-spec.js',
54
'viewportWidth': 500,
65
'viewportHeight': 800,
7-
'componentFolder': 'cypress/component',
86
'component': {
7+
'specPattern': 'cypress/component/**/*cy-spec.js',
98
setupNodeEvents (on, config) {
109
// load file devServer that comes with this plugin
1110
// https://github.com/bahmutov/cypress-react-unit-test#install

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
module.exports = {
22
'video': false,
3-
'testFiles': '**/*cy-spec.tsx',
43
'viewportWidth': 500,
54
'viewportHeight': 800,
6-
'componentFolder': 'src',
75
'component': {
6+
'specPattern': 'src/**/*cy-spec.tsx',
87
setupNodeEvents (on, config) {
98
const devServer = require('@cypress/react/plugins/react-scripts')
109

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module.exports = {
22
'video': false,
3-
'testFiles': '**/*cy-spec.js',
43
'viewportWidth': 500,
54
'viewportHeight': 800,
65
'experimentalFetchPolyfill': true,
7-
'componentFolder': 'src',
86
'component': {
7+
'specPattern': 'src/**/*cy-spec.js',
98
setupNodeEvents (on, config) {
109
// load file devServer that comes with this plugin
1110
// https://github.com/bahmutov/cypress-react-unit-test#install

npm/react/examples/sass-and-ts/cypress.config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
module.exports = {
22
'video': false,
33
'fixturesFolder': false,
4-
'testFiles': '**/*spec.*',
54
'viewportWidth': 500,
65
'viewportHeight': 500,
7-
'componentFolder': 'src',
8-
'nodeVersion': 'system',
96
'env': {
107
'coverage': true,
118
},
129
'component': {
10+
'specPattern': 'src/**/*spec.*',
1311
setupNodeEvents (on, config) {
1412
// load Webpack file devServer that comes with this plugin
1513
// https://github.com/bahmutov/cypress-react-unit-test#install

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
module.exports = {
22
'video': false,
33
'fixturesFolder': false,
4-
'testFiles': '**/*-spec.js',
54
'viewportWidth': 500,
65
'viewportHeight': 500,
7-
'ignoreTestFiles': [
6+
'ignoreSpecPattern': [
87
'**/__snapshots__/*',
98
'**/__image_snapshots__/*',
109
],
@@ -14,6 +13,7 @@ module.exports = {
1413
},
1514
},
1615
'component': {
16+
'specPattern': 'cypress/component/**/*-spec.js',
1717
setupNodeEvents (on, config) {
1818
// load file devServer that comes with this plugin
1919
// https://github.com/bahmutov/cypress-react-unit-test#install

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
module.exports = {
22
'video': false,
33
'fixturesFolder': false,
4-
'testFiles': '**/*cy-spec.js',
54
'viewportWidth': 500,
65
'viewportHeight': 500,
7-
'componentFolder': 'src',
86
'env': {
97
'coverage': true,
108
},
119
config: {
10+
'specPattern': 'src/**/*cy-spec.js',
1211
setupNodeEvents (on, config) {
1312
// load file devServer that comes with this plugin
1413
// https://github.com/bahmutov/cypress-react-unit-test#install

npm/react/examples/using-babel-typescript/cypress.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module.exports = {
22
'video': false,
33
'fixturesFolder': false,
4-
'testFiles': '**/*spec.tsx',
54
'viewportWidth': 500,
65
'viewportHeight': 500,
7-
'componentFolder': 'src',
86
'component': {
7+
'specPattern': 'src/**/*spec.tsx',
98
setupNodeEvents (on, config) {
109
// let's bundle spec files and the components they include using
1110
// the same bundling settings as the project by loading .babelrc

npm/react/examples/using-babel/cypress.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module.exports = {
22
'video': false,
33
'fixturesFolder': false,
4-
'testFiles': '**/*spec.js',
54
'viewportWidth': 500,
65
'viewportHeight': 500,
7-
'componentFolder': 'src',
86
'component': {
7+
'specPattern': 'src/**/*spec.js',
98
setupNodeEvents (on, config) {
109
// let's bundle spec files and the components they include using
1110
// the same bundling settings as the project by loading .babelrc

0 commit comments

Comments
 (0)