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

fix: do not attempt to trim objects when printing to console #18341

Merged
merged 4 commits into from
Oct 11, 2021

Conversation

cbolgiano
Copy link
Contributor

@cbolgiano cbolgiano commented Oct 2, 2021

User facing changelog

There should no longer be a javascript console error when converting a javascript object that is not an array and not null when the logger logs a value. Fixes issue 18143.

Additional details

The issue seemed to have been caused by how lodash handles objects in https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/.internal/baseToString.js#L29. The version of the function in the 4.17.21 tag looks like this https://github.com/lodash/lodash/blob/4.17.21/dist/lodash.js#L4298. Line 4298 is what we see in the video captured in this issue.

I changed

_logValues (consoleProps) {
to convert the javascript object to a string by calling JSON.stringify if it is an object that isn't null and not an array. This should prevent the error "Cannot convert object to primitive value" from occurring in the javascript console.

How has the user experience changed?

Should no longer show "Cannot convert object to primitive value" in the javascript console when the logger tries to output the string value of an javascript object that is not an array and is not null.

PR Tasks

  • Has the original issue or this PR been tagged with a release in ZenHub?

@cbolgiano cbolgiano requested a review from a team as a code owner October 2, 2021 23:36
@cbolgiano cbolgiano requested review from flotwig and jennifer-shehane and removed request for a team October 2, 2021 23:36
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 2, 2021

Thanks for taking the time to open a PR!

@CLAassistant
Copy link

CLAassistant commented Oct 2, 2021

CLA assistant check
All committers have signed the CLA.

@cbolgiano cbolgiano changed the title WIP Resolves Issue 18143 Resolves Issue 18143 Oct 2, 2021
@cbolgiano cbolgiano changed the title Resolves Issue 18143 Fix issue 18143 Oct 2, 2021
@cbolgiano cbolgiano changed the title Fix issue 18143 Fix javascript console error for issue 18143 Oct 2, 2021
@cbolgiano
Copy link
Contributor Author

Good evening! My apologies for the failing Semantic Pull Request. Please can someone help me understand how to get that green again? Thank you.

@cbolgiano cbolgiano changed the title Fix javascript console error for issue 18143 Fix: javascript console error for issue 18143 Oct 3, 2021
@cbolgiano cbolgiano changed the title Fix: javascript console error for issue 18143 fix: javascript console error for issue 18143 Oct 3, 2021
@cbolgiano
Copy link
Contributor Author

I was able to find the document on the rules for the PR title.

Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

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

This change requires tests, one place you could put them would be here: https://github.com/cypress-io/cypress/blob/0964ca2c7d54c747bfae639fa4bda1cd86817f08/packages/runner-shared/src/logger.spec.js#L1-L17

You can run these tests via yarn test in packages/runner-shared

@cbolgiano
Copy link
Contributor Author

Added unit test and refactored based on suggestion. This pull request is ready for review again. Thank you!

@cbolgiano
Copy link
Contributor Author

It looks like the ci/circleci driver-integration-tests-chrome failed. I looked at the details and it looks like it might be a connection issue. How does one execute that job again to see if they pass this time?

@cbolgiano
Copy link
Contributor Author

After pulling in the main line the checks are now all green!

@cbolgiano
Copy link
Contributor Author

It looks like a e2e test failed. Need guidance on how to resolve if it is an issue. Thank you.

@pstakoun pstakoun requested a review from flotwig October 7, 2021 16:00
@cbolgiano
Copy link
Contributor Author

Going to dive into the tests that failed this weekend.

@flotwig
Copy link
Contributor

flotwig commented Oct 8, 2021

Going to dive into the tests that failed this weekend.

Those look like some flaky tests we've been dealing with lately. I'll rerun.

@cbolgiano cbolgiano requested a review from flotwig October 8, 2021 23:01
@cbolgiano
Copy link
Contributor Author

Going to dive into the tests that failed this weekend.

Those look like some flaky tests we've been dealing with lately. I'll rerun.

Thank you! It looks like you were right.

@cbolgiano
Copy link
Contributor Author

Please let me know if there is anything else I can do in order to get this accepted and merged. Thank you!

flotwig
flotwig previously approved these changes Oct 11, 2021
Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks for the contribution @cbolgiano !

@flotwig flotwig changed the base branch from master to develop October 11, 2021 17:21
@flotwig flotwig dismissed their stale review October 11, 2021 17:21

The base branch was changed.

@flotwig flotwig changed the title fix: javascript console error for issue 18143 fix: do not attempt to trim objects when printing to console Oct 11, 2021
@flotwig flotwig merged commit 7a4c59a into cypress-io:develop Oct 11, 2021
tgriesser added a commit that referenced this pull request Oct 13, 2021
…ramework

* unified-desktop-gui:
  fix conflicts
  fix conflicts
  feat: create a copy when selecting a pre-existing story (#18440)
  feat: add configured state to TestingTypeCard (#18461)
  feat(app): run e2e tests (#18448)
  fix: frontend-shared typo on windi config
  feat: make the select language component (#18443)
  chore: Update Chrome (stable) to 94.0.4606.81 (#18411)
  release 8.6.0
  fix: do not attempt to trim objects when printing to console (#18341)
  fix(driver): `cy.pause()` should not be ignored with `cypress run --headed --no-exit` (#18358)
  chore: release @cypress/vite-dev-server-v2.1.1
  chore: release @cypress/react-v5.10.1
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.

Error when printing an object to the dev tools console
3 participants