@camperaid/watest 2.4.7 → 2.4.8

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 (134) hide show
  1. package/.prettierrc.js +1 -3
  2. package/.watestrc.js +1 -3
  3. package/bin/watest.js +3 -8
  4. package/core/base.js +60 -59
  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 +60 -56
  9. package/core/settings.js +27 -32
  10. package/core/spawn.js +14 -21
  11. package/core/util.js +12 -19
  12. package/eslint.config.js +27 -0
  13. package/index.js +11 -17
  14. package/interfaces/logger.js +1 -3
  15. package/interfaces/servicer.js +1 -3
  16. package/logging/filestream.js +3 -7
  17. package/logging/logging.js +5 -11
  18. package/logging/logpipe.js +21 -21
  19. package/package.json +12 -11
  20. package/tests/base/t_api.js +3 -6
  21. package/tests/base/t_contains.js +12 -12
  22. package/tests/base/t_core.js +11 -8
  23. package/tests/base/t_format.js +13 -14
  24. package/tests/base/t_is.js +9 -11
  25. package/tests/base/t_is_object.js +23 -25
  26. package/tests/base/t_is_primitive.js +12 -14
  27. package/tests/base/t_is_string.js +6 -8
  28. package/tests/base/t_ok.js +4 -6
  29. package/tests/base/t_stringify.js +6 -8
  30. package/tests/base/t_test_.js +3 -5
  31. package/tests/base/t_throws.js +10 -12
  32. package/tests/base/test.js +8 -18
  33. package/tests/e2e/samples/{loader/.watestrc.cjs → folder/.watestrc.js} +1 -1
  34. package/tests/e2e/samples/folder/package-lock.json +1019 -5940
  35. package/tests/e2e/samples/folder/package.json +3 -2
  36. package/tests/e2e/samples/folder/tests/meta.js +1 -1
  37. package/tests/e2e/samples/folder/tests/unit/t_test.js +3 -3
  38. package/tests/e2e/samples/{loader_mixed/.watestrc.cjs → loader/.watestrc.js} +1 -1
  39. package/tests/e2e/samples/loader/package-lock.json +1751 -28
  40. package/tests/e2e/samples/loader/package.json +2 -2
  41. package/tests/e2e/samples/{folder/.watestrc.cjs → loader_mixed/.watestrc.js} +1 -1
  42. package/tests/e2e/samples/loader_mixed/package-lock.json +1751 -28
  43. package/tests/e2e/samples/loader_multiple/{.watestrc.cjs → .watestrc.js} +1 -1
  44. package/tests/e2e/samples/loader_multiple/package-lock.json +1751 -28
  45. package/tests/e2e/samples/loader_multiple/package.json +2 -2
  46. package/tests/e2e/samples/single/.watestrc.js +5 -0
  47. package/tests/e2e/samples/single/package-lock.json +1017 -5938
  48. package/tests/e2e/samples/single/package.json +5 -2
  49. package/tests/e2e/samples/wd_mixed/{.watestrc.cjs → .watestrc.js} +1 -1
  50. package/tests/e2e/samples/wd_mixed/package-lock.json +779 -4862
  51. package/tests/e2e/samples/wd_mixed/package.json +2 -2
  52. package/tests/e2e/samples/wd_single/{.watestrc.cjs → .watestrc.js} +1 -1
  53. package/tests/e2e/samples/wd_single/package-lock.json +779 -4862
  54. package/tests/e2e/samples/wd_single/package.json +2 -2
  55. package/tests/e2e/t_folder.js +4 -6
  56. package/tests/e2e/t_loader.js +4 -6
  57. package/tests/e2e/t_loader_mixed.js +4 -6
  58. package/tests/e2e/t_loader_multiple.js +4 -6
  59. package/tests/e2e/t_loader_multiple_patterns.js +4 -6
  60. package/tests/e2e/t_single.js +4 -6
  61. package/tests/e2e/t_wd_firefox.js +4 -6
  62. package/tests/e2e/t_wd_firefox_chrome.js +4 -6
  63. package/tests/e2e/t_wd_firefox_chrome_pattern.js +4 -6
  64. package/tests/e2e/t_wd_mixed_firefox.js +4 -6
  65. package/tests/e2e/t_wd_mixed_firefox_chrome.js +4 -6
  66. package/tests/e2e/test.js +15 -16
  67. package/tests/meta.js +1 -3
  68. package/tests/series/build/t_adjust_names.js +4 -6
  69. package/tests/series/build/t_adjust_names_webdriver.js +6 -10
  70. package/tests/series/build/t_expected_failures.js +4 -6
  71. package/tests/series/build/t_loader.js +4 -6
  72. package/tests/series/build/t_loader_mixed.js +4 -6
  73. package/tests/series/build/t_mixed.js +4 -6
  74. package/tests/series/build/t_nested.js +4 -6
  75. package/tests/series/build/t_patterns_loader.js +4 -6
  76. package/tests/series/build/t_patterns_webdriver.js +4 -6
  77. package/tests/series/build/t_webdriver.js +4 -6
  78. package/tests/series/build/t_webdriver_firefox_mixed.js +4 -6
  79. package/tests/series/build/t_webdriver_nested.js +4 -6
  80. package/tests/series/build/t_webdriver_services.js +4 -6
  81. package/tests/series/generic/t_failures_info.js +9 -12
  82. package/tests/series/logging/t_failures.js +18 -20
  83. package/tests/series/logging/t_success.js +15 -17
  84. package/tests/series/logging/t_verify.js +17 -14
  85. package/tests/series/meta.js +1 -3
  86. package/tests/series/mock_series.js +7 -13
  87. package/tests/series/perform/t_failure.js +4 -6
  88. package/tests/series/perform/t_failure_notest.js +4 -6
  89. package/tests/series/perform/t_intermittent.js +5 -7
  90. package/tests/series/perform/t_intermittent_global.js +4 -6
  91. package/tests/series/perform/t_missing_perma.js +5 -7
  92. package/tests/series/perform/t_nested.js +4 -10
  93. package/tests/series/perform/t_perma.js +4 -6
  94. package/tests/series/perform/t_success.js +5 -11
  95. package/tests/series/run/t_debunk_failure.js +7 -6
  96. package/tests/series/run/t_debunk_success.js +7 -6
  97. package/tests/series/run/t_nested.js +7 -6
  98. package/tests/series/run/t_verify.js +7 -6
  99. package/tests/series/run/t_verify_webdriver.js +7 -6
  100. package/tests/series/test.js +29 -40
  101. package/tests/webdriver/meta.js +1 -3
  102. package/tests/webdriver/t_app_driver.js +3 -5
  103. package/tests/webdriver/t_app_driver_selectors.js +3 -5
  104. package/tests/webdriver/t_attribute.js +5 -7
  105. package/tests/webdriver/t_attribute_all.js +6 -8
  106. package/tests/webdriver/t_doubleclick.js +3 -5
  107. package/tests/webdriver/t_doubleclickat.js +3 -5
  108. package/tests/webdriver/t_execute.js +4 -6
  109. package/tests/webdriver/t_if_has_elements.js +6 -8
  110. package/tests/webdriver/t_if_no_elements.js +6 -8
  111. package/tests/webdriver/t_no_elements_or_not_visible.js +7 -9
  112. package/tests/webdriver/t_properties.js +11 -13
  113. package/tests/webdriver/t_script.js +8 -10
  114. package/tests/webdriver/t_select_all.js +6 -11
  115. package/tests/webdriver/t_selection.js +4 -6
  116. package/tests/webdriver/t_text.js +12 -14
  117. package/tests/webdriver/t_text_all.js +6 -8
  118. package/tests/webdriver/test.js +32 -41
  119. package/webdriver/app_driver.js +15 -19
  120. package/webdriver/control_driver.js +4 -8
  121. package/webdriver/driver.js +58 -61
  122. package/webdriver/driver_base.js +50 -60
  123. package/webdriver/session.js +6 -11
  124. package/webdriver/util.js +7 -8
  125. package/.eslintrc.js +0 -45
  126. package/index.mjs +0 -5
  127. package/tests/e2e/samples/folder/node_modules/.package-lock.json +0 -3871
  128. package/tests/e2e/samples/loader/node_modules/.package-lock.json +0 -36
  129. package/tests/e2e/samples/loader_mixed/node_modules/.package-lock.json +0 -36
  130. package/tests/e2e/samples/loader_multiple/node_modules/.package-lock.json +0 -36
  131. package/tests/e2e/samples/single/.watestrc.cjs +0 -5
  132. package/tests/e2e/samples/single/node_modules/.package-lock.json +0 -3871
  133. package/tests/e2e/samples/wd_mixed/node_modules/.package-lock.json +0 -3586
  134. package/tests/e2e/samples/wd_single/node_modules/.package-lock.json +0 -3586
@@ -1,7 +1,5 @@
1
- 'use strict';
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
- module.exports = {
41
- FileStream,
42
- };
38
+ export { FileStream };
@@ -1,6 +1,4 @@
1
- 'use strict';
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
- module.exports = {
24
- log,
25
- log_trace,
26
- log_error
27
- };
21
+ export { log, log_trace, log_error };
@@ -1,23 +1,21 @@
1
- 'use strict';
1
+ import path from 'path';
2
2
 
3
- const path = require('path');
4
-
5
- const settings = require('../core/settings.js');
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 || require('./filestream.js').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({ run, invocation: this.invocation });
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 ? this.pipeOnStack.logSourceMap(...args) : Promise.resolve();
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
- module.exports = {
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.7",
3
+ "version": "2.4.8",
4
4
  "description": "Web Application Testsuite",
5
+ "type": "module",
5
6
  "engines": {
6
- "node": ">=14.15.1"
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.0.0-beta.2"
39
+ "selenium-webdriver": "^4.23.0"
39
40
  },
40
41
  "devDependencies": {
41
- "dotenv": "^16.0.1",
42
- "eslint": "^8.22.0",
43
- "eslint-plugin-node": "^11.1.0",
44
- "husky": "^8.0.1",
45
- "lint-staged": "^13.0.3",
46
- "prettier": "^2.7.1",
47
- "prettifier": "^0.4.0"
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": [
@@ -1,9 +1,7 @@
1
- 'use strict';
2
-
3
- const api = require('../../index.js');
1
+ import * as api from '../../index.js';
4
2
  const { ok } = api;
5
3
 
6
- module.exports.test = async () => {
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
+ }
@@ -1,14 +1,12 @@
1
- 'use strict';
1
+ import { contains, is_output } from './test.js';
2
2
 
3
- const { contains, is_output } = require('./test.js');
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
- [`Failed: String contains, got string doesn't contain expected string, got: 'cat', expected: 'green cat'`],
35
- `failure`
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
+ }
@@ -1,20 +1,23 @@
1
- 'use strict';
1
+ import { colorify, group, fail, success, is_output } from './test.js';
2
2
 
3
- const { colorify, group, fail, success, is_output } = require('./test.js');
4
-
5
- module.exports.test = async () => {
3
+ export async function test() {
6
4
  // console.log
7
5
  await is_output(() => console.log(3), [`3\n`], [], `console.log(3)`);
8
6
 
9
7
  // console.error
10
- await is_output(() => console.error(3), [], [`3\n`], `console.error(3)`);
8
+ await is_output(
9
+ () => console.error(3),
10
+ [],
11
+ [`3\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
+ }
@@ -1,16 +1,15 @@
1
- 'use strict';
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
- } = require('../../core/format.js');
11
- const { is } = require('../../index.js');
8
+ } from '../../core/format.js';
9
+
10
+ import { is } from '../../index.js';
12
11
 
13
- module.exports.test = () => {
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
+ }
@@ -1,14 +1,12 @@
1
- 'use strict';
1
+ import { is, is_output } from './test.js';
2
2
 
3
- const { is, is_output } = require('./test.js');
4
-
5
- module.exports.test = async () => {
3
+ export async function test() {
6
4
  // is() sucess
7
5
  await is_output(
8
6
  () => is(3, 3, `Equal`),
9
7
  [`Ok: Equal, got: 3`],
10
8
  [],
11
- `is() sucess`
9
+ `is() sucess`,
12
10
  );
13
11
 
14
12
  // is() failure
@@ -16,7 +14,7 @@ module.exports.test = async () => {
16
14
  () => is(3, 4, `Not equal`),
17
15
  [],
18
16
  [`Failed: Not equal, got: 3, expected: 4`],
19
- `is() failure`
17
+ `is() failure`,
20
18
  );
21
19
 
22
20
  // is() regexp sucess
@@ -24,7 +22,7 @@ module.exports.test = async () => {
24
22
  () => is('34', /^\d+$/, `Equal`),
25
23
  [`Ok: Equal '34' matches /^\\d+$/ regexp`],
26
24
  [],
27
- `is() regexp sucess`
25
+ `is() regexp sucess`,
28
26
  );
29
27
 
30
28
  // is() regexp failure
@@ -32,7 +30,7 @@ module.exports.test = async () => {
32
30
  () => is('34a', /^\d+$/, `Equal`),
33
31
  [],
34
32
  [`Failed: Equal '34a' doesn't match /^\\d+$/ regexp`],
35
- `is() regexp failure`
33
+ `is() regexp failure`,
36
34
  );
37
35
 
38
36
  // is() object sucess
@@ -40,7 +38,7 @@ module.exports.test = async () => {
40
38
  () => is({ field: 'hey' }, { field: 'hey' }, `Objects equal`),
41
39
  [`Ok: Objects equal, got: {field: 'hey'}`],
42
40
  [],
43
- `is() object sucess`
41
+ `is() object sucess`,
44
42
  );
45
43
 
46
44
  // is() object failure
@@ -51,6 +49,6 @@ module.exports.test = async () => {
51
49
  `Failed: Objects not equal: 'field' field value mismatch;\ngot:\nhey\nexpected:\npey\nunexpected character: 'h' at 0 pos, expected: 'p' at '' line`,
52
50
  `Failed: Objects not equal`,
53
51
  ],
54
- `is() object failure`
52
+ `is() object failure`,
55
53
  );
56
- };
54
+ }
@@ -1,14 +1,12 @@
1
- 'use strict';
1
+ import { is_output, is_object } from './test.js';
2
2
 
3
- const { is_output, is_object } = require('./test.js');
4
-
5
- module.exports.test = async () => {
3
+ export async function test() {
6
4
  // sucess
7
5
  await is_output(
8
6
  () => is_object({ field: 'hey' }, { field: 'hey' }, 'TstMsg'),
9
7
  [`Ok: TstMsg, got: {field: 'hey'}\n`],
10
8
  [],
11
- `sucess`
9
+ `sucess`,
12
10
  );
13
11
 
14
12
  // types: Set
@@ -16,7 +14,7 @@ module.exports.test = async () => {
16
14
  () => is_object(new Set(['v1', 'v2']), ['v1', 'v2'], 'TstMsg'),
17
15
  [`Ok: TstMsg, got: Set['v1', 'v2']`],
18
16
  [],
19
- `types: Set`
17
+ `types: Set`,
20
18
  );
21
19
 
22
20
  // types: Map
@@ -24,7 +22,7 @@ module.exports.test = async () => {
24
22
  () => is_object(new Map([['key', 'val']]), [['key', 'val']], 'TstMsg'),
25
23
  [`Ok: TstMsg, got: Map{key: 'val'}`],
26
24
  [],
27
- `types: Map`
25
+ `types: Map`,
28
26
  );
29
27
 
30
28
  // types: Date success
@@ -32,7 +30,7 @@ module.exports.test = async () => {
32
30
  () => is_object(new Date('2022-01-01'), new Date('2022-01-01'), 'TstMsg'),
33
31
  [`Ok: TstMsg, got: 2022-01-01T00:00:00.000Z`],
34
32
  [],
35
- `types: Date sucess`
33
+ `types: Date sucess`,
36
34
  );
37
35
 
38
36
  // types: Date failure
@@ -43,7 +41,7 @@ module.exports.test = async () => {
43
41
  `Failed: TstMsg: unexpected value: 2022-01-01T00:00:00.000Z, expected: 2023-02-02T00:00:00.000Z`,
44
42
  `Failed: TstMsg`,
45
43
  ],
46
- `types: Date failure`
44
+ `types: Date failure`,
47
45
  );
48
46
 
49
47
  // function sucess
@@ -51,7 +49,7 @@ module.exports.test = async () => {
51
49
  () => is_object({ field: 'hey' }, () => true, 'TstMsg'),
52
50
  [`Ok: TstMsg, got: {field: 'hey'}`],
53
51
  [],
54
- `function sucess`
52
+ `function sucess`,
55
53
  );
56
54
 
57
55
  // function failure
@@ -62,7 +60,7 @@ module.exports.test = async () => {
62
60
  `Failed: TstMsg: unexpected value: {field: 'hey'}, expected: () => false`,
63
61
  `Failed: TstMsg`,
64
62
  ],
65
- `function failure`
63
+ `function failure`,
66
64
  );
67
65
 
68
66
  // failure: type mismatch
@@ -73,7 +71,7 @@ module.exports.test = async () => {
73
71
  `Failed: TstMsg: 'key' field type mismatch, got type: number, expected type: string, got value: 3, expected value: '3'`,
74
72
  `Failed: TstMsg`,
75
73
  ],
76
- `failure: type mismatch`
74
+ `failure: type mismatch`,
77
75
  );
78
76
 
79
77
  // failure: class mismatch
@@ -84,7 +82,7 @@ module.exports.test = async () => {
84
82
  `Failed: TstMsg: class mismatch, got: Array, expected: Map`,
85
83
  `Failed: TstMsg`,
86
84
  ],
87
- `failure: class mismatch, expected of a different class`
85
+ `failure: class mismatch, expected of a different class`,
88
86
  );
89
87
 
90
88
  // failure: class mismatch
@@ -95,7 +93,7 @@ module.exports.test = async () => {
95
93
  `Failed: TstMsg: class mismatch, got: Set, expected: Map`,
96
94
  `Failed: TstMsg`,
97
95
  ],
98
- `failure: class mismatch, |expected| and |got| belong to different classes`
96
+ `failure: class mismatch, |expected| and |got| belong to different classes`,
99
97
  );
100
98
 
101
99
  // success: class mismatch but |expected| is a generic Object
@@ -109,7 +107,7 @@ module.exports.test = async () => {
109
107
  () => is_object(new A(), { name: 'name' }, 'TstMsg'),
110
108
  [`Ok: TstMsg, got: {name: 'name'}`],
111
109
  [],
112
- `success: class mismatch but |expected| is a generic Object`
110
+ `success: class mismatch but |expected| is a generic Object`,
113
111
  );
114
112
 
115
113
  // failure: value mismatch
@@ -120,7 +118,7 @@ module.exports.test = async () => {
120
118
  `Failed: TstMsg: class mismatch, got: Object, expected: null`,
121
119
  `Failed: TstMsg`,
122
120
  ],
123
- `failure: class mismatch (null) #2`
121
+ `failure: class mismatch (null) #2`,
124
122
  );
125
123
 
126
124
  // failure: value mismatch
@@ -131,7 +129,7 @@ module.exports.test = async () => {
131
129
  `Failed: TstMsg: 'field' field value mismatch;\ngot:\nhey\nexpected:\npey\nunexpected character: 'h' at 0 pos, expected: 'p' at '' line`,
132
130
  `Failed: TstMsg`,
133
131
  ],
134
- `failure: value mismatch (strings)`
132
+ `failure: value mismatch (strings)`,
135
133
  );
136
134
 
137
135
  // failure: not enumerable property value mismatch
@@ -144,14 +142,14 @@ module.exports.test = async () => {
144
142
  }
145
143
  })(),
146
144
  { field: 'pey' },
147
- 'TstMsg'
145
+ 'TstMsg',
148
146
  ),
149
147
  [],
150
148
  [
151
149
  `Failed: TstMsg: 'field' field value mismatch;\ngot:\nhey\nexpected:\npey\nunexpected character: 'h' at 0 pos, expected: 'p' at '' line`,
152
150
  `Failed: TstMsg`,
153
151
  ],
154
- `failure: not enumerable property value mismatch`
152
+ `failure: not enumerable property value mismatch`,
155
153
  );
156
154
 
157
155
  // failure: primitive
@@ -159,7 +157,7 @@ module.exports.test = async () => {
159
157
  () => is_object(null, {}, 'TstMsg'),
160
158
  [],
161
159
  [`Failed: TstMsg, got: null, expected: [object Object]`],
162
- `failure: value mismatch (null)`
160
+ `failure: value mismatch (null)`,
163
161
  );
164
162
 
165
163
  // failure: field was not expected
@@ -175,7 +173,7 @@ module.exports.test = async () => {
175
173
  {
176
174
  f2: {},
177
175
  },
178
- 'TstMsg'
176
+ 'TstMsg',
179
177
  ),
180
178
  [],
181
179
  [
@@ -183,7 +181,7 @@ module.exports.test = async () => {
183
181
  `Failed: TstMsg: 'f2->f21' field was not expected, got: 'f21'`,
184
182
  `Failed: TstMsg`,
185
183
  ],
186
- `failure: class mismatch`
184
+ `failure: class mismatch`,
187
185
  );
188
186
 
189
187
  // failure: nested fields, array length mismatch
@@ -200,13 +198,13 @@ module.exports.test = async () => {
200
198
  f2: [3],
201
199
  },
202
200
  },
203
- 'TstMsg'
201
+ 'TstMsg',
204
202
  ),
205
203
  [],
206
204
  [
207
205
  `Failed: TstMsg: 'f1->f2' field array length mismatch, got: 0, expected: 1.\nGot: []\nExpected: [3]`,
208
206
  `Failed: TstMsg`,
209
207
  ],
210
- `failure: nested fields array length mismatch`
208
+ `failure: nested fields array length mismatch`,
211
209
  );
212
- };
210
+ }