@camperaid/watest 2.5.1 → 2.5.3

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 (162) hide show
  1. package/README.md +274 -129
  2. package/bin/watest.js +36 -2
  3. package/core/core.js +43 -15
  4. package/core/deps.js +211 -0
  5. package/core/{process_args.js → process-args.js} +8 -0
  6. package/core/series.js +41 -40
  7. package/core/settings.js +27 -9
  8. package/core/util.js +1 -1
  9. package/index.js +5 -3
  10. package/interfaces/servicer.js +13 -2
  11. package/logging/logging.js +1 -1
  12. package/logging/logpipe.js +38 -21
  13. package/package.json +1 -1
  14. package/tests/base/{t_core.js → t-core.js} +10 -3
  15. package/tests/base/test.js +1 -2
  16. package/tests/deps/samples/nested/.watestrc.js +3 -0
  17. package/tests/deps/samples/nested/tests/meta.js +1 -0
  18. package/tests/deps/samples/nested/tests/services/meta.js +1 -0
  19. package/tests/deps/samples/nested/tests/services/ws/meta.js +1 -0
  20. package/tests/deps/samples/nested/tests/services/ws/webservice/meta.js +2 -0
  21. package/tests/deps/samples/nested/tests/services/ws/webservice/t-ws.js +3 -0
  22. package/tests/deps/samples/unified/.watestrc.js +3 -0
  23. package/tests/deps/samples/unified/tests/e2e/meta.js +4 -0
  24. package/tests/deps/samples/unified/tests/e2e/pages/meta.js +1 -0
  25. package/tests/deps/samples/unified/tests/e2e/pages/t-example.js +3 -0
  26. package/tests/deps/samples/unified/tests/e2e/t-example.js +3 -0
  27. package/tests/deps/samples/unified/tests/integration/meta.js +3 -0
  28. package/tests/deps/samples/unified/tests/lib/meta.js +0 -0
  29. package/tests/deps/samples/unified/tests/lib/t-example.js +3 -0
  30. package/tests/deps/samples/unified/tests/meta.js +8 -0
  31. package/tests/deps/samples/unified/tests/services/meta.js +3 -0
  32. package/tests/deps/samples/unified/tests/services/request/meta.js +1 -0
  33. package/tests/deps/samples/unified/tests/services/t-example.js +3 -0
  34. package/tests/deps/t-parse-cell-syntax.js +6 -0
  35. package/tests/deps/t-parse-grid-args.js +11 -0
  36. package/tests/deps/t-watest-deps.js +37 -0
  37. package/tests/deps/t-watest-grid.js +122 -0
  38. package/tests/deps/test.js +63 -0
  39. package/tests/e2e/samples/folder/package-lock.json +3 -1
  40. package/tests/e2e/samples/loader/package-lock.json +3 -1
  41. package/tests/e2e/samples/loader/tests/meta.js +1 -1
  42. package/tests/e2e/samples/{loader_mixed → loader-mixed}/package-lock.json +3 -1
  43. package/tests/e2e/samples/{loader_multiple/tests/core → loader-mixed/tests/ui}/meta.js +1 -1
  44. package/tests/e2e/samples/{loader_multiple → loader-multiple}/package-lock.json +3 -1
  45. package/tests/e2e/samples/{loader_multiple → loader-multiple}/tests/base/meta.js +1 -1
  46. package/tests/e2e/samples/{loader_mixed/tests/ui → loader-multiple/tests/core}/meta.js +1 -1
  47. package/tests/e2e/samples/single/package-lock.json +3 -1
  48. package/tests/e2e/samples/{wd_mixed → wd-mixed}/package-lock.json +3 -1
  49. package/tests/e2e/samples/{wd_single → wd-single}/package-lock.json +3 -1
  50. package/tests/e2e/{t_folder.js → t-folder.js} +2 -2
  51. package/tests/e2e/{t_loader_mixed.js → t-loader-mixed.js} +5 -5
  52. package/tests/e2e/{t_loader_multiple_patterns.js → t-loader-multiple-patterns.js} +6 -6
  53. package/tests/e2e/{t_loader_multiple.js → t-loader-multiple.js} +5 -5
  54. package/tests/e2e/{t_loader.js → t-loader.js} +2 -2
  55. package/tests/e2e/{t_single.js → t-single.js} +2 -2
  56. package/tests/e2e/{t_wd_firefox_chrome_pattern.js → t-wd-firefox-chrome-pattern.js} +6 -6
  57. package/tests/e2e/{t_wd_firefox_chrome.js → t-wd-firefox-chrome.js} +5 -5
  58. package/tests/e2e/{t_wd_firefox.js → t-wd-firefox.js} +3 -3
  59. package/tests/e2e/{t_wd_mixed_firefox_chrome.js → t-wd-mixed-firefox-chrome.js} +7 -7
  60. package/tests/e2e/{t_wd_mixed_firefox.js → t-wd-mixed-firefox.js} +5 -5
  61. package/tests/meta.js +1 -1
  62. package/tests/series/build/{t_webdriver_services.js → t-webdriver-services.js} +1 -0
  63. package/tests/series/logging/{t_failures.js → t-failures.js} +1 -1
  64. package/tests/series/logging/{t_success.js → t-success.js} +1 -1
  65. package/tests/series/logging/{t_verify.js → t-verify.js} +1 -1
  66. package/tests/series/servicer/mock-servicer.js +68 -0
  67. package/tests/series/servicer/t-nested-servicer-lifecycle.js +99 -0
  68. package/tests/series/servicer/t-servicer-no-services.js +53 -0
  69. package/tests/series/servicer/t-servicer-type-switching.js +139 -0
  70. package/tests/series/servicer/{t_servicer.js → t-servicer.js} +5 -38
  71. package/tests/series/test.js +1 -1
  72. package/tests/test.js +2 -0
  73. package/tests/webdriver/test.js +3 -3
  74. package/webdriver/{control_driver.js → control-driver.js} +1 -1
  75. package/webdriver/{driver_base.js → driver-base.js} +8 -1
  76. package/webdriver/driver.js +1 -1
  77. package/webdriver/session.js +57 -30
  78. /package/tests/base/{t_api.js → t-api.js} +0 -0
  79. /package/tests/base/{t_contains.js → t-contains.js} +0 -0
  80. /package/tests/base/{t_format.js → t-format.js} +0 -0
  81. /package/tests/base/{t_is_object.js → t-is-object.js} +0 -0
  82. /package/tests/base/{t_is_primitive.js → t-is-primitive.js} +0 -0
  83. /package/tests/base/{t_is_string.js → t-is-string.js} +0 -0
  84. /package/tests/base/{t_is.js → t-is.js} +0 -0
  85. /package/tests/base/{t_ok.js → t-ok.js} +0 -0
  86. /package/tests/base/{t_stringify.js → t-stringify.js} +0 -0
  87. /package/tests/base/{t_system.js → t-system.js} +0 -0
  88. /package/tests/base/{t_test_.js → t-test-.js} +0 -0
  89. /package/tests/base/{t_throws.js → t-throws.js} +0 -0
  90. /package/tests/e2e/samples/folder/tests/unit/{t_test.js → t-test.js} +0 -0
  91. /package/tests/e2e/samples/{loader_multiple/tests/module_mock.js → loader/tests/module-mock.js} +0 -0
  92. /package/tests/e2e/samples/loader/tests/{t_test.js → t-test.js} +0 -0
  93. /package/tests/e2e/samples/{loader_mixed → loader-mixed}/.watestrc.js +0 -0
  94. /package/tests/e2e/samples/{loader_mixed → loader-mixed}/package.json +0 -0
  95. /package/tests/e2e/samples/{loader_mixed → loader-mixed}/tests/meta.js +0 -0
  96. /package/tests/e2e/samples/{loader/tests/module_mock.js → loader-mixed/tests/module-mock.js} +0 -0
  97. /package/tests/e2e/samples/{loader_mixed → loader-mixed}/tests/module.js +0 -0
  98. /package/tests/e2e/samples/{loader_mixed/tests/ui/t_test.js → loader-mixed/tests/ui/t-test.js} +0 -0
  99. /package/tests/e2e/samples/{loader_mixed/tests/unit/t_test.js → loader-mixed/tests/unit/t-test.js} +0 -0
  100. /package/tests/e2e/samples/{loader_multiple → loader-multiple}/.watestrc.js +0 -0
  101. /package/tests/e2e/samples/{loader_multiple → loader-multiple}/package.json +0 -0
  102. /package/tests/e2e/samples/{loader_multiple/tests/base/t_btest.js → loader-multiple/tests/base/t-btest.js} +0 -0
  103. /package/tests/e2e/samples/{loader_multiple/tests/core/t_ctest.js → loader-multiple/tests/core/t-ctest.js} +0 -0
  104. /package/tests/e2e/samples/{loader_multiple → loader-multiple}/tests/meta.js +0 -0
  105. /package/tests/e2e/samples/{loader_mixed/tests/module_mock.js → loader-multiple/tests/module-mock.js} +0 -0
  106. /package/tests/e2e/samples/{loader_multiple → loader-multiple}/tests/module.js +0 -0
  107. /package/tests/e2e/samples/single/tests/{t_test.js → t-test.js} +0 -0
  108. /package/tests/e2e/samples/{wd_mixed → wd-mixed}/.watestrc.js +0 -0
  109. /package/tests/e2e/samples/{wd_mixed → wd-mixed}/package.json +0 -0
  110. /package/tests/e2e/samples/{wd_mixed → wd-mixed}/tests/meta.js +0 -0
  111. /package/tests/e2e/samples/{wd_mixed → wd-mixed}/tests/ui/meta.js +0 -0
  112. /package/tests/e2e/samples/{wd_mixed/tests/ui/t_test.js → wd-mixed/tests/ui/t-test.js} +0 -0
  113. /package/tests/e2e/samples/{wd_mixed/tests/unit/t_test.js → wd-mixed/tests/unit/t-test.js} +0 -0
  114. /package/tests/e2e/samples/{wd_single → wd-single}/.watestrc.js +0 -0
  115. /package/tests/e2e/samples/{wd_single → wd-single}/package.json +0 -0
  116. /package/tests/e2e/samples/{wd_single → wd-single}/tests/meta.js +0 -0
  117. /package/tests/e2e/samples/{wd_single/tests/t_test.js → wd-single/tests/t-test.js} +0 -0
  118. /package/tests/series/build/{t_adjust_names_webdriver.js → t-adjust-names-webdriver.js} +0 -0
  119. /package/tests/series/build/{t_adjust_names.js → t-adjust-names.js} +0 -0
  120. /package/tests/series/build/{t_expected_failures.js → t-expected-failures.js} +0 -0
  121. /package/tests/series/build/{t_loader_mixed.js → t-loader-mixed.js} +0 -0
  122. /package/tests/series/build/{t_loader.js → t-loader.js} +0 -0
  123. /package/tests/series/build/{t_mixed.js → t-mixed.js} +0 -0
  124. /package/tests/series/build/{t_nested.js → t-nested.js} +0 -0
  125. /package/tests/series/build/{t_pattern_filtering.js → t-pattern-filtering.js} +0 -0
  126. /package/tests/series/build/{t_patterns_loader.js → t-patterns-loader.js} +0 -0
  127. /package/tests/series/build/{t_patterns_webdriver.js → t-patterns-webdriver.js} +0 -0
  128. /package/tests/series/build/{t_webdriver_firefox_mixed.js → t-webdriver-firefox-mixed.js} +0 -0
  129. /package/tests/series/build/{t_webdriver_nested.js → t-webdriver-nested.js} +0 -0
  130. /package/tests/series/build/{t_webdriver.js → t-webdriver.js} +0 -0
  131. /package/tests/series/generic/{t_failures_info.js → t-failures-info.js} +0 -0
  132. /package/tests/series/{mock_series.js → mock-series.js} +0 -0
  133. /package/tests/series/perform/{t_failure_notest.js → t-failure-notest.js} +0 -0
  134. /package/tests/series/perform/{t_failure.js → t-failure.js} +0 -0
  135. /package/tests/series/perform/{t_intermittent_global.js → t-intermittent-global.js} +0 -0
  136. /package/tests/series/perform/{t_intermittent.js → t-intermittent.js} +0 -0
  137. /package/tests/series/perform/{t_missing_perma.js → t-missing-perma.js} +0 -0
  138. /package/tests/series/perform/{t_nested.js → t-nested.js} +0 -0
  139. /package/tests/series/perform/{t_perma.js → t-perma.js} +0 -0
  140. /package/tests/series/perform/{t_success.js → t-success.js} +0 -0
  141. /package/tests/series/run/{t_debunk_failure.js → t-debunk-failure.js} +0 -0
  142. /package/tests/series/run/{t_debunk_success.js → t-debunk-success.js} +0 -0
  143. /package/tests/series/run/{t_nested.js → t-nested.js} +0 -0
  144. /package/tests/series/run/{t_verify_webdriver.js → t-verify-webdriver.js} +0 -0
  145. /package/tests/series/run/{t_verify.js → t-verify.js} +0 -0
  146. /package/tests/webdriver/{t_app_driver_selectors.js → t-app-driver-selectors.js} +0 -0
  147. /package/tests/webdriver/{t_app_driver.js → t-app-driver.js} +0 -0
  148. /package/tests/webdriver/{t_attribute_all.js → t-attribute-all.js} +0 -0
  149. /package/tests/webdriver/{t_attribute.js → t-attribute.js} +0 -0
  150. /package/tests/webdriver/{t_doubleclick.js → t-doubleclick.js} +0 -0
  151. /package/tests/webdriver/{t_doubleclickat.js → t-doubleclickat.js} +0 -0
  152. /package/tests/webdriver/{t_execute.js → t-execute.js} +0 -0
  153. /package/tests/webdriver/{t_if_has_elements.js → t-if-has-elements.js} +0 -0
  154. /package/tests/webdriver/{t_if_no_elements.js → t-if-no-elements.js} +0 -0
  155. /package/tests/webdriver/{t_no_elements_or_not_visible.js → t-no-elements-or-not-visible.js} +0 -0
  156. /package/tests/webdriver/{t_properties.js → t-properties.js} +0 -0
  157. /package/tests/webdriver/{t_script.js → t-script.js} +0 -0
  158. /package/tests/webdriver/{t_select_all.js → t-select-all.js} +0 -0
  159. /package/tests/webdriver/{t_selection.js → t-selection.js} +0 -0
  160. /package/tests/webdriver/{t_text_all.js → t-text-all.js} +0 -0
  161. /package/tests/webdriver/{t_text.js → t-text.js} +0 -0
  162. /package/webdriver/{app_driver.js → app-driver.js} +0 -0
@@ -1,40 +1,5 @@
1
1
  import { is_test_output, success } from '../../base/test.js';
2
- import { log } from '../../../logging/logging.js';
3
- import { MockSeries } from '../mock_series.js';
4
-
5
- // Mock servicer that logs to console for output validation
6
- class MockServicer {
7
- constructor(type) {
8
- this.type = type;
9
- }
10
-
11
- async start(service) {
12
- log(`MockServicer:${this.type} starting ${service}`);
13
- return { started: service, type: this.type };
14
- }
15
-
16
- async stop(service) {
17
- log(`MockServicer:${this.type} stopping ${service}`);
18
- return { stopped: service, type: this.type };
19
- }
20
-
21
- async shutdown() {
22
- log(`MockServicer:${this.type} shutdown`);
23
- return { shutdown: true, type: this.type };
24
- }
25
-
26
- async ontest() {
27
- // Optional: log test notifications
28
- return null;
29
- }
30
- }
31
-
32
- // Extended MockSeries that uses our logging servicer
33
- class MockSeriesWithServicer extends MockSeries {
34
- createServicer(type) {
35
- return new MockServicer(type || 'default');
36
- }
37
- }
2
+ import { MockSeriesWithServicer } from './mock-servicer.js';
38
3
 
39
4
  export async function test() {
40
5
  const ts = {
@@ -60,6 +25,7 @@ export async function test() {
60
25
  'Settings: chrome webdrivers',
61
26
  '\x1B[38;5;99mStarted\x1B[0m mac/',
62
27
  '!Running: mac/init, path: tests/meta.js',
28
+ 'MockServicer:docker init',
63
29
  'MockServicer:docker starting mysql',
64
30
  'MockServicer:docker starting redis',
65
31
  '>mac/init completed in',
@@ -67,16 +33,17 @@ export async function test() {
67
33
  '\x1B[32mOk:\x1B[0m Servicer test example works',
68
34
  '>mac/t_example.js completed in',
69
35
  '!Running: mac/uninit, path: tests/meta.js',
36
+ 'MockServicer:docker deinit',
70
37
  'MockServicer:docker stopping redis',
71
38
  'MockServicer:docker stopping mysql',
72
- 'MockServicer:docker shutdown',
73
39
  '>mac/uninit completed in',
74
40
  '\x1B[102mSuccess!\x1B[0m Total: 1',
75
41
  '\x1B[38;5;243mCompleted\x1B[0m mac/',
76
42
  'Logs are written to',
77
43
  'Elapsed:',
78
44
  'Logs are written to',
79
- 'Testsuite: shutdown'
45
+ 'MockServicer:docker shutdown',
46
+ 'Testsuite: shutdown',
80
47
  ],
81
48
  [],
82
49
  'servicer lifecycle',
@@ -32,7 +32,7 @@ class MockLogPipe {
32
32
  export * from '../../core/util.js';
33
33
  export * from '../../core/base.js';
34
34
  export * from '../../core/format.js';
35
- export * from './mock_series.js';
35
+ export * from './mock-series.js';
36
36
 
37
37
  export { Series };
38
38
 
package/tests/test.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from '../core/base.js';
2
+ export * from '../core/core.js';
@@ -1,7 +1,7 @@
1
1
  import { is_output } from '../../core/base.js';
2
2
  import { testflow, fail } from '../../core/core.js';
3
3
  import { scope } from '../../webdriver/session.js';
4
- import { TestExecutionError } from '../../webdriver/driver_base.js';
4
+ import { TestExecutionError } from '../../webdriver/driver-base.js';
5
5
 
6
6
  const reducedTimeout = 0.001;
7
7
 
@@ -30,8 +30,8 @@ const eat_failure = func => async () => {
30
30
 
31
31
  export * from '../../core/core.js';
32
32
  export * from '../../core/base.js';
33
- export * from '../../webdriver/app_driver.js';
34
- export * from '../../webdriver/control_driver.js';
33
+ export * from '../../webdriver/app-driver.js';
34
+ export * from '../../webdriver/control-driver.js';
35
35
 
36
36
  export function do_self_tests(snippet, test) {
37
37
  return scope(snippet, async session => {
@@ -1,5 +1,5 @@
1
1
  import { assert } from '../core/core.js';
2
- import { AppDriver } from './app_driver.js';
2
+ import { AppDriver } from './app-driver.js';
3
3
 
4
4
  /**
5
5
  * Control driver base.
@@ -1,4 +1,4 @@
1
- import settings from '../core/settings.js';
1
+ import { settings } from '../core/settings.js';
2
2
  import { is } from '../core/base.js';
3
3
  import {
4
4
  assert,
@@ -37,6 +37,13 @@ function getChromeOptions() {
37
37
  deviceName: 'iPhone 7',
38
38
  });
39
39
  }
40
+ // Accept self-signed certificates (for k3s testing)
41
+ chromeOptions.addArguments('ignore-certificate-errors');
42
+
43
+ // Required for running in Docker/VPS environments
44
+ chromeOptions.addArguments('no-sandbox');
45
+ chromeOptions.addArguments('disable-dev-shm-usage');
46
+
40
47
  return chromeOptions;
41
48
  }
42
49
 
@@ -3,7 +3,7 @@ import { test_is, test_contains, is, contains, ok } from '../core/base.js';
3
3
  import { assert, fail } from '../core/core.js';
4
4
  import { is_mac, stringify, toDataURL } from '../core/util.js';
5
5
  import { log } from '../logging/logging.js';
6
- import { getTimeout, DriverBase } from './driver_base.js';
6
+ import { getTimeout, DriverBase } from './driver-base.js';
7
7
 
8
8
  /**
9
9
  * A chainable web driver providing a number of handy methods to navigate
@@ -145,38 +145,65 @@ async function start_session(arg1, arg2) {
145
145
 
146
146
  /**
147
147
  * Opens a new browser window and runs the given tests within it.
148
- * @param arg1 - url_or_snippet or tests
149
- * @param arg2 - tests if |arg1| is url_or_snippet or options or libs
150
- @ @param arg3 - libs if |arg2| is not libs
148
+ * @param args - [url?], tests, [options?], [libs?]
149
+ * url: string or function returning string
150
+ * tests: async function receiving session
151
+ * options: object (e.g., {auto_session: false})
152
+ * libs: array of library paths to load
151
153
  */
152
- const scope = (arg1, arg2, arg3) => async () => {
153
- let url_or_snippet = (typeof arg1 == 'string' && arg1) || null;
154
- let tests = (typeof arg1 == 'function' && arg1) || arg2;
155
- let options = (typeof arg1 == 'function' && arg2) || null;
156
- let libs = arg3 || (arg2 instanceof Array && arg2);
157
- assert(tests, 'No tests to run provided');
158
-
159
- // Do the test.
160
- try {
161
- // Start session if requested.
162
- let session = null;
163
- if (!options || options.auto_session !== false) {
164
- session = await start_session(url_or_snippet, libs);
165
- }
166
- await tests(session);
167
- } catch (e) {
168
- log_error(e);
169
- fail(e.message);
170
- } finally {
171
- log(`Quit ${active_sessions.length} wd session(s)`);
172
-
173
- while (active_sessions.length > 1) {
174
- await active_sessions[1].close();
154
+ const scope =
155
+ (...args) =>
156
+ async () => {
157
+ let libs, options, tests, url_or_snippet_getter;
158
+
159
+ // Extract args from end: libs (array) then options (object) then tests (function) then url
160
+ for (let i = args.length - 1; i >= 0; i--) {
161
+ const arg = args[i];
162
+ if (!libs && Array.isArray(arg)) {
163
+ libs = arg;
164
+ } else if (
165
+ !options &&
166
+ arg &&
167
+ typeof arg === 'object' &&
168
+ typeof arg !== 'function'
169
+ ) {
170
+ options = arg;
171
+ } else if (!tests && typeof arg === 'function') {
172
+ tests = arg;
173
+ } else if (typeof arg === 'string' || typeof arg === 'function') {
174
+ url_or_snippet_getter = arg;
175
+ }
175
176
  }
176
- if (active_sessions.length == 1) {
177
- await active_sessions[0].quit();
177
+
178
+ const url_or_snippet = url_or_snippet_getter
179
+ ? typeof url_or_snippet_getter === 'function'
180
+ ? url_or_snippet_getter()
181
+ : url_or_snippet_getter
182
+ : null;
183
+
184
+ assert(tests, 'No tests to run provided');
185
+
186
+ // Do the test.
187
+ try {
188
+ // Start session if requested.
189
+ let session = null;
190
+ if (!options || options.auto_session !== false) {
191
+ session = await start_session(url_or_snippet, libs);
192
+ }
193
+ await tests(session);
194
+ } catch (e) {
195
+ log_error(e);
196
+ fail(e.message);
197
+ } finally {
198
+ log(`Quit ${active_sessions.length} wd session(s)`);
199
+
200
+ while (active_sessions.length > 1) {
201
+ await active_sessions[1].close();
202
+ }
203
+ if (active_sessions.length == 1) {
204
+ await active_sessions[0].quit();
205
+ }
178
206
  }
179
- }
180
- };
207
+ };
181
208
 
182
209
  export { start_session, scope };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes