mercredi 24 février 2021

How to handle type error (Cannot read property ' ' of undefined ) in cypress

I am taking a screenshot of a certain page by "cy.matchImageSnapshot". The error is thrown (Cannot read property ' ' of undefined). How can I resolve/ignore this? I have added my code and a screenshot of the console.

    describe('Test', () => {
    it('Testcase 1', () => {
      cy.on('uncaught:exception', (err, runnable) => {
        expect(err.message).to.include('of undefined')
        done()
        return false
      })
      cy.visit("https://www.damensch.com/?root=logo")
      cy.wait(10000)
      cy.contains('Allow').click()
      cy.scrollTo(0, 10000)     
      cy.scrollTo(10000, 0)
      cy.wait(5000)
      cy.matchImageSnapshot();        
    });

Console Screenshot after adding cy.on('uncaught:exception')

Console Screenshot without adding cy.on('uncaught:exception'

Index.js Screenshot

Aucun commentaire:

Enregistrer un commentaire