testaro 8.0.4 → 8.0.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/README-mixed.md +0 -707
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "8.0.4",
3
+ "version": "8.0.5",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/README-mixed.md DELETED
@@ -1,707 +0,0 @@
1
- # testaro
2
-
3
- Federated accessibility test automation
4
-
5
- ## Summary
6
-
7
- Testaro is a collection of collections of web accessibility tests.
8
-
9
- The purpose of Testaro is to provide programmatic access to accessibility tests defined in several test packages and in Testaro itself.
10
-
11
- ## System requirements
12
-
13
- Version 14 or later of [Node.js](https://nodejs.org/en/).
14
-
15
- ## Dependencies
16
-
17
- Testaro uses:
18
- - [Playwright](https://playwright.dev/) to launch browsers, perform user actions in them, and perform tests
19
- - [pixelmatch](https://www.npmjs.com/package/pixelmatch) to measure motion
20
-
21
- Testaro includes some of its own accessibility tests. In addition, it performs the tests in:
22
- - [accessibility-checker](https://www.npmjs.com/package/accessibility-checker) (the IBM Equal Access Accessibility Checker)
23
- - [alfa](https://alfa.siteimprove.com/) (Siteimprove alfa)
24
- - [Continuum Community Edition](https://www.webaccessibility.com/tools/)
25
- - [HTML CodeSniffer](https://www.npmjs.com/package/html_codesniffer) (Squiz HTML CodeSniffer)
26
- - [axe-playwright](https://www.npmjs.com/package/axe-playwright) (Deque Axe-core)
27
- - [Tenon](https://tenon.io/documentation/what-tenon-tests.php) (Level Access)
28
- - [WAVE API](https://wave.webaim.org/api/) (WebAIM WAVE)
29
- - [Nu Html Checker](https://github.com/validator/validator)
30
-
31
- Some of the Testaro tests are derived from tests performed by the [BBC Accessibility Standards Checker](https://github.com/bbc/bbc-a11y).
32
-
33
- As of this version, the counts of tests in the packages referenced above were:
34
- - Alfa: 103
35
- - Axe-core: 138
36
- - Continuum Community Edition: 267
37
- - Equal Access: 163
38
- - HTML CodeSniffer: 98
39
- - Tenon: 180
40
- - WAVE: 110
41
- - Nu Html Checker: 147
42
- - subtotal: 1206
43
- - Testaro tests: 23
44
- - grand total: 1229
45
-
46
- ## Quasi-tests
47
-
48
- Reports produced by Testaro contain data in addition to the results of these tests. Such data can be used like tests. In particular, the data include:
49
- - Latency (how long a time each test takes)
50
- - Test prevention (the failure of tests to run on particular targets)
51
- - Logging (browser messaging, including about document errors, during testing)
52
-
53
- ## Code organization
54
-
55
- The main directories containing code files are:
56
- - package root: main code files
57
- - `tests`: files containing the code defining particular tests
58
- - `procs`: shared procedures
59
- - `validation`: code and artifacts for the validation of Testaro
60
-
61
- ## Installation
62
-
63
- Some of the dependencies of Testaro are published as Github packages. Installing Testaro therefore requires you to be authorized to read Github packages. If you do not yet have that authorization, you can give it to yourself as follows:
64
- - Log in at [Github](https://github.com).
65
- - From your avatar in the upper-right corner, choose “Settings”.
66
- - In the left sidebar, choose “Developer settings”.
67
- - In the left sidebar, choose “Personal access tokens”.
68
- - Activate the button “Generate new token”.
69
- - Give the new token a descriptive note.
70
- - Select an expiration date.
71
- - Check the checkbox `read:packages`.
72
- - Activate the button “Generate token”.
73
- - Copy the generated token (you can use the copy icon next to it).
74
- - In the local directory of the project into which you will install Testaro, create a file named `.npmrc`, unless it already exists.
75
- - Populate the `.npmrc` file with the following statements, replacing `abc` with your Github username and `xyz` with the token that you copied:
76
-
77
- ```bash
78
- @siteimprove:registry=https://npm.pkg.github.com
79
- //npm.pkg.github.com/:username=abc
80
- //npm.pkg.github.com/:_authToken=xyz
81
- ```
82
-
83
- Once you have done that, you can install Testaro as you would install any `npm` package.
84
-
85
- However, if the Playwright dependency is ever updated to a newer version, you must also reinstall its browers by executing the statement `npx playwright install`.
86
-
87
- ## Payment
88
-
89
- All of the tests that Testaro can perform are free of cost, except those in the Tenon and WAVE packages. The owner of each of those packages gives new registrants a free allowance of credits before it becomes necessary to pay for use of the API of the package. The required environment variables for authentication and payment are described below under “Environment variables”.
90
-
91
- ## Specification
92
-
93
- To use Testaro, you must specify what it should do. You do this with a script and optionally a batch.
94
-
95
- ## Scripts
96
-
97
- ### Introduction
98
-
99
- To use Testaro, you provide a **script** to it. The script contains **commands**. Testaro _runs_ the script, i.e. performs the commands in it and writes a report of the results.
100
-
101
- A script is a JSON file with the properties:
102
-
103
- ```json
104
- {
105
- "id": "string consisting of lower-case ASCII letters and digits",
106
- "what": "string: description of the script",
107
- "strict": "boolean: whether redirections should be treated as failures",
108
- "timeLimit": "number: limit in seconds on the execution of this script",
109
- "commands": "array of objects: the commands to be performed"
110
- }
111
- ```
112
-
113
- The `timeLimit` property is optional. If it is omitted, a default of 300 seconds (5 minutes) is set.
114
-
115
- ### Example
116
-
117
- Here is an example of a script:
118
-
119
- ```json
120
- {
121
- "id": "samplescript",
122
- what: "Test example.com with alfa",
123
- strict: true,
124
- timeLimit: 65,
125
- commands: [
126
- {
127
- type: "launch",
128
- which: "chromium",
129
- what: "Chromium browser"
130
- },
131
- {
132
- type: "url",
133
- which: "https://example.com/",
134
- what: "page with a few accessibility defects"
135
- },
136
- {
137
- type: "test",
138
- which: "alfa",
139
- what: "Siteimprove alfa package"
140
- }
141
- ]
142
- }
143
- ```
144
-
145
- This script tells Testaro to open a page in the Chromium browser, navigate to `example.com`, and perform the tests in the `alfa` package on that URL.
146
-
147
- ### Strictness
148
-
149
- If the `strict` property is `true`, Testaro will accept redirections that add or subtract a final slash, but otherwise will treat redirections as failures.
150
-
151
- ### Commands
152
-
153
- #### Introduction
154
-
155
- The `commands` property’s value is an array of command objects.
156
-
157
- Each command has a `type` property and optionally has a `name` property (used in branching, described below). It must or may have other properties, depending on the value of `type`.
158
-
159
- #### Command sequence
160
-
161
- The first two commands in any script have the types `launch` and `url`, respectively, as shown in the example above. They launch a browser and then use it to visit a URL. For example:
162
-
163
- ```json
164
- {
165
- "type": "launch",
166
- "which": "chromium",
167
- "what": "Open a page in a Chromium browser"
168
- }
169
- ```
170
-
171
- ```json
172
- {
173
- "type": "url",
174
- "which": "https://en.wikipedia.org/wiki/Main_Page",
175
- "what": "English Wikipedia home page"
176
- }
177
- ```
178
-
179
- #### Command types
180
-
181
- The subsequent commands can tell Testaro to perform any of:
182
- - moves (clicks, text inputs, hovers, etc.)
183
- - navigations (browser launches, visits to URLs, waits for page conditions, etc.)
184
- - alterations (changes to the page)
185
- - tests (whether in dependency packages or defined within Testaro)
186
- - branching (continuing from a command other than the next one)
187
-
188
- ##### Moves
189
-
190
- An example of a **move** is:
191
-
192
- ```json
193
- {
194
- "type": "radio",
195
- "which": "No",
196
- "index": 2,
197
- "what": "No, I am not a smoker"
198
- }
199
- ```
200
-
201
- In this case, Testaro checks the third radio button whose text includes the string “No” (case-insensitively).
202
-
203
- In identifying the target element for a move, Testaro matches the `which` property with the texts of the elements of the applicable type (such as radio buttons). It defines the text of an `input` element as the concatenated texts of its implicit label or explicit labels, if any, plus, for the first input in a `fieldset` element, the text content of the `legend` element of that `fieldset` element. For any other element, Testaro defines the text as the text content of the element.
204
-
205
- When multiple elements of the same type have indistinguishable texts, you can include an `index` property to specify the index of the target element, among all those that will match.
206
-
207
- ##### Navigations
208
-
209
- An example of a **navigation** is the command of type `url` above.
210
-
211
- Once you have included a `url` command in a script, you do not need to add more `url` commands unless you want the browser to visit a different URL.
212
-
213
- However, some tests modify web pages. In those cases, Testaro inserts additional `url` commands into the `script` property of the `options` object, after those tests, to ensure that changes made by one test do not affect subsequent acts.
214
-
215
- Another navigation example is:
216
-
217
- ```json
218
- {
219
- "type": "wait",
220
- "which": "travel",
221
- "what": "title"
222
- }
223
- ```
224
-
225
- In this case, Testaro waits until the page title contains the string “travel” (case-insensitively).
226
-
227
- ##### Alterations
228
-
229
- An example of an **alteration** is:
230
-
231
- ```json
232
- {
233
- "type": "reveal",
234
- "what": "make everything visible"
235
- }
236
- ```
237
-
238
- This command causes Testaro to alter the `display` and `visibility` style properties of all elements, where necessary, so those properties do not make any element invisible.
239
-
240
- ##### Tests
241
-
242
- ###### Introduction
243
-
244
- The possible commands of type `test` are enumerated in the `tests` object defined in the `index.js` file.
245
-
246
- A test performs operations and reports results. The results may or may not directly indicate that a page passes or fails requirements. Typically, accessibility tests report successes and failures. But a test in Testaro is defined less restrictively, so it can report any results. As one example, the Testaro `elements` test reports facts about certain elements on a page, without asserting that those facts are successes or failures.
247
-
248
- The term “test” has two meanings for Testaro:
249
- - A command is a test (test command) if its `type` property has the value `test`.
250
- - A package, such as Continuum, performs multiple tests (packaged tests).
251
-
252
- Thus, if a command of type `test` runs Continuum, Continuum performs multiple tests and reports their results.
253
-
254
- ###### Examples
255
-
256
- An example of a **packaged test** is:
257
-
258
- ```json
259
- {
260
- "type": "test",
261
- "which": "wave",
262
- "reportType": 1,
263
- "what": "WAVE summary"
264
- }
265
- ```
266
-
267
- In this case, Testaro runs the WAVE test with report type 1.
268
-
269
- An example of a **Testaro-defined** test is:
270
-
271
- ```json
272
- {
273
- "type": "test",
274
- "which": "motion",
275
- "delay": 1500,
276
- "interval": 2000,
277
- "count": 5,
278
- "what": "test for motion on the page"
279
- }
280
- ```
281
-
282
- In this case, Testaro runs the `motion` test with the specified parameters.
283
-
284
- ###### Tenon
285
-
286
- Most packaged tests require only one command, but the `tenon` test requires two commands:
287
- - A command of type `tenonRequest`.
288
- - A command of type `test` with `tenon` as the value of `which`.
289
-
290
- Example:
291
-
292
- ```json
293
- {
294
- "type": "tenonRequest",
295
- "id": "a",
296
- "withNewContent": true,
297
- "what": "Tenon API version 2 test request"
298
- }
299
- ```
300
-
301
- followed by
302
-
303
- ```json
304
- {
305
- "type": "test",
306
- "which": "tenon",
307
- "id": "a",
308
- "what": "Tenon API version 2 result retrieval"
309
- }
310
- ```
311
-
312
- The reason for this is that the Tenon API operates asynchronously. You ask it to perform a test, and it puts your request into a queue. To learn whether Tenon has completed your test, you make a status request. You can continue making status requests until Tenon replies that your test has been completed. Then you submit a request for the test result, and Tenon replies with the result. (As of May 2022, status requests were observed to misreport still-running tests as completed. The `tenon` test works around that by requesting only the result and using the response to determine whether the tests have been completed.)
313
-
314
- Tenon says that tests are typically completed in 3 to 6 seconds but that the latency can be longer, depending on demand.
315
-
316
- Therefore, you can include a `tenonRequest` command early in your script, and a `tenon` test command late in your script. Tenon will move your request through its queue while Testaro is processing your script. When Testaro reaches your `tenon` test command, Tenon will most likely have completed your test. If not, the `tenon` test will wait and then make a second request before giving up.
317
-
318
- Thus, a `tenon` test actually does not perform any test; it merely collects the result. The page that was active when the `tenonRequest` command was performed is the one that Tenon tests.
319
-
320
- In case you want to perform more than one `tenon` test with the same script, you can do so. Just give each pair of commands a distinct `id` property, so each `tenon` test command will request the correct result.
321
-
322
- 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.
323
-
324
- ###### Continuum
325
-
326
- 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.
327
-
328
- Level Access on 22 August 2022 granted authorization for the copying of the `AccessEngine.community.js` file insofar as necessary for allowing Continuum community edition tests to be included in Testaro.
329
-
330
- ###### HTML CodeSniffer
331
-
332
- The `htmlcs` test makes use of the`htmlcs/HTMLCS.js` file. That file was created, and can be recreated if necessary, as follows:
333
-
334
- 1. Clone the (HTML CodeSniffer package)[https://github.com/squizlabs/HTML_CodeSniffer].
335
- 1. Make that package’s directory the active directory.
336
- 1. Install the HTML CodeSniffer dependencies by executing `npm install`.
337
- 1. Build the HTML CodeSniffer auditor by executing `grunt build`.
338
- 1. Copy the `build/HTMLCS.js` and `build/licence.txt` files into the `htmlcs` directory of Testaro.
339
- 1. Edit the Testaro copy of `htmlcs/HTMLCS.js` to produce the changes shown below.
340
-
341
- The changes in `htmlcs/HTMLCS.js` are:
342
-
343
- ```diff
344
- 479a480
345
- > '4_1_2_attribute': 'attribute',
346
- 6482a6484
347
- > var messageStrings = new Set();
348
- 6496d6497
349
- < console.log('done');
350
- 6499d6499
351
- < console.log('done');
352
- 6500a6501
353
- > return Array.from(messageStrings);
354
- 6531c6532,6534
355
- < console.log('[HTMLCS] ' + typeName + '|' + msg.code + '|' + nodeName + '|' + elementId + '|' + msg.msg + '|' + html);
356
- ---
357
- > messageStrings.add(
358
- > typeName + '|' + msg.code + '|' + nodeName + '|' + elementId + '|' + msg.msg + '|' + html
359
- > );
360
- ```
361
-
362
- ###### BBC Accessibility Standards Checker
363
-
364
- 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 cases 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.
365
-
366
- ##### Branching
367
-
368
- An example of a **branching** command is:
369
-
370
- ```json
371
- {
372
- "type": "next",
373
- "if": ["totals.invalid", ">", 0],
374
- "jump": -4,
375
- "what": "redo search if any invalid elements"
376
- }
377
- ```
378
-
379
- This command checks the result of the previous act to determine whether its `result.totals.invalid` property has a positive value. If so, it changes the next command to be performed, specifying the command 4 commands before this one.
380
-
381
- A `next`-type command can use a `next` property instead of a `jump` property. The value of the `next` property is a command name. It tells Testaro to continue performing commands starting with the command having that value as the value of its `name` property.
382
-
383
- #### Commands file
384
-
385
- ##### Introduction
386
-
387
- The `commands.js` file contains rules governing commands. The rules determine whether a command is valid.
388
-
389
- ##### Rule format
390
-
391
- The rules in `commands.js` are organized into two objects, `etc` and `tests`. The `etc` object contains rules for commands of all types. The `tests` object contains additional rules that apply to some commands of type `test`, depending on the values of their `which` properties, namely which tests they perform.
392
-
393
- Here is an example of a command:
394
-
395
- ```json
396
- {
397
- "type": "link",
398
- "which": "warming",
399
- "what": "article on climate change"
400
- }
401
- ```
402
-
403
- And here is the applicable property of the `etc` object in `commmands.js`:
404
-
405
- ```js
406
- link: [
407
- 'Click a link',
408
- {
409
- which: [true, 'string', 'hasLength', 'substring of the link text'],
410
- what: [false, 'string', 'hasLength', 'comment']
411
- }
412
- ]
413
- ```
414
-
415
- The rule is an array with two elements: a string ('Click a link') describing the command and an object containing requirements for any command of type `link`.
416
-
417
- The requirement `which: [true, 'string', 'hasLength', 'substring of the link text']` specifies what is required for the `which` property of a `link`-type command. The requirement is an array.
418
-
419
- In most cases, the array has length 4:
420
- - 0. Is the property (here `which`) required (`true` or `false`)? The value `true` here means that every `link`-type command **must** contain a `which` property.
421
- - 1. What format must the property value have (`'string'`, `'array'`, `'boolean'`, or `'number'`)?
422
- - 2. What other validity criterion applies (if any)? (Empty string if none.) The `hasLength` criterion means that the string must be at least 1 character long.
423
- - 3. Description of the property. Here, the value of `which` is some substring of the text content of the link that is to be clicked. Thus, a `link` command tells Testaro to find the first link whose text content has this substring and click it.
424
-
425
- The validity criterion named in item 2 may be any of these:
426
- - `'hasLength'`: is not a blank string
427
- - `'isURL`': is a string starting with `http`, `https`, or `file`, then `://`, then ending with 1 or more non-whitespace characters
428
- - `'isBrowserType'`: is `'chromium'`, `'firefox'`, or `'webkit'`
429
- - `'isFocusable'`: is `'a'`, `'button'`, `'input'`, `'select'`, or `'option'`
430
- - `'isState'`: is `'loaded'` or `'idle'`
431
- - `'isTest'`: is the name of a test
432
- - `'isWaitable'`: is `'url'`, `'title'`, or `'body'`
433
- - `'areStrings'`: is an array of strings
434
-
435
- When `commands.js` specifies a `withItems` requirement for a `test`-type command, that requirement is an array of length 2, and is always `[true, 'boolean']`. That means that this `test`-type command must have a `withItems` property, whose value must be `true` or `false`. That property tells Testaro whether to itemize the results of that test.
436
-
437
- Any `test` command can also (in addition to the requirements in `commands.js`) contain an `expect` requirement. If it does, that requirement has a different format: an array of any non-0 length. The items in that array specify expectations about the results of the test.
438
-
439
- For example, a `test` command might have this `expect` property:
440
-
441
- ```json
442
- "expect": [
443
- ["total.links", "=", 5],
444
- ["total.links.underlined", "<", 6],
445
- ["total.links.outlined"],
446
- ["docLang", "!", "es-ES]
447
- ]
448
- ```
449
-
450
- That would state the expectation that the `result` property of the `acts` item for that test in the report will have a `total.links` property with the value 5, a `total.links.underlined` property with a value less than 6, **no** `total.links.outlined` property, and a `docLang` property with a value different from `es-ES`.
451
-
452
- The first item in each array is an identifier of a property within the `result` property. The item has the format of a string with `.` delimiters. Each `.`-delimited segment its the name of the next property in the hierarchy. If the current object is an array, the next segment must be a non-negative integer, representing the index of an element of the array. For example, `items.1.attributes.0` references the first element of the array that is the `attributes` property of the object that is the second element of the array that is the `items` property of `result`. (In JavaScript, this would be written `items[1].attributes[0]`, but in the `expect` property all property names are `.`-delimited.)
453
-
454
- If there is only 1 item in an array, it states the expectation that the specified property does not exist. Otherwise, there are 3 items in the array.
455
-
456
- The second item in each array, if there are 3 items in the array, is an operator, drawn from:
457
- - `<`: less than
458
- - `=`: equal to
459
- - `>`: greater than
460
- - `!`: unequal to
461
- - `i`: includes
462
-
463
- The third item in each array, if there are 3 items in the array, is the criterion with which the value of the first property is compared.
464
-
465
- A typical use for an `expect` property is checking the correctness of a Testaro test. Thus, the validation scripts in the `validation/tests/scripts` directory all contain `test` commands with `expect` properties. See the “Validation” section below.
466
-
467
- ## Batches
468
-
469
- 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:
470
-
471
- ```json
472
- {
473
- what: "Web leaders",
474
- hosts: {
475
- id: "w3c",
476
- which: "https://www.w3.org/",
477
- what: "W3C"
478
- },
479
- {
480
- id: "wikimedia",
481
- which: "https://www.wikimedia.org/",
482
- what: "Wikimedia"
483
- }
484
- }
485
- ```
486
-
487
- With a batch, you can execute a single statement to run a script multiple times, one per host. On each call, Testaro takes one of the hosts in the batch and substitutes it for each host specified in a `url` command of the script. The result is a _host script_. Testaro sequentially runs all of those host scripts.
488
-
489
- Therefore, you cannot use a batch with a script that changes URLs.
490
-
491
- ## Samples
492
-
493
- The `samples` directory contains examples of scripts and batches. If you wish to use them in their current locations, you can give `SCRIPTDIR` the value `'samples/scripts'` and `BATCHDIR` the value `'samples/batches'`. Then execute `node high sss` to run the `sss` script alone or `node high sss bbb` to run the `sss` script with the `bbb` batch (e.g., `node create simple weborgs`). The `high` module will create a job, run the script or host scripts, and save the report(s) in the directory that you have specified with the `REPORTDIR` environment variable.
494
-
495
- ## Execution
496
-
497
- ### Invocation
498
-
499
- There are three methods for using Testaro.
500
-
501
- #### Low-level
502
-
503
- A module in this package can invoke Testaro with this pattern:
504
-
505
- ```javascript
506
- const report = {
507
- script: {…},
508
- log: [],
509
- acts: []
510
- };
511
- const {handleRequest} = require('./run');
512
- handleRequest(report)
513
- .then(() => …);
514
- ```
515
-
516
- Replace `{…}` with a script object, like the example script shown above. The low-level method does not allow the use of batches.
517
-
518
- The argument of `require` is a path relative to the directory of the module in which this code appears. If the module is in a subdirectory, `./run` will need to be revised. In an executor within `validation/executors`, it must be revised to `../../run`.
519
-
520
- Another Node.js package that has Testaro as a dependency can execute the same statements, except changing `'./run'` to `'testaro/run'`.
521
-
522
- 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.
523
-
524
- #### High-level
525
-
526
- Make sure that you have defined these environment variables, with absolute or relative paths to directories as their values:
527
- - `SCRIPTDIR`
528
- - `BATCHDIR`
529
- - `REPORTDIR`
530
-
531
- Relative paths must be relative to the Testaro project directory. For example, if the script directory is `scripts` in a `testing` directory that is a sibling of the Testaro directory, then a relative-path `SCRIPTDIR` must have the value `../testing/scripts`.
532
-
533
- Also ensure that Testaro can read all those directories and write to `REPORTDIR`.
534
-
535
- 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.
536
-
537
- 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.
538
-
539
- The `high` module will call the `runJob` function of the `create` module, which in turn will call the `handleRequest` function of the `run` module. The results will be saved in report files in the `REPORTDIR` directory.
540
-
541
- If there is no batch, the report file will be named with a unique timestamp, suffixed with a `.json` extension. If there is a batch, then the base of each report file’s name will be the same timestamp, suffixed with `-hostid`, where `hostid` is the value of the `id` property of the `host` object in the batch file. For example, if you execute `node create script01 wikis`, you might get these report files deposited into `REPORTDIR`:
542
- - `enp46j-wikipedia.json`
543
- - `enp45j-wiktionary.json`
544
- - `enp45j-wikidata.json`
545
-
546
- #### Watch
547
-
548
- In watch mode, Testaro periodically checks for a script to be run by it. When such a script exists, Testaro runs it, produces a report in JSON format, and disposes of the report as specified.
549
-
550
- Testaro checks periodically. The interval between checks, in seconds, is specified by an `INTERVAL` environment variable.
551
-
552
- After Testaro starts watching, its behavior depends on the environment variable `WATCH_FOREVER`. If its value is `true`, watching continues indefinitely. If its value is `false` or it has no value, watching stops after the first script is found and run.
553
-
554
- To make Testaro start watching, execute the statement `node watch`.
555
-
556
- There are two ways for Testaro to watch for jobs.
557
-
558
- ##### Directory watch
559
-
560
- With directory watch, Testaro checks whether the watch directory (`WATCHDIR`) in its host’s filesystem contains a script.
561
-
562
- When Testaro finds one or more scripts in the watch directory, Testaro runs the first script, writes the report into the report directory, and moves the script into the done directory (`DONEDIR`).
563
-
564
- Testaro suspends checking while it is running a script. Therefore, even though the currently running script file remains in thde watch directory, Testaro will not try to run it again.
565
-
566
- Since Testaro runs the first script (i.e. the script whose name is first in ASCII order), whoever populates the directory with script files has control over the order in which Testaro runs them. For example, to force a new script to be run before the already waiting scripts, one can give it a filename that comes before that of the first waiting job.
567
-
568
- In order to make directory watching possible, you must define these environment variables:
569
- - `WATCH_TYPE=dir`
570
- - `INTERVAL`
571
- - `WATCH_FOREVER` (`=true` or `=false`)
572
- - `REPORTDIR`
573
- - `JOBDIR`
574
- - `EXJOBDIR`
575
-
576
- ##### Network watch
577
-
578
- With network watch, Testaro asks a particular API whether it has any jobs for the current instance of Testaro, identified by an authorization code. If the response is a JSON representation of an object satisfying the same requirements as given above under “Directory watch”, Testaro runs the job and sends the report(s) to the API.
579
-
580
- Thus, if there are multiple jobs queued for the Testaro instance, the API is responsible for choosing one of them to send in response.
581
-
582
- When the API receives the reports, it can dispose of them as desired. Each report is a JSON representation of an object, which has these identification properties:
583
- - `jobID`
584
- - `timeStamp`
585
- - `id`
586
-
587
- The `jobID` property can be used for an association between each report and the job that it arose from. The `timeStamp` property can be used for an association of all the reports in a batched job. And the `id` property (which begins with the time stamp) is unique to each report.
588
-
589
- In order to make network watching possible, you must define these environment variables:
590
- - `WATCH_TYPE=net`
591
- - `INTERVAL`
592
- - `WATCH_FOREVER` (`=true` or `=false`)
593
- - `PROTOCOL` (`=http` or `=https`)
594
- - `JOB_URL` (not including the authorization code)
595
- - `REPORT_URL` (not including the authorization code)
596
-
597
- ### Environment variables
598
-
599
- As mentioned above, using the high-level method to run Testaro jobs requires `SCRIPTDIR`, `BATCHDIR`, and `REPORTDIR` environment variables.
600
-
601
- If a `tenon` test is included in the script, environment variables named `TENON_USER` and `TENON_PASSWORD` must exist, with your Tenon username and password, respectively, as their values. You can obtain those from [Tenon](https://tenon.io/documentation/overview).
602
-
603
- If a `wave` test is included in the script, an environment variable named `WAVE_KEY` must exist, with your WAVE API key as its value. You can get it from [WebAIM](https://wave.webaim.org/api/).
604
-
605
- The `text` command can interpolate the value of an environment variable into text that it enters on a page, as documented in the `commands.js` file.
606
-
607
- Before executing a Testaro script, you can optionally also set the environment variables `DEBUG` (to `'true'` or anything else) and/or `WAITS` (to a non-negative integer). The effects of these variables are described in the `index.js` file.
608
-
609
- You may store these environment variables in an untracked `.env` file if you wish, and Testaro will recognize them.
610
-
611
- ## Validation
612
-
613
- ### Validators
614
-
615
- Testaro and its custom tests can be validated with the _executors_ located in the `validation/executors` directory.
616
-
617
- The executors are:
618
-
619
- - `low`: validates low-level invocation
620
- - `high1`: validates high-level invocation of a script without a batch
621
- - `high2`: validates high-level invocation of a script with a batch
622
- - `watchDir`: validates directory watching
623
- - `watchNet`: validates network watching
624
- - `tests`: validates all the custom tests (not the test packages)
625
-
626
- To validate any single Testaro custom test `xyz`, enter the statement `npm run test1 xyz`.
627
-
628
- To validate all of the Testaro custom tests, enter the statement `npm test`.
629
-
630
- To execute any executor `xyz` other than `test` or `tests`, call it with the statement `node validation/executors/xyz`.
631
-
632
- The `tests` executor makes use of the scripts in the `validation/tests/scripts` directory, and they, in turn, run tests on HTML files in the `validation/tests/targets` directory.
633
-
634
- ## Contribution
635
-
636
- You can define additional Testaro commands and functionality. Contributions are welcome.
637
-
638
- Please report any issues, including feature requests, at the [repository](https://github.com/jrpool/testaro/issues).
639
-
640
- ## Accessibility principles
641
-
642
- The rationales motivating the Testaro-defined tests can be found in comments within the files of those tests, in the `tests` directory. Unavoidably, each test is opinionated. Testaro itself, however, can accommodate other tests representing different opinions. Testaro is intended to be neutral with respect to questions such as the criteria for accessibility, the severities of accessibility issues, whether accessibility is binary or graded, and the distinction between usability and accessibility.
643
-
644
- ## Testing challenges
645
-
646
- ### Abnormal termination
647
-
648
- On rare occasions a test throws an error that terminates the Node process and cannot be handled with a `try`-`catch` structure. It has been observed, for example, that the `ibm` test does this when run on the host at `https://zenythgroup.com/index` or `https://monsido.com`.
649
-
650
- If a single process performed all of the commands in a batch-based script, the process could perform tens of thousands of commands, and such an error could stop the process at any point.
651
-
652
- To handle this risk, Testaro processes batch-based jobs by forking a new process for each host. If such an error occurs, it crashes the child process, preventing a report for that host from being written. The parent process waits for the report to appear in the `REPORTDIR` directory until the time limit. When it fails to appear, the parent process continues to the next host.
653
-
654
- If you are using high-level invocation, your terminal will show the standard output of the parent process and, if there is a batch, the current child process, too. If you interrupt the process with `CTRL-c`, you will send a `SIGINT` signal to the parent process, which will handle it by sending a message to the child process telling it to terminate itself, and then the parent process will terminate by skipping the remaining hosts.
655
-
656
- ### Activation
657
-
658
- Testing to determine what happens when a control or link is activated is straightforward, except in the context of a comprehensive set of tests of a single page. There, activating a control or link can change the page or navigate away from it, interfering with the remaining planned tests of the page.
659
-
660
- The Playwright “Receives Events” actionability check does **not** check whether an event is dispatched on an element. It checks only whether a click on the location of the element makes the element the target of that click, rather than some other element occupying the same location.
661
-
662
- ### Test-package duplication
663
-
664
- Test packages sometimes do redundant testing, in that two or more packages test for the same issues, although such duplications are not necessarily perfect. This fact creates three problems:
665
- - One cannot be confident in excluding some tests of some packages on the assumption that they perfectly duplicate tests of other packages.
666
- - The Testaro report from a script documents each package’s results separately, so a single difect may be documented in multiple locations within the report, making the consumption of the report inefficient.
667
- - An effort to aggregate the results into a single score may distort the scores by inflating the weights of defects that happen to be discovered by multiple packages.
668
-
669
- The tests provided with Testaro do not exclude any apparently duplicative tests from packages.
670
-
671
- To deal with the above problems, you can:
672
- - revise package `test` commands to exclude tests that you consider duplicative
673
- - create derivative reports that organize results by defect types rather than by package
674
- - take duplication into account when defining scoring rules
675
-
676
- Some measures of these kinds are included in the scoring and reporting features of the Testilo package.
677
-
678
- ## Repository exclusions
679
-
680
- The files in the `temp` directory are presumed ephemeral and are not tracked by `git`.
681
-
682
- ## Related packages
683
-
684
- [Testilo](https://www.npmjs.com/package/testilo) is an application that:
685
- - produces scores and adds them to the JSON report files of Testaro
686
- - produces human-oriented HTML digests from scored reports
687
- - produces human-oriented HTML reports comparing the scores of hosts
688
-
689
- Testaro is derived from [Autotest](https://github.com/jrpool/autotest).
690
-
691
- Testaro omits some functionalities of Autotest, such as:
692
- - tests producing results intended to be human-inspected
693
- - scoring (performed now by Testilo)
694
- - file operations for score aggregation, report revision, and HTML reports
695
- - a web user interface
696
-
697
- ## Code style
698
-
699
- The JavaScript code in this project generally conforms to the ESLint configuration file `.eslintrc`. However, the `htmlcs/HTMLCS.js` file implements an older version of JavaScript. Its style is regulated by the `htmlcs/.eslintrc.json` file.
700
-
701
- ## Origin
702
-
703
- Work on the custom tests in this package began in 2017, and work on the multi-package federation that Testaro implements began in early 2018. These two aspects were combined into the [Autotest](https://github.com/jrpool/autotest) package in early 2021 and into the more single-purpose packages, Testaro and Testilo, in January 2022.
704
-
705
- ## Etymology
706
-
707
- “Testaro” means “collection of tests” in Esperanto.