Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/test.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
it('works!', () => {
cy.visit('/');
cy.injectAxe();
cy.checkA11y();
cy.checkA11y('body');
});
14 changes: 4 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as axe from 'axe-core';
import axe from 'axe-core';

declare global {
interface Window {
Expand All @@ -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<string>(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 = {}) => {
Expand Down