Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function runAudit() {
console.log('[a11y]: running accessibility audit...');
axe.run(
document,
{
rules: {
// This is a very annoying property of color-contrast that causes the page to scroll on page load.
// We disable it here. This 'options' structure is insane btw. wtf.
'color-contrast': { checks: { 'color-contrast': { options: { noScroll: true } } } },
},
},
(err, results) => {
if (err) throw err;
console.log('[a11y]:', results);
setErrorCount(results.violations.length);
setResults(results);
}
);
}
it('should be accessible when a query triggers an error', async done => {
// !BOOM
addQueryFilter('$qre()');
buildErrortReportElement();
await afterQueryError();
const axeResults = await axe.run(getRoot());
expect(axeResults).toBeAccessible();
done();
});
progress = progress.then(() => {
axe.reset();
if (config) {
axe.configure(config);
}
return axe
.run(
element || getElement(),
options ||
({
restoreScroll: true,
} as RunOptions) // cast to RunOptions is necessary because axe types are not up to date
)
.then(report)
.catch(error => addons.getChannel().emit(EVENTS.ERROR, String(error)));
});
};
new Promise((resolve, reject) => {
axe.run(html, {}, (err, { violations }) => {
if (err) {
reject(err)
}
if (violations.length > 0) {
reject(violations)
}
resolve(true)
})
})
it('should be accessible when configured as a div', async done => {
const tab = $$('div', {
className: Component.computeCssClassName(Tab),
'data-caption': 'All Content',
'data-id': 'All'
});
getTabSection().appendChild(tab.el);
await afterQuerySuccess();
const axeResults = await axe.run(getRoot());
expect(axeResults).toBeAccessible();
done();
});
it('should be accessible', async done => {
const omniboxElement = getOmniboxElement();
getSearchSection().appendChild(omniboxElement.el);
await afterQuerySuccess();
const axeResults = await axe.run(getRoot());
expect(axeResults).toBeAccessible();
done();
});
runA11yCheck() {
const { channel, axeOptions } = this.props;
const wrapper = findDOMNode(this);
if (wrapper !== null) {
axe.reset();
axe.configure(axeOptions);
axe.run(wrapper).then(results => channel.emit(CHECK_EVENT_ID, results), logger.error);
}
}
it('should be accessible', async done => {
await afterQuerySuccess();
await focusOnFirstSuggestion();
await waitForPreviews();
const axeResults = await axe.run(getRoot());
expect(axeResults).toBeAccessible();
done();
});
});
it('should be accessible when opened', async done => {
const cardOverlayElement = getOverlayElement();
testResultElement(cardOverlayElement.el);
await afterQuerySuccess();
getOverlayInstance().openOverlay();
await afterDelay(1000);
const axeResults = await axe.run(getRoot());
expect(axeResults).toBeAccessible();
done();
});