testaro 4.1.0 → 4.1.1

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
@@ -454,25 +454,23 @@ You may store these environment variables in an untracked `.env` file if you wis
454
454
 
455
455
  ### Samples
456
456
 
457
- The `samples` directory contains scripts and a batch that you can use to test Testaro with with the high-level, by giving `SCRIPTDIR` the value `'samples/scripts'` and `BATCHDIR` the value `'samples/batches'`. Do to this, you must also define `REPORTDIR`.
457
+ The `samples` directory contains scripts and a batch that you can use to test Testaro with with the high-level method, by giving `SCRIPTDIR` the value `'samples/scripts'` and `BATCHDIR` the value `'samples/batches'`. Do to this, you must also define `REPORTDIR`. Then execute `node job simple` or `node job simple weborgs` to run the `simple` script alone or with the `weborgs` batch.
458
458
 
459
459
  ### Validators
460
460
 
461
- _Executors_ for Testaro validation are located in the `validation` directory.
461
+ Testaro can be validated with the _executors_ located in the `validation/executors` directory. Executors are modules that run Testaro with the low-level method and write the results to the standard output.
462
462
 
463
- A basic executor is the `test.js` file. It uses the low-level method to run Testaro with the `simple.js` sample script and outputs the log and the acts to the standard output.
463
+ The executors are:
464
464
 
465
- The other executors are commonJS JavaScript modules that run Testaro and report whether the results are correct.
466
-
467
- The other executors are:
468
- - `app.js`: Reports whether Testaro runs correctly with a script.
469
- - `tests.js`: Runs Testaro with each custom test and reports whether the results are correct.
465
+ - `app`: reports whether Testaro runs correctly with a script
466
+ - `test`: runs the `simple` sample script
467
+ - `tests`: makes Testaro perform each custom test and reports whether the results are correct
470
468
 
471
469
  There are no executors for validating the test packages.
472
470
 
473
- To execute any executor `xyz.js`, call it with the statement `node validation/executors/xyz`. The results will appear in the standard output.
471
+ To execute any executor `xyz`, call it with the statement `node validation/executors/xyz`.
474
472
 
475
- The `tests.js` 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.
473
+ 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.
476
474
 
477
475
  ## Contribution
478
476
 
package/job.js CHANGED
@@ -9,7 +9,7 @@
9
9
  require('dotenv').config();
10
10
  // Module to read and write files.
11
11
  const fs = require('fs/promises');
12
- const { handleRequest } = require('./run');
12
+ const {handleRequest} = require('./run');
13
13
 
14
14
  // ########## CONSTANTS
15
15
  const scriptDir = process.env.SCRIPTDIR;
@@ -45,12 +45,12 @@ const runHost = async (id, script) => {
45
45
  script,
46
46
  acts: []
47
47
  };
48
- await require('./run').handleRequest(report);
48
+ await handleRequest(report);
49
49
  const reportJSON = JSON.stringify(report, null, 2);
50
50
  await fs.writeFile(`${reportDir}/${id}.json`, reportJSON);
51
51
  };
52
52
  // Runs a job.
53
- exports.handleRequest = async (scriptID, batchID) => {
53
+ exports.job = async (scriptID, batchID) => {
54
54
  if (scriptID) {
55
55
  try {
56
56
  const scriptJSON = await fs.readFile(`${scriptDir}/${scriptID}.json`, 'utf8');
@@ -89,4 +89,4 @@ exports.handleRequest = async (scriptID, batchID) => {
89
89
 
90
90
  // ########## OPERATION
91
91
 
92
- handleRequest(process.argv[2], process.argv[3]);
92
+ exports.job(process.argv[2], process.argv[3]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/run.js CHANGED
@@ -7,7 +7,6 @@
7
7
  require('dotenv').config();
8
8
  // Requirements for commands.
9
9
  const {commands} = require('./commands');
10
- const { handleRequest } = require('./job');
11
10
  // ########## CONSTANTS
12
11
  // Set DEBUG environment variable to 'true' to add debugging features.
13
12
  const debug = process.env.TESTARO_DEBUG === 'true';
@@ -1256,7 +1255,3 @@ exports.handleRequest = async report => {
1256
1255
  console.log('ERROR: options missing or invalid');
1257
1256
  }
1258
1257
  };
1259
-
1260
- // ########## OPERATION
1261
-
1262
- handleRequest(process.argv[2]);
@@ -3,6 +3,7 @@
3
3
 
4
4
  const report = {
5
5
  script: {
6
+ id: 'script0',
6
7
  what: 'Sample Testaro executor with 1 test',
7
8
  strict: true,
8
9
  commands: [
@@ -31,7 +32,7 @@ const report = {
31
32
  log: [],
32
33
  acts: []
33
34
  };
34
- const {handleRequest} = require(`${__dirname}/../../index`);
35
+ const {handleRequest} = require(`${__dirname}/../../run`);
35
36
  handleRequest(report)
36
37
  .then(
37
38
  () => {
@@ -2,7 +2,7 @@
2
2
  // Test executor for tenon sample script.
3
3
 
4
4
  const fs = require('fs');
5
- const {handleRequest} = require('../../index');
5
+ const {handleRequest} = require('../../run');
6
6
  const scriptJSON = fs.readFileSync('samples/scripts/tenon.json', 'utf8');
7
7
  const script = JSON.parse(scriptJSON);
8
8
  const report = {
@@ -2,8 +2,8 @@
2
2
  // Test executor.
3
3
 
4
4
  const fs = require('fs');
5
- const {handleRequest} = require('../../index');
6
- const scriptJSON = fs.readFileSync('samples/scripts/simple.json', 'utf8');
5
+ const {handleRequest} = require(`${__dirname}/../../run`);
6
+ const scriptJSON = fs.readFileSync(`${__dirname}/../../samples/scripts/simple.json`, 'utf8');
7
7
  const script = JSON.parse(scriptJSON);
8
8
  const report = {
9
9
  id: '',
@@ -11,8 +11,38 @@ const report = {
11
11
  log: [],
12
12
  acts: []
13
13
  };
14
- (async () => {
15
- await handleRequest(report);
16
- console.log(`Report log:\n${JSON.stringify(report.log, null, 2)}\n`);
17
- console.log(`Report acts:\n${JSON.stringify(report.acts, null, 2)}`);
18
- })();
14
+ handleRequest(report)
15
+ .then(
16
+ () => {
17
+ const {log, acts} = report;
18
+ if (
19
+ log.length === 2
20
+ && log[1].event === 'endTime'
21
+ && /^\d{4}-.+$/.test(log[0].value)
22
+ && log[1].value >= log[0].value
23
+ ) {
24
+ console.log('Success: Log has been correctly populated');
25
+ }
26
+ else {
27
+ console.log('Failure: Log empty or invalid');
28
+ console.log(JSON.stringify(log, null, 2));
29
+ }
30
+ if (
31
+ acts.length === 3
32
+ && acts[0]
33
+ && acts[0].type === 'launch'
34
+ && acts[2].result
35
+ && acts[2].result.visibleElements
36
+ && typeof acts[2].result.visibleElements === 'number'
37
+ ) {
38
+ console.log('Success: Acts have been correctly populated');
39
+ }
40
+ else {
41
+ console.log('Failure: Acts empty or invalid');
42
+ console.log(JSON.stringify(acts, null, 2));
43
+ }
44
+ },
45
+ rejection => {
46
+ console.log(`Failure: ${rejection}`);
47
+ }
48
+ );
@@ -2,7 +2,7 @@
2
2
  // Validator for Testaro tests.
3
3
 
4
4
  const fs = require('fs').promises;
5
- const {handleRequest} = require(`${__dirname}/../../index`);
5
+ const {handleRequest} = require(`${__dirname}/../../run`);
6
6
  const validateTests = async () => {
7
7
  const totals = {
8
8
  attempts: 0,