testaro 3.0.0 → 3.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/README.md +4 -1
- package/commands.js +1 -1
- package/package.json +1 -1
- package/samples/scripts/simple.json +2 -3
- package/tests/ibm.js +45 -19
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ As of this version, the counts of tests in the packages referenced above were:
|
|
|
49
49
|
|
|
50
50
|
## Related packages
|
|
51
51
|
|
|
52
|
-
[Testilo](https://
|
|
52
|
+
[Testilo](https://www.npmjs.com/package/testilo) is an application that facilitates the use of Testaro.
|
|
53
53
|
|
|
54
54
|
## Code organization
|
|
55
55
|
|
|
@@ -461,6 +461,9 @@ Further development is contemplated, is taking place, or is welcomed, on:
|
|
|
461
461
|
- buttons with no text content
|
|
462
462
|
- modal dialogs
|
|
463
463
|
- autocomplete attributes
|
|
464
|
+
- inclusion of other test packages, such as:
|
|
465
|
+
- FAE (https://github.com/opena11y/evaluation-library)
|
|
466
|
+
- Tenon
|
|
464
467
|
|
|
465
468
|
## Testing challenges
|
|
466
469
|
|
package/commands.js
CHANGED
|
@@ -185,7 +185,7 @@ exports.commands = {
|
|
|
185
185
|
{
|
|
186
186
|
withItems: [true, 'boolean'],
|
|
187
187
|
withNewContent: [
|
|
188
|
-
false, 'boolean', '', 'true: use a URL; false: use page content; omitted:
|
|
188
|
+
false, 'boolean', '', 'true: use a URL; false: use page content; omitted: both'
|
|
189
189
|
]
|
|
190
190
|
}
|
|
191
191
|
],
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"what": "Test example.com with
|
|
2
|
+
"what": "Test example.com with bulk",
|
|
3
3
|
"strict": true,
|
|
4
4
|
"commands": [
|
|
5
5
|
{
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"type": "test",
|
|
17
|
-
"which": "
|
|
18
|
-
"what": "Siteimprove alfa package"
|
|
17
|
+
"which": "bulk"
|
|
19
18
|
}
|
|
20
19
|
]
|
|
21
20
|
}
|
package/tests/ibm.js
CHANGED
|
@@ -50,28 +50,54 @@ const report = (result, withItems) => {
|
|
|
50
50
|
}
|
|
51
51
|
return data;
|
|
52
52
|
};
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
// Performs an IBM test.
|
|
54
|
+
const doTest = async (content, withItems, timeLimit) => {
|
|
55
|
+
// Start a timeout clock.
|
|
56
|
+
let timeoutID;
|
|
57
|
+
const wait = new Promise(resolve => {
|
|
58
|
+
timeoutID = setTimeout(() => {
|
|
59
|
+
resolve('');
|
|
60
|
+
}, 1000 * timeLimit);
|
|
61
|
+
});
|
|
62
|
+
// Conduct and report the test.
|
|
63
|
+
const result = run(content);
|
|
64
|
+
// Wait for the report until the time limit expires.
|
|
65
|
+
const resultIfFast = await Promise.race([result, wait]);
|
|
66
|
+
// Delete the report files.
|
|
67
|
+
try {
|
|
68
|
+
const reportNames = await fs.readdir('results');
|
|
69
|
+
for (const reportName of reportNames) {
|
|
70
|
+
await fs.rm(`results/${reportName}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch(error) {
|
|
74
|
+
console.log('ibm test created no result files.');
|
|
75
|
+
}
|
|
76
|
+
// Return the result.
|
|
77
|
+
if (resultIfFast) {
|
|
78
|
+
clearTimeout(timeoutID);
|
|
79
|
+
const typeResult = report(result, withItems);
|
|
80
|
+
return typeResult;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
console.log('ERROR: getting ibm test report took too long');
|
|
84
|
+
return 'ERROR: getting ibm test report took too long';
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
// Returns results of one or two IBM tests.
|
|
55
88
|
exports.reporter = async (page, withItems, withNewContent) => {
|
|
56
|
-
// If
|
|
89
|
+
// If a test with existing content is to be performed:
|
|
90
|
+
const result = {};
|
|
57
91
|
if (! withNewContent) {
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
all.content = report(result, withItems);
|
|
92
|
+
const timeLimit = 15;
|
|
93
|
+
const typeContent = await page.content();
|
|
94
|
+
result.content = await doTest(typeContent, withItems, timeLimit);
|
|
62
95
|
}
|
|
63
|
-
// If
|
|
96
|
+
// If a test with new content is to be performed:
|
|
64
97
|
if ([true, undefined].includes(withNewContent)) {
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
all.url = report(result, withItems);
|
|
98
|
+
const timeLimit = 20;
|
|
99
|
+
const typeContent = page.url();
|
|
100
|
+
result.url = await doTest(typeContent, withItems, timeLimit);
|
|
69
101
|
}
|
|
70
|
-
|
|
71
|
-
const reportNames = await fs.readdir('results');
|
|
72
|
-
for (const reportName of reportNames) {
|
|
73
|
-
await fs.rm(`results/${reportName}`);
|
|
74
|
-
}
|
|
75
|
-
// Return the result.
|
|
76
|
-
return {result: all};
|
|
102
|
+
return {result};
|
|
77
103
|
};
|