diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index b2055cbbecb1..a524f14a8483 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -1,4 +1,12 @@ +## 13.7.2 + +_Released 4/2/2024 (PENDING)_ + +**Bugfixes:** + +- Fixed a bug where fields using arrays in `cypress.config` are not correctly processed. Fixes [#27103](https://github.com/cypress-io/cypress/issues/27103). Fixed in [#27312](https://github.com/cypress-io/cypress/pull/27312). + ## 13.7.1 _Released 3/21/2024_ diff --git a/packages/app/cypress/e2e/subscriptions/specChange-subscription.cy.ts b/packages/app/cypress/e2e/subscriptions/specChange-subscription.cy.ts index cd6d0a6662fb..8f4b5b85d1b7 100644 --- a/packages/app/cypress/e2e/subscriptions/specChange-subscription.cy.ts +++ b/packages/app/cypress/e2e/subscriptions/specChange-subscription.cy.ts @@ -444,6 +444,40 @@ e2e: { cy.get('[data-cy="file-match-indicator"]', { timeout: 7500 }) .should('contain', '3 matches') + + // Regression for https://github.com/cypress-io/cypress/issues/27103 + cy.withCtx(async (ctx) => { + await ctx.actions.file.writeFileInProject('cypress.config.js', +` +module.exports = { + projectId: 'abc123', + experimentalInteractiveRunEvents: true, + component: { + specPattern: 'src/**/*.{spec,cy}.{js,jsx,ts,tsx}', + supportFile: false, + devServer: { + framework: 'react', + bundler: 'webpack', + } + }, + e2e: { + specPattern: ['cypress/e2e/**/dom-cont*.spec.{js,ts}'], + supportFile: false, + setupNodeEvents(on, config) { + /** + * This should make Cypress yield a "no specs found" error. + * + * This stops being the case if 'specPattern' is an array. + */ + config.specPattern = []; + return config; + }, + }, +}`) + }) + + cy.get('[data-cy="create-spec-page-title"]') + .should('contain', defaultMessages.createSpec.page.customPatternNoSpecs.title) }) }) }) diff --git a/packages/config/src/project/index.ts b/packages/config/src/project/index.ts index 00e8984651e1..c997ab7d35d7 100644 --- a/packages/config/src/project/index.ts +++ b/packages/config/src/project/index.ts @@ -105,8 +105,16 @@ export function updateWithPluginValues (cfg: FullConfig, modifiedConfig: any, te debug('resolved config object %o', cfg.resolved) } + const diffsClone = _.cloneDeep(diffs) ?? {} + // merge cfg into overrides - const merged = _.defaultsDeep(diffs, cfg) + const merged = _.defaultsDeep(diffs, cfg) ?? {} + + for (const [key, value] of Object.entries(diffsClone)) { + if (Array.isArray(value)) { + merged[key] = _.cloneDeep(value) + } + } debug('merged config object %o', merged)