Skip to content

Instantly share code, notes, and snippets.

@scalvert
Last active July 22, 2020 20:33
Show Gist options
  • Save scalvert/26ef28a762589d4bf780b2e24e332e48 to your computer and use it in GitHub Desktop.
Save scalvert/26ef28a762589d4bf780b2e24e332e48 to your computer and use it in GitHub Desktop.
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