diff --git a/package-lock.json b/package-lock.json index 88833fe7..76acb000 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index d9705aed..c7b00054 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/script/percy-tests.js b/script/percy-tests.js index ea4f8939..e2a9a7eb 100644 --- a/script/percy-tests.js +++ b/script/percy-tests.js @@ -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 () {