component-driven / cypress-axe

Test accessibility with axe-core in Cypress
MIT License
622 stars 86 forks source link

Using the skipFailures flag results in tests failing #110

Open ivanMatijasTildeLoop opened 3 years ago

ivanMatijasTildeLoop commented 3 years ago

I was trying out the skipFailures flag on some Cypress tests, and while it works in most scenarios, it does fail on a few specific tests due to the following error: Cannot read properties of undefined (reading 'run') at Context.eval (webpack:///node_modules/cypress-axe/dist/index.js:52:1) From previous event: at Context.thenFn (http://localhost:3333/__cypress/runner/cypress_runner.js:156453:24) at Context.then (http://localhost:3333/__cypress/runner/cypress_runner.js:156892:22) at Context.<anonymous> (http://localhost:3333/__cypress/runner/cypress_runner.js:171546:22) at <unknown> (http://localhost:3333/__cypress/runner/cypress_runner.js:170970:16) From previous event: at runCommand (http://localhost:3333/__cypress/runner/cypress_runner.js:170949:9) at next (http://localhost:3333/__cypress/runner/cypress_runner.js:171095:15) at <unknown> (http://localhost:3333/__cypress/runner/cypress_runner.js:171123:17) From previous event: at next (http://localhost:3333/__cypress/runner/cypress_runner.js:171095:35) From previous event: at Promise.catch.err.name (http://localhost:3333/__cypress/runner/cypress_runner.js:171136:38) From previous event: at run (http://localhost:3333/__cypress/runner/cypress_runner.js:171129:22) at $Cy.cy.<computed> [as injectAxe] (http://localhost:3333/__cypress/runner/cypress_runner.js:171586:12) at Context.runnable.fn (http://localhost:3333/__cypress/runner/cypress_runner.js:171813:22) at callFn (http://localhost:3333/__cypress/runner/cypress_runner.js:105099:22) at Test.../driver/node_modules/mocha/lib/runnable.js.Runnable.run (http://localhost:3333/__cypress/runner/cypress_runner.js:105086:8) at <unknown> (http://localhost:3333/__cypress/runner/cypress_runner.js:177607:29) From previous event: at Object.onRunnableRun (http://localhost:3333/__cypress/runner/cypress_runner.js:177595:18) at $Cypress.action (http://localhost:3333/__cypress/runner/cypress_runner.js:167954:29) at Test.Runnable.run (http://localhost:3333/__cypress/runner/cypress_runner.js:175744:14) at Runner.../driver/node_modules/mocha/lib/runner.js.Runner.runTest (http://localhost:3333/__cypress/runner/cypress_runner.js:105758:11) at <unknown> (http://localhost:3333/__cypress/runner/cypress_runner.js:105884:13) at next (http://localhost:3333/__cypress/runner/cypress_runner.js:105667:15) at <unknown> (http://localhost:3333/__cypress/runner/cypress_runner.js:105677:8) at next (http://localhost:3333/__cypress/runner/cypress_runner.js:105579:15) at <unknown> (http://localhost:3333/__cypress/runner/cypress_runner.js:105645:6) at timeslice (http://localhost:3333/__cypress/runner/cypress_runner.js:99571:28)

This is the test in question that fails: describe("and When user selects an active element", () => { it("should navigate away to product page", () => { cy.injectAxe() cy.get("[data-testid='element_1111111']").click().wait(333)

            cy.url().should("include", "#111111")
            cy.checkA11y(null, null, terminalLog, true)
        })

})

Removing the flag will result in the test failing, but due to actual accessibility problems (so the package is working properly)