Allow for "global logging" to be possible from Cypress events
See original GitHub issueCurrent 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:
- Created 5 years ago
- Comments:12 (12 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve added Sentry to the list of integrations we’re considering in our integrations issue: https://github.com/cypress-io/cypress/issues/981
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.