@sa11y/jest 6.9.1 → 6.9.2
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.
|
@@ -6,5 +6,6 @@ import { AggregatedResult } from '@jest/test-result';
|
|
|
6
6
|
* Ref: https://jestjs.io/docs/configuration#testresultsprocessor-string
|
|
7
7
|
* - Mapping of AggregatedResult to JSON format to https://github.com/facebook/jest/blob/master/packages/jest-test-result/src/formatTestResults.ts
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export declare function resultsProcessor(results: AggregatedResult): AggregatedResult;
|
|
10
|
+
export declare function resultsProcessorManualChecks(results: AggregatedResult): AggregatedResult;
|
|
10
11
|
//# sourceMappingURL=groupViolationResultsProcessor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupViolationResultsProcessor.d.ts","sourceRoot":"","sources":["../src/groupViolationResultsProcessor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAA+B,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"groupViolationResultsProcessor.d.ts","sourceRoot":"","sources":["../src/groupViolationResultsProcessor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAA+B,MAAM,mBAAmB,CAAC;AAkLlF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAa5E;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAaxF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resultsProcessorManualChecks = exports.resultsProcessor = void 0;
|
|
3
4
|
const common_1 = require("@sa11y/common");
|
|
4
5
|
const format_1 = require("@sa11y/format");
|
|
5
6
|
const formatSpacing = '\t'.repeat(8);
|
|
@@ -54,6 +55,52 @@ function createA11yRuleViolation(a11yRule, ruleIndex) {
|
|
|
54
55
|
• Help URL: ${a11yRule.helpUrl}
|
|
55
56
|
• WCAG Criteria: ${a11yRule.wcagCriteria}`;
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a test processA11yDetailsAndMessages violation error message grouped by rule violation
|
|
60
|
+
*/
|
|
61
|
+
function processA11yDetailsAndMessages(error, a11yFailureMessages) {
|
|
62
|
+
const a11yRuleViolations = {};
|
|
63
|
+
let a11yRuleViolationsCount = 0;
|
|
64
|
+
let a11yErrorElementsCount = 0;
|
|
65
|
+
error.a11yResults.forEach((a11yResult) => {
|
|
66
|
+
a11yErrorElementsCount++;
|
|
67
|
+
if (!a11yRuleViolations[a11yResult.wcag]) {
|
|
68
|
+
a11yRuleViolationsCount++;
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
70
|
+
a11yRuleViolations[a11yResult.wcag] = {
|
|
71
|
+
id: a11yResult.id,
|
|
72
|
+
description: a11yResult.description,
|
|
73
|
+
helpUrl: a11yResult.helpUrl,
|
|
74
|
+
wcagCriteria: a11yResult.wcag,
|
|
75
|
+
summary: a11yResult.summary,
|
|
76
|
+
errorElements: [],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
a11yRuleViolations[a11yResult.wcag].errorElements.push({
|
|
80
|
+
html: a11yResult.html,
|
|
81
|
+
selectors: a11yResult.selectors,
|
|
82
|
+
hierarchy: a11yResult.ancestry,
|
|
83
|
+
any: a11yResult.any,
|
|
84
|
+
all: a11yResult.all,
|
|
85
|
+
none: a11yResult.none,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
const a11yFailureMessage = `
|
|
89
|
+
The test has failed the accessibility check. Accessibility Stacktrace/Issues:
|
|
90
|
+
${a11yErrorElementsCount} HTML elements have accessibility issue(s). ${a11yRuleViolationsCount} rules failed.
|
|
91
|
+
|
|
92
|
+
${Object.values(a11yRuleViolations)
|
|
93
|
+
.map((a11yRuleViolation, index) => createA11yRuleViolation(a11yRuleViolation, index + 1))
|
|
94
|
+
.join('\n')}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
For more info about automated accessibility testing: https://sfdc.co/a11y-test
|
|
98
|
+
For tips on fixing accessibility bugs: https://sfdc.co/a11y
|
|
99
|
+
For technical questions regarding Salesforce accessibility tools, contact our Sa11y team: http://sfdc.co/sa11y-users
|
|
100
|
+
For guidance on accessibility related specifics, contact our A11y team: http://sfdc.co/tmp-a11y
|
|
101
|
+
`;
|
|
102
|
+
a11yFailureMessages.push(a11yFailureMessage);
|
|
103
|
+
}
|
|
57
104
|
/**
|
|
58
105
|
* Convert any a11y errors from test failures into their own test suite, results
|
|
59
106
|
*/
|
|
@@ -71,47 +118,7 @@ function processA11yErrors(results, testSuite, testResult) {
|
|
|
71
118
|
if (error.name === format_1.A11yError.name) {
|
|
72
119
|
a11yErrorsExist = true;
|
|
73
120
|
a11yFailureDetails.push({ ...failure });
|
|
74
|
-
|
|
75
|
-
let a11yRuleViolationsCount = 0;
|
|
76
|
-
let a11yErrorElementsCount = 0;
|
|
77
|
-
error.a11yResults.forEach((a11yResult) => {
|
|
78
|
-
a11yErrorElementsCount++;
|
|
79
|
-
if (!a11yRuleViolations[a11yResult.wcag]) {
|
|
80
|
-
a11yRuleViolationsCount++;
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
82
|
-
a11yRuleViolations[a11yResult.wcag] = {
|
|
83
|
-
id: a11yResult.id,
|
|
84
|
-
description: a11yResult.description,
|
|
85
|
-
helpUrl: a11yResult.helpUrl,
|
|
86
|
-
wcagCriteria: a11yResult.wcag,
|
|
87
|
-
summary: a11yResult.summary,
|
|
88
|
-
errorElements: [],
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
a11yRuleViolations[a11yResult.wcag].errorElements.push({
|
|
92
|
-
html: a11yResult.html,
|
|
93
|
-
selectors: a11yResult.selectors,
|
|
94
|
-
hierarchy: a11yResult.ancestry,
|
|
95
|
-
any: a11yResult.any,
|
|
96
|
-
all: a11yResult.all,
|
|
97
|
-
none: a11yResult.none,
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
const a11yFailureMessage = `
|
|
101
|
-
The test has failed the accessibility check. Accessibility Stacktrace/Issues:
|
|
102
|
-
${a11yErrorElementsCount} HTML elements have accessibility issue(s). ${a11yRuleViolationsCount} rules failed.
|
|
103
|
-
|
|
104
|
-
${Object.values(a11yRuleViolations)
|
|
105
|
-
.map((a11yRuleViolation, index) => createA11yRuleViolation(a11yRuleViolation, index + 1))
|
|
106
|
-
.join('\n')}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
For more info about automated accessibility testing: https://sfdc.co/a11y-test
|
|
110
|
-
For tips on fixing accessibility bugs: https://sfdc.co/a11y
|
|
111
|
-
For technical questions regarding Salesforce accessibility tools, contact our Sa11y team: http://sfdc.co/sa11y-users
|
|
112
|
-
For guidance on accessibility related specifics, contact our A11y team: http://sfdc.co/tmp-a11y
|
|
113
|
-
`;
|
|
114
|
-
a11yFailureMessages.push(a11yFailureMessage);
|
|
121
|
+
processA11yDetailsAndMessages(error, a11yFailureMessages);
|
|
115
122
|
}
|
|
116
123
|
});
|
|
117
124
|
if (!a11yErrorsExist) {
|
|
@@ -124,6 +131,16 @@ function processA11yErrors(results, testSuite, testResult) {
|
|
|
124
131
|
testResult.failureMessages = [...a11yFailureMessages];
|
|
125
132
|
testResult.status = a11yFailureDetails.length === 0 ? 'passed' : testResult.status;
|
|
126
133
|
}
|
|
134
|
+
function processA11yMatcherErrors(results, testSuite, testResult) {
|
|
135
|
+
const a11yFailureMessages = [];
|
|
136
|
+
testResult.failureDetails.forEach((failure) => {
|
|
137
|
+
const error = failure?.error?.matcherResult?.a11yError;
|
|
138
|
+
if (error !== undefined) {
|
|
139
|
+
processA11yDetailsAndMessages(error, a11yFailureMessages);
|
|
140
|
+
testResult.failureMessages = [...a11yFailureMessages];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
127
144
|
/**
|
|
128
145
|
* Custom results processor for a11y results grouping the violations. Only affects JSON results file output.
|
|
129
146
|
* To be used with jest cli options --json --outputFile
|
|
@@ -144,7 +161,26 @@ function resultsProcessor(results) {
|
|
|
144
161
|
});
|
|
145
162
|
return results;
|
|
146
163
|
}
|
|
147
|
-
exports.
|
|
164
|
+
exports.resultsProcessor = resultsProcessor;
|
|
165
|
+
function resultsProcessorManualChecks(results) {
|
|
166
|
+
(0, common_1.log)(`Processing ${results.numTotalTests} tests ..`);
|
|
167
|
+
results.testResults // suite results
|
|
168
|
+
.filter((testSuite) => testSuite.numFailingTests > 0)
|
|
169
|
+
.forEach((testSuite) => {
|
|
170
|
+
testSuite.testResults // individual test results
|
|
171
|
+
.filter((testResult) => testResult.status === 'failed')
|
|
172
|
+
.forEach((testResult) => {
|
|
173
|
+
processA11yMatcherErrors(results, testSuite, testResult);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
return results;
|
|
177
|
+
}
|
|
178
|
+
exports.resultsProcessorManualChecks = resultsProcessorManualChecks;
|
|
148
179
|
// The processor must be a node module that exports a function
|
|
149
|
-
|
|
180
|
+
// Explicitly typing the exports for Node.js compatibility
|
|
181
|
+
const exportedFunctions = {
|
|
182
|
+
resultsProcessor,
|
|
183
|
+
resultsProcessorManualChecks,
|
|
184
|
+
};
|
|
185
|
+
module.exports = exportedFunctions;
|
|
150
186
|
//# sourceMappingURL=groupViolationResultsProcessor.js.map
|
package/dist/matcher.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
2
|
import { A11yCheckableContext } from '@sa11y/assert';
|
|
3
|
+
import { A11yError } from '@sa11y/format';
|
|
3
4
|
import { A11yConfig } from '@sa11y/common';
|
|
4
5
|
declare global {
|
|
5
6
|
namespace jest {
|
|
@@ -13,7 +14,9 @@ declare global {
|
|
|
13
14
|
* @param received - DOM or HTML Element to be tested for accessibility. Defaults to current DOM.
|
|
14
15
|
* @param config - A11yConfig to be used to test for accessibility. Defaults to `base` ruleset.
|
|
15
16
|
*/
|
|
16
|
-
export declare function toBeAccessible(received?: A11yCheckableContext, config?: A11yConfig): Promise<jest.CustomMatcherResult
|
|
17
|
+
export declare function toBeAccessible(received?: A11yCheckableContext, config?: A11yConfig): Promise<jest.CustomMatcherResult & {
|
|
18
|
+
a11yError: A11yError;
|
|
19
|
+
}>;
|
|
17
20
|
/**
|
|
18
21
|
* Detect if fake timer is being used in a jest test.
|
|
19
22
|
* Fake timers result in axe timeout https://github.com/dequelabs/axe-core/issues/3055
|
package/dist/matcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../src/matcher.ts"],"names":[],"mappings":";AASA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../src/matcher.ts"],"names":[],"mappings":";AASA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,SAAS,EAAW,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,CAAC,MAAM,CAAC;IAEX,UAAU,IAAI,CAAC;QAEX,UAAU,QAAQ,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,aAAa;YAC5C,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;SACrE;KACJ;CACJ;AAeD;;;;GAIG;AACH,wBAAsB,cAAc,CAChC,QAAQ,GAAE,oBAA+B,EACzC,MAAM,GAAE,UAA2B,GACpC,OAAO,CAAC,IAAI,CAAC,mBAAmB,GAAG;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC,CA+B9D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAO9C"}
|
package/dist/matcher.js
CHANGED
|
@@ -52,6 +52,7 @@ async function toBeAccessible(received = document, config = preset_rules_1.defau
|
|
|
52
52
|
return {
|
|
53
53
|
pass: isAccessible,
|
|
54
54
|
message: () => (0, jest_matcher_utils_1.matcherHint)(`${toBeAccessible.name}: ${matcherHintMsg} ${receivedMsg}: \n\n ${a11yError.format(formatOptions)}`, `${a11yError.length} issues`, expectedMsg),
|
|
55
|
+
a11yError: a11yError,
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
exports.toBeAccessible = toBeAccessible;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sa11y/jest",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.2",
|
|
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",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@jest/test-result": "^27",
|
|
27
|
-
"@sa11y/assert": "6.9.
|
|
28
|
-
"@sa11y/format": "6.9.
|
|
29
|
-
"@sa11y/preset-rules": "6.9.
|
|
27
|
+
"@sa11y/assert": "6.9.2",
|
|
28
|
+
"@sa11y/format": "6.9.2",
|
|
29
|
+
"@sa11y/preset-rules": "6.9.2",
|
|
30
30
|
"jest-matcher-utils": "^27"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@jest/globals": "28.1.3",
|
|
37
|
-
"@sa11y/common": "6.9.
|
|
38
|
-
"@sa11y/test-utils": "6.9.
|
|
37
|
+
"@sa11y/common": "6.9.2",
|
|
38
|
+
"@sa11y/test-utils": "6.9.2"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": "^16 || ^18 || ^20"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "2eca6d223e98bd7794c7283bd87d7c1d57d407cb"
|
|
47
47
|
}
|