testaro 8.1.10 → 8.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "8.1.10",
3
+ "version": "8.1.11",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,7 +23,7 @@ runJob(jobID)
23
23
  async () => {
24
24
  try {
25
25
  // Check it against expectations.
26
- const reportJSON = await fs.readFile(`${reportDir}/${jobID}.json`);
26
+ const reportJSON = await fs.readFile(`${reportDir}/${jobID}.json`, 'utf8');
27
27
  const report = JSON.parse(reportJSON);
28
28
  const {job, acts, jobData} = report;
29
29
  if (! job) {
@@ -1,31 +1,53 @@
1
1
  // low.js
2
2
  // Validator for low-level invocation of Testaro.
3
3
 
4
+ // ########## IMPORTS
5
+
4
6
  const fs = require('fs/promises');
5
- const getSampleScript = async scriptID => {
6
- const scriptJSON = await fs.readFile(`${__dirname}/../../samples/scripts/${scriptID}.json`);
7
- return JSON.parse(scriptJSON);
8
- };
9
- const validate = async () => {
10
- const script = await getSampleScript('simple');
7
+
8
+ // ########## CONSTANTS
9
+
10
+ const projectRoot = `${__dirname}/../..`;
11
+ const {doJob} = require(`${projectRoot}/run`);
12
+ process.env.JOBDIR = `${projectRoot}/validation/jobs`;
13
+ process.env.REPORTDIR = `${projectRoot}/temp`;
14
+ const jobID = '00000-simple-example';
15
+
16
+ // ########## OPERATION
17
+
18
+ // Get the simple job.
19
+ fs.readFile(`${process.env.JOBDIR}/${jobID}.json`)
20
+ .then(async jobJSON => {
21
+ const job = JSON.parse(jobJSON);
11
22
  const report = {
12
- script,
13
- log: [],
14
- acts: []
23
+ job,
24
+ acts: [],
25
+ jobData: {}
15
26
  };
16
- const {doJob} = require('../../run');
27
+ // Run it.
17
28
  await doJob(report);
18
- const {log, acts} = report;
19
- if (log.length !== 2) {
20
- console.log(`Failure: log length is ${log.length} instead of 2`);
21
- console.log(JSON.stringify(log, null, 2));
22
- }
23
- else if (acts.length !== 3) {
24
- console.log(`Failure: acts length is ${acts.length} instead of 3`);
25
- console.log(JSON.stringify(acts, null, 2));
29
+ try {
30
+ // Check the report against expectations.
31
+ const reportJSON = await fs.readFile(`${process.env.REPORTDIR}/${jobID}.json`, 'utf8');
32
+ const report = JSON.parse(reportJSON);
33
+ const {job, acts, jobData} = report;
34
+ if (! job) {
35
+ console.log('Failure: Report omits job');
36
+ }
37
+ else if (acts.length !== 3) {
38
+ console.log('Failure: Counts of acts is not 3');
39
+ }
40
+ else if (! jobData) {
41
+ console.log('Failure: Report omits jobData');
42
+ }
43
+ else if (jobData.endTime < jobData.startTime) {
44
+ console.log('Failure: End time precedes start time');
45
+ }
46
+ else {
47
+ console.log(`Success (report is in temp/${jobID}.json)`);
48
+ }
26
49
  }
27
- else {
28
- console.log('Success');
50
+ catch(error) {
51
+ console.log(`ERROR: ${error.message}`);
29
52
  }
30
- };
31
- validate();
53
+ });