diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94178a4b..10dc05f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,3 +20,5 @@ jobs: run: npm run test:browser - name: Unit Tests (Server) run: npm run test:server + - name: Axe Tests + run: npm run test:axe diff --git a/package.json b/package.json index 90891e03..b69e51a4 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "lint:eslint": "eslint .", "lint:style": "stylelint \"**/*.{js,html}\" --ignore-path .gitignore", "test": "npm run lint && npm run test:bin && npm run test:server && npm run test:browser", + "test:axe": "npx d2l-test-runner axe", "test:bin": "mocha './test/bin/**/*.test.js'", "test:browser": "npm run test:browser:other && npm run test:browser:ctor", "test:browser:other": "npx d2l-test-runner --files \"./test/browser/**/*.test.js\"", diff --git a/src/browser/axe.js b/src/browser/axe.js index e172a645..6c0fbf2f 100644 --- a/src/browser/axe.js +++ b/src/browser/axe.js @@ -30,6 +30,7 @@ chai.Assertion.overwriteMethod('accessible', function(_super) { throw new Error(violationsMessages.join('---')); } + return this; }; }); /* eslint-enable */ diff --git a/test/browser/element.axe.js b/test/browser/element.axe.js new file mode 100644 index 00000000..bcb30853 --- /dev/null +++ b/test/browser/element.axe.js @@ -0,0 +1,36 @@ +import { expect, fixture } from '../../src/browser/index.js'; +import { html } from 'lit'; + +describe('axe', () => { + it('typography', async() => { + // If typography is set, font color should not match background color, so this should fail accessibility tests + const el = await fixture(html`
My content
+