Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: throw when writing to 'read only' properties of config #18896

Merged
merged 88 commits into from
Dec 10, 2021

Conversation

davidmunechika
Copy link
Contributor

@davidmunechika davidmunechika commented Nov 12, 2021

User facing changelog

Cypress will throw an error when a user attempts to set these 'non-writable' config values using Cypress.config.

Additional details

The following were identified as properties that could be updated during test time:

  • animationDistanceThreshold
  • baseUrl
  • blockHosts
  • defaultCommandTimeout
  • env
  • execTimeout
  • experimentalSessionSupport
  • includeShadowDom
  • keystrokeDelay
  • numTestsKeptInMemory
  • pageLoadTimeout
  • redirectionLimit
  • requestTimeout
  • responseTimeout
  • retries
  • screenshotOnRunFailure
  • scrollBehavior
  • slowTestThreshold
  • taskTimeout
  • viewportHeight
  • viewportWidth
  • waitForAnimations

The following were identified as read-only properties for per test config:

  • autoOpen (internal)
  • browsers
  • chromeWebSecurity
  • clientCertificates
  • clientRoute (internal)
  • component
  • componentFolder
  • configFile (internal)
  • devServerPublicPathRoute (internal)
  • downloadsFolder
  • e2e
  • exit
  • experimentalFetchPolyfill
  • experimentalInteractiveRunEvents
  • experimentalSourceRewriting
  • experimentalStudio
  • fileServerFolder
  • fixturesFolder
  • hosts
  • ignoreTestFiles
  • integrationFolder
  • isInteractive
  • isTextTerminal
  • modifyObstructiveCode
  • morgan (internal)
  • namespace (internal)
  • nodeVersion
  • pluginsFile
  • port
  • projectId
  • reporter
  • reporterOptions
  • reporterRoute (internal)
  • resolvedNodePath
  • resolvedNodeVersion
  • socketId (internal)
  • socketIoCookie (internal)
  • socketIoRoute (internal)
  • supportFile
  • testFiles
  • trashAssetsBeforeRuns
  • userAgent
  • video
  • videoCompression
  • videoUploadOnPasses
  • videosFolder
  • watchForFileChanges
  • xhrRoute (internal)

User experience

Trying to set read-only config in test configuration:

Screenshot 2021-11-23 at 8 57 09 AM

Trying to set read-only config within test with Cypress.config():

Screenshot 2021-11-23 at 8 57 43 AM

PR Tasks

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 12, 2021

Thanks for taking the time to open a PR!

@davidmunechika davidmunechika self-assigned this Nov 12, 2021
@cypress-io cypress-io deleted a comment from cypress bot Nov 12, 2021
@cypress
Copy link

cypress bot commented Nov 12, 2021



Test summary

18741 0 202 0Flakiness 4


Run details

Project cypress
Status Passed
Commit de7b436
Started Dec 10, 2021 3:23 PM
Ended Dec 10, 2021 3:35 PM
Duration 11:08 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

commands/net_stubbing_spec.ts Flakiness
1 network stubbing > waiting and aliasing > can timeout waiting on a single request using "alias.request"
2 network stubbing > intercepting request > should delay the same amount on every response
cypress/proxy-logging-spec.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code
2 ... > works with forceNetworkError

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@chrisbreiding chrisbreiding self-requested a review December 9, 2021 14:46
chrisbreiding
chrisbreiding previously approved these changes Dec 9, 2021
configUtil.validateNoReadOnlyConfig({ foo: 'bar' }, errorFn)

expect(errorFn).to.been.callCount(0)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also assert that the argument passed to the error function is the expected option?

Copy link
Contributor

Choose a reason for hiding this comment

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

While you're at it, expect(errorFn).to.have.callCount(0) or expect(errorFn).not.to.have.beenCalled 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be updated!

tbiethman
tbiethman previously approved these changes Dec 9, 2021
chrisbreiding
chrisbreiding previously approved these changes Dec 9, 2021
tbiethman
tbiethman previously approved these changes Dec 9, 2021
@davidmunechika davidmunechika merged commit dd0fc9b into develop Dec 10, 2021
@davidmunechika davidmunechika deleted the issue-6407-warn-for-read-only-properties branch December 10, 2021 16:16
tgriesser added a commit that referenced this pull request Dec 15, 2021
* develop:
  chore(deps): update dependency ssri to 6.0.2 [security] (#19351)
  chore: Fix server unit tests running on mac by using actual tmp dir (#19350)
  fix: Add more precise types to Cypress.Commands (#19003)
  fix: Do not screenshot or trigger the failed event when tests are skipped (#19331)
  fix (#19262)
  fix: throw when writing to 'read only' properties of `config` (#18896)
  fix: close chrome when closing electron (#19322)
  fix: disable automatic request retries (#19161)
  chore: refactor cy funcs (#19080)
  chore(deps): update dependency @ffmpeg-installer/ffmpeg to v1.1.0 🌟 (#19300)
@jennifer-shehane jennifer-shehane changed the title fix: throw when writing to 'read only' properties of config feat: throw when writing to 'read only' properties of config Dec 15, 2021
tgriesser added a commit that referenced this pull request Dec 16, 2021
…cycle

* 10.0-release:
  build: remove syncRemoteGraphQL from codegen
  chore: fix incorrect type from merge
  build: allow work with local dashboard (#19376)
  chore: Test example recipes against chrome (#19362)
  test(unify): Settings e2e tests (#19324)
  chore(deps): update dependency ssri to 6.0.2 [security] (#19351)
  fix: spec from story generation, add deps for install (#19352)
  chore: Fix server unit tests running on mac by using actual tmp dir (#19350)
  fix: Add more precise types to Cypress.Commands (#19003)
  fix: Do not screenshot or trigger the failed event when tests are skipped (#19331)
  fix (#19262)
  fix: throw when writing to 'read only' properties of `config` (#18896)
  fix: close chrome when closing electron (#19322)
  fix: disable automatic request retries (#19161)
  chore: refactor cy funcs (#19080)
  chore(deps): update dependency @ffmpeg-installer/ffmpeg to v1.1.0 🌟 (#19300)
@Robdel12
Copy link

Robdel12 commented Dec 27, 2021

Looks like this is a breaking change for the Percy Cypress SDK, but I don't think it should be. percy/percy-cypress#447 We're only calling config to check the value, not setting. https://github.com/percy/percy-cypress/blob/master/index.js#L38-L39

Edit: this is what I get for half doing something on my time off. I just realized we set in the test suite to test the SDK option. 🤦🏼‍♂️ false alarm

Error: CypressError: `Cypress.config()` cannot mutate option `isInteractive` because it is a read-only property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typescript for runtime properties still missing? Warn when writing to 'read only' properties of config
5 participants