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

fix: automatic checks file filter to be exclusion only to keep it simple #84

Merged
merged 9 commits into from
Nov 20, 2021
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
executor:
name: node/default
# TODO: switch back to 'lts'. Temp workaround for issues with lts v16.
# https://github.com/salesforce/sa11y/issues/82
tag: '14.18.1'
steps:
- browser-tools/install-chrome
Expand Down
30 changes: 21 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [3.1.0 (2021-11-18)](#310-2021-11-18)
- [Bug Fixes](#bug-fixes)
- [3.0.2 (2021-11-02)](#302-2021-11-02)
- [Reverts](#reverts)
- [3.0.1 (2021-10-21)](#301-2021-10-21)
- [Refactor](#refactor)
- [3.0.0 (2021-09-16)](#300-2021-09-16)
Expand Down Expand Up @@ -32,42 +36,50 @@
- [0.5.0-beta (2020-12-01)](#050-beta-2020-12-01)
- [Features](#features-6)
- [0.4.1-beta (2020-11-24)](#041-beta-2020-11-24)
- [Bug Fixes](#bug-fixes)
- [Bug Fixes](#bug-fixes-1)
- [0.4.0-beta (2020-10-31)](#040-beta-2020-10-31)
- [Features](#features-7)
- [Refactor](#refactor-2)
- [0.3.2-beta (2020-09-22)](#032-beta-2020-09-22)
- [Bug Fixes](#bug-fixes-1)
- [Bug Fixes](#bug-fixes-2)
- [Refactor](#refactor-3)
- [0.3.1-beta (2020-08-20)](#031-beta-2020-08-20)
- [Refactor](#refactor-4)
- [0.3.0-beta (2020-08-19)](#030-beta-2020-08-19)
- [Features](#features-8)
- [0.2.0-beta (2020-06-25)](#020-beta-2020-06-25)
- [Features](#features-9)
- [Bug Fixes](#bug-fixes-2)
- [Bug Fixes](#bug-fixes-3)
- [BREAKING CHANGES](#breaking-changes-1)
- [v0.1.0-alpha (2020-06-02)](#v010-alpha-2020-06-02)
- [Features](#features-10)
- [(2020-05-29)](#2020-05-29)
- [Features](#features-11)
- [(2020-05-07)](#2020-05-07)
- [Bug Fixes](#bug-fixes-3)
- [Bug Fixes](#bug-fixes-4)
- [Features](#features-12)
- [(2020-04-07)](#2020-04-07)
- [Bug Fixes](#bug-fixes-4)
- [Bug Fixes](#bug-fixes-5)
- [Features](#features-13)
- [(2020-03-20)](#2020-03-20)
- [Bug Fixes](#bug-fixes-5)
- [Bug Fixes](#bug-fixes-6)
- [Features](#features-14)

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

# 3.0.2 (2021-11-02)
# 3.1.0 (2021-11-18)

### Bug Fixes

- automatic checks file filter to be exclusion only to keep it simple
- add sa11y common pkg as dep instead of dev dep

# [3.0.2](https://github.com/salesforce/sa11y/releases/tag/v3.0.2) (2021-11-02)

### Reverts

* filtering of non-a11y results introduced in 3.0.1
* as it is causing issues with certain CI workflows that produce no test results file
- filtering of non-a11y results introduced in 3.0.1
- as it is causing issues with certain CI workflows that produce no test results file

# [3.0.1](https://github.com/salesforce/sa11y/releases/tag/v3.0.1) (2021-10-21)

Expand Down
172 changes: 92 additions & 80 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: 2 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"packages": [
"packages/*"
],
"version": "3.0.2",
"packages": ["packages/*"],
"version": "3.1.0",
"exact": true,
"npmClient": "yarn",
"useWorkspaces": true,
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"build:clean": "tsc --build --clean && rimraf packages/**/dist && yarn build:ci",
"build:watch": "tsc --build --watch",
"commit": "! git diff --cached --exit-code && lint-staged && git-cz",
"install:clean": "lerna clean --yes && rimraf yarn.lock && yarn install",
"install:clean": "lerna clean --yes && rimraf yarn.lock && rimraf node_modules && yarn install",
"install:update": "yarn audit; yarn upgrade-interactive --latest && yarn install:clean && yarn test:clean",
"lint": "eslint . --ext ts,js,md",
"lint:all": "tsc --noEmit && yarn lint && yarn lint:lockfile && yarn lint:deps && yarn lint:depgraph",
"lint:deps": "lerna exec depcheck",
"lint:depgraph": "yarn pkg:depgraph && git diff --quiet docs/sa11y_dependency_graph.svg || echo 'Dependency graph needs to be updated!'",
"lint:depgraph": "yarn pkg:depgraph && git diff --quiet docs/sa11y_dependency_graph.svg || (echo 'Dependency graph needs to be updated!'; exit 1)",
"lint:fix": "yarn lint --fix",
"lint:lockfile": "lockfile-lint --path yarn.lock --allowed-hosts registry.yarnpkg.com --validate-https",
"lint:staged": "lint-staged",
Expand Down Expand Up @@ -54,11 +54,11 @@
}
},
"devDependencies": {
"@babel/core": "7.15.8",
"@babel/preset-env": "7.15.8",
"@babel/preset-typescript": "7.15.0",
"@commitlint/cli": "13.2.1",
"@commitlint/config-conventional": "13.2.0",
"@babel/core": "7.16.0",
"@babel/preset-env": "7.16.4",
"@babel/preset-typescript": "7.16.0",
"@commitlint/cli": "15.0.0",
"@commitlint/config-conventional": "15.0.0",
"@types/jest": "26.0.24",
"@types/node": "15.14.1",
"@typescript-eslint/eslint-plugin": "4.31.1",
Expand All @@ -69,35 +69,35 @@
"@wdio/spec-reporter": "6.11.0",
"@wdio/sync": "6.10.4",
"babel-jest": "27.3.1",
"chromedriver": "94.0.0",
"chromedriver": "96.0.0",
"codecov": "3.8.3",
"commitizen": "4.2.4",
"conventional-changelog-cli": "2.1.1",
"cspell": "5.12.3",
"cspell": "5.13.0",
"depcheck": "1.4.2",
"doctoc": "2.1.0",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-eslint-comments": "3.2.0",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-jest": "24.4.0",
"eslint-plugin-markdown": "2.2.1",
"eslint-plugin-notice": "0.9.10",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-tsdoc": "0.2.14",
"eslint-watch": "7.0.0",
"husky": "7.0.2",
"husky": "7.0.4",
"jest": "26.6.3",
"lerna": "4.0.0",
"lint-staged": "11.2.3",
"lint-staged": "12.0.2",
"lockfile-lint": "4.6.2",
"markdown-link-check": "3.8.7",
"package-dependency-graph": "1.11.2",
"package-dependency-graph": "1.11.3",
"prettier": "2.4.1",
"rimraf": "3.0.2",
"ts-node": "10.3.0",
"typescript": "4.4.4",
"ts-node": "10.4.0",
"typescript": "4.5.2",
"vertioner": "1.0.6",
"wdio-chromedriver-service": "6.0.4",
"webdriverio": "6.12.1"
Expand Down
10 changes: 5 additions & 5 deletions packages/assert/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa11y/assert",
"version": "3.0.2",
"version": "3.1.0",
"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": "3.0.2",
"@sa11y/format": "3.0.2",
"@sa11y/preset-rules": "3.0.2",
"@sa11y/common": "3.1.0",
"@sa11y/format": "3.1.0",
"@sa11y/preset-rules": "3.1.0",
"axe-core": "4.3.3"
},
"devDependencies": {
"@sa11y/test-utils": "3.0.2"
"@sa11y/test-utils": "3.1.0"
},
"publishConfig": {
"access": "public"
Expand Down
14 changes: 7 additions & 7 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": "3.0.2",
"version": "3.1.0",
"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,22 +34,22 @@
"url": "https://github.com/salesforce/sa11y/issues"
},
"dependencies": {
"@sa11y/format": "3.0.2",
"@sa11y/preset-rules": "3.0.2",
"@sa11y/format": "3.1.0",
"@sa11y/preset-rules": "3.1.0",
"axe-core": "4.3.3"
},
"devDependencies": {
"@rollup/plugin-commonjs": "21.0.1",
"@rollup/plugin-node-resolve": "13.0.6",
"@rollup/plugin-replace": "3.0.0",
"@sa11y/common": "3.0.2",
"@sa11y/test-utils": "3.0.2",
"rollup": "2.58.0",
"@sa11y/common": "3.1.0",
"@sa11y/test-utils": "3.1.0",
"rollup": "2.60.0",
"rollup-plugin-polyfill-node": "0.7.0",
"rollup-plugin-progress": "1.1.2",
"rollup-plugin-sizes": "1.0.4",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.30.0"
"rollup-plugin-typescript2": "0.31.0"
},
"publishConfig": {
"access": "public"
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": "3.0.2",
"version": "3.1.0",
"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
8 changes: 4 additions & 4 deletions packages/format/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa11y/format",
"version": "3.0.2",
"version": "3.1.0",
"description": "Accessibility results re-formatter",
"license": "BSD-3-Clause",
"homepage": "https://github.com/salesforce/sa11y/tree/master/packages/format#readme",
Expand All @@ -24,12 +24,12 @@
"dist/**/*.d.ts*"
],
"dependencies": {
"@sa11y/preset-rules": "3.0.2",
"@sa11y/common": "3.1.0",
"@sa11y/preset-rules": "3.1.0",
"axe-core": "4.3.3"
},
"devDependencies": {
"@sa11y/common": "3.0.2",
"@sa11y/test-utils": "3.0.2"
"@sa11y/test-utils": "3.1.0"
},
"publishConfig": {
"access": "public"
Expand Down
6 changes: 1 addition & 5 deletions packages/jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ SA11Y_AUTO=1 SA11Y_CLEANUP=1 jest
- Invoking `jest` with environment variables as above will enable automatic checks with no changes required to `setup()`
- The environment variables can be used to set up parallel builds e.g., in a CI environment without code changes to `setup()` to opt-in to automatic checks
- Setting `SA11Y_DEBUG=1` will output verbose logging
- `SA11Y_AUTO_FILTER` can be used to specify a comma seperated list of test file paths to filter for automatic checks
- When specified, automatic checks will be run only on given files
- A file can be excluded from automatic checks by prefixing the filename with `!`
- e.g. `SA11Y_AUTO_FILTER='!exclude.test.js'`
- The file paths can be also be expressed as [regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet) if necessary
- `SA11Y_AUTO_FILTER` can be used to specify a comma seperated list of test file paths to filter out from automatic checks. When specified automatic checks are skipped for given files.

### Sa11y results processor

Expand Down

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

32 changes: 26 additions & 6 deletions packages/jest/__tests__/automatic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { setup } from '../src';
import * as automatic from '../src/automatic';
import { automaticCheck, registerSa11yAutomaticChecks } from '../src/automatic';
import { automaticCheck, registerSa11yAutomaticChecks, skipTest } from '../src/automatic';
import {
beforeEachSetup,
checkA11yErrorFunc,
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('automatic checks registration', () => {

describe('automatic checks call', () => {
const testPath = expect.getState().testPath;
const nonExistentFilePaths = ['foo', `/(?!${testPath})$`, `!${testPath}`];
const nonExistentFilePaths = ['foo', `foo${testPath}`, `${testPath}foo`];
// Note: cleanup required at end of each test to prevent dom being checked again
// after the test as part of the afterEach automatic check hook
beforeEach(beforeEachSetup);
Expand Down Expand Up @@ -159,14 +159,34 @@ describe('automatic checks call', () => {
await checkA11yErrorFunc(() => automaticCheck({ cleanupAfterEach: true, consolidateResults: false }));
});

it('should skip auto checks when file is not specified in run only option', async () => {
it.each([
['foo', undefined, false],
['foo', [], false],
['foo', ['foo'], true],
['foo', ['Foo'], true],
['foo', ['foo', 'bar'], true],
['foo', ['bar'], false],
['foo', ['foobar'], false],
['foo', ['barfoo'], false],
])(
'should filter test file as expected with args # %#',
(testPath: string, filesFilter: string[] | undefined, expectedResult: boolean) => {
expect(skipTest(testPath, filesFilter)).toBe(expectedResult);
}
);

it('should skip auto checks when file is excluded using filter', async () => {
document.body.innerHTML = domWithA11yIssues;
await checkA11yErrorFunc(() => automaticCheck({ filesFilter: nonExistentFilePaths }), false, true);
await checkA11yErrorFunc(
() => automaticCheck({ filesFilter: [...nonExistentFilePaths, testPath] }),
false,
true
);
});

it('should run auto checks when file is specified in run only option', async () => {
it('should run auto checks when file is not excluded using filter', async () => {
document.body.innerHTML = domWithA11yIssues;
await checkA11yErrorFunc(() => automaticCheck({ filesFilter: [...nonExistentFilePaths, testPath] }));
await checkA11yErrorFunc(() => automaticCheck({ filesFilter: nonExistentFilePaths }));
});
/* eslint-enable jest/expect-expect */
});
12 changes: 6 additions & 6 deletions packages/jest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa11y/jest",
"version": "3.0.2",
"version": "3.1.0",
"description": "Accessibility testing matcher for Jest",
"license": "BSD-3-Clause",
"homepage": "https://github.com/salesforce/sa11y/tree/master/packages/jest#readme",
Expand All @@ -24,17 +24,17 @@
],
"dependencies": {
"@jest/test-result": "26.6.2",
"@sa11y/assert": "3.0.2",
"@sa11y/format": "3.0.2",
"@sa11y/preset-rules": "3.0.2",
"@sa11y/assert": "3.1.0",
"@sa11y/format": "3.1.0",
"@sa11y/preset-rules": "3.1.0",
"jest-matcher-utils": "26.6.2"
},
"peerDependencies": {
"jest": ">=26.0.0"
},
"devDependencies": {
"@sa11y/common": "3.0.2",
"@sa11y/test-utils": "3.0.2"
"@sa11y/common": "3.1.0",
"@sa11y/test-utils": "3.1.0"
},
"publishConfig": {
"access": "public"
Expand Down
Loading