testaro 12.2.5 → 12.2.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/package.json +1 -1
- package/tests/ibm.js +33 -12
- package/watch.js +4 -3
package/package.json
CHANGED
package/tests/ibm.js
CHANGED
|
@@ -120,25 +120,46 @@ const doTest = async (content, withItems, timeLimit, rules) => {
|
|
|
120
120
|
};
|
|
121
121
|
// Returns results of one or two IBM tests.
|
|
122
122
|
exports.reporter = async (page, withItems, withNewContent, rules) => {
|
|
123
|
+
let contentType = 'both';
|
|
124
|
+
if (withNewContent) {
|
|
125
|
+
contentType = 'new';
|
|
126
|
+
}
|
|
127
|
+
else if (withNewContent === false) {
|
|
128
|
+
contentType = 'existing';
|
|
129
|
+
}
|
|
130
|
+
console.log(`>>>>>> Content type: ${contentType}`);
|
|
123
131
|
// If a test with existing content is to be performed:
|
|
124
132
|
const result = {};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
const timeLimit = 20;
|
|
134
|
+
if (['existing', 'both'].includes(contentType)) {
|
|
135
|
+
try {
|
|
136
|
+
console.log('>>>>>> With existing content');
|
|
137
|
+
const typeContent = await page.content();
|
|
138
|
+
result.content = await doTest(typeContent, withItems, timeLimit, rules);
|
|
139
|
+
if (result.content.prevented) {
|
|
140
|
+
result.prevented = true;
|
|
141
|
+
console.log(`ERROR: Getting ibm test report from page timed out at ${timeLimit} seconds`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch(error) {
|
|
130
145
|
result.prevented = true;
|
|
131
|
-
console.log(`ERROR:
|
|
146
|
+
console.log(`ERROR: ibm test on page crashed with error ${error.message.slice(0, 200)}`);
|
|
132
147
|
}
|
|
133
148
|
}
|
|
134
149
|
// If a test with new content is to be performed:
|
|
135
|
-
if ([
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
if (['new', 'both'].includes(contentType)) {
|
|
151
|
+
try {
|
|
152
|
+
console.log('>>>>>> With new content');
|
|
153
|
+
const typeContent = page.url();
|
|
154
|
+
result.url = await doTest(typeContent, withItems, timeLimit, rules);
|
|
155
|
+
if (result.url.prevented) {
|
|
156
|
+
result.prevented = true;
|
|
157
|
+
console.log(`ERROR: Getting ibm test report from URL timed out at ${timeLimit} seconds`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch(error) {
|
|
140
161
|
result.prevented = true;
|
|
141
|
-
console.log(`ERROR:
|
|
162
|
+
console.log(`ERROR: ibm test on URL crashed with error ${error.message.slice(0, 200)}`);
|
|
142
163
|
}
|
|
143
164
|
}
|
|
144
165
|
// Return the result. Execution of close() crashed the Node process.
|
package/watch.js
CHANGED
|
@@ -92,7 +92,7 @@ const checkNetJob = async watchee => {
|
|
|
92
92
|
console.log(job.message);
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
|
-
console.log(job);
|
|
95
|
+
console.log('No network job to do');
|
|
96
96
|
}
|
|
97
97
|
return job;
|
|
98
98
|
};
|
|
@@ -138,7 +138,7 @@ const writeNetReport = async report => {
|
|
|
138
138
|
error: 'ERROR: Response was not JSON',
|
|
139
139
|
message: error.message,
|
|
140
140
|
status: response.statusCode,
|
|
141
|
-
content: content.slice(0,
|
|
141
|
+
content: content.slice(0, 3000)
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
});
|
|
@@ -152,7 +152,8 @@ const writeNetReport = async report => {
|
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
// Send the report to the server.
|
|
155
|
-
|
|
155
|
+
const reportJSON = JSON.stringify(report, null, 2);
|
|
156
|
+
request.write(reportJSON);
|
|
156
157
|
request.end();
|
|
157
158
|
console.log(`Report ${report.id} submitted`);
|
|
158
159
|
}
|