Skip to content

Commit

Permalink
fix: retain original array after defaultsDeep #27240 (#27312)
Browse files Browse the repository at this point in the history
* modifying object after array combination to hold older values

* regression test

* made suggested changes

* config defaults

* log

* logs

* log

* log again

* update log

* changelog

* updates changelog

* fix typo and move changelog entry and fix link

---------

Co-authored-by: Nihar Phansalkar <phansalkarnihar@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com>
Co-authored-by: Cacie Prins <cacie@cypress.io>
Co-authored-by: AtofStryker <bglesias@gmail.com>
  • Loading branch information
6 people committed Mar 25, 2024
1 parent f17fa4c commit 19075c7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
## 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_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
10 changes: 9 additions & 1 deletion packages/config/src/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

4 comments on commit 19075c7

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 19075c7 Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.7.2/linux-x64/develop-19075c70cf642decb47e77295dcfdbcbccfbeeac/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 19075c7 Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.7.2/darwin-arm64/develop-19075c70cf642decb47e77295dcfdbcbccfbeeac/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 19075c7 Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.7.2/darwin-x64/develop-19075c70cf642decb47e77295dcfdbcbccfbeeac/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 19075c7 Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.7.2/linux-arm64/develop-19075c70cf642decb47e77295dcfdbcbccfbeeac/cypress.tgz

Please sign in to comment.