Skip to content

Commit

Permalink
replacing the eval behavior to run axe to work properly with browserify
Browse files Browse the repository at this point in the history
  • Loading branch information
avanslaars committed Dec 5, 2019
1 parent aac748a commit cf6d885
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
Cypress.Commands.add('injectAxe', () => {
cy.window({ log: false }).then(window => {
const axe = require('axe-core')
window.axe = axe
window.eval(axe.source)
})
})

Cypress.Commands.add('configureAxe', (configurationOptions = {}) => {
cy.window({ log: false })
.then(win => {
return win.axe.configure(configurationOptions)
})
cy.window({ log: false }).then(win => {
return win.axe.configure(configurationOptions)
})
})

Cypress.Commands.add('checkA11y', (context, options, violationCallback) => {
Expand All @@ -18,9 +17,10 @@ Cypress.Commands.add('checkA11y', (context, options, violationCallback) => {
if (isEmptyObjectorNull(context)) context = undefined
if (isEmptyObjectorNull(options)) options = undefined
if (isEmptyObjectorNull(violationCallback)) violationCallback = undefined
return win.axe.run(context ?
context = context :
context = win.document, options)
return win.axe.run(
context ? (context = context) : (context = win.document),
options
)
})
.then(({ violations }) => {
if (violations.length) {
Expand Down

0 comments on commit cf6d885

Please sign in to comment.