Begin folding the axe tests into the puppeteer test

This commit is contained in:
Tessa Kelly 2022-04-14 10:15:15 -07:00
parent b09e6d6158
commit 8dfbd77d73
3 changed files with 34 additions and 0 deletions

15
package-lock.json generated
View File

@ -4,6 +4,21 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@axe-core/puppeteer": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/@axe-core/puppeteer/-/puppeteer-4.4.2.tgz",
"integrity": "sha512-HsiXUALjQ5fcWZZgGUvYGr/b7qvWbQXeDuW2z+2YYOJsavlPV9z0IGdm4rmX0lmsdJ9usA5vq5LNLiz23ZyXmw==",
"requires": {
"axe-core": "^4.4.1"
},
"dependencies": {
"axe-core": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.1.tgz",
"integrity": "sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw=="
}
}
},
"@babel/code-frame": {
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz",

View File

@ -33,6 +33,7 @@
"request": "^2.88.0"
},
"dependencies": {
"@axe-core/puppeteer": "^4.4.2",
"axe-core": "3.5.6",
"expect": "^27.4.6",
"http-server": "^14.1.0",

View File

@ -8,6 +8,9 @@ const platform = require('os').platform();
const puppeteerArgs = /^win/.test(platform) ? [] : ['--single-process'];
const PORT = process.env.PORT_NUMBER || 8000;
const { AxePuppeteer } = require('@axe-core/puppeteer');
const assert = require('assert');
describe('Visual tests', function () {
this.timeout(30000);
let page;
@ -74,7 +77,22 @@ describe('Visual tests', function () {
await page.goto(`http://localhost:${PORT}`);
await page.$('#maincontent');
await percySnapshot(page, this.test.fullTitle());
const results = await new AxePuppeteer(page).analyze();
page.close();
const violations = results["violations"];
if (violations) {
violations.map(function(violation) {
console.log("\n\n", violation["id"], ":", violation["description"])
console.log(violation["help"])
console.log(violation["helpUrl"])
console.table(violation["nodes"], ["html"])
});
assert.fail(`Expected no axe violations but got ${violations.length} violations`)
}
});
it('Doodads', async function () {