testaro 2.3.11 → 4.0.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.
package/README.md CHANGED
@@ -10,14 +10,10 @@ The purpose of Testaro is to provide programmatic access to over 600 accessibili
10
10
 
11
11
  Running Testaro requires telling it which operations (including tests) to perform and which URLs to perform them on, and giving Testaro an object to put its output into.
12
12
 
13
- Testaro outputs progress messages to the standard output. It populates the object with log information and test reports.
14
-
15
13
  ## System requirements
16
14
 
17
15
  Version 14 or later of [Node.js](https://nodejs.org/en/).
18
16
 
19
- A file system with a directory that the Testaro user has permission to read and write in.
20
-
21
17
  ## Dependencies
22
18
 
23
19
  Testaro uses:
@@ -29,6 +25,7 @@ Testaro includes some of its own accessibility tests. In addition, it performs t
29
25
  - [alfa](https://alfa.siteimprove.com/) (Siteimprove alfa)
30
26
  - [Automated Accessibility Testing Tool](https://www.npmjs.com/package/aatt) (Paypal AATT, running HTML CodeSniffer)
31
27
  - [axe-playwright](https://www.npmjs.com/package/axe-playwright) (Deque Axe-core)
28
+ - [Tenon](https://tenon.io/documentation/what-tenon-tests.php)
32
29
  - [WAVE API](https://wave.webaim.org/api/) (WebAIM WAVE)
33
30
 
34
31
  As of this version, the counts of tests in the packages referenced above were:
@@ -36,10 +33,11 @@ As of this version, the counts of tests in the packages referenced above were:
36
33
  - Alfa: 103
37
34
  - Axe-core: 138
38
35
  - Equal Access: 163
36
+ - Tenon: 433
39
37
  - WAVE: 110
40
38
  - subtotal: 612
41
39
  - Testaro tests: 16
42
- - grand total: 628
40
+ - grand total: 1061
43
41
 
44
42
  ## Code organization
45
43
 
@@ -100,25 +98,25 @@ A script is a JSON file with the properties:
100
98
 
101
99
  Here is an example of a script:
102
100
 
103
- ```json
101
+ ```javascript
104
102
  {
105
- "what": "Test example.com with alfa",
106
- "strict": true,
107
- "commands": [
103
+ what: 'Test example.com with alfa',
104
+ strict: true,
105
+ commands: [
108
106
  {
109
- "type": "launch",
110
- "which": "chromium",
111
- "what": "Chromium browser"
107
+ type: 'launch',
108
+ which: 'chromium',
109
+ what: 'Chromium browser'
112
110
  },
113
111
  {
114
- "type": "url",
115
- "which": "https://example.com/",
116
- "what": "page with a few accessibility defects"
112
+ type: 'url',
113
+ which: 'https://example.com/',
114
+ what: 'page with a few accessibility defects'
117
115
  },
118
116
  {
119
- "type": "test",
120
- "which": "alfa",
121
- "what": "Siteimprove alfa package"
117
+ type: 'test',
118
+ which: 'alfa',
119
+ what: 'Siteimprove alfa package'
122
120
  }
123
121
  ]
124
122
  }
@@ -256,6 +254,24 @@ An example of a **Testaro-defined** test is:
256
254
 
257
255
  In this case, Testaro runs the `motion` test with the specified parameters.
258
256
 
257
+ ###### Tenon
258
+
259
+ The `tenon` test requires two commands:
260
+ - A command of type `tenonRequest`.
261
+ - A command of type `test` with `tenon` as the value of `which`.
262
+
263
+ 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.)
264
+
265
+ Tenon says that tests are typically completed in 3 to 6 seconds but that the latency can be longer, depending on demand.
266
+
267
+ Therefore, you can include a `tenonRequest` command early in your script, and a `tenon` test 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.
268
+
269
+ 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.
270
+
271
+ In case you want to perform more than one `tenon` test, you can do so. Just give each pair of commands a distinct `id` property, so each `tenon` test command will request the correct result.
272
+
273
+ 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.
274
+
259
275
  ##### Scoring
260
276
 
261
277
  An example of a **scoring** command is:
@@ -383,70 +399,55 @@ A typical use for an `expect` property is checking the correctness of a Testaro
383
399
 
384
400
  ## Batches
385
401
 
386
- There are two ways to use a script to give instructions to Testaro:
387
- - The script can be the complete specification of the operations to perform and the URLs to perform them on.
388
- - The script can specify the operations to perform, and a _batch_ can specify which URLs to perform them on.
389
-
390
- A batch is a JSON file with this format:
391
-
392
- ```json
393
- {
394
- "what": "Accessibility standards",
395
- "hosts": [
396
- {
397
- "which": "https://www.w3.org/TR/WCAG21/",
398
- "what": "WCAG 2.1"
399
- },
400
- {
401
- "which": "https://www.w3.org/WAI/standards-guidelines/aria/",
402
- "what": "W3C WAI-ARIA"
403
- }
404
- ]
405
- }
406
- ```
407
-
408
- When you combine a script with a batch, Testaro performs the script, replacing the `which` and `what` properties of all `url` commands with the values in the first object in the `hosts` array of the batch, then again with the values in the second `host` object, and so on. Those replacements also occur in the inserted extra `url` commands mentioned above.
402
+ In some cases you may wish to repeatedly run Testaro with the same script, changing only its `url` commands. The purpose would be to perform the same set of tests on multiple web pages. Such a use would apply only to scripts whose `url` commands are all identical, not to a script that moves from one host to another.
409
403
 
410
- A batch offers an efficient way to perform a uniform set of operations on every host in a set of hosts. In this way you can run the same set of tests on multiple web pages.
411
-
412
- A no-batch script offers a way to carry out a complex operation, which can include navigating from one host to another, which is not possible with a batch. Any `url` commands are performed as-is, without changes to their URLs.
404
+ Testaro does not support such batch processing, but Testilo does. See its `README.md` file for instructions.
413
405
 
414
406
  ## Execution
415
407
 
416
408
  ### Invocation
417
409
 
418
- To run Testaro, create an options object like this:
410
+ To run Testaro, create a report object like this:
419
411
 
420
412
  ```javascript
421
- {
413
+ const report = {
414
+ id: '',
415
+ script: {…},
422
416
  log: [],
423
- reports: [],
424
- script: {abc},
425
- batch: {def}
426
- }
417
+ acts: []
418
+ };
427
419
  ```
428
420
 
429
- Replace `{abc}` with a script object, like the example script shown above.
421
+ Replace `{}` with a script object, like the example script shown above.
430
422
 
431
- Replace `{def}` with a batch object, like the example batch shown above, or omit the `batch` property if there is no batch.
423
+ Then execute the statement `require('testaro').handleRequest(report)`. That statement will run Testaro.
432
424
 
433
- Then execute the statement `require('testaro').handleRequest(ghi)`, where `ghi` is replaced with the name of the options object. That statement will run Testaro.
425
+ While it runs, Testaro will populate the `log` and `acts` arrays of the report object. When Testaro finishes, the `log` and `acts` properties will contain its results.
434
426
 
435
- While it runs, Testaro will populate the `log` and `reports` arrays of the options object. When Testaro finishes, the `log` and `reports` arrays will contain its results.
427
+ Another way to run Testaro is to use Testilo, which can handle batches and saves results to files. Testilo prepopulates the report object with an `id` property consisting of a timestamp and, if a batch is used, the host ID. If Testaro finds a non-empty `id` property in the `report` object, Testaro leaves it unchanged; if not, Testaro creates an `id` property with a timestamp value.
436
428
 
437
429
  ### Environment variables
438
430
 
439
431
  If a `wave` test is included in the script, an environment variable named `TESTARO_WAVE_KEY` must exist, with your WAVE API key as its value.
440
432
 
433
+ If a `tenon` test is included in the script, environment variables named `TESTARO_TENON_USER` and `TESTARO_TENON_PASSWORD` must exist, with your Tenon username and password, respectively, as their values.
434
+
435
+ 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.
436
+
441
437
  Before executing a Testaro script, you can optionally also set the environment variables `TESTARO_DEBUG` (to `'true'` or anything else) and/or `TESTARO_WAITS` (to a non-negative integer). The effects of these variables are described in the `index.js` file.
442
438
 
439
+ You may store these environment variables in an untracked `.env` file if you wish, and Testaro will recognize them.
440
+
443
441
  ## Validation
444
442
 
445
- Three _executors_ for Testaro validation are located in the `validation` directory. An executor is a commonJS JavaScript module that runs Testaro and reports whether the results are correct.
443
+ _Executors_ for Testaro validation are located in the `validation` directory.
446
444
 
447
- The executors are:
448
- - `appNoBatch.js`: Reports whether Testaro runs correctly with a no-batch script.
449
- - `appBatch.js`: Reports whether Testaro runs correctly with a script and a batch.
445
+ A basic executor is the `test.js` file. It runs Testaro with a simple sample script and outputs the log and the acts.
446
+
447
+ The other executors are commonJS JavaScript modules that run Testaro and report whether the results are correct.
448
+
449
+ The other executors are:
450
+ - `app.js`: Reports whether Testaro runs correctly with a script.
450
451
  - `tests.js`: Runs Testaro with each custom test and reports whether the results are correct.
451
452
 
452
453
  To execute any executor `xyz.js`, call it with the statement `node validation/executors/xyz`. The results will appear in the standard output.
@@ -461,18 +462,6 @@ You can define additional Testaro commands and functionality. Contributions are
461
462
 
462
463
  The rationales motivating the Testaro-defined tests and scoring procs can be found in comments within the files of those tests and procs, in the `tests` and `procs/score` directories. 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.
463
464
 
464
- ### Future work
465
-
466
- Further development is contemplated, is taking place, or is welcomed, on:
467
- - addition of Tenon to the set of packages
468
- - links with href="#"
469
- - links and buttons styled non-distinguishably
470
- - first focused element not first focusable element in DOM
471
- - never-visible skip links
472
- - buttons with no text content
473
- - modal dialogs
474
- - autocomplete attributes
475
-
476
465
  ## Testing challenges
477
466
 
478
467
  ### Activation
@@ -489,9 +478,11 @@ Test packages sometimes do redundant testing, in that two or more packages test
489
478
 
490
479
  The files in the `temp` directory are presumed ephemeral and are not tracked by `git`. When tests require temporary files to be written, Testaro writes them there.
491
480
 
492
- ## Origin
481
+ ## Related packages
482
+
483
+ [Testilo](https://www.npmjs.com/package/testilo) is an application that facilitates the use of Testaro.
493
484
 
494
- Testaro is derived from [Autotest](https://github.com/jrpool/autotest), which in turn is derived from accessibility test investigations beginning in 2018.
485
+ Testaro is derived from [Autotest](https://github.com/jrpool/autotest).
495
486
 
496
487
  Testaro omits some functionalities of Autotest, such as:
497
488
  - tests producing results intended to be human-inspected
@@ -499,6 +490,44 @@ Testaro omits some functionalities of Autotest, such as:
499
490
  - file operations for score aggregation, report revision, and HTML reports
500
491
  - a web user interface
501
492
 
493
+ ## Origin
494
+
495
+ 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 this more single-purpose package, Testaro, in January 2022.
496
+
502
497
  ## Etymology
503
498
 
504
499
  “Testaro” means “collection of tests” in Esperanto.
500
+
501
+ ## Future work
502
+
503
+ ### Improvements
504
+
505
+ Further development is contemplated, is taking place, or is welcomed, on:
506
+ - addition of Tenon to the set of packages
507
+ - links with href="#"
508
+ - links and buttons styled non-distinguishably
509
+ - first focused element not first focusable element in DOM
510
+ - never-visible skip links
511
+ - buttons with no text content
512
+ - modal dialogs
513
+ - autocomplete attributes
514
+ - inclusion of other test packages, such as:
515
+ - FAE (https://github.com/opena11y/evaluation-library)
516
+ - Tenon
517
+
518
+ ## Corrections
519
+
520
+ Issues found or reported with the current version that need diagnosis and correction include:
521
+
522
+ ### hover
523
+
524
+ There seem to be a couple of problems with the hover test:
525
+ - The score for unhoverability is documented as 2 times the count of unhoverables, but is reported as 1 time that count.
526
+ - The list of unhoverables in the report is empty.
527
+ Observed after inquiry by Tobias Christian Jensen of Siteimprove on 2022-05-09.
528
+
529
+ ### axe
530
+
531
+ Configuration to include best practices and experimental tests.
532
+
533
+ Investigation of tags, including wcag2a, wcag2aa, wcag21a, wcag21aa, best-practice, wcag***, ACT, cat.*.
package/commands.js CHANGED
@@ -118,6 +118,14 @@ exports.commands = {
118
118
  what: [false, 'string', 'hasLength', 'comment']
119
119
  }
120
120
  ],
121
+ tenonRequest: [
122
+ 'Request a Tenon test',
123
+ {
124
+ id: [true, 'string', 'hasLength', 'ID for this test instance'],
125
+ withNewContent: [true, 'boolean', '', 'true: use a URL; false: use page content'],
126
+ what: [false, 'string', 'hasLength', 'comment']
127
+ }
128
+ ],
121
129
  text: [
122
130
  'Enter text into a text input, optionally with 1 placeholder for an all-caps literal environment variable',
123
131
  {
@@ -185,7 +193,7 @@ exports.commands = {
185
193
  {
186
194
  withItems: [true, 'boolean'],
187
195
  withNewContent: [
188
- false, 'boolean', '', 'true: use a URL; false: use page content; omitted: use both'
196
+ false, 'boolean', '', 'true: use a URL; false: use page content; omitted: both'
189
197
  ]
190
198
  }
191
199
  ],
@@ -233,6 +241,12 @@ exports.commands = {
233
241
  withItems: [true, 'boolean']
234
242
  }
235
243
  ],
244
+ tenon: [
245
+ 'Perform a Tenon test',
246
+ {
247
+ id: [true, 'string', 'hasLength', 'ID of the requested test instance']
248
+ }
249
+ ],
236
250
  wave: [
237
251
  'Perform a WebAIM WAVE test',
238
252
  {