testaro 10.4.1 → 10.5.0
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/actSpecs.js +11 -0
- package/package.json +1 -1
- package/tests/nuVal.js +12 -1
package/actSpecs.js
CHANGED
|
@@ -294,6 +294,17 @@ exports.actSpecs = {
|
|
|
294
294
|
withItems: [true, 'boolean', '', 'itemize']
|
|
295
295
|
}
|
|
296
296
|
],
|
|
297
|
+
nuVal: [
|
|
298
|
+
'Perform a nuVal test',
|
|
299
|
+
{
|
|
300
|
+
messages: [
|
|
301
|
+
false,
|
|
302
|
+
'array',
|
|
303
|
+
'areStrings',
|
|
304
|
+
'message specifications (e.g., error:Bad value), if not all'
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
],
|
|
297
308
|
radioSet: [
|
|
298
309
|
'Perform a radioSet test',
|
|
299
310
|
{
|
package/package.json
CHANGED
package/tests/nuVal.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
erratic, no better solution is known.
|
|
9
9
|
*/
|
|
10
10
|
const https = require('https');
|
|
11
|
-
exports.reporter = async page => {
|
|
11
|
+
exports.reporter = async (page, messages) => {
|
|
12
12
|
const pageContent = await page.content();
|
|
13
13
|
// Get the data from a Nu validation.
|
|
14
14
|
const dataPromise = new Promise(resolve => {
|
|
@@ -78,6 +78,17 @@ exports.reporter = async page => {
|
|
|
78
78
|
clearTimeout(timeoutID);
|
|
79
79
|
}, 1000 * timeLimit);
|
|
80
80
|
});
|
|
81
|
+
// Get the result, or an error report if nuVal timed out after 12 seconds.
|
|
81
82
|
const data = await Promise.race([dataPromise, timeoutPromise]);
|
|
83
|
+
// If there is a report and restrictions on the report messages were specified:
|
|
84
|
+
if (! data.error && messages && Array.isArray(messages) && messages.length) {
|
|
85
|
+
// Remove all messages except those specified.
|
|
86
|
+
const messageSpecs = messages.map(messageSpec => messageSpec.split(':', 2));
|
|
87
|
+
data.messages = data.messages.filter(message => {
|
|
88
|
+
messageSpecs.some(messageSpec => {
|
|
89
|
+
return message.type === messageSpec[0] && message.message.startsWith(messageSpec[1]);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
82
93
|
return {result: data};
|
|
83
94
|
};
|