Closed orly-from closed 2 years ago
Hi @orly-from ! It looks like this issue was reported earlier in https://github.com/cypress-io/cypress/issues/5047.
I tried out the workaround described in the issue and it worked for me! Can you try it out?
it('Check socialShareIcons - events tests', function(){
cy.visit('https://www.gov.il/he/service/boost-monthly-scholarship');
cy.get('#WhatsappURL_Desktop').click();
cy.window().then(win => {
const gtagEvent = win.performance
.getEntriesByType('resource')
.filter(({name}) => {
return (
name.startsWith('https://www.google-analytics.com/collect?') &&
name.includes('t=event') &&
name.includes('ec=socialShareIcons')
)
})
// note: you may need to wait here if test is flaky b/c 'expect' is sometimes reached too soon
expect(gtagEvent, 'gtagEvent').to.have.lengthOf(1)
})
})
Let me know how it goes 🙂
Thank you Rachel!
It is working. I needed to add cy.wait(200) before cy.window().
Hi, It seems like sometimes cy.window() includes the specific event I need and sometimes not. Do you have any idea how to solve this problem? Â
@orly-from Issues in our GitHub repo are reserved for potential bugs or feature requests. We recommend questions relating to how to use Cypress be asked in our Discord server. Also try searching our existing GitHub issues, reading through our documentation, or searching Stack Overflow for relevant answers.
Hi @rachelruderman,
Thanks for your reply here. Can you help me on how to do the same for adobe analytics please?
Cheers, Jay.
I think that something that sometimes works and sometimes doesn't is a bug. Unless you tell me otherwise...
Current behavior
I want to test a gtag click event, but when I'm running my simple cypress test- the event is not displayed and can not be intercept/spy.
There are no 'collect' network calls displayed after the click.
Desired behavior
Intercept and test this event:
Test code to reproduce
it('Check socialShareIcons - events tests', function(){
Cypress Version
7.7.0
Node version
12.19.0
Operating System
Windows 10
Debug Logs
No response
Other
No response