@w-lfpup/jackrabbit 0.3.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 +15 -5
- package/.github/workflows/tests.yml +0 -11
- package/browser/dist/mod.js +0 -1
- package/nodejs/dist/logger.js +5 -2
- package/nodejs/dist/mod.js +3 -1
- package/nodejs/dist/results.js +11 -5
- package/nodejs/dist/results_str.js +5 -5
- package/nodejs/src/logger.ts +11 -4
- package/nodejs/src/mod.ts +3 -1
- package/nodejs/src/{results_str.ts → results.ts} +10 -5
- package/nodejs/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/tests/dist/mod.js +0 -2
- package/tests/dist/test_error.test.js +0 -2
- package/tests/dist/test_fail.test.js +0 -2
- package/tests/dist/test_pass.test.js +0 -2
- package/tsconfig.json +2 -1
- package/webdriver/dist/config.js +0 -1
- package/webdriver/dist/logger.js +3 -6
- package/webdriver/dist/mod.js +3 -4
- package/webdriver/dist/results.js +190 -1
- package/webdriver/dist/routes.js +13 -23
- package/webdriver/dist/webdriver.js +2 -3
- package/webdriver/src/logger.ts +3 -3
- package/webdriver/src/mod.ts +3 -1
- package/webdriver/src/results.ts +258 -3
- package/webdriver/src/routes.ts +15 -28
- package/webdriver/src/webdriver.ts +3 -2
- package/webdriver/tsconfig.tsbuildinfo +1 -1
- package/webdriver/src/results_str.ts +0 -222
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SessionResults,
|
|
3
|
-
RunResults,
|
|
4
|
-
CollectionResults,
|
|
5
|
-
ModuleResults,
|
|
6
|
-
TestResults,
|
|
7
|
-
} from "./results.js";
|
|
8
|
-
|
|
9
|
-
const SPACE = " ";
|
|
10
|
-
|
|
11
|
-
export function getResultsAsString(sessionResults: SessionResults): string {
|
|
12
|
-
const output: string[] = [];
|
|
13
|
-
|
|
14
|
-
// Lots of nested loops because results a nested structure.
|
|
15
|
-
// I'd rather see composition nested in one function
|
|
16
|
-
// than have for loops spread across each function.
|
|
17
|
-
|
|
18
|
-
logSessionErrors(output, sessionResults);
|
|
19
|
-
|
|
20
|
-
for (let [, result] of sessionResults.runs) {
|
|
21
|
-
if (logRunResults(output, result)) continue;
|
|
22
|
-
|
|
23
|
-
for (const collection of result.collections) {
|
|
24
|
-
if (logCollectionResult(output, collection)) continue;
|
|
25
|
-
|
|
26
|
-
if (collection)
|
|
27
|
-
for (const moduleResult of collection.modules) {
|
|
28
|
-
if (logModuleResult(output, moduleResult)) continue;
|
|
29
|
-
|
|
30
|
-
if (moduleResult)
|
|
31
|
-
for (const testResult of moduleResult.testResults) {
|
|
32
|
-
logTest(output, testResult);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
logSummary(output, sessionResults);
|
|
39
|
-
|
|
40
|
-
return output.join("\n");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function logSessionErrors(output: string[], sessionResults: SessionResults) {
|
|
44
|
-
for (let [, result] of sessionResults.runs) {
|
|
45
|
-
for (let errorAction of result.errorLogs) {
|
|
46
|
-
if ("session_error" === errorAction.type) {
|
|
47
|
-
output.push(
|
|
48
|
-
`\n[${result.webdriverParams.title}:session_error] ${errorAction.error}`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function logRunResults(output: string[], result: RunResults): boolean {
|
|
56
|
-
output.push(`
|
|
57
|
-
${result.webdriverParams.title}`);
|
|
58
|
-
|
|
59
|
-
for (let errorAction of result.errorLogs) {
|
|
60
|
-
if ("log" === errorAction.type) {
|
|
61
|
-
if ("run_error" === errorAction.loggerAction.type) {
|
|
62
|
-
output.push(`${SPACE}[run_error] ${errorAction.loggerAction.error}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!result.expectedTests) {
|
|
68
|
-
output.push(` No test runs occured.`);
|
|
69
|
-
}
|
|
70
|
-
// When everything goes right :3
|
|
71
|
-
if (
|
|
72
|
-
!result.fails &&
|
|
73
|
-
!result.errors &&
|
|
74
|
-
result.expectedTests === result.completedTests &&
|
|
75
|
-
result.expectedModules === result.completedModules &&
|
|
76
|
-
result.expectedCollections === result.completedCollections
|
|
77
|
-
) {
|
|
78
|
-
output.push(`${SPACE}${result.completedTests} tests
|
|
79
|
-
${SPACE}${result.completedModules} modules
|
|
80
|
-
${SPACE}${result.completedCollections} collections`);
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function logCollectionResult(
|
|
88
|
-
output: string[],
|
|
89
|
-
collection: CollectionResults | undefined,
|
|
90
|
-
): boolean {
|
|
91
|
-
if (!collection) return true;
|
|
92
|
-
|
|
93
|
-
let { loggerAction } = collection;
|
|
94
|
-
if ("start_collection" !== loggerAction.type) return true;
|
|
95
|
-
|
|
96
|
-
output.push(`${SPACE}${loggerAction.collection_url}`);
|
|
97
|
-
|
|
98
|
-
// when everything in the collection goes right
|
|
99
|
-
if (
|
|
100
|
-
!collection.fails &&
|
|
101
|
-
!collection.errors &&
|
|
102
|
-
collection.expectedTests === collection.completedTests &&
|
|
103
|
-
collection.expectedModules === collection.completedModules
|
|
104
|
-
) {
|
|
105
|
-
output.push(
|
|
106
|
-
`${SPACE.repeat(2)}${collection.expectedTests} tests
|
|
107
|
-
${SPACE.repeat(2)}${loggerAction.expected_module_count} modules`,
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
for (let errorAction of collection.errorLogs) {
|
|
114
|
-
if ("collection_error" !== errorAction.type) continue;
|
|
115
|
-
output.push(`${SPACE.repeat(2)}[collection_error] ${errorAction.error}`);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function logModuleResult(
|
|
122
|
-
output: string[],
|
|
123
|
-
module: ModuleResults | undefined,
|
|
124
|
-
): boolean {
|
|
125
|
-
if (!module) return true;
|
|
126
|
-
|
|
127
|
-
let { loggerAction } = module;
|
|
128
|
-
if ("start_module" !== loggerAction.type) return true;
|
|
129
|
-
|
|
130
|
-
output.push(`${SPACE.repeat(2)}${loggerAction.module_name}`);
|
|
131
|
-
|
|
132
|
-
// when everything in the module goes right
|
|
133
|
-
if (
|
|
134
|
-
!module.fails &&
|
|
135
|
-
!module.errors &&
|
|
136
|
-
module.expectedTests === module.completedTests
|
|
137
|
-
) {
|
|
138
|
-
output.push(`${SPACE.repeat(3)}${module.expectedTests} tests`);
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
for (let errorAction of module.errorLogs) {
|
|
143
|
-
if ("collection_error" !== errorAction.type) continue;
|
|
144
|
-
output.push(`${SPACE.repeat(2)}[module_error] ${errorAction.error}`);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function logTest(output: string[], test: TestResults | undefined) {
|
|
151
|
-
if (!test) return;
|
|
152
|
-
|
|
153
|
-
let { loggerStartAction, loggerEndAction } = test;
|
|
154
|
-
if ("start_test" !== loggerStartAction.type) return;
|
|
155
|
-
|
|
156
|
-
if ("test_error" === loggerEndAction?.type) {
|
|
157
|
-
let { test_name } = loggerStartAction;
|
|
158
|
-
output.push(
|
|
159
|
-
`${SPACE.repeat(3)}${test_name}
|
|
160
|
-
${SPACE.repeat(4)}[error] ${loggerEndAction.error}`,
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if ("end_test" === loggerEndAction?.type) {
|
|
165
|
-
let { assertions } = loggerEndAction;
|
|
166
|
-
const isAssertionArray = Array.isArray(assertions) && assertions.length;
|
|
167
|
-
const isAssertion =
|
|
168
|
-
!Array.isArray(assertions) &&
|
|
169
|
-
undefined !== assertions &&
|
|
170
|
-
null !== assertions;
|
|
171
|
-
|
|
172
|
-
if (isAssertion || isAssertionArray) {
|
|
173
|
-
let { test_name } = loggerStartAction;
|
|
174
|
-
output.push(`${SPACE.repeat(3)}${test_name}`);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (isAssertion) {
|
|
178
|
-
output.push(`${SPACE.repeat(4)}- ${assertions}`);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (isAssertionArray) {
|
|
182
|
-
for (const assertion of assertions) {
|
|
183
|
-
output.push(`${SPACE.repeat(4)}- ${assertion}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function logSummary(output: string[], sessionResults: SessionResults) {
|
|
190
|
-
let status_with_color = blue("\u{2714} passed");
|
|
191
|
-
if (sessionResults.fails) status_with_color = yellow("\u{2717} failed");
|
|
192
|
-
if (sessionResults.errors) status_with_color = gray("\u{2717} errored");
|
|
193
|
-
|
|
194
|
-
// expected tests
|
|
195
|
-
|
|
196
|
-
let totalTime = 0;
|
|
197
|
-
let testTime = 0;
|
|
198
|
-
for (let [, run] of sessionResults.runs) {
|
|
199
|
-
totalTime += run.endTime - run.startTime;
|
|
200
|
-
testTime += run.testTime;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
output.push(`
|
|
204
|
-
${status_with_color}
|
|
205
|
-
duration: ${testTime.toFixed(4)} mS
|
|
206
|
-
total: ${totalTime.toFixed(4)} mS
|
|
207
|
-
`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// 39 - default foreground color
|
|
211
|
-
// 49 - default background color
|
|
212
|
-
function blue(text: string) {
|
|
213
|
-
return `\x1b[44m\x1b[97m${text}\x1b[0m`;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function yellow(text: string) {
|
|
217
|
-
return `\x1b[43m\x1b[97m${text}\x1b[0m`;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function gray(text: string) {
|
|
221
|
-
return `\x1b[100m\x1b[97m${text}\x1b[0m`;
|
|
222
|
-
}
|