testaro 4.10.1 → 4.10.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.
- package/package.json +1 -1
- package/tests/wave.js +17 -3
package/package.json
CHANGED
package/tests/wave.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
specifies a WAVE report type: 1, 2, 3, or 4. The larger the number, the more detailed (and
|
|
5
5
|
expensive) the report.
|
|
6
6
|
*/
|
|
7
|
+
const fs = require('fs/promises');
|
|
7
8
|
const https = require('https');
|
|
8
9
|
exports.reporter = async (page, reportType) => {
|
|
9
10
|
const waveKey = process.env.WAVE_KEY;
|
|
@@ -20,20 +21,33 @@ exports.reporter = async (page, reportType) => {
|
|
|
20
21
|
response.on('data', chunk => {
|
|
21
22
|
report += chunk;
|
|
22
23
|
});
|
|
23
|
-
// When the data arrive
|
|
24
|
-
response.on('end', () => {
|
|
24
|
+
// When the data arrive:
|
|
25
|
+
response.on('end', async () => {
|
|
25
26
|
try {
|
|
27
|
+
// Delete unnecessary properties.
|
|
26
28
|
const result = JSON.parse(report);
|
|
27
29
|
const {categories} = result;
|
|
28
30
|
delete categories.feature;
|
|
29
31
|
delete categories.structure;
|
|
30
32
|
delete categories.aria;
|
|
33
|
+
// Add WCAG information from the WAVE documentation.
|
|
34
|
+
const waveDocJSON = await fs.readFile('procs/wavedoc.json');
|
|
35
|
+
const waveDoc = JSON.parse(waveDocJSON);
|
|
36
|
+
Object.keys(categories).forEach(categoryName => {
|
|
37
|
+
const category = categories[categoryName];
|
|
38
|
+
const {items} = category;
|
|
39
|
+
Object.keys(items).forEach(issueName => {
|
|
40
|
+
const issueDoc = waveDoc.find((issue => issue.name === issueName));
|
|
41
|
+
const {guidelines} = issueDoc;
|
|
42
|
+
items[issueName].wcag = guidelines;
|
|
43
|
+
});
|
|
44
|
+
})
|
|
31
45
|
return resolve(result);
|
|
32
46
|
}
|
|
33
47
|
catch (error) {
|
|
34
48
|
return resolve({
|
|
35
49
|
prevented: true,
|
|
36
|
-
error:
|
|
50
|
+
error: error.message,
|
|
37
51
|
report
|
|
38
52
|
});
|
|
39
53
|
}
|