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.

Allow for "global logging" to be possible from Cypress events

See original GitHub issue

Current behavior:

Cyrrently, attempting to make a cy.log call either onBeforeLoad or on fail is not working. I need to output some metadata to test runner on each run so i can reconcile the test run with our Sentry integration in case there is a backend or JS error which is not being captured in the test runner.

These codes do not work

Cypress.on('window:before:load', win => {
  win.SentryReleaseVersion = (new Date()).toISOString() + randomString(5);
  console.log('Release Version', win.SentryReleaseVersion)
  cy.log('Release Version', win.SentryReleaseVersion);
});

Cypress.on('fail', () => {
  cy.window().then(win => {
    console.log('Release Version', win.SentryReleaseVersion)
    cy.log('Release Version', win.SentryReleaseVersion);
    Cypress.log({
      name: 'Test',
      message: win.SentryReleaseVersion
    })
  })
})

Desired behavior:

I would like a clear path to accomplish the above use case without writing a beforeEach for every suite in the app.

Versions

3.0.1

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Jun 19, 2018

I’ve added Sentry to the list of integrations we’re considering in our integrations issue: https://github.com/cypress-io/cypress/issues/981

0reactions
jennifer-shehanecommented, Mar 31, 2021

Since this issue hasn’t had activity in a while, we’ll close the issue until we can confirm this is still happening. Please comment if there is new information to provide concerning the original issue and we’d be happy to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Catalog of Events - Cypress Documentation
Logging All Events. Cypress uses the debug node module for both the back end server process, and for everything running in the browser...
Read more >
Best Practices - Cypress Documentation
Use another platform that you control to log in with username and password via cy.origin() . This likely guarantees that you will not...
Read more >
task | Cypress Documentation
The task plugin event handler can return a value or a promise. The command will fail if undefined is returned or if the...
Read more >
Using Events Emitted from Your Application during End-to ...
In this blog post I will show how to start using web app events in your end-to-end tests with minimal effort. Oh, and...
Read more >
visit - Cypress Documentation
The URL to visit. Cypress will prefix the URL with the baseUrl configured in your global configuration if set. If the baseUrl has...
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