Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jest): add custom results processor for a11y failures #62

Merged
merged 78 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
77b7277
refactor: use map to consolidate results; add a util to convert axe r…
mohanraj-r May 12, 2021
5d17571
feat: add minimal custom jest reporter
mohanraj-r May 13, 2021
76aa29f
refactor: move custom jest reporter to typescript inside jest pkg
mohanraj-r May 14, 2021
a6d04be
build: move jest reporter pkg dependency from root to jest pkg
mohanraj-r May 14, 2021
443b4e1
feat: access and store a11y violations from reporter
mohanraj-r May 17, 2021
228b384
refactor: revert to using default test runner with on run complete hook
mohanraj-r May 18, 2021
483cdf7
build: remove obsolete jest circus pkg, add jest test-result pkg
mohanraj-r May 19, 2021
aed493c
refactor: revert conditional gates to reduce indented blocks
mohanraj-r May 21, 2021
43f1f5c
refactor: serialize a11y error into failure message and parse it back
mohanraj-r May 21, 2021
ca71b30
refactor: revert serialize a11y error into failure msg
mohanraj-r May 25, 2021
84c8546
test(eslint): add ignore pattern for unused vars rule
mohanraj-r May 25, 2021
e183191
refactor: consolidate a11y results from reporter keyed on test path
mohanraj-r May 26, 2021
be9661f
refactor: replace hardcoded output file path in reporter with config
mohanraj-r May 26, 2021
8cf387f
build: add xml pkg dependency
mohanraj-r May 27, 2021
7f0bbda
feat: add xml output support for reporter
mohanraj-r May 27, 2021
dba9a81
feat: add a WIP test results processor that currently filters failed …
mohanraj-r May 28, 2021
fc68b02
feat: create a new test suite for a11y errors duplicated from existin…
mohanraj-r May 28, 2021
b0f480d
refactor: remove err msg from original suite for now
mohanraj-r May 28, 2021
0695605
refactor: extract test result processing into its own function
mohanraj-r May 29, 2021
57fa2be
feat: transform a11y error details into suite, test names
mohanraj-r May 29, 2021
097b2a1
test: add data and first set of basic tests for test results processor
mohanraj-r Jun 1, 2021
0457cd2
refactor: split up results processing logic into smaller functions
mohanraj-r Jun 1, 2021
97b8cf0
refactor: update failure msgs format
mohanraj-r Jun 1, 2021
6f19075
feat: add wcag metadata to results output
mohanraj-r Jun 1, 2021
54bf098
refactor: move wcag metadata processing into format pkg, add tests
mohanraj-r Jun 1, 2021
dfd4cfb
refactor: remove sc prefix for best practice
mohanraj-r Jun 1, 2021
5179445
build: add jest test result pkg dep to sa11y pkgs
mohanraj-r Jun 1, 2021
dd0a65f
refactor: remove redundant err msg header in a11y error class
mohanraj-r Jun 3, 2021
fcaaa3b
refactor: convert axe violations into a11y results for reuse
mohanraj-r Jun 3, 2021
1e07f4d
refactor: move sorting violations from a11y error into a11y results
mohanraj-r Jun 3, 2021
878e9d5
test: rename result processor test file name to align with module tested
mohanraj-r Jun 3, 2021
6728614
build: update ES lib/target to ES 2019 based on TS recommendation
mohanraj-r Jun 4, 2021
bcbb2db
test: add tests to generate data for testing results processor
mohanraj-r Jun 4, 2021
4e0ed0b
test: update result processor snapshots
mohanraj-r Jun 4, 2021
8be300c
refactor: reuse a11y results in results processor
mohanraj-r Jun 4, 2021
6686a0c
refactor: reorganize result processor code into smaller functions
mohanraj-r Jun 5, 2021
b9ba221
refactor: replace wcag obj ref with formatted string in result
mohanraj-r Jun 7, 2021
15b0d4b
test: replace hard-coded test results data with generated data
mohanraj-r Jun 8, 2021
067a4d6
refactor: add a11 failure summary, rearrange output order, update tes…
mohanraj-r Jun 8, 2021
817985b
refactor: change formatting of wcag tags, remove redundant format method
mohanraj-r Jun 9, 2021
f224b55
refactor: move suite name to class name and rule name to test name
mohanraj-r Jun 9, 2021
ce51ed0
refactor: narrow scope of function to convert a11y failure to a test …
mohanraj-r Jun 9, 2021
be1de3d
refactor: consolidate a11y results within a suite
mohanraj-r Jun 9, 2021
52b7e05
test: add more data for result processor tests
mohanraj-r Jun 10, 2021
0e05588
refactor: remove obsolete jest custom reporter
mohanraj-r Jun 10, 2021
0a60d6f
refactor: fix code cov for format opts
mohanraj-r Jun 10, 2021
fe47b54
test: add tests for a11y results consolidation
mohanraj-r Jun 10, 2021
c6ef300
docs: update dependency graph
mohanraj-r Jun 10, 2021
8838979
refactor: add format opts to de-duplicate
mohanraj-r Jun 10, 2021
b2482e0
refactor(reporter): rearrange order of output info, sort wcag tags
mohanraj-r Jun 14, 2021
71eea8a
build: add results processor to pkg export, add console log for resul…
mohanraj-r Jun 15, 2021
cce6621
refactor: capitalize a11y error msg header
mohanraj-r Jun 15, 2021
5a4fc3f
refactor: add wrapper for console log with common prefix
mohanraj-r Jun 15, 2021
124256f
docs: revise automatic check docs and add info about custom reporter
mohanraj-r Jun 15, 2021
73004ac
chore: update dev deps
mohanraj-r Jun 15, 2021
a8f2d0d
fix(format): revert default value of formatter to fix codecov
mohanraj-r Jun 15, 2021
a24ed27
chore(release): bump pkg versions, update changelog
mohanraj-r Jun 15, 2021
174c47f
docs: add section about updating deps
mohanraj-r Jun 15, 2021
467cb5b
ci: update circle ci orb versions
mohanraj-r Jun 15, 2021
b4bfda6
build: update jest to v27
mohanraj-r Jun 15, 2021
fc355d5
revert "build: update jest to v27" due to incorrect codecov data
mohanraj-r Jun 15, 2021
b29acf5
ci: add run in band option to jest cli for stable codecov output with…
mohanraj-r Jun 16, 2021
9ef8ac5
test: update utils test to increase code cov
mohanraj-r Jun 16, 2021
131eb9f
test(utils): expand tests to fix missing code cov
mohanraj-r Jun 16, 2021
34dd7e4
test(utils): fix missing code cov on conditional branch
mohanraj-r Jun 16, 2021
7470dab
test: exclude statement from code cov that is causing issue in CI
mohanraj-r Jun 17, 2021
aedf3c1
test: add code cov exceptions to edge cases
mohanraj-r Jun 17, 2021
15decaa
test(jest): add script cmd to invoke automatic checks and output json…
mohanraj-r Jun 17, 2021
fcc2646
refactor(resultsProcessor): rename functions and improve docs for rea…
mohanraj-r Jun 17, 2021
88c30a6
refactor: add a debug flag to enable console log msg and silence by d…
mohanraj-r Jun 21, 2021
acb0ab1
docs(jest): add limitations of automatic checks and json result trans…
mohanraj-r Jun 21, 2021
7717c3d
refactor: remove duplicated consolidation logic based on axe results
mohanraj-r Jun 22, 2021
6582930
refactor: unify consolidation based on a11y results
mohanraj-r Jun 22, 2021
39c80ef
refactor: rename a11y results consolidate function to add for brevity
mohanraj-r Jun 22, 2021
b424e86
test: fix visual a11y issues count for wdio test
mohanraj-r Jun 22, 2021
6e0fc7e
refactor: create a convenience A11yResults class and remove Consolida…
mohanraj-r Jun 22, 2021
3052554
docs(jest): reword limitations of automatic checks for readability
mohanraj-r Jun 22, 2021
d24cea3
docs(jest): fix indentation in json results example
mohanraj-r Jun 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1
orbs:
node: circleci/node@4.1.0
browser-tools: circleci/[email protected].0
node: circleci/node@4.5.0
browser-tools: circleci/[email protected].3
jobs:
build-and-test:
executor:
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = {
templateFile: 'license-header.txt',
},
],
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/naming-convention': 'error',
'tsdoc/syntax': 'warn',
'prefer-arrow-callback': 'warn',
Expand Down
38 changes: 25 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,61 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [0.8.0-beta](#080-beta)
- [0.9.0-beta](#090-beta)
- [Features](#features)
- [0.8.0-beta (2021-03-19)](#080-beta-2021-03-19)
- [Features](#features-1)
- [BREAKING CHANGES](#breaking-changes)
- [Refactor](#refactor)
- [0.7.0-beta (2021-02-24)](#070-beta-2021-02-24)
- [Features](#features-1)
- [0.6.0-beta (2021-01-22)](#060-beta-2021-01-22)
- [Features](#features-2)
- [0.5.0-beta (2020-12-01)](#050-beta-2020-12-01)
- [0.6.0-beta (2021-01-22)](#060-beta-2021-01-22)
- [Features](#features-3)
- [0.5.0-beta (2020-12-01)](#050-beta-2020-12-01)
- [Features](#features-4)
- [0.4.1-beta (2020-11-24)](#041-beta-2020-11-24)
- [Bug Fixes](#bug-fixes)
- [0.4.0-beta (2020-10-31)](#040-beta-2020-10-31)
- [Features](#features-4)
- [Features](#features-5)
- [Refactor](#refactor-1)
- [0.3.2-beta (2020-09-22)](#032-beta-2020-09-22)
- [Bug Fixes](#bug-fixes-1)
- [Refactor](#refactor-2)
- [0.3.1-beta (2020-08-20)](#031-beta-2020-08-20)
- [Refactor](#refactor-3)
- [0.3.0-beta (2020-08-19)](#030-beta-2020-08-19)
- [Features](#features-5)
- [0.2.0-beta (2020-06-25)](#020-beta-2020-06-25)
- [Features](#features-6)
- [0.2.0-beta (2020-06-25)](#020-beta-2020-06-25)
- [Features](#features-7)
- [Bug Fixes](#bug-fixes-2)
- [BREAKING CHANGES](#breaking-changes-1)
- [v0.1.0-alpha (2020-06-02)](#v010-alpha-2020-06-02)
- [Features](#features-7)
- [(2020-05-29)](#2020-05-29)
- [Features](#features-8)
- [(2020-05-29)](#2020-05-29)
- [Features](#features-9)
- [(2020-05-07)](#2020-05-07)
- [Bug Fixes](#bug-fixes-3)
- [Features](#features-9)
- [Features](#features-10)
- [(2020-04-07)](#2020-04-07)
- [Bug Fixes](#bug-fixes-4)
- [Features](#features-10)
- [Features](#features-11)
- [(2020-03-20)](#2020-03-20)
- [Bug Fixes](#bug-fixes-5)
- [Features](#features-11)
- [Features](#features-12)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# [0.8.0-beta] (2021-03-19)
# [0.9.0-beta] (2021-06-15)

### Features

- **jest:** de-duplicate a11y failures for automatic checks ([#61](https://github.com/salesforce/sa11y/issues/61))
- **jest:** add a custom test results processor ([#62](https://github.com/salesforce/sa11y/pull/62))
- create a new test suite to hold a11y errors
- add wcag metadata to results output
- transform a11y error details into suite, test names

# [0.8.0-beta](https://github.com/salesforce/sa11y/releases/tag/v0.8.0-beta) (2021-03-19)

### Features

Expand Down
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ We want to encourage the developer community to contribute to Sa11y. This guide
- [Unit Testing](#unit-testing)
- [Integration Testing](#integration-testing)
- [Release](#release)
- [Upgrade dependencies](#upgrade-dependencies)
- [Use local npm registry for testing](#use-local-npm-registry-for-testing)
- [Editor Configurations](#editor-configurations)
- [Types](#types)
Expand Down Expand Up @@ -161,6 +162,16 @@ Your test should now be running in the Chrome debugger. You get your handy conso
- Push the `release` branch and create a pull request against `master`
- with PR title of the format `chore(release): ...`

#### Upgrade dependencies

- `yarn install:update`
- Select dependencies to update
- Check for CircleCI Orb updates
- [circleci/node](https://circleci.com/developer/orbs/orb/circleci/node)
- [circleci/browser-tools](https://circleci.com/developer/orbs/orb/circleci/browser-tools)
- update CircleCI config file
- [Test CI config](#test-ci-config)

#### Use local npm registry for testing

- Use [verdaccio](https://github.com/verdaccio/verdaccio) to spin-up a local npm registry
Expand Down
168 changes: 90 additions & 78 deletions docs/sa11y_dependency_graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ module.exports = {
testPathIgnorePatterns: [browserLibTestPath, integrationTestPath, wdioTestPath],
// Direct Jest to read the jest config file from integration tests
projects: ['<rootDir>', integrationTestPath],
testEnvironment: 'jsdom',
// Custom results processor for a11y results. Only affects JSON results file output.
// To be used with jest cli options --json --outputFile
// * e.g. jest --json --outputFile jestResults.json
// Ref: https://jestjs.io/docs/configuration#testresultsprocessor-string
testResultsProcessor: '<rootDir>/packages/jest/dist/resultsProcessor.js',
};
49 changes: 25 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sa11y-monorepo",
"version": "0.8.0-beta",
"version": "0.9.0-beta",
"private": true,
"description": "Salesforce Accessibility Automated Testing Libraries and Tools (@sa11y packages)",
"license": "BSD-3-Clause",
Expand Down Expand Up @@ -40,11 +40,12 @@
"release:version": "yarn pkg:diff; lerna version --no-push --no-git-tag-version && yarn build:clean",
"release:version:auto": "yarn release:version --conventional-commits --no-changelog && yarn build:clean",
"release:publish": "yarn test:clean && lerna publish from-package",
"test": "jest --coverage",
"test": "jest --coverage --runInBand",
"test:ci": "yarn lint:all && yarn test --ci && yarn test:wdio",
"test:clean": "yarn build:clean && yarn test:ci",
"test:debug": "node --inspect node_modules/.bin/jest --runInBand --watch",
"test:debug": "SA11Y_DEBUG=1 node --inspect node_modules/.bin/jest --runInBand --watch",
"test:watch": "jest --watch",
"test:auto": "SA11Y_AUTO=1 yarn test --json --outputFile jestResults.json",
"test:wdio": "wdio run wdio.conf.js --suite wdio --suite integration --suite browserLib < /dev/null",
"prepare": "husky install"
},
Expand All @@ -54,50 +55,50 @@
}
},
"devDependencies": {
"@babel/core": "7.14.0",
"@babel/preset-env": "7.14.1",
"@babel/preset-typescript": "7.13.0",
"@commitlint/cli": "12.1.1",
"@commitlint/config-conventional": "12.1.1",
"@babel/core": "7.14.6",
"@babel/preset-env": "7.14.5",
"@babel/preset-typescript": "7.14.5",
"@commitlint/cli": "12.1.4",
"@commitlint/config-conventional": "12.1.4",
"@types/jest": "26.0.23",
"@types/node": "15.0.2",
"@typescript-eslint/eslint-plugin": "4.22.1",
"@typescript-eslint/parser": "4.22.1",
"@types/node": "15.12.2",
"@typescript-eslint/eslint-plugin": "4.27.0",
"@typescript-eslint/parser": "4.27.0",
"@wdio/cli": "6.12.1",
"@wdio/local-runner": "6.10.5",
"@wdio/mocha-framework": "6.10.4",
"@wdio/spec-reporter": "6.11.0",
"@wdio/sync": "6.10.4",
"babel-jest": "26.6.3",
"chromedriver": "90.0.0",
"babel-jest": "27.0.2",
"chromedriver": "91.0.1",
"codecov": "3.8.2",
"commitizen": "4.2.3",
"commitizen": "4.2.4",
"conventional-changelog-cli": "2.1.1",
"cspell": "5.4.0",
"depcheck": "1.4.0",
"doctoc": "2.0.0",
"eslint": "7.25.0",
"cspell": "5.6.4",
"depcheck": "1.4.1",
"doctoc": "2.0.1",
"eslint": "7.28.0",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.4.0",
"eslint-plugin-eslint-comments": "3.2.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jest": "24.3.6",
"eslint-plugin-markdown": "2.1.0",
"eslint-plugin-markdown": "2.2.0",
"eslint-plugin-notice": "0.9.10",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-tsdoc": "0.2.14",
"eslint-watch": "7.0.0",
"husky": "6.0.0",
"jest": "26.6.3",
"lerna": "4.0.0",
"lint-staged": "10.5.4",
"lint-staged": "11.0.0",
"lockfile-lint": "4.6.2",
"markdown-link-check": "3.8.7",
"package-dependency-graph": "1.11.2",
"prettier": "2.2.1",
"prettier": "2.3.1",
"rimraf": "3.0.2",
"ts-node": "9.1.1",
"typescript": "4.2.4",
"ts-node": "10.0.0",
"typescript": "4.3.2",
"vertioner": "1.0.6",
"wdio-chromedriver-service": "6.0.4",
"webdriverio": "6.12.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/assert/__tests__/__snapshots__/assert.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/assert/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa11y/assert",
"version": "0.2.3",
"version": "0.2.4",
"description": "Provides assertAccessible API to check DOM for accessibility issues",
"license": "BSD-3-Clause",
"homepage": "https://github.com/salesforce/sa11y/tree/master/packages/assert#readme",
Expand All @@ -21,13 +21,13 @@
"dist/**/*.d.ts*"
],
"dependencies": {
"@sa11y/common": "0.3.0",
"@sa11y/format": "0.3.4",
"@sa11y/common": "0.3.1",
"@sa11y/format": "0.4.0",
"@sa11y/preset-rules": "0.3.3",
"axe-core": "4.1.4"
},
"devDependencies": {
"@sa11y/test-utils": "0.4.0"
"@sa11y/test-utils": "0.4.1"
},
"publishConfig": {
"access": "public"
Expand Down
12 changes: 6 additions & 6 deletions packages/browser-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa11y/browser-lib",
"version": "0.4.0",
"version": "0.4.1",
"description": "Provides a minified version of selected `@sa11y` libraries to be injected into a browser (using webdriver) and executed from integration testing workflows.",
"license": "BSD-3-Clause",
"homepage": "https://github.com/salesforce/sa11y/tree/master/packages/browser-lib#readme",
Expand Down Expand Up @@ -34,16 +34,16 @@
"url": "https://github.com/salesforce/sa11y/issues"
},
"dependencies": {
"@sa11y/format": "0.3.4",
"@sa11y/format": "0.4.0",
"@sa11y/preset-rules": "0.3.3",
"axe-core": "4.1.4"
},
"devDependencies": {
"@rollup/plugin-commonjs": "18.1.0",
"@rollup/plugin-commonjs": "19.0.0",
"@rollup/plugin-node-resolve": "13.0.0",
"@sa11y/common": "0.3.0",
"@sa11y/test-utils": "0.4.0",
"rollup": "2.47.0",
"@sa11y/common": "0.3.1",
"@sa11y/test-utils": "0.4.1",
"rollup": "2.51.2",
"rollup-plugin-polyfill-node": "0.6.2",
"rollup-plugin-progress": "1.1.2",
"rollup-plugin-sizes": "1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa11y/common",
"version": "0.3.0",
"version": "0.3.1",
"description": "Common utilities, constants, error messages for @sa11y",
"license": "BSD-3-Clause",
"homepage": "https://github.com/salesforce/sa11y/tree/master/packages/common#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { AxeResults } from './axe';

export const errMsgHeader = 'accessibility issues found';
export const errMsgHeader = 'Accessibility issues found';

/**
* Filter to post-process a11y results from axe
Expand Down
16 changes: 16 additions & 0 deletions packages/common/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

/**
* Convenience wrapper to prefix a standard header for console log messages.
* Logging is enabled only when environment variable `SA11Y_DEBUG` is set.
*/
export function log(...args: unknown[]): void {
// Probably not worth it to mock and test console logging for this helper util
/* istanbul ignore next */
if (process.env.SA11Y_DEBUG) console.log('♿[Sa11y]', ...args);
}
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
export { A11yConfig, AxeResults, axeRuntimeExceptionMsgPrefix, axeVersion, getViolations } from './axe';
export { WdioAssertFunction, WdioOptions, WdioBrowser } from './wdio';
export { errMsgHeader, ExceptionList } from './format';
export { log } from './helpers';
Loading