Skip to content

Commit 2f1f7cc

Browse files
authored
Merge branch '10.0-release' into view-spec-pattern-modal
2 parents 43030d7 + 8f32960 commit 2f1f7cc

File tree

26 files changed

+106
-51
lines changed

26 files changed

+106
-51
lines changed

cli/schema/cypress.schema.json

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

npm/angular/cypress.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export default defineConfig({
77
'fileServerFolder': 'src',
88
'projectId': 'nf7zag',
99
'component': {
10-
'supportFile': 'cypress/support/component.ts',
1110
setupNodeEvents (on, config) {
1211
return require('./cypress/plugins')(on, config)
1312
},

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export default defineConfig({
44
'video': true,
55
'projectId': 'jq5xpp',
66
'component': {
7-
'supportFile': 'cypress/support/component.ts',
87
devServer (cypressConfig) {
98
const findReactScriptsWebpackConfig = require('@cypress/react/plugins/react-scripts/findReactScriptsWebpackConfig')
109
const { startDevServer } = require('@cypress/webpack-dev-server')

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = defineConfig({
55
'viewportWidth': 500,
66
'viewportHeight': 800,
77
'component': {
8-
'supportFile': 'cypress/support/component.ts',
98
devServer: require('@cypress/react/plugins/react-scripts'),
109
},
1110
})

packages/config/__snapshots__/index_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ exports['src/index .getDefaultValues returns list of public config keys 1'] = {
5858
"screenshotsFolder": "cypress/screenshots",
5959
"slowTestThreshold": 10000,
6060
"scrollBehavior": "top",
61-
"supportFile": "cypress/support/e2e.js",
61+
"supportFile": "cypress/support/e2e.{js,jsx,ts,tsx}",
6262
"supportFolder": false,
6363
"taskTimeout": 60000,
6464
"trashAssetsBeforeRuns": true,

packages/config/lib/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ const resolvedOptions: Array<ResolvedConfigOption> = [
314314
canUpdateDuringTestTime: true,
315315
}, {
316316
name: 'supportFile',
317-
defaultValue: (options: Record<string, any> = {}) => options.testingType === 'component' ? 'cypress/support/component.js' : 'cypress/support/e2e.js',
317+
defaultValue: (options: Record<string, any> = {}) => options.testingType === 'component' ? 'cypress/support/component.{js,jsx,ts,tsx}' : 'cypress/support/e2e.{js,jsx,ts,tsx}',
318318
validation: validate.isStringOrFalse,
319319
isFolder: true,
320320
canUpdateDuringTestTime: false,

packages/data-context/src/actions/WizardActions.ts

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import fs from 'fs'
66
import path from 'path'
77

88
import type { DataContext } from '..'
9-
import { getDefaultSpecPatterns } from '../util/config-options'
109

1110
interface WizardGetCodeComponent {
1211
chosenLanguage: CodeLanguage
@@ -144,6 +143,7 @@ export class WizardActions {
144143
}
145144

146145
private async scaffoldConfig (configCode: string): Promise<NexusGenObjects['ScaffoldedFile']> {
146+
this.ctx.lifecycleManager.setConfigFilePath(this.ctx.coreData.wizard.chosenLanguage)
147147
if (!fs.existsSync(this.ctx.lifecycleManager.configFilePath)) {
148148
return this.scaffoldFile(
149149
this.ctx.lifecycleManager.configFilePath,
@@ -196,9 +196,7 @@ export class WizardActions {
196196
codeBlocks.push(lang === 'ts' ? `import { defineConfig } from 'cypress'` : `const { defineConfig } = require('cypress')`)
197197
codeBlocks.push('')
198198
codeBlocks.push(lang === 'ts' ? `export default defineConfig({` : `module.exports = defineConfig({`)
199-
codeBlocks.push(` ${E2E_SCAFFOLD_BODY({
200-
lang,
201-
}).replace(/\n/g, '\n ')}`)
199+
codeBlocks.push(` ${E2E_SCAFFOLD_BODY.replace(/\n/g, '\n ')}`)
202200

203201
codeBlocks.push('})\n')
204202

@@ -212,7 +210,7 @@ export class WizardActions {
212210
codeBlocks.push(chosenLanguage.type === 'ts' ? `import { defineConfig } from 'cypress'` : `const { defineConfig } = require('cypress')`)
213211
codeBlocks.push('')
214212
codeBlocks.push(chosenLanguage.type === 'ts' ? `export default defineConfig({` : `module.exports = defineConfig({`)
215-
codeBlocks.push(`// Component testing, ${chosenLanguage.name}, ${chosenFramework.name}, ${chosenBundler.name}`)
213+
codeBlocks.push(` // Component testing, ${chosenLanguage.name}, ${chosenFramework.name}, ${chosenBundler.name}`)
216214

217215
codeBlocks.push(` ${COMPONENT_SCAFFOLD_BODY({
218216
lang: chosenLanguage.type,
@@ -319,23 +317,13 @@ export class WizardActions {
319317
}
320318
}
321319

322-
interface E2eScaffoldOpts {
323-
lang: CodeLanguageEnum
324-
}
325-
326-
const E2E_SCAFFOLD_BODY = (opts: E2eScaffoldOpts) => {
327-
return dedent`
320+
const E2E_SCAFFOLD_BODY = dedent`
328321
e2e: {
329-
supportFile: 'cypress/support/e2e.${opts.lang}',
330-
specPattern: '${getDefaultSpecPatterns().e2e}',
331-
viewportHeight: 660,
332-
viewportWidth: 1000,
333322
setupNodeEvents(on, config) {
334323
// implement node event listeners here
335324
},
336325
},
337-
`
338-
}
326+
`
339327

340328
interface ComponentScaffoldOpts {
341329
lang: CodeLanguageEnum
@@ -346,13 +334,11 @@ interface ComponentScaffoldOpts {
346334

347335
const COMPONENT_SCAFFOLD_BODY = (opts: ComponentScaffoldOpts) => {
348336
return dedent`
349-
component: {
350-
supportFile: 'cypress/support/component.${opts.lang}',
351-
specPattern: '${getDefaultSpecPatterns().component}',
352-
devServer: import('${opts.requirePath}'),
353-
devServerConfig: ${opts.configOptionsString}
354-
},
355-
`
337+
component: {
338+
devServer: import('${opts.requirePath}'),
339+
devServerConfig: ${opts.configOptionsString}
340+
},
341+
`
356342
}
357343

358344
const FIXTURE_DATA = {

packages/data-context/src/data/ProjectLifecycleManager.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,20 +1105,20 @@ export class ProjectLifecycleManager {
11051105

11061106
if (fs.existsSync(configFileTs)) {
11071107
metaState.hasValidConfigFile = true
1108-
this._configFilePath = configFileTs
1108+
this.setConfigFilePath('ts')
11091109
}
11101110

11111111
if (fs.existsSync(configFileJs)) {
11121112
metaState.hasValidConfigFile = true
11131113
if (this._configFilePath) {
11141114
metaState.hasMultipleConfigPaths = true
11151115
} else {
1116-
this._configFilePath = configFileJs
1116+
this.setConfigFilePath('js')
11171117
}
11181118
}
11191119

11201120
if (!this._configFilePath) {
1121-
this._configFilePath = metaState.hasTypescript ? configFileTs : configFileJs
1121+
this.setConfigFilePath(metaState.hasTypescript ? 'ts' : 'js')
11221122
}
11231123

11241124
if (metaState.hasLegacyCypressJson && !metaState.hasValidConfigFile) {
@@ -1130,6 +1130,10 @@ export class ProjectLifecycleManager {
11301130
return metaState
11311131
}
11321132

1133+
setConfigFilePath (lang: 'ts' | 'js') {
1134+
this._configFilePath = this._pathToFile(`cypress.config.${lang}`)
1135+
}
1136+
11331137
private _pathToFile (file: string) {
11341138
return path.isAbsolute(file) ? file : path.join(this.projectRoot, file)
11351139
}

packages/frontend-shared/cypress.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export default defineConfig({
1717
'configFile': '../../mocha-reporter-config.json',
1818
},
1919
'component': {
20-
'supportFile': 'cypress/support/component.ts',
2120
devServer (cypressConfig, devServerConfig) {
2221
const { startDevServer } = require('@cypress/vite-dev-server')
2322

packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export const e2eProjectDirs = [
3131
'max-listeners',
3232
'migration',
3333
'multiple-task-registrations',
34-
'multiples-config-files-with-json',
34+
'multiple-config-files-with-json',
35+
'multiple-support-files',
3536
'no-scaffolding',
3637
'no-server',
3738
'no-specs-found',

0 commit comments

Comments
 (0)