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.

Capture + Display all logs for everything that happens in Cypress

See original GitHub issue

Problem

Many of our users express the desire to see console.log statements when running headlessly. Typically you’d be able to see these when you’re working in Dev Tools (in headed GUI mode).

We can pretty easily display console.log statements by mixing them into stdout when running headlessly, but we don’t think this is really a “true” solution. It’s kind of a hack and it still doesn’t really tell you “everything” that’s happening. For instance, when a console.log happens, how would you know when it happened in relation to everything else that’s going on in a test?

So, we think to truly solve this problem, we need a comprehensive way of displaying not just console.log statements but also capturing:

  • Network Traffic
  • Commands
  • Retries
  • Under the hood Cypress wizardry
  • DOM snapshots on failure

By providing all of this, the entire picture of what happened during a test is revealed and now you actually have even more information at your disposal than even what the GUI headed version provides you.

Solution

We’re going to make these logs available both in our Dashboard, and in the Desktop App itself.

Once we capture and parse these logs, it will unlock an enormous amount of power in Cypress. We’ll also be able to analyze the logs and deliver things like:

  • Analytics into your tests
  • Comparing a failing test to a previously passing one
  • Diffing the logs for changes in response bodies, etc
  • Understanding why tests are slow
  • Discovering command anti patterns (like explicit waits in your code)

The logs could also be interactive - for instance they should “sync” up to the video and enable you to playback everything that actually happened in a Cypress test.

Here is an example comp of what we’re going for.

logs 1

We’re still working on communicating the start and end of logs, and also communicating that a log event acts as “a stream” but that events are connected to other events.

For instance when a HTTP request starts - that’s a ‘start’ event. When the response comes back, thats a separate ‘end’ event. However these are connected and you likely need to be able to view the data for both events from either the start or end event.

Another example:

A command starts. It retries 65x times. It eventually finishes. The duration of the retry events, the reason its retrying, and the eventual delta between a start and an end needs to be communicated intelligently.

These log files end up being a massive amount of data, but we already have the infrastructure in place to capture, parse and deliver them. At this point we’re just iterating on a UI that’s intuitive and doesn’t overwhelm the user.

We’re going to be providing a new Logs tab, but also for individual test failures, we’ll just be providing the logs for that one independent test.

Feedback

…is welcome 😉

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:300
  • Comments:76 (20 by maintainers)

github_iconTop GitHub Comments

62reactions
jennifer-shehanecommented, Apr 14, 2020

This issue is still in the ‘proposal’ stage, which means no work has been done on this issue as of today, so we do not have an estimate on when this will be delivered.

Current workarounds: use these plugins

53reactions
mitarcommented, Mar 2, 2019

OK, while we wait for this perfect solution described in OP to arrive, I would really like to vote for a very simple solution of redirecting all browser console to the terminal during CI run. It is really hard to debug anything currently when it fails in CI. I would love to simple see in terminal all logging calls I might have inside tests themselves and also from my app. I mean, we already have those logging calls for debugging with a browser, let’s just log them to the terminal as well.

Let’s not make the perfect the enemy of the good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging
You can see a walk-through of debugging some application code from Cypress in this segment from our React tutorial series. Get console logs...
Read more >
log
Print a message to the Cypress Command Log. Syntax Usage Correct Usage Arguments ... The commands above will display in the Command Log...
Read more >
Screenshots and Videos
Cypress comes with the ability to take screenshots, whether you are running via cypress open or cypress run , even in CI. To...
Read more >
screenshot
Take a screenshot of the application under test and, optionally, the Cypress Command Log. Syntax Usage Correct Usage Arguments fileName (String) A name....
Read more >
Catalog of Events
Logging All Events ... Cypress uses the debug node module for both the back end server process, and for everything running in the...
Read more >

github_iconTop Related Medium Post

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