testdriverai 4.0.31 → 4.0.32
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/lib/analytics.js +10 -7
- package/lib/commands.js +11 -6
- package/lib/config.js +30 -0
- package/lib/notify.js +2 -1
- package/lib/speak.js +2 -1
- package/package.json +1 -1
package/lib/analytics.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
const sdk = require('./sdk');
|
|
2
|
+
const config = require('./config');
|
|
2
3
|
|
|
3
|
-
module.exports = {
|
|
4
|
+
module.exports = {
|
|
5
|
+
track: async (event, data) => {
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (config["TD_ANALYTICS"]) {
|
|
8
|
+
return;
|
|
9
|
+
} else {
|
|
10
|
+
sdk.req('analytics', { event, data });
|
|
11
|
+
}
|
|
10
12
|
|
|
11
|
-
}
|
|
13
|
+
}
|
|
14
|
+
};
|
package/lib/commands.js
CHANGED
|
@@ -40,23 +40,28 @@ const findImageOnScreen = async (relativePath, haystack, restrictToWindow) => {
|
|
|
40
40
|
relativePath = relativePath + '.png';
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
let needle = path.join(rootpath, relativePath);
|
|
44
|
+
|
|
43
45
|
// check if the file exists
|
|
44
|
-
if (await !fs.access(
|
|
45
|
-
throw new AiError(`Image not
|
|
46
|
+
if (await !fs.access(needle)) {
|
|
47
|
+
throw new AiError(`Image does not exist or do not have access: ${needle}`)
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
let needle = path.join(rootpath, relativePath);
|
|
49
|
-
|
|
50
50
|
const bar1 = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
|
51
51
|
|
|
52
52
|
let thresholds = [
|
|
53
|
-
0.9
|
|
53
|
+
0.9,
|
|
54
|
+
0.8,
|
|
55
|
+
0.7,
|
|
54
56
|
];
|
|
55
57
|
|
|
56
58
|
let scaleFactors = [
|
|
57
59
|
1,
|
|
58
60
|
.5,
|
|
59
|
-
2
|
|
61
|
+
2,
|
|
62
|
+
.75,
|
|
63
|
+
1.25,
|
|
64
|
+
1.5
|
|
60
65
|
];
|
|
61
66
|
|
|
62
67
|
let result = null;
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require('dotenv').config()
|
|
2
|
+
|
|
3
|
+
// Parse out true and false string values
|
|
4
|
+
function parseValue(value) {
|
|
5
|
+
if (value === "false") {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (value === "true") {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Object for TD related config, with defaults
|
|
17
|
+
const config = {
|
|
18
|
+
TD_SPEAK: false,
|
|
19
|
+
TD_ANALYTICS: false,
|
|
20
|
+
TD_NOTIFY: false,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Find all env vars starting with TD_
|
|
24
|
+
for (let key in process.env) {
|
|
25
|
+
if (key.startsWith("TD_")) {
|
|
26
|
+
config[key] = parseValue(process.env[key]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = config;
|
package/lib/notify.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const notifier = require("node-notifier");
|
|
2
2
|
const path = require("path");
|
|
3
|
+
const config = require("./config");
|
|
3
4
|
|
|
4
5
|
module.exports = (message) => {
|
|
5
6
|
|
|
6
|
-
if (
|
|
7
|
+
if (config["TD_NOTIFY"]) {
|
|
7
8
|
|
|
8
9
|
return notifier.notify({
|
|
9
10
|
title: "TestDriver.ai",
|
package/lib/speak.js
CHANGED