diff --git a/cypress/e2e/test.cy.js b/cypress/e2e/test.cy.js index 9350f23..3a90af6 100644 --- a/cypress/e2e/test.cy.js +++ b/cypress/e2e/test.cy.js @@ -1,5 +1,5 @@ it('works!', () => { cy.visit('/'); cy.injectAxe(); - cy.checkA11y(); + cy.checkA11y('body'); }); diff --git a/src/index.ts b/src/index.ts index 89d9981..8fe6c1d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import * as axe from 'axe-core'; +import axe from 'axe-core'; declare global { interface Window { @@ -22,15 +22,9 @@ export interface Options extends axe.RunOptions { } export const injectAxe = () => { - const fileName = - typeof require?.resolve === 'function' - ? require.resolve('axe-core/axe.min.js') - : 'node_modules/axe-core/axe.min.js'; - cy.readFile(fileName).then((source) => - cy.window({ log: false }).then((window) => { - window.eval(source); - }) - ); + cy.window({ log: false }).then((window) => { + window.axe = axe; + }) }; export const configureAxe = (configurationOptions = {}) => {