question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cy.log args are no longer printed to the console showing newlines after cypress 7.2

See original GitHub issue

Current behavior

cy.log shows args as an array and doesn’t show the newlines that may be present. This make it very difficult to read large debug messages (something my QA users have come to depend on when debugging tests).

Desired behavior

cy.log entries when clicked are printed to the developer console showing newlines. This is helpful if you have large debug logs you wish to view. This is how it used to work in 7.2 and prior.

Test code to reproduce

"cypress": "7.2.0",  <=== shows newlines in console logs
...
"cypress": "7.3.0",  <=== behavior changed
it('cy.log works', () => {
  cy.log("Hello there from javascript", "this is not an array\nlarge logs with lots of lines\n\nmore logging\n\neven more")
})

Cypress Version

7.3+

Other

Cypress 7.2 and earlier: Screen Shot 2021-07-30 at 3 24 39 PM

Cypress 7.3 and later: Screen Shot 2021-07-30 at 3 23 45 PM

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sainthkhcommented, Aug 9, 2021

@westhomas I tried your solution, but it makes the output look unintuitive when there are 2+ args like below:

Screenshot from 2021-08-09 09-56-36

It’s hard to guess what 0, 1 means at a glance.

So, I changed it this way:

0reactions
chrisbreidingcommented, Sep 28, 2021

Released in 8.4.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v8.4.0, please open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

log - Cypress Documentation
Accepts a Markdown formatted message. args... Additional arguments to be printed to the Cypress Command Log. There is no limit to the number...
Read more >
archfz/cypress-terminal-report - GitHub
Plugin for cypress that adds better terminal output for easier debugging. Prints cy commands, browser console logs, cy.request and cy.intercept data.
Read more >
Why cy.log Prints Nothing - Gleb Bahmutov
Why cy.log command prints null or undefined even if the variable is set by the Cypress test. This is a very common question...
Read more >
Cypress - print both on console AND on log file - Windows
According to other users this should solve your problem: custom command: Cypress.Commands.overwrite('log', (subject, message) => cy.task('log', ...
Read more >
How to use Cypress cy.log command to output ... - YouTube
... to quickly dump some info into the Cypress Command Log. If needed, we can use `.then(JSON.stringify).then( cy. log )` to print larger......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found