Im new in cypress, trying to login to my practice web, but I got problem with this gtag. The actual testing with cypress is done (user success login) but there is one error that keeps make this testing failed, does anyone can help me?. this my pic and my cypress code and my config
This is my error pic
describe('Login user', () => {
beforeEach(() => {
cy.viewport(1392, 768)
cy.visit('thiswebcom')
})
it('Login as user', () => {
cy.get('a[href*="/login"]').first().click()
cy.get('#buttonLoginTrack').should('have.text', '\n Login\n ')
const userName = 'mymail@gmail.com'
const password = 'mypassword'
cy.get('#email').type(`${userName}`)
cy.get('#password').type(`${password}`).type('{enter}')
})
this is my cypress code for login in
module.exports = {
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
};
this is my cypress.config.js file
I tried with blockHosts but no idea how to put it in, thanks
Kitty.Flanagan's answer is a good one but should be cautious when using Cypress.on()
as it will have a global impact, whereas cy.on()
will only persist for the test file.
Furthermore, returning false will bypass all uncaught exceptions and can lead to issues not being caught by your tests.
Ultimately, you want raise issues for any uncaught exceptions to your dev team. In the chance that the uncaught exception is something thrown by 3rd party and cannot be addressed, then I would suggest adding the following to your test file.
cy.on('uncaught:exception', (err, runnable) => {
return !e.message.includes('ReferenceError: gtag is not defined in Cypress')
})