@w-lfpup/jackrabbit 0.1.0 → 0.3.0

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 (98) hide show
  1. package/.github/workflows/browsers.json +45 -0
  2. package/.github/workflows/browsers.macos.json +51 -0
  3. package/.github/workflows/browsers.windows.json +19 -0
  4. package/.github/workflows/tests.yml +42 -0
  5. package/README.md +151 -8
  6. package/browser/dist/logger.js +43 -0
  7. package/browser/dist/mod.js +26 -0
  8. package/browser/dist/queue.js +27 -0
  9. package/browser/dist/runner.js +20 -0
  10. package/{cli → browser}/package.json +1 -1
  11. package/browser/src/logger.ts +57 -0
  12. package/browser/src/mod.ts +30 -0
  13. package/browser/src/runner.ts +22 -0
  14. package/browser/tsconfig.json +11 -0
  15. package/browser/tsconfig.tsbuildinfo +1 -0
  16. package/browsers.json +38 -0
  17. package/core/dist/jackrabbit_types.d.ts +62 -28
  18. package/core/dist/mod.d.ts +2 -2
  19. package/core/dist/mod.js +1 -1
  20. package/core/dist/run_steps.d.ts +2 -2
  21. package/core/dist/run_steps.js +83 -67
  22. package/core/src/jackrabbit_types.ts +73 -29
  23. package/core/src/mod.ts +2 -8
  24. package/core/src/run_steps.ts +111 -80
  25. package/examples/hello_world/goodbye_world.ts +1 -1
  26. package/examples/hello_world/hello_world.ts +1 -1
  27. package/nodejs/dist/logger.js +161 -0
  28. package/nodejs/dist/mod.js +31 -0
  29. package/nodejs/dist/results.js +139 -0
  30. package/nodejs/dist/results_str.js +147 -0
  31. package/nodejs/dist/runner.js +17 -0
  32. package/nodejs/src/logger.ts +193 -0
  33. package/nodejs/src/mod.ts +37 -0
  34. package/nodejs/src/results_str.ts +234 -0
  35. package/{cli → nodejs}/tsconfig.json +2 -1
  36. package/nodejs/tsconfig.tsbuildinfo +1 -0
  37. package/package.json +9 -6
  38. package/tests/dist/mod.d.ts +14 -3
  39. package/tests/dist/mod.js +33 -13
  40. package/tests/dist/test_error.test.d.ts +9 -0
  41. package/tests/dist/test_error.test.js +27 -0
  42. package/tests/dist/test_errors.test.d.ts +9 -0
  43. package/tests/dist/test_errors.test.js +27 -0
  44. package/tests/dist/test_logger.d.ts +3 -2
  45. package/tests/dist/test_logger.js +5 -1
  46. package/tests/src/mod.ts +31 -15
  47. package/tests/src/test_error.test.ts +32 -0
  48. package/tests/src/test_logger.ts +6 -1
  49. package/tests/tsconfig.tsbuildinfo +1 -1
  50. package/tsconfig.json +1 -1
  51. package/webdriver/dist/config.js +57 -0
  52. package/webdriver/dist/eventbus.js +18 -0
  53. package/webdriver/dist/listeners.js +21 -0
  54. package/webdriver/dist/logger.js +203 -0
  55. package/webdriver/dist/mod.js +36 -0
  56. package/webdriver/dist/results_str.js +167 -0
  57. package/webdriver/dist/routes.js +172 -0
  58. package/webdriver/dist/routes2.js +163 -0
  59. package/webdriver/dist/test_hangar.js +20 -0
  60. package/webdriver/dist/webdriver.js +273 -0
  61. package/webdriver/package.json +8 -0
  62. package/webdriver/src/config.ts +89 -0
  63. package/webdriver/src/eventbus.ts +104 -0
  64. package/webdriver/src/logger.ts +247 -0
  65. package/webdriver/src/mod.ts +43 -0
  66. package/webdriver/src/results.ts +56 -0
  67. package/webdriver/src/results_str.ts +222 -0
  68. package/webdriver/src/routes.ts +211 -0
  69. package/webdriver/src/test_hangar.ts +25 -0
  70. package/webdriver/src/webdriver.ts +372 -0
  71. package/{nodejs_cli → webdriver}/tsconfig.json +1 -0
  72. package/webdriver/tsconfig.tsbuildinfo +1 -0
  73. package/.github/workflows/build_and_test.yml +0 -18
  74. package/cli/dist/cli.d.ts +0 -3
  75. package/cli/dist/cli.js +0 -8
  76. package/cli/dist/cli_types.d.ts +0 -7
  77. package/cli/dist/config.d.ts +0 -5
  78. package/cli/dist/config.js +0 -27
  79. package/cli/dist/importer.d.ts +0 -7
  80. package/cli/dist/importer.js +0 -16
  81. package/cli/dist/logger.d.ts +0 -7
  82. package/cli/dist/logger.js +0 -88
  83. package/cli/dist/mod.d.ts +0 -6
  84. package/cli/dist/mod.js +0 -4
  85. package/cli/src/cli.ts +0 -17
  86. package/cli/src/cli_types.ts +0 -9
  87. package/cli/src/config.ts +0 -36
  88. package/cli/src/importer.ts +0 -25
  89. package/cli/src/logger.ts +0 -126
  90. package/cli/src/mod.ts +0 -7
  91. package/cli/tsconfig.tsbuildinfo +0 -1
  92. package/nodejs_cli/dist/mod.d.ts +0 -2
  93. package/nodejs_cli/dist/mod.js +0 -20
  94. package/nodejs_cli/src/mod.ts +0 -25
  95. package/nodejs_cli/tsconfig.tsbuildinfo +0 -1
  96. package/test_guide.md +0 -114
  97. /package/{nodejs_cli → nodejs}/package.json +0 -0
  98. /package/{cli/dist/cli_types.js → webdriver/dist/results.js} +0 -0
@@ -1,56 +1,90 @@
1
1
  interface Stringable {
2
2
  toString: Object["toString"];
3
3
  }
4
- export type Assertions = Stringable | Stringable[] | undefined;
4
+ export type Assertions = Stringable | Stringable[] | undefined | null;
5
5
  type SyncTest = () => Assertions;
6
6
  type AsyncTest = () => Promise<Assertions>;
7
7
  export type Test = SyncTest | AsyncTest;
8
- export interface Options {
9
- title?: string;
8
+ export interface TestOptions {
10
9
  runAsynchronously?: boolean;
11
10
  timeoutMs?: number;
11
+ title?: string;
12
12
  }
13
13
  export interface TestModule {
14
+ options?: TestOptions;
14
15
  tests: Test[];
15
- options: Options;
16
16
  }
17
- interface StartRun {
18
- type: "start_run";
17
+ export interface StartRun {
18
+ expected_collection_count: number;
19
19
  time: number;
20
+ type: "start_run";
20
21
  }
21
- interface EndRun {
22
- type: "end_run";
22
+ export interface EndRun {
23
23
  time: number;
24
+ type: "end_run";
24
25
  }
25
- interface CancelRun {
26
- type: "cancel_run";
27
- time: number;
26
+ export interface RunError {
27
+ error: string;
28
+ type: "run_error";
28
29
  }
29
- interface StartModule {
30
+ export interface StartTestCollection {
31
+ collection_id: number;
32
+ collection_url: string;
33
+ expected_module_count: number;
34
+ type: "start_collection";
35
+ }
36
+ export interface EndTestCollection {
37
+ collection_id: number;
38
+ type: "end_collection";
39
+ }
40
+ export interface TestCollectionError {
41
+ collection_id: number;
42
+ error: string;
43
+ type: "collection_error";
44
+ }
45
+ export interface StartModule {
46
+ collection_id: number;
47
+ expected_test_count: number;
48
+ module_id: number;
49
+ module_name: string;
30
50
  type: "start_module";
31
- moduleId: number;
32
51
  }
33
- interface EndModule {
52
+ export interface EndModule {
53
+ collection_id: number;
54
+ module_id: number;
34
55
  type: "end_module";
35
- moduleId: number;
36
56
  }
37
- interface StartTest {
57
+ export interface ModuleError {
58
+ collection_id: number;
59
+ error: string;
60
+ module_id: number;
61
+ type: "module_error";
62
+ }
63
+ export interface StartTest {
64
+ collection_id: number;
65
+ module_id: number;
66
+ test_id: number;
67
+ test_name: string;
38
68
  type: "start_test";
39
- testId: number;
40
- moduleId: number;
41
69
  }
42
- interface EndTest {
43
- type: "end_test";
44
- testId: number;
45
- moduleId: number;
46
- startTime: number;
47
- endTime: number;
70
+ export interface EndTest {
48
71
  assertions: Assertions;
72
+ collection_id: number;
73
+ module_id: number;
74
+ test_id: number;
75
+ start_time: number;
76
+ end_time: number;
77
+ type: "end_test";
78
+ }
79
+ export interface TestError {
80
+ collection_id: number;
81
+ error: string;
82
+ module_id: number;
83
+ test_id: number;
84
+ type: "test_error";
49
85
  }
50
- export type LoggerAction = StartRun | EndRun | CancelRun | StartModule | EndModule | StartTest | EndTest;
86
+ export type LoggerAction = StartRun | EndRun | RunError | StartTestCollection | EndTestCollection | TestCollectionError | StartModule | ModuleError | EndModule | StartTest | EndTest | TestError;
51
87
  export interface LoggerInterface {
52
- readonly failed: boolean;
53
- readonly cancelled: boolean;
54
- log(testModules: TestModule[], action: LoggerAction): void;
88
+ log(action: LoggerAction): void;
55
89
  }
56
90
  export {};
@@ -1,2 +1,2 @@
1
- export type { LoggerAction, LoggerInterface, Test, Options, TestModule, } from "./jackrabbit_types.ts";
2
- export { startRun, cancelRun } from "./run_steps.js";
1
+ export type * from "./jackrabbit_types.ts";
2
+ export { runCollection, sleep } from "./run_steps.js";
package/core/dist/mod.js CHANGED
@@ -1 +1 @@
1
- export { startRun, cancelRun } from "./run_steps.js";
1
+ export { runCollection, sleep } from "./run_steps.js";
@@ -1,3 +1,3 @@
1
1
  import type { LoggerInterface, TestModule } from "./jackrabbit_types.ts";
2
- export declare function startRun(logger: LoggerInterface, testModules: TestModule[]): Promise<void>;
3
- export declare function cancelRun(logger: LoggerInterface, testModules: TestModule[]): void;
2
+ export declare function sleep(time: number): Promise<void>;
3
+ export declare function runCollection(logger: LoggerInterface, testModules: TestModule[], collection_id: number, collection_url: string): Promise<void>;
@@ -1,95 +1,111 @@
1
1
  const TIMEOUT_INTERVAL_MS = 10000;
2
- function sleep(time) {
2
+ export function sleep(time) {
3
3
  return new Promise((resolve) => {
4
4
  setTimeout(() => {
5
5
  resolve();
6
6
  }, time);
7
7
  });
8
8
  }
9
- async function createTimeout(timeoutMs = TIMEOUT_INTERVAL_MS) {
9
+ async function failAfterTimeout(timeoutMs) {
10
10
  await sleep(timeoutMs);
11
11
  return `timed out at ${performance.now()} after ${timeoutMs} ms.`;
12
12
  }
13
- async function execTest(testModules, logger, moduleId, testId) {
14
- if (logger.cancelled)
15
- return;
16
- logger.log(testModules, {
13
+ async function execTest(params) {
14
+ const { logger, options, jrTest, test_id, collection_id, module_id } = params;
15
+ const test_name = jrTest.name ?? test_id.toString();
16
+ logger.log({
17
+ collection_id,
18
+ module_id,
19
+ test_id,
20
+ test_name,
17
21
  type: "start_test",
18
- moduleId,
19
- testId,
20
- });
21
- const { tests, options } = testModules[moduleId];
22
- const testFunc = tests[testId];
23
- const startTime = performance.now();
24
- const assertions = await Promise.race([
25
- createTimeout(options.timeoutMs),
26
- testFunc(),
27
- ]);
28
- if (logger.cancelled)
29
- return;
30
- const endTime = performance.now();
31
- logger.log(testModules, {
32
- type: "end_test",
33
- assertions,
34
- endTime,
35
- moduleId,
36
- startTime,
37
- testId,
38
22
  });
23
+ let start_time = performance.now();
24
+ let assertions;
25
+ try {
26
+ assertions = await Promise.race([
27
+ failAfterTimeout(options?.timeoutMs ?? TIMEOUT_INTERVAL_MS),
28
+ jrTest(),
29
+ ]);
30
+ let end_time = performance.now();
31
+ logger.log({
32
+ assertions,
33
+ collection_id,
34
+ start_time,
35
+ end_time,
36
+ module_id,
37
+ test_id,
38
+ type: "end_test",
39
+ });
40
+ }
41
+ catch (e) {
42
+ return logger.log({
43
+ collection_id,
44
+ error: e?.toString() ?? "wild test error",
45
+ module_id,
46
+ test_id,
47
+ type: "test_error",
48
+ });
49
+ }
39
50
  }
40
- async function execCollection(testModules, logger, moduleId) {
41
- if (logger.cancelled)
42
- return;
43
- const { tests } = testModules[moduleId];
51
+ async function execCollection(logger, testModule, collection_id, module_id) {
52
+ const { tests, options } = testModule;
44
53
  const wrappedTests = [];
45
- for (let [testID] of tests.entries()) {
46
- wrappedTests.push(execTest(testModules, logger, moduleId, testID));
54
+ for (let [test_id, jrTest] of tests.entries()) {
55
+ wrappedTests.push(function () {
56
+ return execTest({
57
+ logger,
58
+ options,
59
+ jrTest,
60
+ collection_id,
61
+ module_id,
62
+ test_id,
63
+ });
64
+ });
47
65
  }
48
- if (logger.cancelled)
49
- return;
50
66
  await Promise.all(wrappedTests);
51
67
  }
52
- async function execCollectionOrdered(testModules, logger, moduleId) {
53
- const { tests } = testModules[moduleId];
54
- for (let [testID] of tests.entries()) {
55
- if (logger.cancelled)
56
- return;
57
- await execTest(testModules, logger, moduleId, testID);
68
+ async function execCollectionOrdered(logger, testModule, collection_id, module_id) {
69
+ const { tests, options } = testModule;
70
+ for (let [test_id, jrTest] of tests.entries()) {
71
+ await execTest({
72
+ logger,
73
+ options,
74
+ jrTest,
75
+ collection_id,
76
+ module_id,
77
+ test_id,
78
+ });
58
79
  }
59
80
  }
60
- export async function startRun(logger, testModules) {
61
- logger.log(testModules, {
62
- type: "start_run",
63
- time: performance.now(),
81
+ export async function runCollection(logger, testModules, collection_id, collection_url) {
82
+ logger.log({
83
+ collection_id,
84
+ collection_url,
85
+ expected_module_count: testModules.length,
86
+ type: "start_collection",
64
87
  });
65
- for (let [moduleId, testModule] of testModules.entries()) {
66
- if (logger.cancelled)
67
- return;
68
- logger.log(testModules, {
88
+ for (let [module_id, testModule] of testModules.entries()) {
89
+ const { options } = testModule;
90
+ const module_name = options?.title ?? module_id.toString();
91
+ logger.log({
69
92
  type: "start_module",
70
- moduleId,
93
+ module_id,
94
+ module_name,
95
+ collection_id,
96
+ expected_test_count: testModule.tests.length,
71
97
  });
72
- const { options } = testModule;
73
98
  options?.runAsynchronously
74
- ? await execCollection(testModules, logger, moduleId)
75
- : await execCollectionOrdered(testModules, logger, moduleId);
76
- if (logger.cancelled)
77
- return;
78
- logger.log(testModules, {
99
+ ? await execCollection(logger, testModule, collection_id, module_id)
100
+ : await execCollectionOrdered(logger, testModule, collection_id, module_id);
101
+ logger.log({
79
102
  type: "end_module",
80
- moduleId,
103
+ collection_id,
104
+ module_id,
81
105
  });
82
106
  }
83
- logger.log(testModules, {
84
- type: "end_run",
85
- time: performance.now(),
86
- });
87
- }
88
- export function cancelRun(logger, testModules) {
89
- if (logger.cancelled)
90
- return;
91
- logger.log(testModules, {
92
- type: "cancel_run",
93
- time: performance.now(),
107
+ logger.log({
108
+ type: "end_collection",
109
+ collection_id,
94
110
  });
95
111
  }
@@ -2,74 +2,118 @@ interface Stringable {
2
2
  toString: Object["toString"];
3
3
  }
4
4
 
5
- export type Assertions = Stringable | Stringable[] | undefined;
5
+ export type Assertions = Stringable | Stringable[] | undefined | null;
6
6
 
7
7
  type SyncTest = () => Assertions;
8
8
  type AsyncTest = () => Promise<Assertions>;
9
9
  export type Test = SyncTest | AsyncTest;
10
10
 
11
- export interface Options {
12
- title?: string;
11
+ export interface TestOptions {
13
12
  runAsynchronously?: boolean;
14
13
  timeoutMs?: number;
14
+ title?: string;
15
15
  }
16
16
 
17
17
  export interface TestModule {
18
+ options?: TestOptions;
18
19
  tests: Test[];
19
- options: Options;
20
20
  }
21
21
 
22
- interface StartRun {
23
- type: "start_run";
22
+ export interface StartRun {
23
+ expected_collection_count: number;
24
24
  time: number;
25
+ type: "start_run";
25
26
  }
26
27
 
27
- interface EndRun {
28
- type: "end_run";
28
+ export interface EndRun {
29
29
  time: number;
30
+ type: "end_run";
30
31
  }
31
32
 
32
- interface CancelRun {
33
- type: "cancel_run";
34
- time: number;
33
+ export interface RunError {
34
+ error: string;
35
+ type: "run_error";
35
36
  }
36
37
 
37
- interface StartModule {
38
+ export interface StartTestCollection {
39
+ collection_id: number;
40
+ collection_url: string;
41
+ expected_module_count: number;
42
+ type: "start_collection";
43
+ }
44
+
45
+ export interface EndTestCollection {
46
+ collection_id: number;
47
+ type: "end_collection";
48
+ }
49
+
50
+ export interface TestCollectionError {
51
+ collection_id: number;
52
+ error: string;
53
+ type: "collection_error";
54
+ }
55
+
56
+ export interface StartModule {
57
+ collection_id: number;
58
+ expected_test_count: number;
59
+ module_id: number;
60
+ module_name: string;
38
61
  type: "start_module";
39
- moduleId: number;
40
62
  }
41
63
 
42
- interface EndModule {
64
+ export interface EndModule {
65
+ collection_id: number;
66
+ module_id: number;
43
67
  type: "end_module";
44
- moduleId: number;
45
68
  }
46
69
 
47
- interface StartTest {
70
+ export interface ModuleError {
71
+ collection_id: number;
72
+ error: string;
73
+ module_id: number;
74
+ type: "module_error";
75
+ }
76
+
77
+ export interface StartTest {
78
+ collection_id: number;
79
+ module_id: number;
80
+ test_id: number;
81
+ test_name: string;
48
82
  type: "start_test";
49
- testId: number;
50
- moduleId: number;
51
83
  }
52
84
 
53
- interface EndTest {
54
- type: "end_test";
55
- testId: number;
56
- moduleId: number;
57
- startTime: number;
58
- endTime: number;
85
+ export interface EndTest {
59
86
  assertions: Assertions;
87
+ collection_id: number;
88
+ module_id: number;
89
+ test_id: number;
90
+ start_time: number;
91
+ end_time: number;
92
+ type: "end_test";
93
+ }
94
+
95
+ export interface TestError {
96
+ collection_id: number;
97
+ error: string;
98
+ module_id: number;
99
+ test_id: number;
100
+ type: "test_error";
60
101
  }
61
102
 
62
103
  export type LoggerAction =
63
104
  | StartRun
64
105
  | EndRun
65
- | CancelRun
106
+ | RunError
107
+ | StartTestCollection
108
+ | EndTestCollection
109
+ | TestCollectionError
66
110
  | StartModule
111
+ | ModuleError
67
112
  | EndModule
68
113
  | StartTest
69
- | EndTest;
114
+ | EndTest
115
+ | TestError;
70
116
 
71
117
  export interface LoggerInterface {
72
- readonly failed: boolean;
73
- readonly cancelled: boolean;
74
- log(testModules: TestModule[], action: LoggerAction): void;
118
+ log(action: LoggerAction): void;
75
119
  }
package/core/src/mod.ts CHANGED
@@ -1,9 +1,3 @@
1
- export type {
2
- LoggerAction,
3
- LoggerInterface,
4
- Test,
5
- Options,
6
- TestModule,
7
- } from "./jackrabbit_types.ts";
1
+ export type * from "./jackrabbit_types.ts";
8
2
 
9
- export { startRun, cancelRun } from "./run_steps.js";
3
+ export { runCollection, sleep } from "./run_steps.js";