@sa11y/jest 3.1.0 → 4.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automatic.d.ts +1 -1
- package/dist/automatic.d.ts.map +1 -1
- package/dist/automatic.js +4 -5
- package/dist/resultsProcessor.js +1 -2
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +4 -4
- package/package.json +11 -10
package/dist/automatic.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare type AutoCheckOpts = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Check if current test file needs to be skipped based on any provided filter
|
|
12
12
|
*/
|
|
13
|
-
export declare function skipTest(testPath: string, filesFilter?: string[]): boolean;
|
|
13
|
+
export declare function skipTest(testPath: string | undefined, filesFilter?: string[]): boolean;
|
|
14
14
|
/**
|
|
15
15
|
* Run accessibility check on each element node in the body using {@link toBeAccessible}
|
|
16
16
|
* @param opts - Options for automatic checks {@link AutoCheckOpts}
|
package/dist/automatic.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automatic.d.ts","sourceRoot":"","sources":["../src/automatic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"automatic.d.ts","sourceRoot":"","sources":["../src/automatic.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,oBAAY,aAAa,GAAG;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAI7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAYF;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAUtF;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,GAAE,aAAoC,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B9F;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,aAAoC,GAAG,IAAI,CAM7F"}
|
package/dist/automatic.js
CHANGED
|
@@ -11,6 +11,7 @@ const common_1 = require("@sa11y/common");
|
|
|
11
11
|
const assert_1 = require("@sa11y/assert");
|
|
12
12
|
const format_1 = require("@sa11y/format");
|
|
13
13
|
const matcher_1 = require("./matcher");
|
|
14
|
+
const globals_1 = require("@jest/globals");
|
|
14
15
|
/**
|
|
15
16
|
* Default options when {@link registerSa11yAutomaticChecks} is invoked
|
|
16
17
|
*/
|
|
@@ -24,7 +25,7 @@ const defaultAutoCheckOpts = {
|
|
|
24
25
|
* Check if current test file needs to be skipped based on any provided filter
|
|
25
26
|
*/
|
|
26
27
|
function skipTest(testPath, filesFilter) {
|
|
27
|
-
if (!
|
|
28
|
+
if (!testPath || !filesFilter || !(filesFilter?.length > 0))
|
|
28
29
|
return false;
|
|
29
30
|
const skipTest = filesFilter.some((fileName) => testPath.toLowerCase().includes(fileName.toLowerCase()));
|
|
30
31
|
if (skipTest) {
|
|
@@ -38,7 +39,7 @@ exports.skipTest = skipTest;
|
|
|
38
39
|
* @param opts - Options for automatic checks {@link AutoCheckOpts}
|
|
39
40
|
*/
|
|
40
41
|
async function automaticCheck(opts = defaultAutoCheckOpts) {
|
|
41
|
-
if (skipTest(expect.getState().testPath, opts.filesFilter))
|
|
42
|
+
if (skipTest(globals_1.expect.getState().testPath, opts.filesFilter))
|
|
42
43
|
return;
|
|
43
44
|
// Skip automatic check if test is using fake timer as it would result in timeout
|
|
44
45
|
if ((0, matcher_1.isTestUsingFakeTimer)()) {
|
|
@@ -79,9 +80,7 @@ function registerSa11yAutomaticChecks(opts = defaultAutoCheckOpts) {
|
|
|
79
80
|
if (opts.runAfterEach) {
|
|
80
81
|
// TODO (fix): Make registration idempotent
|
|
81
82
|
(0, common_1.log)('Registering sa11y checks to be run automatically after each test');
|
|
82
|
-
afterEach(
|
|
83
|
-
await automaticCheck(opts);
|
|
84
|
-
});
|
|
83
|
+
afterEach(() => automaticCheck(opts));
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
exports.registerSa11yAutomaticChecks = registerSa11yAutomaticChecks;
|
package/dist/resultsProcessor.js
CHANGED
|
@@ -54,13 +54,12 @@ function processA11yErrors(testSuite, testResult) {
|
|
|
54
54
|
// TODO (spike) : What happens if there are ever multiple failureDetails?
|
|
55
55
|
// Ideally there shouldn't be as test execution should be stopped on failure
|
|
56
56
|
format_1.A11yResults.add(error.a11yResults, suiteName).forEach((a11yResult) => {
|
|
57
|
-
var _a;
|
|
58
57
|
const className = `${suiteName}${metadataSeparator}${a11yResult.wcag}`;
|
|
59
58
|
// TODO (code cov): Fix - should be covered by existing tests
|
|
60
59
|
/* istanbul ignore next */
|
|
61
60
|
if (!Array.isArray(consolidatedErrors.get(className)))
|
|
62
61
|
consolidatedErrors.set(className, []);
|
|
63
|
-
|
|
62
|
+
consolidatedErrors.get(className)?.push(createA11yTestResult(testResult, a11yResult));
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
65
|
});
|
package/dist/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAgC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAgC,MAAM,aAAa,CAAC;AAG1E,eAAO,MAAM,aAAa,UAiBzB,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS,GAAG;IACpB,aAAa,EAAE,aAAa,CAAC;CAKhC,CAAC;AAaF;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,GAAE,SAA4B,GAAG,IAAI,CAW9D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAU3C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,WAAgB,GAAG,UAAU,CAK3F"}
|
package/dist/setup.js
CHANGED
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.adaptA11yConfig = exports.registerSa11yMatcher = exports.setup = exports.disabledRules = void 0;
|
|
10
10
|
const matcher_1 = require("./matcher");
|
|
11
11
|
const automatic_1 = require("./automatic");
|
|
12
|
+
const globals_1 = require("@jest/globals");
|
|
12
13
|
exports.disabledRules = [
|
|
13
14
|
// Descendancy checks that would fail at unit/component level, but pass at page level
|
|
14
15
|
'aria-required-children',
|
|
@@ -42,7 +43,6 @@ const defaultSa11yOpts = {
|
|
|
42
43
|
* @param opts - {@link Sa11yOpts} to opt-in to automatic checks
|
|
43
44
|
*/
|
|
44
45
|
function setup(opts = defaultSa11yOpts) {
|
|
45
|
-
var _a;
|
|
46
46
|
registerSa11yMatcher();
|
|
47
47
|
// Set defaults from env vars
|
|
48
48
|
const autoCheckOpts = opts.autoCheckOpts;
|
|
@@ -50,7 +50,7 @@ function setup(opts = defaultSa11yOpts) {
|
|
|
50
50
|
// Consolidate results if automatic checks is enabled
|
|
51
51
|
autoCheckOpts.consolidateResults || (autoCheckOpts.consolidateResults = autoCheckOpts.runAfterEach);
|
|
52
52
|
autoCheckOpts.cleanupAfterEach || (autoCheckOpts.cleanupAfterEach = !!process.env.SA11Y_CLEANUP);
|
|
53
|
-
if (
|
|
53
|
+
if (process.env.SA11Y_AUTO_FILTER?.trim().length)
|
|
54
54
|
autoCheckOpts.filesFilter || (autoCheckOpts.filesFilter = process.env.SA11Y_AUTO_FILTER.split(','));
|
|
55
55
|
(0, automatic_1.registerSa11yAutomaticChecks)(autoCheckOpts);
|
|
56
56
|
}
|
|
@@ -59,8 +59,8 @@ exports.setup = setup;
|
|
|
59
59
|
* Register accessibility helpers toBeAccessible as jest matchers
|
|
60
60
|
*/
|
|
61
61
|
function registerSa11yMatcher() {
|
|
62
|
-
if (expect !== undefined) {
|
|
63
|
-
expect.extend({ toBeAccessible: matcher_1.toBeAccessible });
|
|
62
|
+
if (globals_1.expect !== undefined) {
|
|
63
|
+
globals_1.expect.extend({ toBeAccessible: matcher_1.toBeAccessible });
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
66
|
throw new Error("Unable to find Jest's expect function." +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sa11y/jest",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "Accessibility testing matcher for Jest",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"homepage": "https://github.com/salesforce/sa11y/tree/master/packages/jest#readme",
|
|
@@ -23,21 +23,22 @@
|
|
|
23
23
|
"dist/**/*.d.ts*"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@jest/test-result": "
|
|
27
|
-
"@sa11y/assert": "
|
|
28
|
-
"@sa11y/format": "
|
|
29
|
-
"@sa11y/preset-rules": "
|
|
30
|
-
"jest-matcher-utils": "
|
|
26
|
+
"@jest/test-result": "^27",
|
|
27
|
+
"@sa11y/assert": "4.0.0-alpha.0",
|
|
28
|
+
"@sa11y/format": "4.0.0-alpha.0",
|
|
29
|
+
"@sa11y/preset-rules": "4.0.0-alpha.0",
|
|
30
|
+
"jest-matcher-utils": "^27"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"jest": ">=
|
|
33
|
+
"jest": ">=27.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@sa11y/
|
|
36
|
+
"@jest/globals": "28.1.3",
|
|
37
|
+
"@sa11y/common": "4.0.0-alpha.0",
|
|
38
|
+
"@sa11y/test-utils": "4.0.0-alpha.0"
|
|
38
39
|
},
|
|
39
40
|
"publishConfig": {
|
|
40
41
|
"access": "public"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "aeb87b6b27bfd56cf9f3de201456dd821e57b408"
|
|
43
44
|
}
|