testaro 32.0.0 → 32.0.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/package.json +1 -1
- package/run.js +3 -1
- package/validation/validateTest.js +13 -1
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -325,7 +325,7 @@ const goTo = async (report, page, url, timeout, waitUntil) => {
|
|
|
325
325
|
// If the URL is a file path:
|
|
326
326
|
if (url.startsWith('file://')) {
|
|
327
327
|
// Make it absolute.
|
|
328
|
-
url = url.replace('file://', `file://${__dirname
|
|
328
|
+
url = url.replace('file://', `file://${__dirname}/`);
|
|
329
329
|
}
|
|
330
330
|
// Visit the URL.
|
|
331
331
|
const startTime = Date.now();
|
|
@@ -725,6 +725,7 @@ const addError = async(alsoLog, alsoAbort, report, actIndex, message) => {
|
|
|
725
725
|
};
|
|
726
726
|
// Recursively performs the acts in a report.
|
|
727
727
|
const doActs = async (report, actIndex, page) => {
|
|
728
|
+
// FUNCTION DEFINITION START
|
|
728
729
|
// Quits and reports the job being aborted.
|
|
729
730
|
const abortActs = async () => {
|
|
730
731
|
// Add data on the aborted act to the report.
|
|
@@ -736,6 +737,7 @@ const doActs = async (report, actIndex, page) => {
|
|
|
736
737
|
// Report this.
|
|
737
738
|
console.log('ERROR: Job aborted');
|
|
738
739
|
};
|
|
740
|
+
// FUNCTION DEFINITION END
|
|
739
741
|
const {acts} = report;
|
|
740
742
|
// If any more acts are to be performed:
|
|
741
743
|
if (actIndex > -1 && actIndex < acts.length) {
|
|
@@ -36,11 +36,14 @@ const {doJob} = require('../run');
|
|
|
36
36
|
|
|
37
37
|
// Validates a test.
|
|
38
38
|
exports.validateTest = async testID => {
|
|
39
|
+
// Get the job that validates the test.
|
|
39
40
|
const jobFileNames = await fs.readdir(`${__dirname}/tests/jobs`);
|
|
40
41
|
for (const jobFileName of jobFileNames.filter(fileName => fileName === `${testID}.json`)) {
|
|
41
42
|
const jobJSON = await fs.readFile(`${__dirname}/tests/jobs/${jobFileName}`, 'utf8');
|
|
42
43
|
const report = JSON.parse(jobJSON);
|
|
44
|
+
// Perform it.
|
|
43
45
|
await doJob(report);
|
|
46
|
+
// Report whether the end time was reported.
|
|
44
47
|
const {acts, jobData} = report;
|
|
45
48
|
if (jobData.endTime && /^\d{4}-.+$/.test(jobData.endTime)) {
|
|
46
49
|
console.log('Success: End time has been correctly populated');
|
|
@@ -48,19 +51,28 @@ exports.validateTest = async testID => {
|
|
|
48
51
|
else {
|
|
49
52
|
console.log('Failure: End time empty or invalid');
|
|
50
53
|
}
|
|
54
|
+
// If the test acts were correctly reported:
|
|
51
55
|
const testActs = acts.filter(act => act.type && act.type === 'test');
|
|
52
56
|
if (
|
|
53
57
|
testActs.length === report.acts.filter(act => act.type === 'test').length
|
|
54
|
-
&& testActs.every(
|
|
58
|
+
&& testActs.every(
|
|
59
|
+
testAct => testAct.standardResult && testAct.expectationFailures !== undefined
|
|
60
|
+
)
|
|
55
61
|
) {
|
|
62
|
+
// Report this.
|
|
56
63
|
console.log('Success: Reports have been correctly populated');
|
|
64
|
+
// If all expectations were satisfied:
|
|
57
65
|
if (testActs.every(testAct => testAct.expectationFailures === 0)) {
|
|
66
|
+
// Report this.
|
|
58
67
|
console.log('######## Success: No failures\n');
|
|
59
68
|
}
|
|
69
|
+
// Otherwise, i.e. if not all expectations were satisfied:
|
|
60
70
|
else {
|
|
71
|
+
// Report this.
|
|
61
72
|
console.log(
|
|
62
73
|
'######## Failure: The test has at least one failure (see “"passed": false” below)\n'
|
|
63
74
|
);
|
|
75
|
+
// Output the acts that had failures.
|
|
64
76
|
console.log(
|
|
65
77
|
JSON.stringify(
|
|
66
78
|
acts.filter(act => act.type === 'test' && act.expectationFailures), null, 2
|