Last active
July 22, 2020 20:33
-
-
Save scalvert/26ef28a762589d4bf780b2e24e332e48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { _registerHook } from '@ember/test-helpers'; | |
import a11yAuditIf from 'ember-a11y-testing/test-support/audit-if'; | |
function getUrlParameter(name) { | |
const location = utils.getLocation(); | |
const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); | |
const results = regex.exec(location.search); | |
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); | |
} | |
/** | |
* Should be imported and invoked early in the test suite, ideally in test-helper.js | |
*/ | |
export function setupA11yGloablHooks() { | |
if (getUrlParameter('setupA11yGloablHooks')) { | |
_registerHook('visit', 'end', async (...args) => { | |
await a11yAuditIf(...args); | |
}); | |
// implement hooks calls for every other helper you want to hook into, such as click | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment