@camperaid/watest 2.4.7 → 2.4.9
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/.prettierrc.js +1 -3
- package/.watestrc.js +7 -3
- package/bin/watest.js +3 -8
- package/core/base.js +83 -69
- package/core/core.js +25 -46
- package/core/format.js +96 -56
- package/core/process_args.js +1 -5
- package/core/series.js +62 -57
- package/core/settings.js +32 -32
- package/core/spawn.js +14 -21
- package/core/util.js +12 -19
- package/esling.config.js +0 -0
- package/eslint.config.js +27 -0
- package/index.js +11 -17
- package/interfaces/logger.js +1 -3
- package/interfaces/servicer.js +1 -3
- package/logging/filestream.js +3 -7
- package/logging/logging.js +5 -11
- package/logging/logpipe.js +21 -21
- package/package.json +12 -11
- package/tests/base/t_api.js +3 -6
- package/tests/base/t_contains.js +12 -12
- package/tests/base/t_core.js +11 -8
- package/tests/base/t_format.js +13 -14
- package/tests/base/t_is.js +9 -11
- package/tests/base/t_is_object.js +23 -25
- package/tests/base/t_is_primitive.js +12 -14
- package/tests/base/t_is_string.js +6 -8
- package/tests/base/t_ok.js +4 -6
- package/tests/base/t_stringify.js +6 -8
- package/tests/base/t_test_.js +3 -5
- package/tests/base/t_throws.js +82 -18
- package/tests/base/test.js +14 -21
- package/tests/e2e/samples/{loader/.watestrc.cjs → folder/.watestrc.js} +1 -1
- package/tests/e2e/samples/folder/package-lock.json +1019 -5940
- package/tests/e2e/samples/folder/package.json +3 -2
- package/tests/e2e/samples/folder/tests/meta.js +1 -1
- package/tests/e2e/samples/folder/tests/unit/t_test.js +3 -3
- package/tests/e2e/samples/{loader_mixed/.watestrc.cjs → loader/.watestrc.js} +1 -1
- package/tests/e2e/samples/loader/package-lock.json +1751 -28
- package/tests/e2e/samples/loader/package.json +2 -2
- package/tests/e2e/samples/loader/tests/meta.js +2 -2
- package/tests/e2e/samples/{folder/.watestrc.cjs → loader_mixed/.watestrc.js} +1 -1
- package/tests/e2e/samples/loader_mixed/package-lock.json +1751 -28
- package/tests/e2e/samples/loader_mixed/tests/ui/meta.js +2 -2
- package/tests/e2e/samples/loader_multiple/{.watestrc.cjs → .watestrc.js} +1 -1
- package/tests/e2e/samples/loader_multiple/package-lock.json +1751 -28
- package/tests/e2e/samples/loader_multiple/package.json +2 -2
- package/tests/e2e/samples/loader_multiple/tests/base/meta.js +2 -2
- package/tests/e2e/samples/loader_multiple/tests/core/meta.js +2 -2
- package/tests/e2e/samples/single/.watestrc.js +5 -0
- package/tests/e2e/samples/single/package-lock.json +1017 -5938
- package/tests/e2e/samples/single/package.json +5 -2
- package/tests/e2e/samples/wd_mixed/{.watestrc.cjs → .watestrc.js} +1 -1
- package/tests/e2e/samples/wd_mixed/package-lock.json +779 -4862
- package/tests/e2e/samples/wd_mixed/package.json +2 -2
- package/tests/e2e/samples/wd_single/{.watestrc.cjs → .watestrc.js} +1 -1
- package/tests/e2e/samples/wd_single/package-lock.json +779 -4862
- package/tests/e2e/samples/wd_single/package.json +2 -2
- package/tests/e2e/t_folder.js +4 -6
- package/tests/e2e/t_loader.js +4 -6
- package/tests/e2e/t_loader_mixed.js +4 -6
- package/tests/e2e/t_loader_multiple.js +4 -6
- package/tests/e2e/t_loader_multiple_patterns.js +4 -6
- package/tests/e2e/t_single.js +4 -6
- package/tests/e2e/t_wd_firefox.js +4 -6
- package/tests/e2e/t_wd_firefox_chrome.js +4 -6
- package/tests/e2e/t_wd_firefox_chrome_pattern.js +4 -6
- package/tests/e2e/t_wd_mixed_firefox.js +4 -6
- package/tests/e2e/t_wd_mixed_firefox_chrome.js +4 -6
- package/tests/e2e/test.js +15 -16
- package/tests/meta.js +1 -3
- package/tests/series/build/t_adjust_names.js +4 -6
- package/tests/series/build/t_adjust_names_webdriver.js +6 -10
- package/tests/series/build/t_expected_failures.js +4 -6
- package/tests/series/build/t_loader.js +4 -6
- package/tests/series/build/t_loader_mixed.js +4 -6
- package/tests/series/build/t_mixed.js +4 -6
- package/tests/series/build/t_nested.js +4 -6
- package/tests/series/build/t_patterns_loader.js +4 -6
- package/tests/series/build/t_patterns_webdriver.js +4 -6
- package/tests/series/build/t_webdriver.js +4 -6
- package/tests/series/build/t_webdriver_firefox_mixed.js +4 -6
- package/tests/series/build/t_webdriver_nested.js +4 -6
- package/tests/series/build/t_webdriver_services.js +4 -6
- package/tests/series/generic/t_failures_info.js +9 -12
- package/tests/series/loader/meta.mjs +2 -2
- package/tests/series/logging/t_failures.js +18 -20
- package/tests/series/logging/t_success.js +15 -17
- package/tests/series/logging/t_verify.js +17 -14
- package/tests/series/meta.js +1 -3
- package/tests/series/mock_series.js +7 -13
- package/tests/series/perform/t_failure.js +4 -6
- package/tests/series/perform/t_failure_notest.js +4 -6
- package/tests/series/perform/t_intermittent.js +5 -7
- package/tests/series/perform/t_intermittent_global.js +4 -6
- package/tests/series/perform/t_missing_perma.js +5 -7
- package/tests/series/perform/t_nested.js +4 -10
- package/tests/series/perform/t_perma.js +4 -6
- package/tests/series/perform/t_success.js +5 -11
- package/tests/series/run/t_debunk_failure.js +7 -6
- package/tests/series/run/t_debunk_success.js +7 -6
- package/tests/series/run/t_nested.js +7 -6
- package/tests/series/run/t_verify.js +7 -6
- package/tests/series/run/t_verify_webdriver.js +7 -6
- package/tests/series/test.js +29 -40
- package/tests/webdriver/meta.js +1 -3
- package/tests/webdriver/t_app_driver.js +3 -5
- package/tests/webdriver/t_app_driver_selectors.js +3 -5
- package/tests/webdriver/t_attribute.js +5 -7
- package/tests/webdriver/t_attribute_all.js +6 -8
- package/tests/webdriver/t_doubleclick.js +3 -5
- package/tests/webdriver/t_doubleclickat.js +3 -5
- package/tests/webdriver/t_execute.js +4 -6
- package/tests/webdriver/t_if_has_elements.js +6 -8
- package/tests/webdriver/t_if_no_elements.js +6 -8
- package/tests/webdriver/t_no_elements_or_not_visible.js +7 -9
- package/tests/webdriver/t_properties.js +11 -13
- package/tests/webdriver/t_script.js +8 -10
- package/tests/webdriver/t_select_all.js +6 -11
- package/tests/webdriver/t_selection.js +4 -6
- package/tests/webdriver/t_text.js +12 -14
- package/tests/webdriver/t_text_all.js +6 -8
- package/tests/webdriver/test.js +32 -41
- package/webdriver/app_driver.js +28 -19
- package/webdriver/control_driver.js +4 -8
- package/webdriver/driver.js +64 -63
- package/webdriver/driver_base.js +52 -62
- package/webdriver/session.js +6 -11
- package/webdriver/util.js +7 -8
- package/.eslintrc.js +0 -45
- package/index.mjs +0 -5
- package/tests/e2e/samples/folder/node_modules/.package-lock.json +0 -3871
- package/tests/e2e/samples/loader/node_modules/.package-lock.json +0 -36
- package/tests/e2e/samples/loader_mixed/node_modules/.package-lock.json +0 -36
- package/tests/e2e/samples/loader_multiple/node_modules/.package-lock.json +0 -36
- package/tests/e2e/samples/single/.watestrc.cjs +0 -5
- package/tests/e2e/samples/single/node_modules/.package-lock.json +0 -3871
- package/tests/e2e/samples/wd_mixed/node_modules/.package-lock.json +0 -3586
- package/tests/e2e/samples/wd_single/node_modules/.package-lock.json +0 -3586
package/core/spawn.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { spawn } = require('child_process');
|
|
4
|
-
|
|
5
|
-
const { log_error } = require('../logging/logging.js');
|
|
1
|
+
import { spawn as spawn_process } from 'child_process';
|
|
2
|
+
import { log_error } from '../logging/logging.js';
|
|
6
3
|
|
|
7
4
|
class ChildProcess {
|
|
8
5
|
constructor(on_output) {
|
|
@@ -12,17 +9,17 @@ class ChildProcess {
|
|
|
12
9
|
|
|
13
10
|
spawn(cmd, args, options) {
|
|
14
11
|
return new Promise((resolve, reject) => {
|
|
15
|
-
const cp =
|
|
12
|
+
const cp = spawn_process(cmd, args, options);
|
|
16
13
|
cp.on('close', (code, signal) =>
|
|
17
14
|
Promise.resolve(this.processChildProcessOutputPromise).then(() =>
|
|
18
|
-
signal == 'SIGUSR1' ? reject(code) : resolve(code)
|
|
19
|
-
)
|
|
15
|
+
signal == 'SIGUSR1' ? reject(code) : resolve(code),
|
|
16
|
+
),
|
|
20
17
|
);
|
|
21
18
|
cp.stdout.on('data', data =>
|
|
22
|
-
this.bufferizeChildProcesOutput(cp, data, true)
|
|
19
|
+
this.bufferizeChildProcesOutput(cp, data, true),
|
|
23
20
|
);
|
|
24
21
|
cp.stderr.on('data', data =>
|
|
25
|
-
this.bufferizeChildProcesOutput(cp, data, false)
|
|
22
|
+
this.bufferizeChildProcesOutput(cp, data, false),
|
|
26
23
|
);
|
|
27
24
|
cp.on('error', reject);
|
|
28
25
|
});
|
|
@@ -31,9 +28,8 @@ class ChildProcess {
|
|
|
31
28
|
bufferizeChildProcesOutput(cp, data, is_stdout) {
|
|
32
29
|
let str_data = data.toString();
|
|
33
30
|
|
|
34
|
-
let lastChunk =
|
|
35
|
-
this.childProcessOutputBuffer.length - 1
|
|
36
|
-
];
|
|
31
|
+
let lastChunk =
|
|
32
|
+
this.childProcessOutputBuffer[this.childProcessOutputBuffer.length - 1];
|
|
37
33
|
if (lastChunk && lastChunk.is_stdout == is_stdout) {
|
|
38
34
|
lastChunk.str_data += str_data;
|
|
39
35
|
} else {
|
|
@@ -57,9 +53,8 @@ class ChildProcess {
|
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
async processChildProcessBuffer() {
|
|
60
|
-
let lastChunk =
|
|
61
|
-
this.childProcessOutputBuffer.length - 1
|
|
62
|
-
];
|
|
56
|
+
let lastChunk =
|
|
57
|
+
this.childProcessOutputBuffer[this.childProcessOutputBuffer.length - 1];
|
|
63
58
|
if (!lastChunk || !lastChunk.str_data.endsWith('\n')) {
|
|
64
59
|
return null;
|
|
65
60
|
}
|
|
@@ -72,8 +67,6 @@ class ChildProcess {
|
|
|
72
67
|
}
|
|
73
68
|
}
|
|
74
69
|
|
|
75
|
-
|
|
76
|
-
spawn(cmd, args, options
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
};
|
|
70
|
+
export function spawn(cmd, args, options, on_output) {
|
|
71
|
+
return new ChildProcess(on_output).spawn(cmd, args, options);
|
|
72
|
+
}
|
package/core/util.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import querystring from 'querystring';
|
|
3
|
+
import util from 'util';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const cfg = require('./settings.js');
|
|
5
|
+
import { log } from '../logging/logging.js';
|
|
6
|
+
import settings from './settings.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Logs object in console colored.
|
|
9
10
|
*/
|
|
10
11
|
function inspect(obj) {
|
|
11
|
-
log(
|
|
12
|
+
log(util.inspect(obj, false, null, true /* enable colors */));
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -38,7 +39,7 @@ function stringify(obj, traces = new Set()) {
|
|
|
38
39
|
}
|
|
39
40
|
if (obj instanceof Map) {
|
|
40
41
|
let entries = Array.from(obj.entries()).map(
|
|
41
|
-
([k, v]) => `${k}: ${stringify(v, traces)}
|
|
42
|
+
([k, v]) => `${k}: ${stringify(v, traces)}`,
|
|
42
43
|
);
|
|
43
44
|
return `Map{${entries.join(', ')}}`;
|
|
44
45
|
}
|
|
@@ -74,9 +75,9 @@ function stringify(obj, traces = new Set()) {
|
|
|
74
75
|
* A temporary storage dir.
|
|
75
76
|
*/
|
|
76
77
|
function initTmpStorage() {
|
|
77
|
-
if (
|
|
78
|
-
removeDir(
|
|
79
|
-
fs.mkdirSync(
|
|
78
|
+
if (settings.tmp_storage_dir) {
|
|
79
|
+
removeDir(settings.tmp_storage_dir);
|
|
80
|
+
fs.mkdirSync(settings.tmp_storage_dir);
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -102,15 +103,7 @@ function is_mac() {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
function toDataURL(html) {
|
|
105
|
-
return `data:text/html,${
|
|
106
|
+
return `data:text/html,${querystring.escape(html)}`;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
inspect,
|
|
110
|
-
stringify,
|
|
111
|
-
is_mac,
|
|
112
|
-
toDataURL,
|
|
113
|
-
|
|
114
|
-
removeDir,
|
|
115
|
-
initTmpStorage,
|
|
116
|
-
};
|
|
109
|
+
export { inspect, stringify, is_mac, toDataURL, removeDir, initTmpStorage };
|
package/esling.config.js
ADDED
|
File without changes
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import js from '@eslint/js'; // eslint-disable-line n/no-unpublished-import
|
|
2
|
+
import nodePlugin from 'eslint-plugin-n'; // eslint-disable-line n/no-unpublished-import
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
js.configs.recommended,
|
|
6
|
+
nodePlugin.configs['flat/recommended-script'],
|
|
7
|
+
{
|
|
8
|
+
languageOptions: {
|
|
9
|
+
ecmaVersion: 2021,
|
|
10
|
+
sourceType: 'module',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
files: ['bin/watest.js'],
|
|
15
|
+
rules: {
|
|
16
|
+
'n/no-process-exit': 'off',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
files: ['tests/e2e/samples/**'],
|
|
21
|
+
settings: {
|
|
22
|
+
node: {
|
|
23
|
+
allowModules: ['watest'],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
package/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import {
|
|
4
2
|
assert,
|
|
5
3
|
group,
|
|
6
4
|
fail,
|
|
@@ -10,32 +8,28 @@ const {
|
|
|
10
8
|
success,
|
|
11
9
|
todo,
|
|
12
10
|
warn,
|
|
13
|
-
}
|
|
11
|
+
} from './core/core.js';
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
import {
|
|
16
14
|
ok,
|
|
17
15
|
is,
|
|
18
16
|
contains,
|
|
19
17
|
is_output,
|
|
20
18
|
no_throws,
|
|
21
19
|
throws,
|
|
22
|
-
|
|
23
20
|
test_is,
|
|
24
21
|
test_contains,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const { inspect } = require('./core/util.js');
|
|
22
|
+
} from './core/base.js';
|
|
28
23
|
|
|
29
|
-
|
|
24
|
+
import settings from './core/settings.js';
|
|
25
|
+
import { inspect } from './core/util.js';
|
|
26
|
+
import { AppDriver } from './webdriver/app_driver.js';
|
|
27
|
+
import { ControlDriver } from './webdriver/control_driver.js';
|
|
28
|
+
import { start_session, scope } from './webdriver/session.js';
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
const { ControlDriver } = require('./webdriver/control_driver.js');
|
|
33
|
-
const { start_session, scope } = require('./webdriver/session.js');
|
|
34
|
-
|
|
35
|
-
module.exports = {
|
|
30
|
+
export {
|
|
36
31
|
AppDriver,
|
|
37
32
|
ControlDriver,
|
|
38
|
-
|
|
39
33
|
assert,
|
|
40
34
|
contains,
|
|
41
35
|
failed,
|
|
@@ -55,6 +49,6 @@ module.exports = {
|
|
|
55
49
|
test_is,
|
|
56
50
|
test_contains,
|
|
57
51
|
throws,
|
|
58
|
-
tmp_storage_dir,
|
|
59
52
|
warn,
|
|
53
|
+
settings,
|
|
60
54
|
};
|
package/interfaces/logger.js
CHANGED
package/interfaces/servicer.js
CHANGED
package/logging/filestream.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Writes to a local file.
|
|
@@ -37,6 +35,4 @@ class FileStream {
|
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
FileStream,
|
|
42
|
-
};
|
|
38
|
+
export { FileStream };
|
package/logging/logging.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { ProcessArgs } = require('../core/process_args.js');
|
|
1
|
+
import { ProcessArgs } from '../core/process_args.js';
|
|
4
2
|
|
|
5
3
|
function log(...args) {
|
|
6
4
|
console.log(...args);
|
|
@@ -15,13 +13,9 @@ function log_error(...args) {
|
|
|
15
13
|
// before sending it via callbacks, which may make buffers to contain output
|
|
16
14
|
// from multiple console.log/error calls, which makes the child process output
|
|
17
15
|
// processing messy.
|
|
18
|
-
ProcessArgs.asObject().childProcess
|
|
19
|
-
console.log(...args)
|
|
20
|
-
console.error(...args);
|
|
16
|
+
ProcessArgs.asObject().childProcess
|
|
17
|
+
? console.log(...args)
|
|
18
|
+
: console.error(...args);
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
log,
|
|
25
|
-
log_trace,
|
|
26
|
-
log_error
|
|
27
|
-
};
|
|
21
|
+
export { log, log_trace, log_error };
|
package/logging/logpipe.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import path from 'path';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { log, log_error } = require('./logging.js');
|
|
7
|
-
const { log_dir, run } = settings;
|
|
3
|
+
import { FileStream as DefaultFileStream } from './filestream.js';
|
|
4
|
+
import { log, log_error } from './logging.js';
|
|
5
|
+
import settings from '../core/settings.js';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* A single instance of a logpipe writing to std and file streams.
|
|
11
9
|
*/
|
|
12
10
|
class LogPipeInstance {
|
|
13
11
|
constructor({ FileStream, suppress_logging }) {
|
|
14
|
-
this.FS = FileStream ||
|
|
12
|
+
this.FS = FileStream || DefaultFileStream;
|
|
15
13
|
this.suppress_logging = suppress_logging;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
attach(invocation) {
|
|
19
17
|
this.invocation = invocation;
|
|
20
|
-
this.log_dir = path.join(log_dir, this.invocation);
|
|
18
|
+
this.log_dir = path.join(settings.log_dir, this.invocation);
|
|
21
19
|
if (this.suppress_logging) {
|
|
22
20
|
return;
|
|
23
21
|
}
|
|
@@ -30,7 +28,7 @@ class LogPipeInstance {
|
|
|
30
28
|
log_error(e);
|
|
31
29
|
});
|
|
32
30
|
|
|
33
|
-
return settings.logger.testRunStarted({ run, invocation });
|
|
31
|
+
return settings.logger.testRunStarted({ run: settings.run, invocation });
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
async logScreenshot(pic) {
|
|
@@ -43,7 +41,7 @@ class LogPipeInstance {
|
|
|
43
41
|
log(`Screenshot is captured and written to ${stream.filepath}`);
|
|
44
42
|
|
|
45
43
|
await settings.logger.writeLogFile({
|
|
46
|
-
run,
|
|
44
|
+
run: settings.run,
|
|
47
45
|
invocation: this.invocation,
|
|
48
46
|
name,
|
|
49
47
|
content,
|
|
@@ -51,7 +49,10 @@ class LogPipeInstance {
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
logSourceMap() {
|
|
54
|
-
return settings.logger.writeSourceMap({
|
|
52
|
+
return settings.logger.writeSourceMap({
|
|
53
|
+
run: settings.run,
|
|
54
|
+
invocation: this.invocation,
|
|
55
|
+
});
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
release() {
|
|
@@ -62,12 +63,12 @@ class LogPipeInstance {
|
|
|
62
63
|
.then(() => this.fstream.readFile())
|
|
63
64
|
.then(content =>
|
|
64
65
|
settings.logger.writeLogFile({
|
|
65
|
-
run,
|
|
66
|
+
run: settings.run,
|
|
66
67
|
invocation: this.invocation,
|
|
67
68
|
name: this.fname,
|
|
68
69
|
content,
|
|
69
70
|
zip: true,
|
|
70
|
-
})
|
|
71
|
+
}),
|
|
71
72
|
)
|
|
72
73
|
.catch(e => {
|
|
73
74
|
log_error(`Logging shutdown rejected: ${e}`);
|
|
@@ -82,7 +83,7 @@ class LogPipeInstance {
|
|
|
82
83
|
*/
|
|
83
84
|
class LogPipe {
|
|
84
85
|
static attach(invocation, options = {}) {
|
|
85
|
-
if (!log_dir) {
|
|
86
|
+
if (!settings.log_dir) {
|
|
86
87
|
return Promise.resolve();
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -100,13 +101,15 @@ class LogPipe {
|
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
static logScreenshot(...args) {
|
|
103
|
-
return log_dir
|
|
104
|
+
return settings.log_dir
|
|
104
105
|
? this.pipeOnStack.logScreenshot(...args)
|
|
105
106
|
: Promise.resolve();
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
static logSourceMap(...args) {
|
|
109
|
-
return log_dir
|
|
110
|
+
return settings.log_dir
|
|
111
|
+
? this.pipeOnStack.logSourceMap(...args)
|
|
112
|
+
: Promise.resolve();
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
static logToFile(msg) {
|
|
@@ -117,7 +120,7 @@ class LogPipe {
|
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
static async release(...args) {
|
|
120
|
-
if (!log_dir) {
|
|
123
|
+
if (!settings.log_dir) {
|
|
121
124
|
return Promise.resolve();
|
|
122
125
|
}
|
|
123
126
|
|
|
@@ -184,9 +187,6 @@ class LogPipe {
|
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
189
|
|
|
187
|
-
LogPipe.FileStream = require('./filestream.js').FileStream;
|
|
188
190
|
LogPipe.stack = [];
|
|
189
191
|
|
|
190
|
-
|
|
191
|
-
LogPipe,
|
|
192
|
-
};
|
|
192
|
+
export { LogPipe };
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camperaid/watest",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.9",
|
|
4
4
|
"description": "Web Application Testsuite",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
7
|
+
"node": ">=20.16.0"
|
|
7
8
|
},
|
|
8
9
|
"main": "index.js",
|
|
9
|
-
"module": "index.mjs",
|
|
10
10
|
"bin": {
|
|
11
11
|
"watest": "./bin/watest.js"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
+
"prepare": "husky || true",
|
|
14
15
|
"postprepare": "bash tests/install.sh",
|
|
15
16
|
"lint": "eslint '**/*.js'",
|
|
16
17
|
"lint:staged": "eslint --",
|
|
@@ -35,16 +36,16 @@
|
|
|
35
36
|
},
|
|
36
37
|
"homepage": "https://github.com/camperaid/watest#readme",
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"selenium-webdriver": "^4.
|
|
39
|
+
"selenium-webdriver": "^4.23.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"dotenv": "^16.
|
|
42
|
-
"eslint": "^8.
|
|
43
|
-
"eslint
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
42
|
+
"dotenv": "^16.4.5",
|
|
43
|
+
"eslint": "^9.8.0",
|
|
44
|
+
"@eslint/js": "^9.8.0",
|
|
45
|
+
"eslint-plugin-n": "^17.10.1",
|
|
46
|
+
"husky": "^9.1.4",
|
|
47
|
+
"lint-staged": "^15.2.7",
|
|
48
|
+
"prettier": "^3.3.3"
|
|
48
49
|
},
|
|
49
50
|
"lint-staged": {
|
|
50
51
|
"*.js": [
|
package/tests/base/t_api.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const api = require('../../index.js');
|
|
1
|
+
import * as api from '../../index.js';
|
|
4
2
|
const { ok } = api;
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
export async function test() {
|
|
7
5
|
const props = [
|
|
8
6
|
'AppDriver',
|
|
9
7
|
'ControlDriver',
|
|
@@ -24,11 +22,10 @@ module.exports.test = async () => {
|
|
|
24
22
|
'todo',
|
|
25
23
|
'test_is',
|
|
26
24
|
'test_contains',
|
|
27
|
-
'tmp_storage_dir',
|
|
28
25
|
'warn',
|
|
29
26
|
];
|
|
30
27
|
|
|
31
28
|
for (let prop of props) {
|
|
32
29
|
ok(prop in api, `${prop} present`);
|
|
33
30
|
}
|
|
34
|
-
}
|
|
31
|
+
}
|
package/tests/base/t_contains.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { contains, is_output } from './test.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.test = async () => {
|
|
3
|
+
export async function test() {
|
|
6
4
|
// string: success
|
|
7
5
|
await is_output(
|
|
8
6
|
() => contains('green cat', 'cat', `String contains`),
|
|
9
7
|
[`Ok: String contains, got: 'green cat'`],
|
|
10
8
|
[],
|
|
11
|
-
`success
|
|
9
|
+
`success`,
|
|
12
10
|
);
|
|
13
11
|
|
|
14
12
|
// string: failure: expected string, got array
|
|
@@ -16,7 +14,7 @@ module.exports.test = async () => {
|
|
|
16
14
|
() => contains([], 'green cat', `String contains`),
|
|
17
15
|
[],
|
|
18
16
|
[`Failed: String contains, expected string, got object: []`],
|
|
19
|
-
`failure
|
|
17
|
+
`failure`,
|
|
20
18
|
);
|
|
21
19
|
|
|
22
20
|
// string: failure: got string, expected array
|
|
@@ -24,15 +22,17 @@ module.exports.test = async () => {
|
|
|
24
22
|
() => contains('cat', [], `String contains`),
|
|
25
23
|
[],
|
|
26
24
|
[`Failed: String contains, got string, expected object: []`],
|
|
27
|
-
`failure
|
|
25
|
+
`failure`,
|
|
28
26
|
);
|
|
29
27
|
|
|
30
28
|
// string: failure: doesn't contains
|
|
31
29
|
await is_output(
|
|
32
30
|
() => contains('cat', 'green cat', `String contains`),
|
|
33
31
|
[],
|
|
34
|
-
[
|
|
35
|
-
|
|
32
|
+
[
|
|
33
|
+
`Failed: String contains, got string doesn't contain expected string, got: 'cat', expected: 'green cat'`,
|
|
34
|
+
],
|
|
35
|
+
`failure`,
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
// array: success
|
|
@@ -40,7 +40,7 @@ module.exports.test = async () => {
|
|
|
40
40
|
() => contains([0, 1], [1], `Array contains`),
|
|
41
41
|
[`Ok: Array contains, got: [0, 1]`],
|
|
42
42
|
[],
|
|
43
|
-
`success
|
|
43
|
+
`success`,
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
// array: failure
|
|
@@ -48,6 +48,6 @@ module.exports.test = async () => {
|
|
|
48
48
|
() => contains([0, 1], [1, 3], `Array contains`),
|
|
49
49
|
[],
|
|
50
50
|
[`Failed: Array contains, array has no expected item 3, got: [0, 1]`],
|
|
51
|
-
`failure
|
|
51
|
+
`failure`,
|
|
52
52
|
);
|
|
53
|
-
}
|
|
53
|
+
}
|
package/tests/base/t_core.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { colorify, group, fail, success, is_output } from './test.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.test = async () => {
|
|
3
|
+
export async function test() {
|
|
6
4
|
// console.log
|
|
7
5
|
await is_output(() => console.log(3), [`[33m3[39m\n`], [], `console.log(3)`);
|
|
8
6
|
|
|
9
7
|
// console.error
|
|
10
|
-
await is_output(
|
|
8
|
+
await is_output(
|
|
9
|
+
() => console.error(3),
|
|
10
|
+
[],
|
|
11
|
+
[`[33m3[39m\n`],
|
|
12
|
+
`console.error(3)`,
|
|
13
|
+
);
|
|
11
14
|
|
|
12
15
|
// group(msg)
|
|
13
16
|
await is_output(
|
|
14
17
|
() => group('message'),
|
|
15
18
|
[colorify('group', `Group:`, 'message')],
|
|
16
19
|
[],
|
|
17
|
-
`group(msg)
|
|
20
|
+
`group(msg)`,
|
|
18
21
|
);
|
|
19
22
|
|
|
20
23
|
// group(msg, label);
|
|
@@ -22,7 +25,7 @@ module.exports.test = async () => {
|
|
|
22
25
|
() => group('message', 'Block'),
|
|
23
26
|
[colorify('group', `Block:`, 'message')],
|
|
24
27
|
[],
|
|
25
|
-
`group(msg, label)
|
|
28
|
+
`group(msg, label)`,
|
|
26
29
|
);
|
|
27
30
|
|
|
28
31
|
// success()
|
|
@@ -30,4 +33,4 @@ module.exports.test = async () => {
|
|
|
30
33
|
|
|
31
34
|
// fail()
|
|
32
35
|
await is_output(() => fail('Fail'), [], [`Failed: Fail`], `fail()`);
|
|
33
|
-
}
|
|
36
|
+
}
|
package/tests/base/t_format.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import {
|
|
4
2
|
format_completed,
|
|
5
3
|
format_failure,
|
|
6
4
|
format_failures,
|
|
7
5
|
format_success,
|
|
8
6
|
parse,
|
|
9
7
|
parse_failure,
|
|
10
|
-
}
|
|
11
|
-
|
|
8
|
+
} from '../../core/format.js';
|
|
9
|
+
|
|
10
|
+
import { is } from '../../index.js';
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
export function test() {
|
|
14
13
|
// parse: failure
|
|
15
14
|
is(
|
|
16
15
|
parse(format_failure('Oops')),
|
|
@@ -19,7 +18,7 @@ module.exports.test = () => {
|
|
|
19
18
|
label: 'Failed:',
|
|
20
19
|
msg: 'Oops',
|
|
21
20
|
},
|
|
22
|
-
'parse: failure'
|
|
21
|
+
'parse: failure',
|
|
23
22
|
);
|
|
24
23
|
|
|
25
24
|
// parse: completed
|
|
@@ -30,7 +29,7 @@ module.exports.test = () => {
|
|
|
30
29
|
label: 'Completed',
|
|
31
30
|
msg: 'Yes',
|
|
32
31
|
},
|
|
33
|
-
'parse: completed'
|
|
32
|
+
'parse: completed',
|
|
34
33
|
);
|
|
35
34
|
|
|
36
35
|
// parse: failures
|
|
@@ -41,7 +40,7 @@ module.exports.test = () => {
|
|
|
41
40
|
label: '>mac/webdriver/chrome/t_locmarker_click.js',
|
|
42
41
|
msg: 'Failure count: 1',
|
|
43
42
|
},
|
|
44
|
-
'parse: failures'
|
|
43
|
+
'parse: failures',
|
|
45
44
|
);
|
|
46
45
|
|
|
47
46
|
// parse: success
|
|
@@ -52,7 +51,7 @@ module.exports.test = () => {
|
|
|
52
51
|
label: 'mac/webdriver',
|
|
53
52
|
msg: 'Total: 1',
|
|
54
53
|
},
|
|
55
|
-
'parse: success'
|
|
54
|
+
'parse: success',
|
|
56
55
|
);
|
|
57
56
|
|
|
58
57
|
// parse_failure
|
|
@@ -60,12 +59,12 @@ module.exports.test = () => {
|
|
|
60
59
|
parse_failure(
|
|
61
60
|
format_failure(
|
|
62
61
|
'has 4 failure(s)',
|
|
63
|
-
'>mac/webdriver/ui-blocks/firefox/map/t_locmarker_click.js'
|
|
64
|
-
)
|
|
62
|
+
'>mac/webdriver/ui-blocks/firefox/map/t_locmarker_click.js',
|
|
63
|
+
),
|
|
65
64
|
),
|
|
66
65
|
{
|
|
67
66
|
name: 'mac/webdriver/ui-blocks/firefox/map/t_locmarker_click.js',
|
|
68
67
|
count: '4',
|
|
69
|
-
}
|
|
68
|
+
},
|
|
70
69
|
);
|
|
71
|
-
}
|
|
70
|
+
}
|