Skip to content

Commit 5670344

Browse files
authored
feat: remove testFiles reference (#20565)
* feat: remove testFiles reference * feat: remove testFiles reference * Fix test/TS
1 parent 31ed4dd commit 5670344

File tree

21 files changed

+139
-35
lines changed

21 files changed

+139
-35
lines changed

cli/schema/cypress.schema.json

-8
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@
5050
"default": 10000,
5151
"description": "Slow test threshold in milliseconds. Only affects the visual output of some reporters. For example, the spec reporter will display the test time in yellow if over the threshold. See https://on.cypress.io/configuration#Timeouts"
5252
},
53-
"testFiles": {
54-
"type": [
55-
"string",
56-
"array"
57-
],
58-
"default": "**/*.*",
59-
"description": "A String or Array of string glob patterns of the test files to load. See https://on.cypress.io/configuration#Global"
60-
},
6153
"watchForFileChanges": {
6254
"type": "boolean",
6355
"default": true,

cli/types/cypress.d.ts

-12
Original file line numberDiff line numberDiff line change
@@ -2622,12 +2622,6 @@ declare namespace Cypress {
26222622
* @default {}
26232623
*/
26242624
env: { [key: string]: any }
2625-
/**
2626-
* 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.
2627-
* @default "*.hot-update.js"
2628-
* @deprecated use `excludeSpecPattern` instead
2629-
*/
2630-
ignoreTestFiles: string | string[]
26312625
/**
26322626
* 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.
26332627
* @default "*.hot-update.js"
@@ -2866,12 +2860,6 @@ declare namespace Cypress {
28662860
* Glob pattern to determine what test files to load.
28672861
*/
28682862
specPattern: string | string[]
2869-
/**
2870-
* Glob pattern to determine what test files to load.
2871-
*
2872-
* @deprecated Use `specPattern` under `component` or `e2e`
2873-
*/
2874-
testFiles: string | string[]
28752863
/**
28762864
* The user agent the browser sends in all request headers.
28772865
*/

npm/angular/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Enable component testing in `cypress.config.js`.
2828
module.exports = {
2929
"component": {
3030
"componentFolder": "src/app",
31-
"testFiles": "**/*cy-spec.ts"
31+
"specPattern": "**/*cy-spec.ts"
3232
}
3333
}
3434
```

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
exports['injects guessed next.js template cypress.config.ts'] = `
22
export default {
33
componentFolder: "src",
4-
testFiles: "**/*.spec.{js,ts,jsx,tsx}"
4+
specPattern: "**/*.spec.{js,ts,jsx,tsx}"
55
};
66
77
`
@@ -22,7 +22,7 @@ module.exports = (on, config) => {
2222
exports['Injected overridden webpack template cypress.config.ts'] = `
2323
export default {
2424
componentFolder: "cypress/component",
25-
testFiles: "**/*.spec.{js,ts,jsx,tsx}"
25+
specPattern: "**/*.spec.{js,ts,jsx,tsx}"
2626
};
2727
2828
`

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ describe('init component tests script', () => {
275275
expect(JSON.stringify(injectedCode.default, null, 2)).to.equal(JSON.stringify(
276276
{
277277
componentFolder: 'cypress/component',
278-
testFiles: '**/*.spec.{js,ts,jsx,tsx}',
278+
specPattern: '**/*.spec.{js,ts,jsx,tsx}',
279279
},
280280
null,
281281
2,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async function injectAndShowCypressConfig (
5858
) {
5959
const configToInject = {
6060
componentFolder,
61-
testFiles: '**/*.spec.{js,ts,jsx,tsx}',
61+
specPattern: '**/*.spec.{js,ts,jsx,tsx}',
6262
}
6363

6464
await injectOrShowConfigCode(() => insertValuesInConfigFile(cypressJsonPath, configToInject), {

npm/react/examples/find-webpack/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ Next, create a `cypress.json` with some basic configuration:
2727
```json
2828
{
2929
"component": {
30-
"testFiles": "**/*.test.{js,ts,jsx,tsx}",
30+
"specPattern": "**/*.test.{js,ts,jsx,tsx}",
3131
"componentFolder": "src"
3232
}
3333
}
3434
```
3535

36-
Here we are adding some Component Testing specific options, hence the `"component"` key. `"componentFolder"` is where all the components and tests are located, and `"testFiles"` is the pattern to search for test files.
36+
Here we are adding some Component Testing specific options, hence the `"component"` key. `"componentFolder"` is where all the components and tests are located, and `"specPattern"` is the pattern to search for test files.
3737

3838
The last thing we need to is tell Cypress to use `@cypress/webpack-dev-server` for component tests. Plugins are explained in detail in the [Cypress documentation](https://on.cypress.io/installing-plugins). By default plugins are loaded from `cypress/plugins/index.js`. Create that file and add:
3939

npm/vite-dev-server/cypress/new-signature/plugins.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = (on, config) => {
1717
)
1818
})
1919

20-
config.testFiles = '**/smoke.spec.ts'
20+
config.component.specPattern = '**/smoke.spec.ts'
2121

2222
return config
2323
}

packages/config/__snapshots__/index_spec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [
77
"experimentalShadowDomSupport",
88
"firefoxGcInterval",
99
"nodeVersion",
10-
"nodeVersion"
10+
"nodeVersion",
11+
"testFiles"
1112
]
1213

1314
exports['src/index .getDefaultValues returns list of public config keys 1'] = {

packages/config/lib/options.ts

+5
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ export const breakingOptions: Array<BreakingOption> = [
533533
errorKey: 'NODE_VERSION_DEPRECATION_BUNDLED',
534534
isWarning: true,
535535
},
536+
{
537+
name: 'testFiles',
538+
errorKey: 'TEST_FILES_DEPRECATION',
539+
isWarning: false,
540+
},
536541
]
537542

538543
export const breakingRootOptions: Array<BreakingOption> = [

packages/data-context/src/sources/migration/codegen.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ type ConfigOptions = {
2121
component: Record<string, unknown>
2222
}
2323

24+
type ResolvedConfigOptions = Cypress.ResolvedConfigOptions & {
25+
testFiles: string | string[]
26+
ignoreTestFiles: string | string[]
27+
}
28+
2429
/**
2530
* config format pre-10.0
2631
*/
@@ -361,7 +366,7 @@ export function reduceConfig (cfg: OldCypressConfig): ConfigOptions {
361366
}
362367

363368
if (key === 'e2e' || key === 'component') {
364-
const value = val as Cypress.ResolvedConfigOptions
369+
const value = val as ResolvedConfigOptions
365370

366371
if (!value) {
367372
return acc

packages/errors/__snapshot-html__/TEST_FILES_DEPRECATION.html

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

packages/errors/src/errors.ts

+21
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,27 @@ export const AllCypressErrors = {
13211321
`
13221322
},
13231323

1324+
TEST_FILES_DEPRECATION: (errShape: BreakingErrResult) => {
1325+
const code = errPartial`
1326+
{
1327+
e2e: {
1328+
specPattern: '...',
1329+
},
1330+
component: {
1331+
specPattern: '...',
1332+
},
1333+
}`
1334+
1335+
return errTemplate`\
1336+
The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}.
1337+
1338+
It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a testing type property: ${fmt.highlightSecondary('e2e.specPattern')} and ${fmt.highlightSecondary('component.specPattern')}
1339+
1340+
${fmt.code(code)}
1341+
1342+
https://on.cypress.io/migration-guide`
1343+
},
1344+
13241345
} as const
13251346

13261347
// eslint-disable-next-line @typescript-eslint/no-unused-vars

packages/errors/test/unit/visualSnapshotErrors_spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1101,5 +1101,10 @@ describe('visual error templates', () => {
11011101
default: ['custom.config.js', 'custom.json'],
11021102
}
11031103
},
1104+
TEST_FILES_DEPRECATION: () => {
1105+
return {
1106+
default: [{ name: 'testFiles', configFile: '/path/to/cypress.config.js.ts' }],
1107+
}
1108+
},
11041109
})
11051110
})

packages/server/test/integration/cypress_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,15 @@ describe('lib/cypress', () => {
411411
})
412412
})
413413

414-
it('runs project by limiting spec files via config.testFiles string glob pattern', function () {
414+
it('runs project by limiting spec files via config.e2e.specPattern string glob pattern', function () {
415415
return cypress.start([`--run-project=${this.todosPath}`, `--config={"e2e":{"specPattern":"${this.todosPath}/tests/test2.coffee"}}`])
416416
.then(() => {
417417
expect(browsers.open).to.be.calledWithMatch(ELECTRON_BROWSER, { url: 'http://localhost:8888/__/#/specs/runner?file=tests/test2.coffee' })
418418
this.expectExitWith(0)
419419
})
420420
})
421421

422-
it('runs project by limiting spec files via config.testFiles as a JSON array of string glob patterns', function () {
422+
it('runs project by limiting spec files via config.e2e.specPattern as a JSON array of string glob patterns', function () {
423423
return cypress.start([`--run-project=${this.todosPath}`, '--config={"e2e":{"specPattern":["**/test2.coffee","**/test1.js"]}}'])
424424
.then(() => {
425425
expect(browsers.open).to.be.calledWithMatch(ELECTRON_BROWSER, { url: 'http://localhost:8888/__/#/specs/runner?file=tests/test2.coffee' })

packages/types/src/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface FullConfig extends Partial<Cypress.RuntimeConfigOptions & Cypre
2929
// and are required when creating a project.
3030
export type ReceivedCypressOptions =
3131
Pick<Cypress.RuntimeConfigOptions, 'hosts' | 'projectName' | 'clientRoute' | 'devServerPublicPathRoute' | 'namespace' | 'report' | 'socketIoCookie' | 'configFile' | 'isTextTerminal' | 'isNewProject' | 'proxyUrl' | 'browsers' | 'browserUrl' | 'socketIoRoute' | 'arch' | 'platform' | 'spec' | 'specs' | 'browser' | 'version' | 'remote'>
32-
& Pick<Cypress.ResolvedConfigOptions, 'chromeWebSecurity' | 'supportFolder' | 'experimentalSourceRewriting' | 'fixturesFolder' | 'reporter' | 'reporterOptions' | 'screenshotsFolder' | 'pluginsFile' | 'supportFile' | 'baseUrl' | 'viewportHeight' | 'viewportWidth' | 'port' | 'experimentalInteractiveRunEvents' | 'userAgent' | 'downloadsFolder' | 'env' | 'testFiles' | 'excludeSpecPattern' | 'specPattern'> // TODO: Figure out how to type this better.
32+
& Pick<Cypress.ResolvedConfigOptions, 'chromeWebSecurity' | 'supportFolder' | 'experimentalSourceRewriting' | 'fixturesFolder' | 'reporter' | 'reporterOptions' | 'screenshotsFolder' | 'pluginsFile' | 'supportFile' | 'baseUrl' | 'viewportHeight' | 'viewportWidth' | 'port' | 'experimentalInteractiveRunEvents' | 'userAgent' | 'downloadsFolder' | 'env' | 'excludeSpecPattern' | 'specPattern'> // TODO: Figure out how to type this better.
3333

3434
export interface SampleConfigFile{
3535
status: 'changes' | 'valid' | 'skipped' | 'error'

system-tests/__snapshots__/config_spec.js

+20
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,23 @@ Please remove this option or add this as an e2e testing type property: e2e.baseU
281281
https://on.cypress.io/migration-guide
282282
283283
`
284+
285+
exports['e2e config throws an error if testFiles is set on the config file 1'] = `
286+
The testFiles configuration option is now invalid when set on the config object in Cypress version 10.0.0.
287+
288+
It is now renamed to specPattern and configured separately as a testing type property: e2e.specPattern and component.specPattern
289+
290+
291+
292+
{
293+
e2e: {
294+
specPattern: '...',
295+
},
296+
component: {
297+
specPattern: '...',
298+
},
299+
}
300+
301+
https://on.cypress.io/migration-guide
302+
303+
`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
testFiles: 'cypress/support/e2e.js',
3+
e2e: {},
4+
}

system-tests/projects/same-fixtures-integration-folders/cypress.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module.exports = {
22
'pluginsFile': false,
33
'fixturesFolder': 'cypress/e2e',
4-
'testFiles': '**/*spec.js',
54
'e2e': {
65
'supportFile': false,
76
},

system-tests/projects/unify-onboarding-with-config/cypress.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { devServer } = require('@cypress/webpack-dev-server')
33
module.exports = {
44
component: {
55
supportFile: false,
6-
testFiles: '**/*cy-spec.{js,jsx,ts,tsx}',
6+
specPattern: '**/*cy-spec.{js,jsx,ts,tsx}',
77
componentFolder: 'src',
88
devServer,
99
devServerConfig: {

system-tests/test/config_spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,15 @@ describe('e2e config', () => {
169169
snapshot: true,
170170
})
171171
})
172+
173+
it('throws an error if testFiles is set on the config file', async function () {
174+
await Fixtures.scaffoldProject('invalid-root-level-config')
175+
176+
return systemTests.exec(this, {
177+
project: 'invalid-root-level-config',
178+
configFile: 'invalid-testFiles-config.js',
179+
expectedExitCode: 1,
180+
snapshot: true,
181+
})
182+
})
172183
})

0 commit comments

Comments
 (0)