@w-lfpup/jackrabbit 0.2.0 → 0.3.1
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.
- package/.github/workflows/browsers.json +55 -0
- package/.github/workflows/browsers.macos.json +51 -0
- package/.github/workflows/browsers.windows.json +19 -0
- package/.github/workflows/tests.yml +13 -0
- package/README.md +41 -1
- package/browser/dist/logger.js +43 -0
- package/browser/dist/mod.js +25 -0
- package/browser/dist/queue.js +27 -0
- package/browser/dist/runner.js +20 -0
- package/{cli → browser}/package.json +1 -1
- package/browser/src/logger.ts +57 -0
- package/browser/src/mod.ts +30 -0
- package/browser/src/runner.ts +22 -0
- package/browser/tsconfig.json +11 -0
- package/browser/tsconfig.tsbuildinfo +1 -0
- package/browsers.json +38 -0
- package/core/dist/jackrabbit_types.d.ts +61 -27
- package/core/dist/mod.d.ts +2 -2
- package/core/dist/mod.js +1 -1
- package/core/dist/run_steps.d.ts +2 -2
- package/core/dist/run_steps.js +83 -67
- package/core/src/jackrabbit_types.ts +72 -28
- package/core/src/mod.ts +2 -8
- package/core/src/run_steps.ts +111 -80
- package/examples/hello_world/goodbye_world.ts +1 -1
- package/examples/hello_world/hello_world.ts +1 -1
- package/nodejs/dist/logger.js +164 -0
- package/nodejs/dist/mod.js +33 -0
- package/nodejs/dist/results.js +145 -0
- package/nodejs/dist/results_str.js +147 -0
- package/nodejs/dist/runner.js +17 -0
- package/nodejs/src/logger.ts +200 -0
- package/nodejs/src/mod.ts +39 -0
- package/nodejs/src/results.ts +239 -0
- package/{nodejs_cli → nodejs}/tsconfig.json +2 -1
- package/nodejs/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -4
- package/tests/dist/mod.d.ts +14 -3
- package/tests/dist/mod.js +33 -15
- package/tests/dist/test_error.test.d.ts +9 -0
- package/tests/dist/test_error.test.js +25 -0
- package/tests/dist/test_errors.test.d.ts +9 -0
- package/tests/dist/test_errors.test.js +27 -0
- package/tests/dist/test_fail.test.js +0 -2
- package/tests/dist/test_logger.d.ts +3 -2
- package/tests/dist/test_logger.js +5 -1
- package/tests/dist/test_pass.test.js +0 -2
- package/tests/src/mod.ts +31 -15
- package/tests/src/test_error.test.ts +32 -0
- package/tests/src/test_logger.ts +6 -1
- package/tests/tsconfig.tsbuildinfo +1 -1
- package/tsconfig.json +3 -2
- package/webdriver/dist/config.js +56 -0
- package/webdriver/dist/eventbus.js +18 -0
- package/webdriver/dist/listeners.js +21 -0
- package/webdriver/dist/logger.js +200 -0
- package/webdriver/dist/mod.js +35 -0
- package/webdriver/dist/results.js +190 -0
- package/webdriver/dist/results_str.js +167 -0
- package/webdriver/dist/routes.js +162 -0
- package/webdriver/dist/routes2.js +163 -0
- package/webdriver/dist/test_hangar.js +20 -0
- package/webdriver/dist/webdriver.js +272 -0
- package/webdriver/package.json +8 -0
- package/webdriver/src/config.ts +89 -0
- package/webdriver/src/eventbus.ts +104 -0
- package/webdriver/src/logger.ts +247 -0
- package/webdriver/src/mod.ts +45 -0
- package/webdriver/src/results.ts +311 -0
- package/webdriver/src/routes.ts +198 -0
- package/webdriver/src/test_hangar.ts +25 -0
- package/webdriver/src/webdriver.ts +373 -0
- package/{cli → webdriver}/tsconfig.json +1 -0
- package/webdriver/tsconfig.tsbuildinfo +1 -0
- package/cli/dist/cli.d.ts +0 -3
- package/cli/dist/cli.js +0 -8
- package/cli/dist/cli_types.d.ts +0 -7
- package/cli/dist/cli_types.js +0 -1
- package/cli/dist/config.d.ts +0 -5
- package/cli/dist/config.js +0 -6
- package/cli/dist/importer.d.ts +0 -7
- package/cli/dist/importer.js +0 -16
- package/cli/dist/logger.d.ts +0 -7
- package/cli/dist/logger.js +0 -88
- package/cli/dist/mod.d.ts +0 -6
- package/cli/dist/mod.js +0 -4
- package/cli/src/cli.ts +0 -17
- package/cli/src/cli_types.ts +0 -9
- package/cli/src/config.ts +0 -9
- package/cli/src/importer.ts +0 -25
- package/cli/src/logger.ts +0 -126
- package/cli/src/mod.ts +0 -7
- package/cli/tsconfig.tsbuildinfo +0 -1
- package/nodejs_cli/dist/mod.d.ts +0 -2
- package/nodejs_cli/dist/mod.js +0 -20
- package/nodejs_cli/src/mod.ts +0 -25
- package/nodejs_cli/tsconfig.tsbuildinfo +0 -1
- /package/{nodejs_cli → nodejs}/package.json +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
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 || !logger.completed
|
|
38
|
+
? process.exit(1)
|
|
39
|
+
: process.exit(0);
|
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
if (result.errorLogs.length) output.push("");
|
|
101
|
+
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function logCollectionResult(
|
|
106
|
+
output: string[],
|
|
107
|
+
collection: CollectionResults | undefined,
|
|
108
|
+
): boolean {
|
|
109
|
+
if (!collection) return true;
|
|
110
|
+
|
|
111
|
+
let { loggerAction } = collection;
|
|
112
|
+
if ("start_collection" !== loggerAction.type) return true;
|
|
113
|
+
|
|
114
|
+
output.push(`${loggerAction.collection_url}`);
|
|
115
|
+
|
|
116
|
+
// when everything in the collection goes right
|
|
117
|
+
if (
|
|
118
|
+
!collection.fails &&
|
|
119
|
+
!collection.errors &&
|
|
120
|
+
collection.expectedTests === collection.completedTests &&
|
|
121
|
+
collection.expectedModules === collection.completedModules
|
|
122
|
+
) {
|
|
123
|
+
output.push(
|
|
124
|
+
`${SPACE}${collection.expectedTests} tests
|
|
125
|
+
${SPACE}${loggerAction.expected_module_count} modules`,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
for (let errorAction of collection.errorLogs) {
|
|
132
|
+
if ("collection_error" !== errorAction.type) continue;
|
|
133
|
+
output.push(`${SPACE}[collection_error] ${errorAction.error}`);
|
|
134
|
+
}
|
|
135
|
+
if (collection.errorLogs.length) output.push("");
|
|
136
|
+
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function logModuleResult(
|
|
141
|
+
output: string[],
|
|
142
|
+
module: ModuleResults | undefined,
|
|
143
|
+
): boolean {
|
|
144
|
+
if (!module) return true;
|
|
145
|
+
|
|
146
|
+
let { loggerAction } = module;
|
|
147
|
+
if ("start_module" !== loggerAction.type) return true;
|
|
148
|
+
|
|
149
|
+
output.push(`${SPACE}${loggerAction.module_name}`);
|
|
150
|
+
|
|
151
|
+
// when everything in the module goes right
|
|
152
|
+
if (
|
|
153
|
+
!module.fails &&
|
|
154
|
+
!module.errors &&
|
|
155
|
+
module.expectedTests === module.completedTests
|
|
156
|
+
) {
|
|
157
|
+
output.push(`${SPACE.repeat(2)}${module.expectedTests} tests`);
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
for (let errorAction of module.errorLogs) {
|
|
162
|
+
if ("collection_error" !== errorAction.type) continue;
|
|
163
|
+
output.push(`${SPACE.repeat(2)}[module_error] ${errorAction.error}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (module.errorLogs.length) output.push("");
|
|
167
|
+
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function logTest(output: string[], test: TestResults | undefined) {
|
|
172
|
+
if (!test) return;
|
|
173
|
+
|
|
174
|
+
let { loggerStartAction, loggerEndAction } = test;
|
|
175
|
+
if ("start_test" !== loggerStartAction.type) return;
|
|
176
|
+
|
|
177
|
+
if ("test_error" === loggerEndAction?.type) {
|
|
178
|
+
let { test_name } = loggerStartAction;
|
|
179
|
+
output.push(
|
|
180
|
+
`${SPACE.repeat(2)}${test_name}
|
|
181
|
+
${SPACE.repeat(3)}[error] ${loggerEndAction.error}`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if ("end_test" === loggerEndAction?.type) {
|
|
186
|
+
let { assertions } = loggerEndAction;
|
|
187
|
+
const isAssertionArray = Array.isArray(assertions) && assertions.length;
|
|
188
|
+
const isAssertion =
|
|
189
|
+
!Array.isArray(assertions) &&
|
|
190
|
+
undefined !== assertions &&
|
|
191
|
+
null !== assertions;
|
|
192
|
+
|
|
193
|
+
if (isAssertion || isAssertionArray) {
|
|
194
|
+
let { test_name } = loggerStartAction;
|
|
195
|
+
output.push(`${SPACE.repeat(2)}${test_name}`);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (isAssertion) {
|
|
199
|
+
output.push(`${SPACE.repeat(3)}- ${assertions}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (isAssertionArray) {
|
|
203
|
+
for (const assertion of assertions) {
|
|
204
|
+
output.push(`${SPACE.repeat(3)}- ${assertion}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function logSummary(output: string[], runResults: RunResults) {
|
|
211
|
+
let status_with_color = runResults.fails
|
|
212
|
+
? yellow("\u{2717} failed")
|
|
213
|
+
: blue("\u{2714} passed");
|
|
214
|
+
|
|
215
|
+
if (runResults.errors) {
|
|
216
|
+
status_with_color = gray("\u{2717} errored");
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
let totalTime = runResults.endTime - runResults.startTime;
|
|
220
|
+
output.push(`
|
|
221
|
+
${status_with_color}
|
|
222
|
+
duration: ${runResults.testTime.toFixed(4)} mS
|
|
223
|
+
total: ${totalTime.toFixed(4)} mS
|
|
224
|
+
`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// 39 - default foreground color
|
|
228
|
+
// 49 - default background color
|
|
229
|
+
function blue(text: string) {
|
|
230
|
+
return `\x1b[44m\x1b[97m${text}\x1b[0m`;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function yellow(text: string) {
|
|
234
|
+
return `\x1b[43m\x1b[97m${text}\x1b[0m`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function gray(text: string) {
|
|
238
|
+
return `\x1b[100m\x1b[97m${text}\x1b[0m`;
|
|
239
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/logger.ts","./src/mod.ts","./src/results.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.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"workspaces": [
|
|
7
7
|
"core",
|
|
8
8
|
"tests",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"nodejs",
|
|
10
|
+
"browser",
|
|
11
|
+
"webdriver"
|
|
11
12
|
],
|
|
12
13
|
"bin": {
|
|
13
|
-
"jackrabbit": "
|
|
14
|
+
"jackrabbit": "nodejs/dist/mod.js",
|
|
15
|
+
"jackrabbit_webdriver": "webdriver/dist/mod.js"
|
|
14
16
|
},
|
|
15
17
|
"scripts": {
|
|
16
18
|
"prepare": "npm run build",
|
package/tests/dist/mod.d.ts
CHANGED
|
@@ -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
|
-
|
|
4
|
-
|
|
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,48 @@
|
|
|
1
1
|
import * as FailTests from "./test_fail.test.js";
|
|
2
2
|
import * as PassTests from "./test_pass.test.js";
|
|
3
|
-
import
|
|
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
|
-
// jackrabbit test run won't pass failing tests
|
|
9
6
|
async function testsFail() {
|
|
10
7
|
let logger = new TestLogger();
|
|
11
|
-
await
|
|
8
|
+
await runCollection(logger, [FailTests], 0, "test_pass.tests.js");
|
|
9
|
+
if (logger.errored)
|
|
10
|
+
throw new Error("an error occured");
|
|
12
11
|
if (!logger.failed)
|
|
13
12
|
return "fail tests failed to fail";
|
|
14
13
|
}
|
|
15
|
-
// jackrabbit test run won't fail passing tests
|
|
16
14
|
async function testsPass() {
|
|
17
15
|
let logger = new TestLogger();
|
|
18
|
-
await
|
|
16
|
+
await runCollection(logger, [PassTests], 1, "test_fail.tests.js");
|
|
17
|
+
if (logger.errored)
|
|
18
|
+
throw new Error("an error occured");
|
|
19
19
|
if (logger.failed)
|
|
20
20
|
return "passing tests failed to pass";
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
async function testsError() {
|
|
23
|
+
let logger = new TestLogger();
|
|
24
|
+
await runCollection(logger, [ErrorTests], 2, "test_error.tests.js");
|
|
25
|
+
if (!logger.errored)
|
|
26
|
+
return "tests failed to error";
|
|
27
|
+
if (logger.failed)
|
|
28
|
+
return "tests should error not fail";
|
|
29
|
+
}
|
|
30
|
+
const testFailures = {
|
|
31
|
+
tests: [testsFail],
|
|
32
|
+
options: {
|
|
33
|
+
title: "Failures",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const testSuccesses = {
|
|
37
|
+
tests: [testsPass],
|
|
38
|
+
options: {
|
|
39
|
+
title: "Sucesses",
|
|
40
|
+
},
|
|
25
41
|
};
|
|
26
|
-
const
|
|
27
|
-
tests,
|
|
28
|
-
options
|
|
42
|
+
const testErrors = {
|
|
43
|
+
tests: [testsError],
|
|
44
|
+
options: {
|
|
45
|
+
title: "Errors",
|
|
46
|
+
},
|
|
29
47
|
};
|
|
30
|
-
export const testModules = [
|
|
48
|
+
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,25 @@
|
|
|
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 const tests = [
|
|
18
|
+
testStuffAndError,
|
|
19
|
+
testMoreStuffAndError,
|
|
20
|
+
testStuffAndErrorAsync,
|
|
21
|
+
testMoreStuffAndErrorAsync,
|
|
22
|
+
];
|
|
23
|
+
export const options = {
|
|
24
|
+
title: import.meta.url,
|
|
25
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -10,14 +10,12 @@ async function testStuffAndFailAsync() {
|
|
|
10
10
|
async function testMoreStuffAndFailAsync() {
|
|
11
11
|
return ["this test also failed!"];
|
|
12
12
|
}
|
|
13
|
-
// export tests
|
|
14
13
|
export const tests = [
|
|
15
14
|
testStuffAndFail,
|
|
16
15
|
testMoreStuffAndFail,
|
|
17
16
|
testStuffAndFailAsync,
|
|
18
17
|
testMoreStuffAndFailAsync,
|
|
19
18
|
];
|
|
20
|
-
// export optional test details
|
|
21
19
|
export const options = {
|
|
22
20
|
title: import.meta.url,
|
|
23
21
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { LoggerAction, LoggerInterface
|
|
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(
|
|
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(
|
|
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) {
|
|
@@ -10,14 +10,12 @@ async function testStuffAndPassAsync() {
|
|
|
10
10
|
async function testMoreStuffAndPassAsync() {
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
|
-
// export tests
|
|
14
13
|
export const tests = [
|
|
15
14
|
testStuffAndPass,
|
|
16
15
|
testMoreStuffAndPass,
|
|
17
16
|
testStuffAndPassAsync,
|
|
18
17
|
testMoreStuffAndPassAsync,
|
|
19
18
|
];
|
|
20
|
-
// export optional test details
|
|
21
19
|
export const options = {
|
|
22
20
|
title: import.meta.url,
|
|
23
21
|
};
|
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 {
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
31
|
-
|
|
41
|
+
const testSuccesses = {
|
|
42
|
+
tests: [testsPass],
|
|
43
|
+
options: {
|
|
44
|
+
title: "Sucesses",
|
|
45
|
+
},
|
|
32
46
|
};
|
|
33
47
|
|
|
34
|
-
const
|
|
35
|
-
tests,
|
|
36
|
-
options
|
|
48
|
+
const testErrors = {
|
|
49
|
+
tests: [testsError],
|
|
50
|
+
options: {
|
|
51
|
+
title: "Errors",
|
|
52
|
+
},
|
|
37
53
|
};
|
|
38
54
|
|
|
39
|
-
export const testModules = [
|
|
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
|
+
};
|
package/tests/src/test_logger.ts
CHANGED
|
@@ -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(
|
|
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"}
|