component-driven / cypress-axe

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

Suppost Cypress 5.0 #56

Closed 1881713 closed 4 years ago

1881713 commented 4 years ago

With Cypress 5.0 released, could this be added now to peerDependencies? I don't know if other changes would be needed. "peerDependencies": { "cypress": "^3.1.1 || ^4.0.2" },

amrwahdan3 commented 4 years ago

when running cypress 5.2.0 with cypress-axe i get: 'exports is not defined' error for axeFunction

is this related? Capture

aldosuwandi commented 4 years ago

This issue seemed to be caused by this line https://github.com/component-driven/cypress-axe/blob/master/src/index.js#L5 Unsure why cypress 5 is unhappy with axe.source. If I replace axe.source with cy.readFile('node_modules/axe-core/axe.min.js') it will solve the issue.

sapegin commented 4 years ago

@aldosuwandi That works, thanks! I believe #72 should fix the problem with Cypress 5.

github-actions[bot] commented 4 years ago

:tada: This issue has been resolved in version 0.10.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

rodrigomf24 commented 4 years ago

I am still getting this issue even using the latest version of cypress and cypress-axe, anyone found a solution?

rodrigomf24 commented 4 years ago

FYI for those using typescript the following script in the cypress/support/commands.ts file fixed it for me:

Cypress.Commands.add('injectAxe', () => {
  cy.readFile('./node_modules/axe-core/axe.js').then(function (source) {
    return cy.window({ log: false }).then(function (window) {
      window.eval(source);
    });
  });
});