testaro 5.7.2 → 5.7.4
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/README.md +30 -24
- package/package.json +1 -1
- package/run.js +6 -2
- package/tests/nuVal.js +11 -3
package/README.md
CHANGED
|
@@ -93,6 +93,7 @@ A script is a JSON file with the properties:
|
|
|
93
93
|
|
|
94
94
|
```json
|
|
95
95
|
{
|
|
96
|
+
"id": "string consisting of lower-case ASCII letters and digits",
|
|
96
97
|
"what": "string: description of the script",
|
|
97
98
|
"strict": "boolean: whether redirections should be treated as failures",
|
|
98
99
|
"timeLimit": "number: limit in seconds on the execution of this script",
|
|
@@ -100,32 +101,33 @@ A script is a JSON file with the properties:
|
|
|
100
101
|
}
|
|
101
102
|
```
|
|
102
103
|
|
|
103
|
-
The `timeLimit` property is optional. If it is omitted, a default of 300 seconds (5 minutes) is set.
|
|
104
|
+
The `timeLimit` property is optional. If it is omitted, a default of 300 seconds (5 minutes) is set.
|
|
104
105
|
|
|
105
106
|
### Example
|
|
106
107
|
|
|
107
108
|
Here is an example of a script:
|
|
108
109
|
|
|
109
|
-
```
|
|
110
|
+
```json
|
|
110
111
|
{
|
|
111
|
-
|
|
112
|
+
"id": "samplescript",
|
|
113
|
+
what: "Test example.com with alfa",
|
|
112
114
|
strict: true,
|
|
113
|
-
timeLimit:
|
|
115
|
+
timeLimit: 65,
|
|
114
116
|
commands: [
|
|
115
117
|
{
|
|
116
|
-
type:
|
|
117
|
-
which:
|
|
118
|
-
what:
|
|
118
|
+
type: "launch",
|
|
119
|
+
which: "chromium",
|
|
120
|
+
what: "Chromium browser"
|
|
119
121
|
},
|
|
120
122
|
{
|
|
121
|
-
type:
|
|
122
|
-
which:
|
|
123
|
-
what:
|
|
123
|
+
type: "url",
|
|
124
|
+
which: "https://example.com/",
|
|
125
|
+
what: "page with a few accessibility defects"
|
|
124
126
|
},
|
|
125
127
|
{
|
|
126
|
-
type:
|
|
127
|
-
which:
|
|
128
|
-
what:
|
|
128
|
+
type: "test",
|
|
129
|
+
which: "alfa",
|
|
130
|
+
what: "Siteimprove alfa package"
|
|
129
131
|
}
|
|
130
132
|
]
|
|
131
133
|
}
|
|
@@ -302,6 +304,10 @@ In case you want to perform more than one `tenon` test with the same script, you
|
|
|
302
304
|
|
|
303
305
|
Tenon recommends giving it a public URL rather than giving it the content of a page, if possible. So, it is best to give the `withNewContent` property of the `tenonRequest` command the value `true`, unless the page is not public.
|
|
304
306
|
|
|
307
|
+
###### Continuum
|
|
308
|
+
|
|
309
|
+
The `continuum` test makes use of the files in the `continuum` directory. The test inserts the contents of all three files into the page as scripts and then uses them to perform the tests of the Continuum package.
|
|
310
|
+
|
|
305
311
|
###### HTML CodeSniffer
|
|
306
312
|
|
|
307
313
|
The `htmlcs` test makes use of the`htmlcs/HTMLCS.js` file. That file was created, and can be recreated if necessary, as follows:
|
|
@@ -336,7 +342,7 @@ The changes in `htmlcs/HTMLCS.js` are:
|
|
|
336
342
|
|
|
337
343
|
###### BBC Accessibility Standards Checker
|
|
338
344
|
|
|
339
|
-
The BBC Accessibility Standards Checker has obsolete dependencies with security vulnerabilities. Therefore, it is not used as a dependency of Testaro. Instead, 6 of its tests
|
|
345
|
+
The BBC Accessibility Standards Checker has obsolete dependencies with security vulnerabilities. Therefore, it is not used as a dependency of Testaro. Instead, 6 of its tests are reimplemented, in some case with revisions, as Testaro tests. They are drawn from the 18 automated tests of the Checker. The other 12 tests were found too duplicative of other tests to justify reimplementation.
|
|
340
346
|
|
|
341
347
|
##### Branching
|
|
342
348
|
|
|
@@ -436,18 +442,18 @@ A typical use for an `expect` property is checking the correctness of a Testaro
|
|
|
436
442
|
|
|
437
443
|
You may wish to have Testaro perform the same sequence of tests on multiple web pages. In that case, you can create a _batch_, with the following structure:
|
|
438
444
|
|
|
439
|
-
```
|
|
445
|
+
```json
|
|
440
446
|
{
|
|
441
|
-
what:
|
|
447
|
+
what: "Web leaders",
|
|
442
448
|
hosts: {
|
|
443
|
-
id:
|
|
444
|
-
which:
|
|
445
|
-
what:
|
|
449
|
+
id: "w3c",
|
|
450
|
+
which: "https://www.w3.org/",
|
|
451
|
+
what: "W3C"
|
|
446
452
|
},
|
|
447
453
|
{
|
|
448
|
-
id:
|
|
449
|
-
which:
|
|
450
|
-
what:
|
|
454
|
+
id: "wikimedia",
|
|
455
|
+
which: "https://www.wikimedia.org/",
|
|
456
|
+
what: "Wikimedia"
|
|
451
457
|
}
|
|
452
458
|
}
|
|
453
459
|
```
|
|
@@ -487,7 +493,7 @@ The argument of `require` is a path relative to the directory of the module in w
|
|
|
487
493
|
|
|
488
494
|
Another Node.js package that has Testaro as a dependency can execute the same statements, except changing `'./run'` to `'testaro/run'`.
|
|
489
495
|
|
|
490
|
-
Testaro will run the script and
|
|
496
|
+
Testaro will run the script and modify the properties of the `report` object. When Testaro finishes, the `log`, `acts`, and other properties of `report` will contain the results. The final statement can further process the `report` object as desired in the `then` callback.
|
|
491
497
|
|
|
492
498
|
#### High-level
|
|
493
499
|
|
|
@@ -500,7 +506,7 @@ Relative paths must be relative to the Testaro project directory. For example, i
|
|
|
500
506
|
|
|
501
507
|
Also ensure that Testaro can read all those directories and write to `REPORTDIR`.
|
|
502
508
|
|
|
503
|
-
Place a script into `SCRIPTDIR` and, optionally, a batch into `BATCHDIR`. Each should be named `
|
|
509
|
+
Place a script into `SCRIPTDIR` and, optionally, a batch into `BATCHDIR`. Each should be named with a `.json` extension., where `idvalue` is replaced with the value of its `id` property. That value must consist of only lower-case ASCII letters and digits.
|
|
504
510
|
|
|
505
511
|
Then execute the statement `node high scriptID` or `node high scriptID batchID`, replacing `scriptID` and `batchID` with the `id` values of the script and the batch, respectively.
|
|
506
512
|
|
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
|
|
2
|
+
run.js
|
|
3
3
|
testaro main script.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -103,6 +103,7 @@ let errorLogSize = 0;
|
|
|
103
103
|
let prohibitedCount = 0;
|
|
104
104
|
let visitTimeoutCount = 0;
|
|
105
105
|
let visitRejectionCount = 0;
|
|
106
|
+
let visitLatency = 0;
|
|
106
107
|
let actCount = 0;
|
|
107
108
|
// Facts about the current browser.
|
|
108
109
|
let browserContext;
|
|
@@ -511,6 +512,7 @@ const goto = async (page, url, timeout, waitUntil, isStrict) => {
|
|
|
511
512
|
url = url.replace('file://', `file://${__dirname}/`);
|
|
512
513
|
}
|
|
513
514
|
// Visit the URL.
|
|
515
|
+
const startTime = Date.now();
|
|
514
516
|
const response = await page.goto(url, {
|
|
515
517
|
timeout,
|
|
516
518
|
waitUntil
|
|
@@ -520,6 +522,7 @@ const goto = async (page, url, timeout, waitUntil, isStrict) => {
|
|
|
520
522
|
visitTimeoutCount++;
|
|
521
523
|
return 'error';
|
|
522
524
|
});
|
|
525
|
+
visitLatency += Math.round((Date.now() - startTime) / 1000);
|
|
523
526
|
// If the visit succeeded:
|
|
524
527
|
if (typeof response !== 'string') {
|
|
525
528
|
const httpStatus = response.status();
|
|
@@ -733,7 +736,7 @@ const doActs = async (report, actIndex, page) => {
|
|
|
733
736
|
// If the command is a url:
|
|
734
737
|
if (act.type === 'url') {
|
|
735
738
|
// Visit it and wait until it is stable.
|
|
736
|
-
page = await visit(act, page, report.
|
|
739
|
+
page = await visit(act, page, report.isStrict);
|
|
737
740
|
}
|
|
738
741
|
// Otherwise, if the act is a wait for text:
|
|
739
742
|
else if (act.type === 'wait') {
|
|
@@ -1335,6 +1338,7 @@ const doScript = async (report) => {
|
|
|
1335
1338
|
report.prohibitedCount = prohibitedCount;
|
|
1336
1339
|
report.visitTimeoutCount = visitTimeoutCount;
|
|
1337
1340
|
report.visitRejectionCount = visitRejectionCount;
|
|
1341
|
+
report.visitLatency = visitLatency;
|
|
1338
1342
|
// Add the end time and duration to the report.
|
|
1339
1343
|
const endTime = new Date();
|
|
1340
1344
|
report.endTime = endTime.toISOString().slice(0, 19);
|
package/tests/nuVal.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
2
|
nuVal
|
|
3
3
|
This test subjects a page to the Nu Html Checker.
|
|
4
|
+
That API erratically replaces left and right double quotation marks with invalid UTF-8, which
|
|
5
|
+
appears as 2 or 3 successive instances of the replacement character (U+fffd). Therefore, this
|
|
6
|
+
test removes all such quotation marks and the replacement character. That causes
|
|
7
|
+
'Bad value “” for' to become 'Bad value for'. Since the corruption of quotation marks is
|
|
8
|
+
erratic, no better solution is known.
|
|
4
9
|
*/
|
|
5
10
|
const https = require('https');
|
|
6
11
|
exports.reporter = async page => {
|
|
@@ -10,7 +15,10 @@ exports.reporter = async page => {
|
|
|
10
15
|
try {
|
|
11
16
|
const request = https.request(
|
|
12
17
|
{
|
|
13
|
-
|
|
18
|
+
/*
|
|
19
|
+
Alternatives (more timeout-prone): host=validator.nu; path=/?parser=html@out=json
|
|
20
|
+
That host crashes instead of ending with a fatal error.
|
|
21
|
+
*/
|
|
14
22
|
host: 'validator.w3.org',
|
|
15
23
|
path: '/nu/?parser=html&out=json',
|
|
16
24
|
method: 'POST',
|
|
@@ -27,8 +35,8 @@ exports.reporter = async page => {
|
|
|
27
35
|
// When the data arrive:
|
|
28
36
|
response.on('end', async () => {
|
|
29
37
|
try {
|
|
30
|
-
// Delete
|
|
31
|
-
const result = JSON.parse(report);
|
|
38
|
+
// Delete left and right quotation marks and their erratic invalid replacements.
|
|
39
|
+
const result = JSON.parse(report.replace(/[\u{fffd}“”]/ug, ''));
|
|
32
40
|
return resolve(result);
|
|
33
41
|
}
|
|
34
42
|
catch (error) {
|