@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.
Files changed (140) hide show
  1. package/.prettierrc.js +1 -3
  2. package/.watestrc.js +7 -3
  3. package/bin/watest.js +3 -8
  4. package/core/base.js +83 -69
  5. package/core/core.js +25 -46
  6. package/core/format.js +96 -56
  7. package/core/process_args.js +1 -5
  8. package/core/series.js +62 -57
  9. package/core/settings.js +32 -32
  10. package/core/spawn.js +14 -21
  11. package/core/util.js +12 -19
  12. package/esling.config.js +0 -0
  13. package/eslint.config.js +27 -0
  14. package/index.js +11 -17
  15. package/interfaces/logger.js +1 -3
  16. package/interfaces/servicer.js +1 -3
  17. package/logging/filestream.js +3 -7
  18. package/logging/logging.js +5 -11
  19. package/logging/logpipe.js +21 -21
  20. package/package.json +12 -11
  21. package/tests/base/t_api.js +3 -6
  22. package/tests/base/t_contains.js +12 -12
  23. package/tests/base/t_core.js +11 -8
  24. package/tests/base/t_format.js +13 -14
  25. package/tests/base/t_is.js +9 -11
  26. package/tests/base/t_is_object.js +23 -25
  27. package/tests/base/t_is_primitive.js +12 -14
  28. package/tests/base/t_is_string.js +6 -8
  29. package/tests/base/t_ok.js +4 -6
  30. package/tests/base/t_stringify.js +6 -8
  31. package/tests/base/t_test_.js +3 -5
  32. package/tests/base/t_throws.js +82 -18
  33. package/tests/base/test.js +14 -21
  34. package/tests/e2e/samples/{loader/.watestrc.cjs → folder/.watestrc.js} +1 -1
  35. package/tests/e2e/samples/folder/package-lock.json +1019 -5940
  36. package/tests/e2e/samples/folder/package.json +3 -2
  37. package/tests/e2e/samples/folder/tests/meta.js +1 -1
  38. package/tests/e2e/samples/folder/tests/unit/t_test.js +3 -3
  39. package/tests/e2e/samples/{loader_mixed/.watestrc.cjs → loader/.watestrc.js} +1 -1
  40. package/tests/e2e/samples/loader/package-lock.json +1751 -28
  41. package/tests/e2e/samples/loader/package.json +2 -2
  42. package/tests/e2e/samples/loader/tests/meta.js +2 -2
  43. package/tests/e2e/samples/{folder/.watestrc.cjs → loader_mixed/.watestrc.js} +1 -1
  44. package/tests/e2e/samples/loader_mixed/package-lock.json +1751 -28
  45. package/tests/e2e/samples/loader_mixed/tests/ui/meta.js +2 -2
  46. package/tests/e2e/samples/loader_multiple/{.watestrc.cjs → .watestrc.js} +1 -1
  47. package/tests/e2e/samples/loader_multiple/package-lock.json +1751 -28
  48. package/tests/e2e/samples/loader_multiple/package.json +2 -2
  49. package/tests/e2e/samples/loader_multiple/tests/base/meta.js +2 -2
  50. package/tests/e2e/samples/loader_multiple/tests/core/meta.js +2 -2
  51. package/tests/e2e/samples/single/.watestrc.js +5 -0
  52. package/tests/e2e/samples/single/package-lock.json +1017 -5938
  53. package/tests/e2e/samples/single/package.json +5 -2
  54. package/tests/e2e/samples/wd_mixed/{.watestrc.cjs → .watestrc.js} +1 -1
  55. package/tests/e2e/samples/wd_mixed/package-lock.json +779 -4862
  56. package/tests/e2e/samples/wd_mixed/package.json +2 -2
  57. package/tests/e2e/samples/wd_single/{.watestrc.cjs → .watestrc.js} +1 -1
  58. package/tests/e2e/samples/wd_single/package-lock.json +779 -4862
  59. package/tests/e2e/samples/wd_single/package.json +2 -2
  60. package/tests/e2e/t_folder.js +4 -6
  61. package/tests/e2e/t_loader.js +4 -6
  62. package/tests/e2e/t_loader_mixed.js +4 -6
  63. package/tests/e2e/t_loader_multiple.js +4 -6
  64. package/tests/e2e/t_loader_multiple_patterns.js +4 -6
  65. package/tests/e2e/t_single.js +4 -6
  66. package/tests/e2e/t_wd_firefox.js +4 -6
  67. package/tests/e2e/t_wd_firefox_chrome.js +4 -6
  68. package/tests/e2e/t_wd_firefox_chrome_pattern.js +4 -6
  69. package/tests/e2e/t_wd_mixed_firefox.js +4 -6
  70. package/tests/e2e/t_wd_mixed_firefox_chrome.js +4 -6
  71. package/tests/e2e/test.js +15 -16
  72. package/tests/meta.js +1 -3
  73. package/tests/series/build/t_adjust_names.js +4 -6
  74. package/tests/series/build/t_adjust_names_webdriver.js +6 -10
  75. package/tests/series/build/t_expected_failures.js +4 -6
  76. package/tests/series/build/t_loader.js +4 -6
  77. package/tests/series/build/t_loader_mixed.js +4 -6
  78. package/tests/series/build/t_mixed.js +4 -6
  79. package/tests/series/build/t_nested.js +4 -6
  80. package/tests/series/build/t_patterns_loader.js +4 -6
  81. package/tests/series/build/t_patterns_webdriver.js +4 -6
  82. package/tests/series/build/t_webdriver.js +4 -6
  83. package/tests/series/build/t_webdriver_firefox_mixed.js +4 -6
  84. package/tests/series/build/t_webdriver_nested.js +4 -6
  85. package/tests/series/build/t_webdriver_services.js +4 -6
  86. package/tests/series/generic/t_failures_info.js +9 -12
  87. package/tests/series/loader/meta.mjs +2 -2
  88. package/tests/series/logging/t_failures.js +18 -20
  89. package/tests/series/logging/t_success.js +15 -17
  90. package/tests/series/logging/t_verify.js +17 -14
  91. package/tests/series/meta.js +1 -3
  92. package/tests/series/mock_series.js +7 -13
  93. package/tests/series/perform/t_failure.js +4 -6
  94. package/tests/series/perform/t_failure_notest.js +4 -6
  95. package/tests/series/perform/t_intermittent.js +5 -7
  96. package/tests/series/perform/t_intermittent_global.js +4 -6
  97. package/tests/series/perform/t_missing_perma.js +5 -7
  98. package/tests/series/perform/t_nested.js +4 -10
  99. package/tests/series/perform/t_perma.js +4 -6
  100. package/tests/series/perform/t_success.js +5 -11
  101. package/tests/series/run/t_debunk_failure.js +7 -6
  102. package/tests/series/run/t_debunk_success.js +7 -6
  103. package/tests/series/run/t_nested.js +7 -6
  104. package/tests/series/run/t_verify.js +7 -6
  105. package/tests/series/run/t_verify_webdriver.js +7 -6
  106. package/tests/series/test.js +29 -40
  107. package/tests/webdriver/meta.js +1 -3
  108. package/tests/webdriver/t_app_driver.js +3 -5
  109. package/tests/webdriver/t_app_driver_selectors.js +3 -5
  110. package/tests/webdriver/t_attribute.js +5 -7
  111. package/tests/webdriver/t_attribute_all.js +6 -8
  112. package/tests/webdriver/t_doubleclick.js +3 -5
  113. package/tests/webdriver/t_doubleclickat.js +3 -5
  114. package/tests/webdriver/t_execute.js +4 -6
  115. package/tests/webdriver/t_if_has_elements.js +6 -8
  116. package/tests/webdriver/t_if_no_elements.js +6 -8
  117. package/tests/webdriver/t_no_elements_or_not_visible.js +7 -9
  118. package/tests/webdriver/t_properties.js +11 -13
  119. package/tests/webdriver/t_script.js +8 -10
  120. package/tests/webdriver/t_select_all.js +6 -11
  121. package/tests/webdriver/t_selection.js +4 -6
  122. package/tests/webdriver/t_text.js +12 -14
  123. package/tests/webdriver/t_text_all.js +6 -8
  124. package/tests/webdriver/test.js +32 -41
  125. package/webdriver/app_driver.js +28 -19
  126. package/webdriver/control_driver.js +4 -8
  127. package/webdriver/driver.js +64 -63
  128. package/webdriver/driver_base.js +52 -62
  129. package/webdriver/session.js +6 -11
  130. package/webdriver/util.js +7 -8
  131. package/.eslintrc.js +0 -45
  132. package/index.mjs +0 -5
  133. package/tests/e2e/samples/folder/node_modules/.package-lock.json +0 -3871
  134. package/tests/e2e/samples/loader/node_modules/.package-lock.json +0 -36
  135. package/tests/e2e/samples/loader_mixed/node_modules/.package-lock.json +0 -36
  136. package/tests/e2e/samples/loader_multiple/node_modules/.package-lock.json +0 -36
  137. package/tests/e2e/samples/single/.watestrc.cjs +0 -5
  138. package/tests/e2e/samples/single/node_modules/.package-lock.json +0 -3871
  139. package/tests/e2e/samples/wd_mixed/node_modules/.package-lock.json +0 -3586
  140. package/tests/e2e/samples/wd_single/node_modules/.package-lock.json +0 -3586
package/core/format.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ const esc_char = ''; // \x1b
2
2
 
3
3
  const colors = {
4
4
  group: '36',
@@ -13,17 +13,17 @@ const colors = {
13
13
  intermittents: '105',
14
14
  todos: '103',
15
15
  warnings: '103',
16
- failures: '41m\x1b[37',
16
+ failures: `41m${esc_char}[37`,
17
17
  success: '102',
18
18
  };
19
19
 
20
20
  const codes = new Map(
21
- Array.from(Object.keys(colors)).map(key => [colors[key], key])
21
+ Array.from(Object.keys(colors)).map(key => [colors[key], key]),
22
22
  );
23
23
 
24
24
  // Colorifies the message.
25
25
  function colorify(color, label, msg) {
26
- return `\x1b[${colors[color]}m${label}\x1b[0m ${msg}`;
26
+ return `${esc_char}[${colors[color]}m${label}${esc_char}[0m ${msg}`;
27
27
  }
28
28
 
29
29
  // Parses the given message.
@@ -53,60 +53,100 @@ function parse_failure(str) {
53
53
  return null;
54
54
  }
55
55
 
56
- module.exports = {
57
- colorify,
58
- parse,
59
- parse_failure,
56
+ function format_started(msg) {
57
+ return colorify('started', 'Started', msg);
58
+ }
59
+
60
+ function format_completed(msg) {
61
+ return colorify('completed', 'Completed', msg);
62
+ }
63
+
64
+ function format_intermittent(msg) {
65
+ return colorify('intermittent', 'Intermittent:', msg);
66
+ }
67
+
68
+ function format_intermittents(count, context) {
69
+ let label = context ? `${context} > intermittents` : 'Intermittents';
70
+ return colorify('intermittents', label, `Total: ${count}`);
71
+ }
60
72
 
61
- format_started(msg) {
62
- return colorify('started', 'Started', msg);
63
- },
64
- format_completed(msg) {
65
- return colorify('completed', 'Completed', msg);
66
- },
67
- format_intermittent(msg) {
68
- return colorify('intermittent', 'Intermittent:', msg);
69
- },
70
- format_intermittents(count, context) {
71
- let label = context ? `${context} > intermittents` : 'Intermittents';
72
- return colorify('intermittents', label, `Total: ${count}`);
73
- },
74
- format_failure(msg, label) {
75
- return colorify('failure', label || 'Failed:', msg);
76
- },
77
- format_failures(count, context_or_okcount, context) {
78
- if (typeof context_or_okcount == 'string') {
79
- return colorify(
80
- 'failures',
81
- `>${context_or_okcount}`,
82
- `Failure count: ${count}`
83
- );
84
- }
85
- let label = !context ? 'Failed!' : `${context} > failed`;
73
+ function format_failure(msg, label) {
74
+ return colorify('failure', label || 'Failed:', msg);
75
+ }
76
+
77
+ function format_failures(count, context_or_okcount, context) {
78
+ if (typeof context_or_okcount == 'string') {
86
79
  return colorify(
87
80
  'failures',
88
- label,
89
- `Passed: ${context_or_okcount}. Failed: ${count}`
81
+ `>${context_or_okcount}`,
82
+ `Failure count: ${count}`,
90
83
  );
91
- },
92
- format_ok(msg) {
93
- return colorify('ok', 'Ok:', msg);
94
- },
95
- format_success(okcount, context) {
96
- return colorify('success', context || 'Success!', `Total: ${okcount}`);
97
- },
98
- format_todo(msg) {
99
- return colorify('todo', 'Todo:', msg);
100
- },
101
- format_todos(count, context) {
102
- let label = context ? `${context} > todos` : 'Todos';
103
- return colorify('todos', label, `Total: ${count}`);
104
- },
105
- format_warning(msg) {
106
- return colorify('warning', 'Warning:', msg);
107
- },
108
- format_warnings(count, context) {
109
- let label = context ? `${context} > warnings` : 'Warnings';
110
- return colorify('warnings', label, `Total: ${count}`);
111
- },
84
+ }
85
+ let label = !context ? 'Failed!' : `${context} > failed`;
86
+ return colorify(
87
+ 'failures',
88
+ label,
89
+ `Passed: ${context_or_okcount}. Failed: ${count}`,
90
+ );
91
+ }
92
+
93
+ function format_ok(msg) {
94
+ return colorify('ok', 'Ok:', msg);
95
+ }
96
+
97
+ function format_success(okcount, context) {
98
+ return colorify('success', context || 'Success!', `Total: ${okcount}`);
99
+ }
100
+
101
+ function format_todo(msg) {
102
+ return colorify('todo', 'Todo:', msg);
103
+ }
104
+
105
+ function format_todos(count, context) {
106
+ let label = context ? `${context} > todos` : 'Todos';
107
+ return colorify('todos', label, `Total: ${count}`);
108
+ }
109
+
110
+ function format_warning(msg) {
111
+ return colorify('warning', 'Warning:', msg);
112
+ }
113
+
114
+ function format_warnings(count, context) {
115
+ let label = context ? `${context} > warnings` : 'Warnings';
116
+ return colorify('warnings', label, `Total: ${count}`);
117
+ }
118
+
119
+ // Node v20 wraps stderr by '\[31m' and '\[39m' characters.
120
+ function stderr_wrap(s) {
121
+ return `${s}`;
122
+ }
123
+
124
+ function stderr_unwrap(s) {
125
+ // eslint-disable-next-line no-control-regex
126
+ return s.replace(/\[31m(.*?)\[39m(\n?)/gs, '$1$2');
127
+ }
128
+
129
+ function stderr_format_failure(...args) {
130
+ return stderr_wrap(format_failure(...args));
131
+ }
132
+
133
+ export {
134
+ colorify,
135
+ parse,
136
+ parse_failure,
137
+ format_started,
138
+ format_completed,
139
+ format_intermittent,
140
+ format_intermittents,
141
+ format_failure,
142
+ format_failures,
143
+ format_ok,
144
+ format_success,
145
+ format_todo,
146
+ format_todos,
147
+ format_warning,
148
+ format_warnings,
149
+ stderr_wrap,
150
+ stderr_unwrap,
151
+ stderr_format_failure,
112
152
  };
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  class ProcessArgs {
4
2
  static asObject() {
5
3
  let obj = {
@@ -68,6 +66,4 @@ class ProcessArgs {
68
66
  }
69
67
  }
70
68
 
71
- module.exports = {
72
- ProcessArgs,
73
- };
69
+ export { ProcessArgs };
package/core/series.js CHANGED
@@ -1,21 +1,18 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const nodepath = path;
6
-
7
- const { log, log_error } = require('../logging/logging.js');
8
- const { DriverBase } = require('../webdriver/driver_base.js');
9
- const testflow = require('./core.js');
10
- const { parse, parse_failure } = require('./format.js');
11
- const { ProcessArgs } = require('./process_args.js');
12
- const settings = require('./settings.js');
13
- const { spawn } = require('./spawn');
14
- const { stringify } = require('./util.js');
15
-
16
- const { assert, fail } = testflow;
17
-
18
- const {
1
+ import fs from 'fs';
2
+ import nodepath from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ import { assert, fail, testflow } from './core.js';
6
+ import { parse, parse_failure } from './format.js';
7
+ import { ProcessArgs } from './process_args.js';
8
+ import settings from './settings.js';
9
+ import { spawn } from './spawn.js';
10
+ import { stringify } from './util.js';
11
+ import { log, log_error } from '../logging/logging.js';
12
+ import { LogPipe } from '../logging/logpipe.js';
13
+ import { DriverBase } from '../webdriver/driver_base.js';
14
+
15
+ import {
19
16
  format_started,
20
17
  format_completed,
21
18
  format_failure,
@@ -25,10 +22,13 @@ const {
25
22
  format_todos,
26
23
  format_warnings,
27
24
  colorify,
28
- } = require('./format.js');
25
+ } from './format.js';
26
+
27
+ const __filename = fileURLToPath(import.meta.url);
28
+ const __dirname = nodepath.dirname(__filename);
29
29
 
30
30
  const root_folder = 'tests';
31
- const root_dir = path.resolve('.');
31
+ const root_dir = nodepath.resolve('.');
32
32
 
33
33
  const kKungFuDeathGripTimeout = {};
34
34
  const kKungFuDeathGripCancelled = {};
@@ -44,7 +44,7 @@ process.on('unhandledRejection', error => {
44
44
  class Series {
45
45
  static run(patterns, options) {
46
46
  if (!('LogPipe' in options)) {
47
- options.LogPipe = require('../logging/logpipe.js').LogPipe;
47
+ options.LogPipe = LogPipe;
48
48
  }
49
49
  options.LogPipe.suppress_logging = options.childProcess;
50
50
 
@@ -57,7 +57,7 @@ class Series {
57
57
  .run()
58
58
  .then(() =>
59
59
  // shutdown returns list of failures or null if no failures
60
- options.LogPipe.release()
60
+ options.LogPipe.release(),
61
61
  )
62
62
  .then(
63
63
  () => series.shutdown(),
@@ -66,7 +66,7 @@ class Series {
66
66
  fail(e.message);
67
67
  log_error(e);
68
68
  return failures;
69
- }
69
+ },
70
70
  );
71
71
  });
72
72
  }
@@ -86,7 +86,7 @@ class Series {
86
86
  LogPipe,
87
87
  webdriver,
88
88
  webdrivers = settings.webdrivers,
89
- }
89
+ },
90
90
  ) {
91
91
  this.debunk = debunk;
92
92
  this.invocation = invocation || settings.invocation;
@@ -107,7 +107,7 @@ class Series {
107
107
  this.ocnt = 0;
108
108
 
109
109
  this.core = core || testflow.core;
110
- testflow.lock(this.core);
110
+ testflow.lock({ core: this.core });
111
111
 
112
112
  this.core.setTimeout(timeout);
113
113
  this.core.clearStats();
@@ -128,7 +128,7 @@ class Series {
128
128
  this.patterns.map(pattern => ({
129
129
  path: pattern,
130
130
  webdriver: this.webdriver,
131
- }))
131
+ })),
132
132
  );
133
133
 
134
134
  // In debunk mode re-run tests until it fails.
@@ -171,8 +171,8 @@ class Series {
171
171
  colorify(
172
172
  'failures',
173
173
  '!Failed:',
174
- `no tests matching '${stringify(patterns)}' pattern(s) found`
175
- )
174
+ `no tests matching '${stringify(patterns)}' pattern(s) found`,
175
+ ),
176
176
  );
177
177
  return Promise.resolve();
178
178
  }
@@ -206,7 +206,7 @@ class Series {
206
206
 
207
207
  if (test_module.expected_failures) {
208
208
  inherited_expected_failures = inherited_expected_failures.concat(
209
- test_module.expected_failures.filter(v => v[0] == '**')
209
+ test_module.expected_failures.filter(v => v[0] == '**'),
210
210
  );
211
211
  }
212
212
 
@@ -251,7 +251,7 @@ class Series {
251
251
  // A separate folder for the webdriver tests.
252
252
  assert(
253
253
  this.webdrivers instanceof Array,
254
- `Webdrivers are misconfigured, got: ${JSON.stringify(this.webdrivers)}`
254
+ `Webdrivers are misconfigured, got: ${JSON.stringify(this.webdrivers)}`,
255
255
  );
256
256
 
257
257
  // Build the tests for webdrivers. Filter the list according traversed
@@ -378,8 +378,8 @@ class Series {
378
378
  }).then(subtests => ({
379
379
  subfolder,
380
380
  subtests,
381
- }))
382
- )
381
+ })),
382
+ ),
383
383
  );
384
384
 
385
385
  return subtests_for_subfolders
@@ -425,7 +425,7 @@ class Series {
425
425
  }
426
426
 
427
427
  const expected_failures = inherited_expected_failures.concat(
428
- test_module.expected_failures || []
428
+ test_module.expected_failures || [],
429
429
  );
430
430
 
431
431
  // Initialize
@@ -494,7 +494,7 @@ class Series {
494
494
  await Promise.all(
495
495
  [...(test_module.services || [])]
496
496
  .reverse()
497
- .map(s => settings.servicer.stop(s))
497
+ .map(s => settings.servicer.stop(s)),
498
498
  );
499
499
  };
500
500
  tests.push({
@@ -533,7 +533,7 @@ class Series {
533
533
  list = list.filter(
534
534
  test =>
535
535
  this.matchedPatterns({ path: test.path, webdriver, patterns })
536
- .length != 0
536
+ .length != 0,
537
537
  );
538
538
  }
539
539
 
@@ -545,7 +545,7 @@ class Series {
545
545
  pattern =>
546
546
  (!webdriver || !pattern.webdriver || pattern.webdriver == webdriver) &&
547
547
  (path.startsWith(pattern.path) ||
548
- (path_is_not_final && pattern.path.startsWith(path)))
548
+ (path_is_not_final && pattern.path.startsWith(path))),
549
549
  );
550
550
  }
551
551
 
@@ -647,18 +647,18 @@ class Series {
647
647
  // If timeout is given then race it against the test.
648
648
  if (settings.timeout) {
649
649
  kungFuDeathGrip = new Promise(
650
- resolve => (kungFuDeathGripResolve = resolve)
650
+ resolve => (kungFuDeathGripResolve = resolve),
651
651
  ).then(value => {
652
652
  if (value != kKungFuDeathGripCancelled) {
653
653
  fail(
654
- `Test ${name} takes longer than ${settings.timeout}ms. It's either slow or never ends.`
654
+ `Test ${name} takes longer than ${settings.timeout}ms. It's either slow or never ends.`,
655
655
  );
656
656
  return kKungFuDeathGripTimeout;
657
657
  }
658
658
  });
659
659
  kungFuDeathGripTimer = setTimeout(
660
660
  kungFuDeathGripResolve,
661
- settings.timeout
661
+ settings.timeout,
662
662
  );
663
663
  let retval = await Promise.race([func(), kungFuDeathGrip]);
664
664
  if (retval != kKungFuDeathGripTimeout) {
@@ -825,8 +825,8 @@ class Series {
825
825
  format_failures(
826
826
  this.core.failureCount - fcnt,
827
827
  this.core.okCount - ocnt,
828
- !is_root && folder
829
- )
828
+ !is_root && folder,
829
+ ),
830
830
  );
831
831
  } else {
832
832
  log_func(format_success(this.core.okCount - ocnt, !is_root && folder));
@@ -835,7 +835,7 @@ class Series {
835
835
 
836
836
  static failuresInfo({ failures, webdriver, platform, testname }) {
837
837
  let filtered_failures = failures.filter(
838
- v => testname.includes(v[0]) || v[0] == '*' || v[0] == '**'
838
+ v => testname.includes(v[0]) || v[0] == '*' || v[0] == '**',
839
839
  );
840
840
 
841
841
  return (
@@ -865,13 +865,14 @@ class Series {
865
865
  async loadTestMeta(folder) {
866
866
  try {
867
867
  return await import(this.getTestMetaPath(folder));
868
+ // eslint-disable-next-line no-unused-vars
868
869
  } catch (e) {
869
870
  return {}; // no meta.js
870
871
  }
871
872
  }
872
873
 
873
874
  loadTest(test_path) {
874
- return import(path.join(root_dir, test_path)).then(
875
+ return import(nodepath.join(root_dir, test_path)).then(
875
876
  test_module => {
876
877
  if (!test_module.test) {
877
878
  throw new Error(`No test was found in ${test_path}`);
@@ -881,32 +882,33 @@ class Series {
881
882
  e => {
882
883
  log_error(e);
883
884
  throw new Error(`Failed to load test: ${test_path}`);
884
- }
885
+ },
885
886
  );
886
887
  }
887
888
 
888
889
  getTestMetaPath(folder) {
889
- let meta_path = path.join(root_dir, `${folder}/meta.js`);
890
+ let meta_path = nodepath.join(root_dir, `${folder}/meta.js`);
890
891
  return (
891
892
  (fs.existsSync(meta_path) && meta_path) ||
892
- path.join(root_dir, `${folder}/meta.mjs`)
893
+ nodepath.join(root_dir, `${folder}/meta.mjs`)
893
894
  );
894
895
  }
895
896
 
896
897
  getTestFileList(folder) {
897
898
  return fs
898
- .readdirSync(path.join(root_dir, folder))
899
+ .readdirSync(nodepath.join(root_dir, folder))
899
900
  .filter(
900
901
  n =>
901
902
  n.startsWith('t_') &&
902
- (!settings.ignorePattern || !settings.ignorePattern.test(n))
903
+ (!settings.ignorePattern || !settings.ignorePattern.test(n)),
903
904
  );
904
905
  }
905
906
 
906
907
  performInChildProcess({ name, path, loader, webdriver }) {
907
908
  let args = [];
908
909
  if (loader) {
909
- args.push('--loader', loader);
910
+ // Use the new --import flag with register() API instead of deprecated --loader
911
+ args.push('--import', `data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("${loader}", pathToFileURL("./"));`);
910
912
  }
911
913
  const watest_bin = nodepath.join(__dirname, '../bin/watest.js');
912
914
  args.push(
@@ -916,14 +918,14 @@ class Series {
916
918
  '--root-folder',
917
919
  nodepath.join(name, '../'),
918
920
  ...ProcessArgs.controlArguments,
919
- path
921
+ path,
920
922
  );
921
923
  if (webdriver) {
922
924
  args.push('--webdriver', webdriver);
923
925
  }
924
926
 
925
927
  return spawn('node', args, {}, buffer =>
926
- this.processChildProcessOutput(name, buffer)
928
+ this.processChildProcessOutput(name, buffer),
927
929
  ).catch(e => {
928
930
  log_error(e);
929
931
  fail(`Failed to process child process output`);
@@ -944,22 +946,22 @@ class Series {
944
946
  if (line.startsWith('console.debug')) {
945
947
  line = line.replace(
946
948
  /console\.debug: "(.+)"/,
947
- (match, p) => `[DEBUG] ${p}`
949
+ (match, p) => `[DEBUG] ${p}`,
948
950
  );
949
951
  } else if (line.startsWith('console.log')) {
950
952
  line = line.replace(
951
953
  /console\.log: "(.+)"/,
952
- (match, p) => `[INFO] ${p}`
954
+ (match, p) => `[INFO] ${p}`,
953
955
  );
954
956
  } else if (line.startsWith('console.assert')) {
955
957
  line = line.replace(
956
958
  /console\.assert: "(.+)"/,
957
- (match, p) => `[SEVERE] ${p}`
959
+ (match, p) => `[SEVERE] ${p}`,
958
960
  );
959
961
  } else if (line.startsWith('console.error')) {
960
962
  line = line.replace(
961
963
  /console\.error: "(.+)"/,
962
- (match, p) => `[SEVERE] ${p}`
964
+ (match, p) => `[SEVERE] ${p}`,
963
965
  );
964
966
  } else if (line.startsWith('data:text/html,')) {
965
967
  line = line.replace(/\S*/, '@dataurl_placeholder');
@@ -1018,5 +1020,8 @@ class Series {
1018
1020
  }
1019
1021
  }
1020
1022
 
1021
- module.exports.Series = Series;
1022
- module.exports.runSeries = (...args) => Series.run(...args);
1023
+ export { Series };
1024
+
1025
+ export function runSeries(...args) {
1026
+ return Series.run(...args);
1027
+ }
package/core/settings.js CHANGED
@@ -1,13 +1,4 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
-
5
- let rc = null;
6
- try {
7
- rc = require(path.resolve('.', './.watestrc.js'));
8
- } catch (e) {
9
- rc = require(path.resolve('.', './.watestrc.cjs'));
10
- }
1
+ import path from 'path';
11
2
 
12
3
  class Settings {
13
4
  constructor() {
@@ -16,20 +7,22 @@ class Settings {
16
7
  this.tmp_storage_dir = '';
17
8
  this.logger = null;
18
9
  this.servicer = null;
19
-
20
- this.setupTmpStorageDir();
21
- this.setupLogDir();
22
- this.setupWebdrivers();
23
10
  }
24
11
 
25
12
  async initialize() {
13
+ this.rc = (await import(path.resolve('.', './.watestrc.js'))).default;
14
+
26
15
  this.logger = (
27
- await import(rc.logger || '../interfaces/logger.js')
16
+ await import(this.rc.logger || '../interfaces/logger.js')
28
17
  ).default;
29
18
 
30
19
  this.servicer = (
31
- await import(rc.servicer || '../interfaces/servicer.js')
20
+ await import(this.rc.servicer || '../interfaces/servicer.js')
32
21
  ).default;
22
+
23
+ this.setupTmpStorageDir();
24
+ this.setupLogDir();
25
+ this.setupWebdrivers();
33
26
  }
34
27
 
35
28
  get invocation() {
@@ -41,64 +34,71 @@ class Settings {
41
34
  break;
42
35
  }
43
36
 
44
- this._invocation = rc.invocation || `${platform}`;
37
+ this._invocation = this.rc.invocation || `${platform}`;
45
38
  }
46
39
  return this._invocation;
47
40
  }
48
41
 
49
42
  get ignorePattern() {
50
- return rc.ignore_pattern && new RegExp(rc.ignore_pattern);
43
+ return this.rc.ignore_pattern && new RegExp(this.rc.ignore_pattern);
51
44
  }
52
45
 
53
46
  get debunkLimit() {
54
- return parseInt(rc.debunk_limit) || 5;
47
+ return parseInt(this.rc.debunk_limit) || 5;
55
48
  }
56
49
 
57
50
  get timeout() {
58
- return parseInt(rc.timeout) || 0;
51
+ return parseInt(this.rc.timeout) || 0;
59
52
  }
60
53
 
61
54
  setupTmpStorageDir() {
62
- if (!rc.tmp_dir) {
55
+ if (!this.rc.tmp_dir) {
63
56
  console.log(`Settings: no temporary storage dir`);
64
57
  return;
65
58
  }
66
59
 
67
- this.tmp_storage_dir = path.join(rc.tmp_dir, 'watest-tmpstorage');
60
+ this.tmp_storage_dir = path.join(this.rc.tmp_dir, 'watest-tmpstorage');
68
61
  console.log(
69
- `Settings: temporary storage dir is at ${this.tmp_storage_dir}`
62
+ `Settings: temporary storage dir is at ${this.tmp_storage_dir}`,
70
63
  );
71
64
  }
72
65
 
73
66
  setupLogDir() {
74
- const log_dir = rc.log_dir;
67
+ const log_dir = this.rc.log_dir;
75
68
  if (!log_dir) {
76
69
  console.log('Settings: no file logging');
77
70
  return;
78
71
  }
79
72
 
80
- this.run = rc.run || `${parseInt(Date.now() / 1000)}`;
73
+ this.run = this.rc.run || `${parseInt(Date.now() / 1000)}`;
81
74
 
82
75
  this.log_dir = path.join(log_dir, this.run);
83
76
  console.log(`Settings: logging into ${log_dir}`);
84
77
  }
85
78
 
86
79
  setupWebdrivers() {
87
- this.webdrivers = rc.webdrivers;
88
- if (typeof rc.webdrivers == 'string') {
80
+ this.webdrivers = this.rc.webdrivers;
81
+ if (typeof this.rc.webdrivers == 'string') {
89
82
  try {
90
- this.webdrivers = JSON.parse(rc.webdrivers);
83
+ this.webdrivers = JSON.parse(this.rc.webdrivers);
91
84
  } catch (e) {
92
85
  console.error(
93
- `Settings: failed to parse webdrivers '${rc.webdrivers}'`
86
+ `Settings: failed to parse webdrivers '${this.rc.webdrivers}'`,
87
+ e,
94
88
  );
95
89
  }
96
90
  }
97
91
 
98
92
  this.webdriver = null;
99
93
  this.webdriver_headless =
100
- rc.webdriver_headless == true || rc.webdriver_headless == 'true';
101
- this.webdriver_loglevel = rc.webdriver_loglevel;
94
+ this.rc.webdriver_headless == true ||
95
+ this.rc.webdriver_headless == 'true';
96
+ this.webdriver_loglevel = this.rc.webdriver_loglevel;
97
+
98
+ this.webdriver_window_width =
99
+ parseInt(this.rc.webdriver_window_width) || 1366;
100
+ this.webdriver_window_height =
101
+ parseInt(this.rc.webdriver_window_height) || 768;
102
102
 
103
103
  if (this.webdrivers) {
104
104
  console.log(`Settings: ${this.webdrivers.join(', ')} webdrivers`);
@@ -106,4 +106,4 @@ class Settings {
106
106
  }
107
107
  }
108
108
 
109
- module.exports = new Settings();
109
+ export default new Settings();