testaro 60.2.1 → 60.4.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.
@@ -30,7 +30,7 @@
30
30
  // ########## IMPORTS
31
31
 
32
32
  // Module to perform common operations.
33
- const {init, report} = require('../procs/testaro');
33
+ const {init, getRuleResult} = require('../procs/testaro');
34
34
  // Module to get locator data.
35
35
  const {getLocatorData} = require('../procs/getLocatorData');
36
36
 
@@ -81,5 +81,5 @@ exports.reporter = async (
81
81
  'Input is missing an autocomplete attribute with value __param__',
82
82
  'Inputs are missing applicable autocomplete attributes'
83
83
  ];
84
- return await report(withItems, all, 'autocomplete', whats, 2);
84
+ return await getRuleResult(withItems, all, 'autocomplete', whats, 2);
85
85
  };
@@ -28,7 +28,7 @@
28
28
  Report caption elements that are not the first child of their table element.
29
29
  */
30
30
 
31
- const {init, report} = require('../procs/testaro');
31
+ const {init, getRuleResult} = require('../procs/testaro');
32
32
 
33
33
  exports.reporter = async (page, withItems) => {
34
34
  const all = await init(100, page, 'caption');
@@ -44,5 +44,5 @@ exports.reporter = async (page, withItems) => {
44
44
  'Element is not the first child of a table element',
45
45
  'caption elements are not the first children of table elements'
46
46
  ];
47
- return await report(withItems, all, 'captionLoc', whats, 3, 'CAPTION');
47
+ return await getRuleResult(withItems, all, 'captionLoc', whats, 3, 'CAPTION');
48
48
  };
@@ -28,7 +28,7 @@
28
28
  Report inputs whose list attribute references a missing or ambiguous datalist
29
29
  */
30
30
 
31
- const {init, report} = require('../procs/testaro');
31
+ const {init, getRuleResult} = require('../procs/testaro');
32
32
 
33
33
  exports.reporter = async (page, withItems) => {
34
34
  const all = await init(100, page, 'input[list]');
@@ -45,5 +45,5 @@ exports.reporter = async (page, withItems) => {
45
45
  'list attribute of the element references an ambiguous or missing datalist element',
46
46
  'list attributes of elements reference ambiguous or missing datalist elements'
47
47
  ];
48
- return await report(withItems, all, 'datalistRef', whats, 3, 'INPUT');
48
+ return await getRuleResult(withItems, all, 'datalistRef', whats, 3, 'INPUT');
49
49
  };
package/testaro/embAc.js CHANGED
@@ -33,7 +33,7 @@
33
33
  // ########## IMPORTS
34
34
 
35
35
  // Module to perform common operations.
36
- const {init, report} = require('../procs/testaro');
36
+ const {init, getRuleResult} = require('../procs/testaro');
37
37
 
38
38
  // ########## FUNCTIONS
39
39
 
@@ -66,5 +66,5 @@ exports.reporter = async (page, withItems) => {
66
66
  'Interactive element is embedded in __param__',
67
67
  'Interactive elements are contained by links or buttons'
68
68
  ];
69
- return await report(withItems, all, 'embAc', whats, 2);
69
+ return await getRuleResult(withItems, all, 'embAc', whats, 2);
70
70
  };
package/testaro/focInd.js CHANGED
@@ -44,7 +44,7 @@
44
44
  // ########## IMPORTS
45
45
 
46
46
  // Module to perform common operations.
47
- const {init, report} = require('../procs/testaro');
47
+ const {init, getRuleResult} = require('../procs/testaro');
48
48
 
49
49
  // ########## FUNCTIONS
50
50
 
@@ -126,5 +126,5 @@ exports.reporter = async (page, withItems) => {
126
126
  }
127
127
  // Populate and return the result.
128
128
  const whats = ['Element has __param__', 'Elements fail to have standard focus indicators'];
129
- return await report(withItems, all, 'focInd', whats, 1);
129
+ return await getRuleResult(withItems, all, 'focInd', whats, 1);
130
130
  };
package/testaro/focOp.js CHANGED
@@ -38,7 +38,7 @@
38
38
  // ########## IMPORTS
39
39
 
40
40
  // Module to perform common operations.
41
- const {init, report} = require('../procs/testaro');
41
+ const {init, getRuleResult} = require('../procs/testaro');
42
42
  // Module to get operabilities.
43
43
  const {isOperable} = require('../procs/operable');
44
44
 
@@ -70,6 +70,6 @@ exports.reporter = async (page, withItems) => {
70
70
  const whats = [
71
71
  'Element is Tab-focusable but not operable', 'Elements are Tab-focusable but not operable'
72
72
  ];
73
- const result = await report(withItems, all, 'focOp', whats, 2);
73
+ const result = await getRuleResult(withItems, all, 'focOp', whats, 2);
74
74
  return result;
75
75
  };
package/testaro/focVis.js CHANGED
@@ -32,7 +32,7 @@
32
32
  // ########## IMPORTS
33
33
 
34
34
  // Module to perform common operations.
35
- const {init, report} = require('../procs/testaro');
35
+ const {init, getRuleResult} = require('../procs/testaro');
36
36
 
37
37
  // ########## FUNCTIONS
38
38
 
@@ -69,5 +69,5 @@ exports.reporter = async (page, withItems) => {
69
69
  'Visible link is __param__ the display',
70
70
  'Visible links are above or to the left of the display'
71
71
  ];
72
- return await report(withItems, all, 'focVis', whats, 2);
72
+ return await getRuleResult(withItems, all, 'focVis', whats, 2);
73
73
  };
package/testaro/hover.js CHANGED
@@ -36,7 +36,7 @@
36
36
  // ########## IMPORTS
37
37
 
38
38
  // Module to perform common operations.
39
- const {init, report} = require('../procs/testaro');
39
+ const {init, getRuleResult} = require('../procs/testaro');
40
40
 
41
41
  // ########## FUNCTIONS
42
42
 
@@ -105,5 +105,5 @@ exports.reporter = async (page, withItems) => {
105
105
  'Hovering over the element __param__',
106
106
  'Hovering over elements adds elements to or subtracts elements from the page'
107
107
  ];
108
- return await report(withItems, all, 'hover', whats, 0);
108
+ return await getRuleResult(withItems, all, 'hover', whats, 0);
109
109
  };
@@ -30,7 +30,7 @@
30
30
  */
31
31
 
32
32
  // Module to perform common operations.
33
- const {init, report} = require('../procs/testaro');
33
+ const {init, getRuleResult} = require('../procs/testaro');
34
34
 
35
35
  // ########## FUNCTIONS
36
36
 
@@ -66,5 +66,5 @@ exports.reporter = async (page, withItems) => {
66
66
  const whats = [
67
67
  'Element has inconsistent label types (__param__)', 'Elements have inconsistent label types'
68
68
  ];
69
- return await report(withItems, all, 'labClash', whats, 2);
69
+ return await getRuleResult(withItems, all, 'labClash', whats, 2);
70
70
  };
@@ -35,7 +35,7 @@
35
35
  // IMPORTS
36
36
 
37
37
  // Module to perform common operations.
38
- const {init, report} = require('../procs/testaro');
38
+ const {init, getRuleResult} = require('../procs/testaro');
39
39
 
40
40
  // FUNCTIONS
41
41
 
@@ -66,5 +66,5 @@ exports.reporter = async (page, withItems) => {
66
66
  'Element line height is less than 1.5 times its font size (__param__)',
67
67
  'Elements have line heights less than 1.5 times their font sizes'
68
68
  ];
69
- return await report(withItems, all, 'lineHeight', whats, 1);
69
+ return await getRuleResult(withItems, all, 'lineHeight', whats, 1);
70
70
  };
@@ -31,7 +31,7 @@
31
31
  */
32
32
 
33
33
  // Module to perform common operations.
34
- const {init, report} = require('../procs/testaro');
34
+ const {init, getRuleResult} = require('../procs/testaro');
35
35
  // Module to get locator data.
36
36
  const {getLocatorData} = require('../procs/getLocatorData');
37
37
 
@@ -71,5 +71,5 @@ exports.reporter = async (page, withItems) => {
71
71
  'Link has the same text as, but a different destination from, another',
72
72
  'Links have the same texts but different destinations'
73
73
  ];
74
- return await report(withItems, all, 'linkAmb', whats, 2);
74
+ return await getRuleResult(withItems, all, 'linkAmb', whats, 2);
75
75
  };
@@ -30,7 +30,7 @@
30
30
  */
31
31
 
32
32
  // Module to perform common operations.
33
- const {init, report} = require('../procs/testaro');
33
+ const {init, getRuleResult} = require('../procs/testaro');
34
34
 
35
35
  // ########## FUNCTIONS
36
36
 
@@ -58,5 +58,5 @@ exports.reporter = async (page, withItems) => {
58
58
  'Element has a font size of __param__ pixels, smaller than 11 pixels',
59
59
  'Elements have font sizes smaller than 11 pixels'
60
60
  ];
61
- return await report(withItems, all, 'miniText', whats, 2);
61
+ return await getRuleResult(withItems, all, 'miniText', whats, 2);
62
62
  };
package/testaro/motion.js CHANGED
@@ -1,83 +1,91 @@
1
1
  /*
2
- © 2021–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
-
4
- MIT License
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
2
+ © 2025 Jonathan Robert Pool. All rights reserved.
3
+ Licensed under the MIT License. See LICENSE for details.
23
4
  */
24
5
 
25
6
  /*
26
7
  motion
27
- This test reports motion in a page. For minimal accessibility, standards require motion to be
28
- brief, or else stoppable by the user. But stopping motion can be difficult or impossible, and,
29
- by the time a user manages to stop motion, the motion may have caused annoyance or harm. For
30
- superior accessibility, a page contains no motion until and unless the user authorizes it. The
31
- test compares two screen shots of the viewport 2 seconds and 6 seconds after page load. It
32
- reports a rule violation if any pixels change. The larger the change fraction, the greater the
8
+ This test reports motion in a page by comparing the first and last of the screenshots previously
9
+ made by the shoot test.
10
+
11
+ For minimal accessibility, standards require motion to be brief, or else stoppable by the user.
12
+ But stopping motion can be difficult or impossible, and, by the time a user manages to stop
13
+ motion, the motion may have caused annoyance or harm. For superior accessibility, a page contains
14
+ no motion until and unless the user authorizes it. The test reports a rule violation if any
15
+ pixels differ between the screenshots. The larger the change fraction, the greater the
33
16
  ordinal severity.
34
17
 
35
- WARNING: This test uses the procs/visChange module. See the warning in that module about browser
36
- types.
18
+ WARNING: The shoot test uses the procs/screenShot module. See the warning in that module about
19
+ browser types.
37
20
  */
38
21
 
39
22
  // IMPORTS
40
23
 
41
- // Module to get pixel changes between two times.
42
- const {visChange} = require('../procs/visChange');
24
+ // Module to make a screenshot.
25
+ const pixelmatch = require('pixelmatch').default;
26
+ const {result} = require('../tests/testaro');
43
27
 
44
28
  // FUNCTIONS
45
29
 
46
30
  // Reports motion in a page.
47
31
  exports.reporter = async page => {
48
32
  // Initialize the totals and standard instances.
33
+ const data = {};
49
34
  const totals = [0, 0, 0, 0];
50
35
  const standardInstances = [];
51
- // Make screenshots and get the result.
52
- const data = await visChange(page, {
53
- delayBefore: 2000,
54
- delayBetween: 3000
55
- });
56
- // If the screenshots succeeded:
57
- if (data.success) {
58
- // If any pixels were changed:
59
- if (data.pixelChanges) {
60
- // Get the ordinal severity from the fractional pixel change.
61
- const ordinalSeverity = Math.floor(Math.min(3, 0.4 * Math.sqrt(data.changePercent)));
62
- // Add to the totals.
63
- totals[ordinalSeverity] = 1;
64
- // Get a summary standard instance.
65
- standardInstances.push({
66
- ruleID: 'motion',
67
- what: 'Content moves or changes without user request',
68
- count: 1,
69
- ordinalSeverity,
70
- tagName: 'HTML',
71
- id: '',
72
- location: {
73
- doc: '',
74
- type: '',
75
- spec: ''
76
- },
77
- excerpt: ''
78
- });
36
+ // Get the screenshots made by the shoot test.
37
+ const shootResult = result ? result.shoot || {} : {};
38
+ // If there are at least 2 of them:
39
+ if (shootResult.pngs && shootResult.pngs.length > 1) {
40
+ let {pngs} = shootResult;
41
+ // Choose the first and last of them for comparison.
42
+ const pngPair = [pngs[0], pngs[pngs.length - 1]];
43
+ // Get their dimensions.
44
+ const {width, height} = pngPair[0];
45
+ // If their dimensions differ:
46
+ if (width !== pngPair[1].width || height !== pngPair[1].height) {
47
+ // Report this.
48
+ data.prevented = true;
49
+ data.error = 'Screenshots have differing dimensions';
50
+ }
51
+ // Otherwise, i.e. if their dimensions are identical:
52
+ else {
53
+ // Get the count of differing pixels between the shots.
54
+ const pixelChanges = pixelmatch(pngPair[0].data, pngPair[1].data, null, width, height);
55
+ // Get the ratio of differing to all pixels as a percentage.
56
+ const changePercent = 100 * pixelChanges / (width * height);
57
+ // Free the memory used by screenshots.
58
+ pngs = [];
59
+ // If any pixels were changed:
60
+ if (pixelChanges) {
61
+ // Get the ordinal severity from the fractional pixel change.
62
+ const ordinalSeverity = Math.floor(Math.min(3, 0.4 * Math.sqrt(changePercent)));
63
+ // Add to the totals.
64
+ totals[ordinalSeverity] = 1;
65
+ // Get a summary standard instance.
66
+ standardInstances.push({
67
+ ruleID: 'motion',
68
+ what: 'Content moves or changes without user request',
69
+ count: 1,
70
+ ordinalSeverity,
71
+ tagName: 'HTML',
72
+ id: '',
73
+ location: {
74
+ doc: '',
75
+ type: '',
76
+ spec: ''
77
+ },
78
+ excerpt: ''
79
+ });
80
+ }
79
81
  }
80
82
  }
83
+ // Otherwise, i.e. if there are not at least 2 of them
84
+ else {
85
+ // Report this.
86
+ data.prevented = true;
87
+ data.error = 'Fewer than 2 screenshots recorded';
88
+ }
81
89
  // Return the result.
82
90
  return {
83
91
  data,
@@ -0,0 +1,94 @@
1
+ /*
2
+ © 2021–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
+ © 2025 Jonathan Robert Pool. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+ */
25
+
26
+ /*
27
+ motion
28
+ This test reports motion in a page. For minimal accessibility, standards require motion to be
29
+ brief, or else stoppable by the user. But stopping motion can be difficult or impossible, and,
30
+ by the time a user manages to stop motion, the motion may have caused annoyance or harm. For
31
+ superior accessibility, a page contains no motion until and unless the user authorizes it. The
32
+ test compares two screen shots of the viewport 2 seconds and 6 seconds after page load. It
33
+ reports a rule violation if any pixels change. The larger the change fraction, the greater the
34
+ ordinal severity.
35
+
36
+ This test is an alternative to the motion test. Whereas the motion test relies on screenshots made
37
+ earlier in the same job by the shoot test, this test makes its own screenshots. MotionSolo waits
38
+ several seconds between its screenshots to allow time for motion to occur. That mait makes
39
+ motionSolo, and any job containing it, take longer than the combination of shoot tests and the
40
+ motion test.
41
+
42
+ WARNING: This test uses the procs/visChange module. See the warning in that module about browser
43
+ types.
44
+ */
45
+
46
+ // IMPORTS
47
+
48
+ // Module to get pixel changes between two times.
49
+ const {visChange} = require('../procs/visChange');
50
+
51
+ // FUNCTIONS
52
+
53
+ // Reports motion in a page.
54
+ exports.reporter = async page => {
55
+ // Initialize the totals and standard instances.
56
+ const totals = [0, 0, 0, 0];
57
+ const standardInstances = [];
58
+ // Make screenshots and get the result.
59
+ const data = await visChange(page, {
60
+ delayBefore: 2000,
61
+ delayBetween: 3000
62
+ });
63
+ // If the screenshots succeeded:
64
+ if (data.success) {
65
+ // If any pixels were changed:
66
+ if (data.pixelChanges) {
67
+ // Get the ordinal severity from the fractional pixel change.
68
+ const ordinalSeverity = Math.floor(Math.min(3, 0.4 * Math.sqrt(data.changePercent)));
69
+ // Add to the totals.
70
+ totals[ordinalSeverity] = 1;
71
+ // Get a summary standard instance.
72
+ standardInstances.push({
73
+ ruleID: 'motionSolo',
74
+ what: 'Content moves or changes without user request',
75
+ count: 1,
76
+ ordinalSeverity,
77
+ tagName: 'HTML',
78
+ id: '',
79
+ location: {
80
+ doc: '',
81
+ type: '',
82
+ spec: ''
83
+ },
84
+ excerpt: ''
85
+ });
86
+ }
87
+ }
88
+ // Return the result.
89
+ return {
90
+ data,
91
+ totals,
92
+ standardInstances
93
+ };
94
+ };
package/testaro/opFoc.js CHANGED
@@ -38,7 +38,7 @@
38
38
  // ########## IMPORTS
39
39
 
40
40
  // Module to perform common operations.
41
- const {init, report} = require('../procs/testaro');
41
+ const {init, getRuleResult} = require('../procs/testaro');
42
42
  // Module to get operabilities.
43
43
  const {isOperable} = require('../procs/operable');
44
44
 
@@ -71,6 +71,6 @@ exports.reporter = async (page, withItems) => {
71
71
  'Element is operable (__param__) but not Tab-focusable',
72
72
  'Elements are operable but not Tab-focusable'
73
73
  ];
74
- const result = await report(withItems, all, 'opFoc', whats, 3);
74
+ const result = await getRuleResult(withItems, all, 'opFoc', whats, 3);
75
75
  return result;
76
76
  };
package/testaro/phOnly.js CHANGED
@@ -28,7 +28,7 @@
28
28
  Clean-room rule: input elements that have a placeholder but no accessible name (no label/title/aria-label/aria-labelledby)
29
29
  */
30
30
 
31
- const {init, report} = require('../procs/testaro');
31
+ const {init, getRuleResult} = require('../procs/testaro');
32
32
 
33
33
  const hasAccessibleName = async (loc) => {
34
34
  return await loc.evaluate(el => {
@@ -62,5 +62,5 @@ exports.reporter = async (page, withItems) => {
62
62
  'Element has a placeholder but no accessible name',
63
63
  'input elements have placeholders but no accessible names'
64
64
  ];
65
- return await report(withItems, all, 'phOnly', whats, 2, 'INPUT');
65
+ return await getRuleResult(withItems, all, 'phOnly', whats, 2, 'INPUT');
66
66
  };
@@ -32,7 +32,7 @@
32
32
  // ########## IMPORTS
33
33
 
34
34
  // Module to perform common operations.
35
- const {init, report} = require('../procs/testaro');
35
+ const {init, getRuleResult} = require('../procs/testaro');
36
36
 
37
37
  // ########## FUNCTIONS
38
38
 
@@ -62,5 +62,5 @@ exports.reporter = async (page, withItems) => {
62
62
  'Adjacent BR elements within a __param__ element may be pseudo-paragraphs',
63
63
  'Elements contain 2 or more adjacent br elements that may be pseudo-paragraphs'
64
64
  ];
65
- return await report(withItems, all, 'pseudoP', whats, 0, 'br');
65
+ return await getRuleResult(withItems, all, 'pseudoP', whats, 0, 'br');
66
66
  };
@@ -32,7 +32,7 @@
32
32
  // ########## IMPORTS
33
33
 
34
34
  // Module to perform common operations.
35
- const {init, report} = require('../procs/testaro');
35
+ const {init, getRuleResult} = require('../procs/testaro');
36
36
 
37
37
  // ########## FUNCTIONS
38
38
 
@@ -120,5 +120,5 @@ exports.reporter = async (page, withItems) => {
120
120
  const whats = [
121
121
  'Radio button __param__', 'Radio buttons are not validly grouped in fieldsets with legends'
122
122
  ];
123
- return await report(withItems, all, 'radioSet', whats, 2, 'INPUT');
123
+ return await getRuleResult(withItems, all, 'radioSet', whats, 2, 'INPUT');
124
124
  };
package/testaro/role.js CHANGED
@@ -31,7 +31,7 @@
31
31
  // IMPORTS
32
32
 
33
33
  // Module to perform common operations.
34
- const {init, report} = require('../procs/testaro');
34
+ const {init, getRuleResult} = require('../procs/testaro');
35
35
 
36
36
  // CONSTANTS
37
37
 
@@ -100,5 +100,5 @@ exports.reporter = async (page, withItems) => {
100
100
  'Element has an explicit __param__ role, which is also an implicit HTML element role',
101
101
  'Elements have roles assigned that are also implicit roles of HTML elements'
102
102
  ];
103
- return await report(withItems, all, 'role', whats, 0);
103
+ return await getRuleResult(withItems, all, 'role', whats, 0);
104
104
  };
@@ -29,7 +29,7 @@
29
29
  immediately preceding heading within the same sectioning container.
30
30
  */
31
31
 
32
- const {init, report} = require('../procs/testaro');
32
+ const {init, getRuleResult} = require('../procs/testaro');
33
33
 
34
34
  exports.reporter = async (page, withItems) => {
35
35
  const all = await init(200, page, 'h1,h2,h3,h4,h5,h6');
@@ -55,5 +55,5 @@ exports.reporter = async (page, withItems) => {
55
55
  'Element violates the logical level order in its sectioning container',
56
56
  'Heading elements violate the logical level order in their sectioning containers'
57
57
  ];
58
- return await report(withItems, all, 'secHeading', whats, 1);
58
+ return await getRuleResult(withItems, all, 'secHeading', whats, 1);
59
59
  };
@@ -0,0 +1,57 @@
1
+ /*
2
+ © 2025 Jonathan Robert Pool. All rights reserved.
3
+ Licensed under the MIT License. See LICENSE file for details.
4
+ */
5
+
6
+ /*
7
+ shoot
8
+ This test makes a full-page screenshot and returns it as a PNG object.
9
+ */
10
+
11
+ // IMPORTS
12
+
13
+ const {PNG} = require('pngjs');
14
+ const {screenShot} = require('../procs/screenShot');
15
+ const {result} = require('../tests/testaro');
16
+
17
+ // FUNCTIONS
18
+
19
+ exports.reporter = async page => {
20
+ // Get the result of the previous iterations of this test, if any.
21
+ const shootResult = result ? result.shoot || {} : {};
22
+ // If any previous failure occurred:
23
+ if (shootResult && shootResult.success === false) {
24
+ // Return a failure without making a screenshot.
25
+ return {
26
+ success: false,
27
+ prevented: true,
28
+ error: 'At least 1 screenshot failed'
29
+ };
30
+ }
31
+ // Otherwise, make and get a screenshot.
32
+ const shot = await screenShot(page);
33
+ // If it succeeded:
34
+ if (shot.length) {
35
+ // Get the screenshot as an object representation of a PNG image.
36
+ const png = PNG.sync.read(shot);
37
+ shootResult.pngs ??= [];
38
+ const {pngs} = shootResult;
39
+ // Add it to the test result.
40
+ pngs.push(png);
41
+ // Return the updated result.
42
+ return {
43
+ success: true,
44
+ prevented: false,
45
+ pngs
46
+ };
47
+ }
48
+ // Otherwise, i.e. if it failed:
49
+ else {
50
+ // Return this.
51
+ return {
52
+ success: false,
53
+ prevented: true,
54
+ error: 'Screenshot failed'
55
+ };
56
+ }
57
+ };
@@ -33,7 +33,7 @@
33
33
  // ########## IMPORTS
34
34
 
35
35
  // Module to perform common operations.
36
- const {init, report} = require('../procs/testaro');
36
+ const {init, getRuleResult} = require('../procs/testaro');
37
37
  // Module to classify links.
38
38
  const {isTooSmall} = require('../procs/target');
39
39
 
@@ -58,5 +58,5 @@ exports.reporter = async (page, withItems) => {
58
58
  'Interactive element pixel size (__param__) is less than 44 by 44',
59
59
  'Interactive elements are smaller than 44 pixels wide and high'
60
60
  ];
61
- return await report(withItems, all, 'targetSmall', whats, 0);
61
+ return await getRuleResult(withItems, all, 'targetSmall', whats, 0);
62
62
  };
@@ -33,7 +33,7 @@
33
33
  // ########## IMPORTS
34
34
 
35
35
  // Module to perform common operations.
36
- const {init, report} = require('../procs/testaro');
36
+ const {init, getRuleResult} = require('../procs/testaro');
37
37
  // Module to classify links.
38
38
  const {isTooSmall} = require('../procs/target');
39
39
 
@@ -58,5 +58,5 @@ exports.reporter = async (page, withItems) => {
58
58
  'Interactive element pixel size (__param__) is less than 24 by 24',
59
59
  'Interactive elements are smaller than 24 pixels wide and high'
60
60
  ];
61
- return await report(withItems, all, 'targetTiny', whats, 1);
61
+ return await getRuleResult(withItems, all, 'targetTiny', whats, 1);
62
62
  };
@@ -28,7 +28,7 @@
28
28
  Report semantically vague inline elements: i, b, small
29
29
  */
30
30
 
31
- const {init, report} = require('../procs/testaro');
31
+ const {init, getRuleResult} = require('../procs/testaro');
32
32
 
33
33
  exports.reporter = async (page, withItems) => {
34
34
  const all = await init(100, page, 'i, b, small');
@@ -44,5 +44,5 @@ exports.reporter = async (page, withItems) => {
44
44
  'Element is semantically vague',
45
45
  'Semantically vague elements i, b, and/or small are used'
46
46
  ];
47
- return await report(withItems, all, 'textSem', whats, 0);
47
+ return await getRuleResult(withItems, all, 'textSem', whats, 0);
48
48
  };