Skip to content

Commit 8365251

Browse files
authored
fix: Don't crash when require.resolve is not defined (#86)
Fixes #82
1 parent db50459 commit 8365251

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export interface Options extends axe.RunOptions {
2222
}
2323

2424
export const injectAxe = () => {
25-
cy.readFile<string>(require.resolve('axe-core/axe.min.js')).then((source) =>
25+
const fileName =
26+
typeof require?.resolve === 'function'
27+
? require.resolve('axe-core/axe.min.js')
28+
: 'node_modules/axe-core/axe.min.js';
29+
cy.readFile<string>(fileName).then((source) =>
2630
cy.window({ log: false }).then((window) => {
2731
window.eval(source);
2832
})

0 commit comments

Comments
 (0)