Skip to content

Instantly share code, notes, and snippets.

@jcdalton2201
Last active October 7, 2019 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcdalton2201/75e17d52f9c3f70b44316c69bb313f12 to your computer and use it in GitHub Desktop.
Save jcdalton2201/75e17d52f9c3f70b44316c69bb313f12 to your computer and use it in GitHub Desktop.
it('Test accessibility of the button', async () => {
const Differencify = require('differencify');
const differencify = new Differencify({});
browser = difUtil.setTestName(
differencify,
'Test accessibility of the button'
);
page = await difUtil.createPage(browser);
const bodyhandle = await difUtil.createBodyHandle(page);
await page.evaluate(element => {
element.innerHTML =
'<simple-button >Test Button</simple-button>';
}, bodyhandle);
await page.waitForSelector('pen-button');
const results = await new AxePuppeteer(page).include('pen-button').analyze();
expect(isValid(results)).toBeTruthy();
});
function isValid(results) {
results.violations.forEach(item => {
const id = item.id;
item.nodes.forEach(node => {
const html = node.html;
node.any.forEach(any => {
console.log(
`${any.impact} - ${chalk.magenta(
'id:' + id
)}: at location ${chalk.blue(html)}: ${chalk.red(any.message)}`
);
});
});
});
return results.violations.length < 1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment