testaro 4.12.1 → 4.12.2
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/aceconfig.js +1 -1
- package/package.json +1 -1
- package/run.js +28 -9
- package/tests/ibm.js +5 -4
package/aceconfig.js
CHANGED
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
index.js
|
|
3
3
|
testaro main script.
|
|
4
4
|
*/
|
|
5
|
+
|
|
5
6
|
// ########## IMPORTS
|
|
7
|
+
|
|
6
8
|
// Module to keep secrets.
|
|
7
9
|
require('dotenv').config();
|
|
8
10
|
// Requirements for commands.
|
|
9
11
|
const {commands} = require('./commands');
|
|
12
|
+
|
|
10
13
|
// ########## CONSTANTS
|
|
14
|
+
|
|
11
15
|
// Set DEBUG environment variable to 'true' to add debugging features.
|
|
12
16
|
const debug = process.env.DEBUG === 'true';
|
|
13
17
|
// Set WAITS environment variable to a positive number to insert delays (in ms).
|
|
@@ -77,7 +81,9 @@ const errorWords = [
|
|
|
77
81
|
'missing',
|
|
78
82
|
'deprecated'
|
|
79
83
|
];
|
|
84
|
+
|
|
80
85
|
// ########## VARIABLES
|
|
86
|
+
|
|
81
87
|
// Facts about the current session.
|
|
82
88
|
let logCount = 0;
|
|
83
89
|
let logSize = 0;
|
|
@@ -91,7 +97,11 @@ let actCount = 0;
|
|
|
91
97
|
let browserContext;
|
|
92
98
|
let browserTypeName;
|
|
93
99
|
let requestedURL = '';
|
|
100
|
+
// All browsers launched.
|
|
101
|
+
let browsers = [];
|
|
102
|
+
|
|
94
103
|
// ########## VALIDATORS
|
|
104
|
+
|
|
95
105
|
// Validates a browser type.
|
|
96
106
|
const isBrowserType = type => ['chromium', 'firefox', 'webkit'].includes(type);
|
|
97
107
|
// Validates a load state.
|
|
@@ -234,13 +244,17 @@ const isValidReport = async report => {
|
|
|
234
244
|
return false;
|
|
235
245
|
}
|
|
236
246
|
};
|
|
247
|
+
|
|
237
248
|
// ########## OTHER FUNCTIONS
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
249
|
+
|
|
250
|
+
// Closes all existing browsers.
|
|
251
|
+
const closeBrowsers = async () => {
|
|
252
|
+
for (const browserObj of browsers) {
|
|
253
|
+
const {browser, typeName} = browserObj;
|
|
254
|
+
if (browser) {
|
|
255
|
+
console.log(`Closing ${typeName} browser, version ${browser.version()}`);
|
|
256
|
+
await browser.close();
|
|
257
|
+
}
|
|
244
258
|
}
|
|
245
259
|
};
|
|
246
260
|
// Launches a browser.
|
|
@@ -249,7 +263,7 @@ const launch = async typeName => {
|
|
|
249
263
|
// If the specified browser type exists:
|
|
250
264
|
if (browserType) {
|
|
251
265
|
// Close any existing browser.
|
|
252
|
-
await
|
|
266
|
+
await closeBrowsers();
|
|
253
267
|
// Launch a browser of the specified type.
|
|
254
268
|
const browserOptions = {};
|
|
255
269
|
if (debug) {
|
|
@@ -259,6 +273,11 @@ const launch = async typeName => {
|
|
|
259
273
|
browserOptions.slowMo = waits;
|
|
260
274
|
}
|
|
261
275
|
const browser = await browserType.launch(browserOptions);
|
|
276
|
+
// Register it.
|
|
277
|
+
browsers.push({
|
|
278
|
+
browser,
|
|
279
|
+
typeName
|
|
280
|
+
});
|
|
262
281
|
// Create a new context (window) in it, taller if debugging is on.
|
|
263
282
|
const viewport = debug ? {
|
|
264
283
|
viewPort: {
|
|
@@ -1262,8 +1281,8 @@ const doScript = async (report) => {
|
|
|
1262
1281
|
report.testTimes = [];
|
|
1263
1282
|
// Perform the specified acts.
|
|
1264
1283
|
await doActs(report, 0, null);
|
|
1265
|
-
// Close
|
|
1266
|
-
await
|
|
1284
|
+
// Close all browsers.
|
|
1285
|
+
await closeBrowsers();
|
|
1267
1286
|
// Add the log statistics to the report.
|
|
1268
1287
|
report.logCount = logCount;
|
|
1269
1288
|
report.logSize = logSize;
|
package/tests/ibm.js
CHANGED
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
*/
|
|
20
20
|
// Import required modules.
|
|
21
21
|
const fs = require('fs').promises;
|
|
22
|
-
const {getCompliance} = require('accessibility-checker');
|
|
22
|
+
const {getCompliance, close} = require('accessibility-checker');
|
|
23
23
|
// Runs the IBM test.
|
|
24
24
|
const run = async content => {
|
|
25
25
|
const nowLabel = (new Date()).toISOString().slice(0, 19);
|
|
26
26
|
// Return the result of a test.
|
|
27
27
|
const ibmReport = await getCompliance(content, nowLabel);
|
|
28
|
+
await close();
|
|
28
29
|
return ibmReport;
|
|
29
30
|
};
|
|
30
31
|
// Trims an IBM report.
|
|
@@ -67,11 +68,11 @@ const doTest = async (content, withItems, timeLimit) => {
|
|
|
67
68
|
resolve({});
|
|
68
69
|
}, 1000 * timeLimit);
|
|
69
70
|
});
|
|
70
|
-
// Conduct and
|
|
71
|
+
// Conduct the test and get a Promise of the report.
|
|
71
72
|
const ibmReport = run(content);
|
|
72
|
-
// Wait for
|
|
73
|
+
// Wait for completion or until the time limit expires.
|
|
73
74
|
const ibmReportIfFast = await Promise.race([ibmReport, wait]);
|
|
74
|
-
// Delete
|
|
75
|
+
// Delete existing report files.
|
|
75
76
|
try {
|
|
76
77
|
const reportNames = await fs.readdir('results');
|
|
77
78
|
for (const reportName of reportNames) {
|