testaro 8.1.6 → 8.1.7

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/commands.js CHANGED
@@ -138,7 +138,7 @@ exports.commands = {
138
138
  url: [
139
139
  'Navigate to a new URL',
140
140
  {
141
- which: [true, 'string', 'isURL', 'URL'],
141
+ which: [true, 'string', 'isURL', 'URL (if file://, path relative to main project directory'],
142
142
  what: [false, 'string', 'hasLength', 'comment'],
143
143
  id: [false, 'string', 'hasLength', 'ID of the host']
144
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "8.1.6",
3
+ "version": "8.1.7",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/run.js CHANGED
@@ -236,31 +236,40 @@ const isValidCommand = command => {
236
236
  // Validates a report object.
237
237
  const isValidReport = report => {
238
238
  if (report) {
239
- // Return whether the job is valid.
239
+ // Return whether the report is valid.
240
240
  const {job, acts, jobData} = report;
241
241
  const {id, what, strict, commands, sources, jobCreationTime, timeStamp} = job;
242
- const isValid = job
243
- && acts
244
- && jobData
245
- && id
246
- && what
247
- && typeof strict === 'boolean'
248
- && commands
249
- && sources
250
- && jobCreationTime
251
- && timeStamp
252
- && Array.isArray(acts)
253
- && typeof id === 'string'
254
- && typeof what === 'string'
255
- && Array.isArray(commands)
256
- && commands[0].type === 'launch'
257
- && commands.length > 1
258
- && commands[1].type === 'url'
259
- && isURL(commands[1].which)
260
- && commands.every(command => isValidCommand(command))
261
- && sources.script
262
- && sources.host;
263
- return isValid;
242
+ const criteria = [
243
+ [job, 'report has job property'],
244
+ [acts, 'report has acts property'],
245
+ [jobData, 'report has jobData property'],
246
+ [id, 'job has id property'],
247
+ [what, 'job has what property'],
248
+ [typeof strict === 'boolean', 'job has true or false strict property'],
249
+ [commands, 'job has commands property'],
250
+ [sources, 'job has sources property'],
251
+ [jobCreationTime, 'job has jobCreationTime property'],
252
+ [timeStamp, 'job has timeStamp property'],
253
+ [Array.isArray(acts), 'acts has array value'],
254
+ [typeof id === 'string', 'id has string value'],
255
+ [typeof what === 'string', 'what has string value'],
256
+ [Array.isArray(commands), 'commands has array value'],
257
+ [commands[0].type, 'first command has type property'],
258
+ [commands[0].type === 'launch', 'first command has launch type'],
259
+ [commands.length > 1, 'command count greater than 1'],
260
+ [commands[1].type, 'second command has type property'],
261
+ [commands[1].type === 'url', 'second command has url type'],
262
+ [commands[1].which, 'second command has which property'],
263
+ [isURL(commands[1].which), 'second command which property has URL value'],
264
+ [commands.every(command => isValidCommand(command)), 'every command is valid'],
265
+ [typeof sources.script === 'string', 'sources has script property with string value'],
266
+ [sources.host, 'sources has host property']
267
+ ];
268
+ const invalidityIndex = criteria.findIndex(criterion => ! criterion[0]);
269
+ if (invalidityIndex > -1) {
270
+ console.log(`ERROR: report fails “${criteria[invalidityIndex][1]}” requirement`);
271
+ }
272
+ return invalidityIndex === -1;
264
273
  }
265
274
  else {
266
275
  return false;
@@ -6,10 +6,8 @@ const {doJob} = require(`${__dirname}/../run`);
6
6
  exports.validateTest = async testID => {
7
7
  const jobFileNames = await fs.readdir(`${__dirname}/tests/jobs`);
8
8
  for (const jobFileName of jobFileNames.filter(fileName => fileName === `${testID}.json`)) {
9
- const rawJobJSON = await fs
10
- .readFile(`${__dirname}/tests/jobs/${jobFileName}`, 'utf8');
11
- const jobJSON = rawJobJSON
12
- .replace(/__targets__/g, `file://${__dirname}/../tests/targets`);
9
+ const rawJobJSON = await fs.readFile(`${__dirname}/tests/jobs/${jobFileName}`, 'utf8');
10
+ const jobJSON = rawJobJSON.replace(/__targets__/g, 'file://validation/tests/targets');
13
11
  const job = JSON.parse(jobJSON);
14
12
  const report = {
15
13
  job,