Skip to content

Instantly share code, notes, and snippets.

@bjankord bjankord/index.js
Created Jan 14, 2019

Embed
What would you like to do?
axe-core + puppeteer set up
const util = require('util');
const puppeteer = require('puppeteer');
const axe = require('axe-core');
const urls = [
'https://engineering.cerner.com/terra-ui/#/home/terra-ui/index',
'https://engineering.cerner.com/terra-ui/#/getting-started/terra-ui/what-is-terra',
];
const results = [];
let axeResults;
puppeteer.launch().then(async browser => {
const promises = [];
for (let i = 0; i < urls.length; i++) {
const url = urls[i];
promises.push(browser.newPage().then(async page => {
await page.goto(`${url}`);
// add axe-core to the pages
await page.addScriptTag({
path: require.resolve('axe-core')
});
// run axe on the page
axeResults = await page.evaluate(async () => {
return await axe.run();
});
// remove result data we don't need
delete axeResults.passes;
delete axeResults.inapplicable;
delete axeResults.incomplete;
// add results to the collection of axe results
results.push(axeResults);
}))
}
await Promise.all(promises)
browser.close();
console.log(util.inspect(results, false, null, true))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.