testaro 46.2.2 → 47.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
@@ -520,11 +520,11 @@ The `wax` tool imposes a limit on the size of a page to be tested. If the page e
520
520
 
521
521
  #### WAVE
522
522
 
523
- If a `wave` test act is included in the job, 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/).
523
+ If a `wave` test act is included in the job, the WAVE tests will be performed either by the subscription API or by the stand-alone API.
524
524
 
525
- The `wave` API does not accept a transmitted document for testing. WAVE must be given only a URL, which it then visits to perform its tests. Therefore, you cannot manipulate a page and then have WAVE test it, or ask WAVE to test a page that cannot be reached directly with a URL.
525
+ If you want the subscription API to perform the tests, you must get a WAVE API key from [WebAIM](https://wave.webaim.org/api/) and assign it as the value of an environment variable named `WAVE_KEY`. The subscription API does not accept a transmitted document for testing. WAVE must be given only a URL, which it then visits to perform its tests. Therefore, you cannot manipulate a page and then have WAVE test it, or ask WAVE to test a page that cannot be reached directly with a URL.
526
526
 
527
- This limitation of WAVE may be overcome in a future version of Testaro by means of the invocation of the WAVE Chrome extension with Playwright.
527
+ If you want the stand-alone API to perform the tests, you need to have that API installed and running, and the `wave` test act needs to define the URL of your stand-alone API. The test act can also define a `prescript` script and/or a `postscript` script.
528
528
 
529
529
  ### Browser types
530
530
 
package/actSpecs.js CHANGED
@@ -205,7 +205,10 @@ exports.actSpecs = {
205
205
  wave: [
206
206
  'Perform WAVE tests',
207
207
  {
208
- reportType: [true, 'number', '', 'WAVE report type (1, 2, 3, or 4)']
208
+ reportType: [true, 'number', '', 'WAVE report type (1, 2, 3, or 4)'],
209
+ url: [false, 'isURL', '', 'URL of stand-alone WAVE API'],
210
+ prescript: [false, 'string', '', 'content of pre-load script, if any'],
211
+ postscript: [false, 'string', '', 'content of post-load script, if any']
209
212
  }
210
213
  ]
211
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "46.2.2",
3
+ "version": "47.0.0",
4
4
  "description": "Run 1000 web accessibility tests from 10 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tests/wave.js CHANGED
@@ -23,8 +23,7 @@
23
23
  /*
24
24
  wave
25
25
  This test implements the WebAIM WAVE ruleset for accessibility. The 'reportType' argument
26
- specifies a WAVE report type: 1, 2, 3, or 4. The larger the number, the more detailed (and
27
- expensive) the report.
26
+ specifies a WAVE report type: 1, 2, 3, or 4.
28
27
  */
29
28
 
30
29
  // CONSTANTS
@@ -37,8 +36,29 @@ const https = require('https');
37
36
  // Conducts and reports the WAVE tests.
38
37
  exports.reporter = async (page, report, actIndex) => {
39
38
  const act = report.acts[actIndex];
40
- const {reportType, rules} = act;
39
+ const {reportType, url, prescript, postscript, rules} = act;
41
40
  const waveKey = process.env.WAVE_KEY;
41
+ const waveKeyParam = waveKey ? `key=${waveKey}` : '';
42
+ let host = 'wave.webaim.org';
43
+ let scheme = 'https';
44
+ if (url && url.startsWith('http')) {
45
+ if (url.startsWith('http://')) {
46
+ scheme = 'http';
47
+ }
48
+ host = url.replace(/^https?:\/\//, '');
49
+ }
50
+ let prescriptParam = prescript ? `prescript=${prescript}` : '';
51
+ let postscriptParam = postscript ? `postscript=${postscript}` : '';
52
+ const wavePath = '/api/request';
53
+ const queryParams = [
54
+ waveKeyParam,
55
+ `url=${page.url()}`,
56
+ `reporttype=${reportType}`,
57
+ prescriptParam,
58
+ postscriptParam
59
+ ];
60
+ const query = queryParams.filter(param => param).join('&');
61
+ const path = [wavePath, query].join('?');
42
62
  // Initialize the results.
43
63
  const data = {};
44
64
  let result = {};
@@ -47,8 +67,8 @@ exports.reporter = async (page, report, actIndex) => {
47
67
  // Get the test results.
48
68
  https.get(
49
69
  {
50
- host: 'wave.webaim.org',
51
- path: `/api/request?key=${waveKey}&url=${page.url()}&reporttype=${reportType}`
70
+ host,
71
+ path
52
72
  },
53
73
  response => {
54
74
  let rawReport = '';
@@ -113,7 +133,6 @@ exports.reporter = async (page, report, actIndex) => {
113
133
  }
114
134
  catch(error) {
115
135
  console.log(`ERROR parsing tool report: ${error.message}`);
116
- console.log(`rawReport: ${rawReport}`);
117
136
  data.prevented = true;
118
137
  data.error = error.message;
119
138
  resolve(result);