Skip to content

Commit

Permalink
fix(component testing): default config values (#15902)
Browse files Browse the repository at this point in the history
Co-authored-by: Jessica Sachs <jess@jessicasachs.io>
  • Loading branch information
Akryum and JessicaSachs authored Apr 9, 2021
1 parent 8e894a0 commit a5bb2e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
19 changes: 4 additions & 15 deletions packages/server-ct/src/project-ct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import Debug from 'debug'
import config from '@packages/server/lib/config'
import plugins from '@packages/server/lib/plugins'
import devServer from '@packages/server/lib/plugins/dev-server'
import { ProjectBase } from '@packages/server/lib/project-base'
import { Cfg, ProjectBase } from '@packages/server/lib/project-base'
import settings from '@packages/server/lib/util/settings'
import specsUtil from '@packages/server/lib/util/specs'
import { ServerCt } from './server-ct'
import { SpecsStore } from './specs-store'
import { options } from '@packages/server/lib/config_options'

export * from '@packages/server/lib/project-base'

Expand All @@ -24,22 +23,12 @@ export class ProjectCt extends ProjectBase<ServerCt> {
* 2. otherwise, use 500/500 by default.
*/
addComponentTestingUniqueDefaults (cfg: Record<string, unknown>) {
const defaultViewport = options.reduce<Record<string, number>>((acc, curr) => {
if (curr.name === 'viewportHeight') {
return { ...acc, viewportHeight: curr.defaultValue as number }
}

if (curr.name === 'viewportWidth') {
return { ...acc, viewportWidth: curr.defaultValue as number }
}

return acc
}, {})
const rawJson = cfg.rawJson as Cfg

return {
...cfg,
viewportHeight: cfg.viewportHeight !== defaultViewport.viewportHeight ? cfg.viewportHeight : 500,
viewportWidth: cfg.viewportWidth !== defaultViewport.viewportWidth ? cfg.viewportWidth : 500,
viewportHeight: rawJson.viewportHeight ?? 500,
viewportWidth: rawJson.viewportWidth ?? 500,
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/server/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ module.exports = {
mergeDefaults (config = {}, options = {}) {
const resolved = {}

config.rawJson = _.cloneDeep(config)

_.extend(config, _.pick(options, 'configFile', 'morgan', 'isTextTerminal', 'socketId', 'report', 'browsers'))
debug('merged config with options, got %o', config)

Expand Down

4 comments on commit a5bb2e0

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a5bb2e0 Apr 9, 2021

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.2/circle-develop-a5bb2e0764c222fd482fbd0c17443d946a0ca15b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a5bb2e0 Apr 9, 2021

Choose a reason for hiding this comment

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

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.2/appveyor-develop-a5bb2e0764c222fd482fbd0c17443d946a0ca15b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a5bb2e0 Apr 9, 2021

Choose a reason for hiding this comment

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

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.2/appveyor-develop-a5bb2e0764c222fd482fbd0c17443d946a0ca15b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a5bb2e0 Apr 9, 2021

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.2/circle-develop-a5bb2e0764c222fd482fbd0c17443d946a0ca15b/cypress.tgz

Please sign in to comment.