cypress-axe icon indicating copy to clipboard operation
cypress-axe copied to clipboard

TypeError : Cannot read properties of undefined (reading 'run')

Open Harvo09 opened this issue 2 years ago • 3 comments

Visiting my homepage and running checkA11y() is working just fine. My next test selects the login button to get us to the Login page. I run checkAlly() there and get the following

image image

The documentation says this should be fine, use Cypress to interact, then call checkA11y()

// Basic usage after interacting with the page it('Has no a11y violations after button click', () => { // Interact with the page, then check for a11y issues cy.get('button').click() cy.checkA11y() })

Any help welcome

Harvo09 avatar Jul 13 '23 09:07 Harvo09

I'm getting the same error while running my tests too !

Radhey2040 avatar Aug 04 '23 20:08 Radhey2040

I was seeing a similar issue, if I had a simple test it seemed to be working fine but once I started adding a few more steps everything seemed to return this same error.

I managed to fix my issue, hopefully this helps others: according to the documentation they recommended placing the cy.injectAxe(); near the top of the code block, and then in most examples I see the cy.checkA11y(); placed near the end. Well, in a few of my tests I believe I was loading a new view or page in between the two, causing it to blow up.

My fix ended up being moving all of the cy.injectAxe(); down to directly above the cy.checkA11y(); and suddenly all of my "TypeError : Cannot read properties of undefined (reading 'run')" issues disappeared.

Not sure if this is the ultimate fix, but it worked for me.

cqc-dave avatar Sep 08 '23 17:09 cqc-dave

I am also seeing something similar to this issue

Cannot read properties of undefined (reading 'run') "cypress-axe": "1.5.0", "cypress": "12.17.4", and also on "cypress": "13.13.1",

describe('check a11y', () => { it('running a11y on google', () => { cy.visit(https://www.google.com/); cy.injectAxe(); cy.checkA11y(); }); });

Screenshot 2023-10-18 at 2 20 31 PM

Screenshot 2023-10-18 at 2 21 26 PM

artipsingh avatar Oct 18 '23 18:10 artipsingh