Skip to content
1 change: 0 additions & 1 deletion packages/data-context/__snapshots__/codegen.spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ const { defineConfig } = require('cypress')
module.exports = defineConfig({
component: {
setupNodeEvents(on, config) {},
componentFolder: '.',
specPattern: './**/*.spec.cy.{js,ts,jsx,tsx}',
},
})
Expand Down
14 changes: 10 additions & 4 deletions packages/data-context/src/sources/migration/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { hasDefaultExport } from './parserUtils'
import type { LegacyCypressConfigJson } from '..'
import { parse } from '@babel/parser'
import generate from '@babel/generator'
import _ from 'lodash'
import { getBreakingKeys } from '@packages/config'

const debug = Debug('cypress:data-context:sources:migration:codegen')

Expand Down Expand Up @@ -383,19 +385,23 @@ export function reduceConfig (cfg: LegacyCypressConfigJson, options: CreateConfi
const isDefaultE2E = key === 'e2e' && specPattern === `cypress/e2e/${ext}`
const isDefaultCT = key === 'component' && specPattern === ext

const breakingKeys = getBreakingKeys()
const restWithoutBreakingKeys = _.omit(rest, breakingKeys)
const existingWithoutBreakingKeys = _.omit(acc[key], breakingKeys)

if (isDefaultE2E || isDefaultCT) {
return {
...acc, [key]: {
...rest,
...acc[key],
...restWithoutBreakingKeys,
...existingWithoutBreakingKeys,
},
}
}

return {
...acc, [key]: {
...rest,
...acc[key],
...restWithoutBreakingKeys,
...existingWithoutBreakingKeys,
specPattern,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ describe('reduceConfig', () => {
hasE2ESpec: false,
hasPluginsFile: false,
projectRoot: '',
hasTypescript: false,
isUsingTypeScript: false,
isProjectUsingESModules: false,
shouldAddCustomE2ESpecPattern: false,
}
Expand Down Expand Up @@ -448,6 +448,7 @@ describe('reduceConfig', () => {
}
const newConfig = reduceConfig(config, options)

expect(newConfig.component.componentFolder).to.not.exist
expect(newConfig.component.specPattern).to.eq('src/**/**.cy.js')
expect(newConfig.e2e.specPattern).to.eq(`${config.e2e.integrationFolder}/${config.testFiles}`)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"componentFolder": "src",
"supportFile": false,
"component": {
"testFiles": "**/*spec.{js,tsx}"
"testFiles": "**/*spec.{js,tsx}",
"componentFolder": "src"
}
}