@w-lfpup/jackrabbit 0.2.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 (96) 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 +24 -0
  5. package/README.md +41 -1
  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 +61 -27
  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 +72 -28
  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/{nodejs_cli → nodejs}/tsconfig.json +2 -1
  36. package/nodejs/tsconfig.tsbuildinfo +1 -0
  37. package/package.json +6 -4
  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/{cli → webdriver}/tsconfig.json +1 -0
  72. package/webdriver/tsconfig.tsbuildinfo +1 -0
  73. package/cli/dist/cli.d.ts +0 -3
  74. package/cli/dist/cli.js +0 -8
  75. package/cli/dist/cli_types.d.ts +0 -7
  76. package/cli/dist/config.d.ts +0 -5
  77. package/cli/dist/config.js +0 -6
  78. package/cli/dist/importer.d.ts +0 -7
  79. package/cli/dist/importer.js +0 -16
  80. package/cli/dist/logger.d.ts +0 -7
  81. package/cli/dist/logger.js +0 -88
  82. package/cli/dist/mod.d.ts +0 -6
  83. package/cli/dist/mod.js +0 -4
  84. package/cli/src/cli.ts +0 -17
  85. package/cli/src/cli_types.ts +0 -9
  86. package/cli/src/config.ts +0 -9
  87. package/cli/src/importer.ts +0 -25
  88. package/cli/src/logger.ts +0 -126
  89. package/cli/src/mod.ts +0 -7
  90. package/cli/tsconfig.tsbuildinfo +0 -1
  91. package/nodejs_cli/dist/mod.d.ts +0 -2
  92. package/nodejs_cli/dist/mod.js +0 -20
  93. package/nodejs_cli/src/mod.ts +0 -25
  94. package/nodejs_cli/tsconfig.tsbuildinfo +0 -1
  95. /package/{nodejs_cli → nodejs}/package.json +0 -0
  96. /package/{cli/dist/cli_types.js → webdriver/dist/results.js} +0 -0
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Logger } from "./logger.js";
4
+ import * as path from "path";
5
+ import { runCollection } from "../../core/dist/mod.js";
6
+
7
+ let filepaths = process.argv.slice(2);
8
+
9
+ const logger = new Logger();
10
+
11
+ logger.log({
12
+ type: "start_run",
13
+ time: performance.now(),
14
+ expected_collection_count: filepaths.length,
15
+ });
16
+
17
+ for (const [collection_id, file] of filepaths.entries()) {
18
+ try {
19
+ let filepath = path.join(process.cwd(), file);
20
+ const { testModules } = await import(filepath);
21
+ await runCollection(logger, testModules, collection_id, filepath);
22
+ } catch (e: unknown) {
23
+ logger.log({
24
+ type: "collection_error",
25
+ collection_id,
26
+ error: e?.toString() ?? "wild horses error",
27
+ });
28
+ }
29
+ }
30
+
31
+ logger.log({
32
+ type: "end_run",
33
+ time: performance.now(),
34
+ });
35
+
36
+ console.log(logger.results);
37
+ logger.failed || logger.errored ? process.exit(1) : process.exit(0);
@@ -0,0 +1,234 @@
1
+ import type { LoggerAction } from "../../core/dist/mod.js";
2
+
3
+ export interface TestResults {
4
+ loggerStartAction: LoggerAction;
5
+ loggerEndAction: LoggerAction | undefined;
6
+ }
7
+
8
+ export interface ModuleResults {
9
+ loggerAction: LoggerAction;
10
+ fails: number;
11
+ errors: number;
12
+ expectedTests: number;
13
+ completedTests: number;
14
+ errorLogs: LoggerAction[];
15
+ testResults: (TestResults | undefined)[];
16
+ }
17
+
18
+ export interface CollectionResults {
19
+ loggerAction: LoggerAction;
20
+ fails: number;
21
+ errors: number;
22
+ expectedTests: number;
23
+ completedTests: number;
24
+ expectedModules: number;
25
+ completedModules: number;
26
+ errorLogs: LoggerAction[];
27
+ modules: (ModuleResults | undefined)[];
28
+ }
29
+
30
+ export interface RunResults {
31
+ fails: number;
32
+ errors: number;
33
+ startTime: number;
34
+ endTime: number;
35
+ testTime: number;
36
+ expectedTests: number;
37
+ completedTests: number;
38
+ expectedModules: number;
39
+ completedModules: number;
40
+ expectedCollections: number;
41
+ completedCollections: number;
42
+ errorLogs: LoggerAction[];
43
+ collections: (CollectionResults | undefined)[];
44
+ }
45
+
46
+ const SPACE = " ";
47
+
48
+ export function getResultsAsString(runResults: RunResults): string {
49
+ const output: string[] = [];
50
+
51
+ for (let errorAction of runResults.errorLogs) {
52
+ if ("run_error" !== errorAction.type) continue;
53
+ output.push(`${SPACE}[session_error]\n${errorAction.error}`);
54
+ }
55
+
56
+ // Lots of nested loops because results a nested structure.
57
+ // I'd rather see composition nested in one function
58
+ // than have for loops spread across each function.
59
+
60
+ if (!logRunResults(output, runResults))
61
+ for (const collection of runResults.collections) {
62
+ if (logCollectionResult(output, collection)) continue;
63
+
64
+ if (collection)
65
+ for (const moduleResult of collection.modules) {
66
+ if (logModuleResult(output, moduleResult)) continue;
67
+
68
+ if (moduleResult)
69
+ for (const testResult of moduleResult.testResults) {
70
+ logTest(output, testResult);
71
+ }
72
+ }
73
+ }
74
+
75
+ logSummary(output, runResults);
76
+
77
+ return output.join("\n");
78
+ }
79
+
80
+ function logRunResults(output: string[], result: RunResults): boolean {
81
+ // When everything goes right :3
82
+ if (
83
+ !result.fails &&
84
+ !result.errors &&
85
+ result.expectedTests === result.completedTests &&
86
+ result.expectedModules === result.completedModules &&
87
+ result.expectedCollections === result.completedCollections
88
+ ) {
89
+ output.push(`${result.completedTests} tests
90
+ ${result.completedModules} modules
91
+ ${result.completedCollections} collections`);
92
+ return true;
93
+ }
94
+
95
+ for (let errorAction of result.errorLogs) {
96
+ if ("run_error" !== errorAction.type) continue;
97
+ output.push(`[run_error] ${errorAction.error}`);
98
+ }
99
+
100
+ return false;
101
+ }
102
+
103
+ function logCollectionResult(
104
+ output: string[],
105
+ collection: CollectionResults | undefined,
106
+ ): boolean {
107
+ if (!collection) return true;
108
+
109
+ let { loggerAction } = collection;
110
+ if ("start_collection" !== loggerAction.type) return true;
111
+
112
+ output.push(`${SPACE}${loggerAction.collection_url}`);
113
+
114
+ // when everything in the collection goes right
115
+ if (
116
+ !collection.fails &&
117
+ !collection.errors &&
118
+ collection.expectedTests === collection.completedTests &&
119
+ collection.expectedModules === collection.completedModules
120
+ ) {
121
+ output.push(
122
+ `${collection.expectedTests} tests
123
+ ${loggerAction.expected_module_count} modules`,
124
+ );
125
+
126
+ return true;
127
+ }
128
+
129
+ for (let errorAction of collection.errorLogs) {
130
+ if ("collection_error" !== errorAction.type) continue;
131
+ output.push(`[collection_error] ${errorAction.error}`);
132
+ }
133
+
134
+ return false;
135
+ }
136
+
137
+ function logModuleResult(
138
+ output: string[],
139
+ module: ModuleResults | undefined,
140
+ ): boolean {
141
+ if (!module) return true;
142
+
143
+ let { loggerAction } = module;
144
+ if ("start_module" !== loggerAction.type) return true;
145
+
146
+ output.push(`${SPACE}${loggerAction.module_name}`);
147
+
148
+ // when everything in the module goes right
149
+ if (
150
+ !module.fails &&
151
+ !module.errors &&
152
+ module.expectedTests === module.completedTests
153
+ ) {
154
+ output.push(`${SPACE.repeat(2)}${module.expectedTests} tests`);
155
+ return true;
156
+ }
157
+
158
+ for (let errorAction of module.errorLogs) {
159
+ if ("collection_error" !== errorAction.type) continue;
160
+ output.push(`${SPACE}[module_error] ${errorAction.error}`);
161
+ }
162
+
163
+ return false;
164
+ }
165
+
166
+ function logTest(output: string[], test: TestResults | undefined) {
167
+ if (!test) return;
168
+
169
+ let { loggerStartAction, loggerEndAction } = test;
170
+ if ("start_test" !== loggerStartAction.type) return;
171
+
172
+ if ("test_error" === loggerEndAction?.type) {
173
+ let { test_name } = loggerStartAction;
174
+ output.push(
175
+ `${SPACE.repeat(2)}${test_name}
176
+ ${SPACE.repeat(3)}[error] ${loggerEndAction.error}`,
177
+ );
178
+ }
179
+
180
+ if ("end_test" === loggerEndAction?.type) {
181
+ let { assertions } = loggerEndAction;
182
+ const isAssertionArray = Array.isArray(assertions) && assertions.length;
183
+ const isAssertion =
184
+ !Array.isArray(assertions) &&
185
+ undefined !== assertions &&
186
+ null !== assertions;
187
+
188
+ if (isAssertion || isAssertionArray) {
189
+ let { test_name } = loggerStartAction;
190
+ output.push(`${SPACE.repeat(2)}${test_name}`);
191
+ }
192
+
193
+ if (isAssertion) {
194
+ output.push(`${SPACE.repeat(3)}- ${assertions}`);
195
+ }
196
+
197
+ if (isAssertionArray) {
198
+ for (const assertion of assertions) {
199
+ output.push(`${SPACE.repeat(3)}- ${assertion}`);
200
+ }
201
+ }
202
+ }
203
+ }
204
+
205
+ function logSummary(output: string[], runResults: RunResults) {
206
+ let status_with_color = runResults.fails
207
+ ? yellow("\u{2717} failed")
208
+ : blue("\u{2714} passed");
209
+
210
+ if (runResults.errors) {
211
+ status_with_color = gray("\u{2717} errored");
212
+ }
213
+
214
+ let totalTime = runResults.endTime - runResults.startTime;
215
+ output.push(`
216
+ ${status_with_color}
217
+ duration: ${runResults.testTime.toFixed(4)} mS
218
+ total: ${totalTime.toFixed(4)} mS
219
+ `);
220
+ }
221
+
222
+ // 39 - default foreground color
223
+ // 49 - default background color
224
+ function blue(text: string) {
225
+ return `\x1b[44m\x1b[97m${text}\x1b[0m`;
226
+ }
227
+
228
+ function yellow(text: string) {
229
+ return `\x1b[43m\x1b[97m${text}\x1b[0m`;
230
+ }
231
+
232
+ function gray(text: string) {
233
+ return `\x1b[100m\x1b[97m${text}\x1b[0m`;
234
+ }
@@ -2,6 +2,7 @@
2
2
  "extends": "../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": "./src",
5
- "outDir": "./dist"
5
+ "outDir": "./dist",
6
+ "declaration": false
6
7
  }
7
8
  }
@@ -0,0 +1 @@
1
+ {"root":["./src/logger.ts","./src/mod.ts","./src/results_str.ts"],"version":"5.9.3"}
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@w-lfpup/jackrabbit",
3
3
  "description": "A test runner without dependencies",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "license": "BSD-3-Clause",
6
6
  "workspaces": [
7
7
  "core",
8
8
  "tests",
9
- "cli",
10
- "nodejs_cli"
9
+ "nodejs",
10
+ "browser",
11
+ "webdriver"
11
12
  ],
12
13
  "bin": {
13
- "jackrabbit": "nodejs_cli/dist/mod.js"
14
+ "jackrabbit": "nodejs/dist/mod.js",
15
+ "jackrabbit_webdriver": "webdriver/dist/mod.js"
14
16
  },
15
17
  "scripts": {
16
18
  "prepare": "npm run build",
@@ -1,9 +1,20 @@
1
1
  declare function testsFail(): Promise<"fail tests failed to fail" | undefined>;
2
2
  declare function testsPass(): Promise<"passing tests failed to pass" | undefined>;
3
- export declare const testModules: {
4
- tests: (typeof testsFail | typeof testsPass)[];
3
+ declare function testsError(): Promise<"tests failed to error" | "tests should error not fail" | undefined>;
4
+ export declare const testModules: ({
5
+ tests: (typeof testsFail)[];
5
6
  options: {
6
7
  title: string;
7
8
  };
8
- }[];
9
+ } | {
10
+ tests: (typeof testsPass)[];
11
+ options: {
12
+ title: string;
13
+ };
14
+ } | {
15
+ tests: (typeof testsError)[];
16
+ options: {
17
+ title: string;
18
+ };
19
+ })[];
9
20
  export {};
package/tests/dist/mod.js CHANGED
@@ -1,30 +1,50 @@
1
1
  import * as FailTests from "./test_fail.test.js";
2
2
  import * as PassTests from "./test_pass.test.js";
3
- import { startRun } from "../../core/dist/mod.js";
3
+ import * as ErrorTests from "./test_error.test.js";
4
+ import { runCollection } from "../../core/dist/mod.js";
4
5
  import { TestLogger } from "./test_logger.js";
5
- // Test pass and fail behavior
6
- const failTestModules = [FailTests];
7
- const passTestModules = [PassTests];
8
6
  // jackrabbit test run won't pass failing tests
9
7
  async function testsFail() {
10
8
  let logger = new TestLogger();
11
- await startRun(logger, failTestModules);
9
+ await runCollection(logger, [FailTests], 0, "test_pass.tests.js");
10
+ if (logger.errored)
11
+ throw new Error("an error occured");
12
12
  if (!logger.failed)
13
13
  return "fail tests failed to fail";
14
14
  }
15
15
  // jackrabbit test run won't fail passing tests
16
16
  async function testsPass() {
17
17
  let logger = new TestLogger();
18
- await startRun(logger, passTestModules);
18
+ await runCollection(logger, [PassTests], 1, "test_fail.tests.js");
19
+ if (logger.errored)
20
+ throw new Error("an error occured");
19
21
  if (logger.failed)
20
22
  return "passing tests failed to pass";
21
23
  }
22
- const tests = [testsFail, testsPass];
23
- const options = {
24
- title: "Failures and Successes",
24
+ async function testsError() {
25
+ let logger = new TestLogger();
26
+ await runCollection(logger, [ErrorTests], 2, "test_error.tests.js");
27
+ if (!logger.errored)
28
+ return "tests failed to error";
29
+ if (logger.failed)
30
+ return "tests should error not fail";
31
+ }
32
+ const testFailures = {
33
+ tests: [testsFail],
34
+ options: {
35
+ title: "Failures",
36
+ },
37
+ };
38
+ const testSuccesses = {
39
+ tests: [testsPass],
40
+ options: {
41
+ title: "Sucesses",
42
+ },
25
43
  };
26
- const testModule = {
27
- tests,
28
- options,
44
+ const testErrors = {
45
+ tests: [testsError],
46
+ options: {
47
+ title: "Errors",
48
+ },
29
49
  };
30
- export const testModules = [testModule];
50
+ export const testModules = [testFailures, testSuccesses, testErrors];
@@ -0,0 +1,9 @@
1
+ declare function testStuffAndError(): undefined;
2
+ declare function testMoreStuffAndError(): string[];
3
+ declare function testStuffAndErrorAsync(): Promise<undefined>;
4
+ declare function testMoreStuffAndErrorAsync(): Promise<string[]>;
5
+ export declare const tests: (typeof testStuffAndError | typeof testMoreStuffAndError | typeof testStuffAndErrorAsync | typeof testMoreStuffAndErrorAsync)[];
6
+ export declare const options: {
7
+ title: string;
8
+ };
9
+ export {};
@@ -0,0 +1,27 @@
1
+ function testStuffAndError() {
2
+ throw Error("yo");
3
+ return;
4
+ }
5
+ function testMoreStuffAndError() {
6
+ throw Error("bro");
7
+ return ["bro"];
8
+ }
9
+ async function testStuffAndErrorAsync() {
10
+ throw Error("what's");
11
+ return;
12
+ }
13
+ async function testMoreStuffAndErrorAsync() {
14
+ throw Error("good");
15
+ return ["good"];
16
+ }
17
+ // export tests
18
+ export const tests = [
19
+ testStuffAndError,
20
+ testMoreStuffAndError,
21
+ testStuffAndErrorAsync,
22
+ testMoreStuffAndErrorAsync,
23
+ ];
24
+ // export optional test details
25
+ export const options = {
26
+ title: import.meta.url,
27
+ };
@@ -0,0 +1,9 @@
1
+ declare function testStuffAndError(): undefined;
2
+ declare function testMoreStuffAndError(): string[];
3
+ declare function testStuffAndErrorAsync(): Promise<undefined>;
4
+ declare function testMoreStuffAndErrorAsync(): Promise<string[]>;
5
+ export declare const tests: (typeof testStuffAndError | typeof testMoreStuffAndError | typeof testStuffAndErrorAsync | typeof testMoreStuffAndErrorAsync)[];
6
+ export declare const options: {
7
+ title: string;
8
+ };
9
+ export {};
@@ -0,0 +1,27 @@
1
+ function testStuffAndError() {
2
+ throw Error("yo");
3
+ return;
4
+ }
5
+ function testMoreStuffAndError() {
6
+ throw Error("bro");
7
+ return ["bro"];
8
+ }
9
+ async function testStuffAndErrorAsync() {
10
+ throw Error("what's");
11
+ return;
12
+ }
13
+ async function testMoreStuffAndErrorAsync() {
14
+ throw Error("good");
15
+ return ["good"];
16
+ }
17
+ // export tests
18
+ export const tests = [
19
+ testStuffAndError,
20
+ testMoreStuffAndError,
21
+ testStuffAndErrorAsync,
22
+ testMoreStuffAndErrorAsync,
23
+ ];
24
+ // export optional test details
25
+ export const options = {
26
+ title: import.meta.url,
27
+ };
@@ -1,7 +1,8 @@
1
- import type { LoggerAction, LoggerInterface, TestModule } from "../../core/dist/mod.ts";
1
+ import type { LoggerAction, LoggerInterface } from "../../core/dist/mod.ts";
2
2
  declare class TestLogger implements LoggerInterface {
3
3
  cancelled: boolean;
4
+ errored: boolean;
4
5
  failed: boolean;
5
- log(_testModule: TestModule[], action: LoggerAction): void;
6
+ log(action: LoggerAction): void;
6
7
  }
7
8
  export { TestLogger };
@@ -1,10 +1,14 @@
1
1
  class TestLogger {
2
2
  cancelled = false;
3
+ errored = false;
3
4
  failed = false;
4
- log(_testModule, action) {
5
+ log(action) {
5
6
  if (hasTestFailed(action)) {
6
7
  this.failed = true;
7
8
  }
9
+ if ("test_error" === action.type) {
10
+ this.errored = true;
11
+ }
8
12
  }
9
13
  }
10
14
  function hasTestFailed(action) {
package/tests/src/mod.ts CHANGED
@@ -1,39 +1,55 @@
1
1
  import * as FailTests from "./test_fail.test.js";
2
2
  import * as PassTests from "./test_pass.test.js";
3
+ import * as ErrorTests from "./test_error.test.js";
3
4
 
4
- import { startRun } from "../../core/dist/mod.js";
5
+ import { runCollection } from "../../core/dist/mod.js";
5
6
  import { TestLogger } from "./test_logger.js";
6
7
 
7
- // Test pass and fail behavior
8
-
9
- const failTestModules = [FailTests];
10
- const passTestModules = [PassTests];
11
-
12
8
  // jackrabbit test run won't pass failing tests
13
9
  async function testsFail() {
14
10
  let logger = new TestLogger();
15
- await startRun(logger, failTestModules);
11
+ await runCollection(logger, [FailTests], 0, "test_pass.tests.js");
16
12
 
13
+ if (logger.errored) throw new Error("an error occured");
17
14
  if (!logger.failed) return "fail tests failed to fail";
18
15
  }
19
16
 
20
17
  // jackrabbit test run won't fail passing tests
21
18
  async function testsPass() {
22
19
  let logger = new TestLogger();
23
- await startRun(logger, passTestModules);
20
+ await runCollection(logger, [PassTests], 1, "test_fail.tests.js");
24
21
 
22
+ if (logger.errored) throw new Error("an error occured");
25
23
  if (logger.failed) return "passing tests failed to pass";
26
24
  }
27
25
 
28
- const tests = [testsFail, testsPass];
26
+ async function testsError() {
27
+ let logger = new TestLogger();
28
+ await runCollection(logger, [ErrorTests], 2, "test_error.tests.js");
29
+
30
+ if (!logger.errored) return "tests failed to error";
31
+ if (logger.failed) return "tests should error not fail";
32
+ }
33
+
34
+ const testFailures = {
35
+ tests: [testsFail],
36
+ options: {
37
+ title: "Failures",
38
+ },
39
+ };
29
40
 
30
- const options = {
31
- title: "Failures and Successes",
41
+ const testSuccesses = {
42
+ tests: [testsPass],
43
+ options: {
44
+ title: "Sucesses",
45
+ },
32
46
  };
33
47
 
34
- const testModule = {
35
- tests,
36
- options,
48
+ const testErrors = {
49
+ tests: [testsError],
50
+ options: {
51
+ title: "Errors",
52
+ },
37
53
  };
38
54
 
39
- export const testModules = [testModule];
55
+ export const testModules = [testFailures, testSuccesses, testErrors];
@@ -0,0 +1,32 @@
1
+ function testStuffAndError(): undefined {
2
+ throw Error("yo");
3
+ return;
4
+ }
5
+
6
+ function testMoreStuffAndError() {
7
+ throw Error("bro");
8
+ return ["bro"];
9
+ }
10
+
11
+ async function testStuffAndErrorAsync(): Promise<undefined> {
12
+ throw Error("what's");
13
+ return;
14
+ }
15
+
16
+ async function testMoreStuffAndErrorAsync(): Promise<string[]> {
17
+ throw Error("good");
18
+ return ["good"];
19
+ }
20
+
21
+ // export tests
22
+ export const tests = [
23
+ testStuffAndError,
24
+ testMoreStuffAndError,
25
+ testStuffAndErrorAsync,
26
+ testMoreStuffAndErrorAsync,
27
+ ];
28
+
29
+ // export optional test details
30
+ export const options = {
31
+ title: import.meta.url,
32
+ };
@@ -6,12 +6,17 @@ import type {
6
6
 
7
7
  class TestLogger implements LoggerInterface {
8
8
  cancelled: boolean = false;
9
+ errored: boolean = false;
9
10
  failed: boolean = false;
10
11
 
11
- log(_testModule: TestModule[], action: LoggerAction) {
12
+ log(action: LoggerAction) {
12
13
  if (hasTestFailed(action)) {
13
14
  this.failed = true;
14
15
  }
16
+
17
+ if ("test_error" === action.type) {
18
+ this.errored = true;
19
+ }
15
20
  }
16
21
  }
17
22
 
@@ -1 +1 @@
1
- {"root":["./src/mod.ts","./src/test_fail.test.ts","./src/test_logger.ts","./src/test_pass.test.ts"],"version":"5.9.3"}
1
+ {"root":["./src/mod.ts","./src/test_error.test.ts","./src/test_fail.test.ts","./src/test_logger.ts","./src/test_pass.test.ts"],"version":"5.9.3"}
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "lib": ["ESNext"],
3
+ "lib": ["ESNext", "DOM"],
4
4
  "module": "nodenext",
5
5
  "target": "esnext",
6
6
  "strict": true,