@allurereport/reader 3.15.0 → 3.16.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/dist/allure2/index.js +52 -7
- package/dist/allure2/model.d.ts +2 -0
- package/package.json +4 -4
package/dist/allure2/index.js
CHANGED
|
@@ -17,6 +17,13 @@ const xmlParser = new XMLParser({
|
|
|
17
17
|
isArray: (tagName, jPath) => arrayTags.has(jPath.toString()),
|
|
18
18
|
});
|
|
19
19
|
const readerId = "allure2";
|
|
20
|
+
const historyMetadataKeys = {
|
|
21
|
+
"history.json": "allure2_history",
|
|
22
|
+
"history-trend.json": "allure2_history_trend",
|
|
23
|
+
"duration-trend.json": "allure2_duration_trend",
|
|
24
|
+
"retry-trend.json": "allure2_retry_trend",
|
|
25
|
+
"categories-trend.json": "allure2_categories_trend",
|
|
26
|
+
};
|
|
20
27
|
const isAllure2AttachmentFileName = (fileName) => {
|
|
21
28
|
const attachmentIdx = fileName.lastIndexOf("-attachment");
|
|
22
29
|
if (attachmentIdx === -1) {
|
|
@@ -44,6 +51,8 @@ const matchesAllure2File = (fileName) => {
|
|
|
44
51
|
return true;
|
|
45
52
|
if (fileName === "environment.xml")
|
|
46
53
|
return true;
|
|
54
|
+
if (fileName in historyMetadataKeys)
|
|
55
|
+
return true;
|
|
47
56
|
return false;
|
|
48
57
|
};
|
|
49
58
|
export const allure2 = {
|
|
@@ -90,6 +99,20 @@ export const allure2 = {
|
|
|
90
99
|
}
|
|
91
100
|
return true;
|
|
92
101
|
}
|
|
102
|
+
const historyMetadataKey = historyMetadataKeys[originalFileName];
|
|
103
|
+
if (historyMetadataKey) {
|
|
104
|
+
try {
|
|
105
|
+
const parsed = await data.asJson();
|
|
106
|
+
if (parsed && (isStringAnyRecord(parsed) || isStringAnyRecordArray(parsed))) {
|
|
107
|
+
await visitor.visitMetadata({ [historyMetadataKey]: parsed }, { readerId });
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
console.error("error parsing", originalFileName, e);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
93
116
|
if (originalFileName === "executor.json") {
|
|
94
117
|
try {
|
|
95
118
|
const parsed = await data.asJson();
|
|
@@ -156,6 +179,8 @@ export const allure2 = {
|
|
|
156
179
|
readerId: () => readerId,
|
|
157
180
|
};
|
|
158
181
|
const processTestResult = async (visitor, result, originalFileName) => {
|
|
182
|
+
const links = result?.links?.filter(notNull) ?? [];
|
|
183
|
+
const topLevelAttachmentCount = result?.attachments?.filter(notNull).length ?? 0;
|
|
159
184
|
const dest = {
|
|
160
185
|
uuid: ensureString(result.uuid),
|
|
161
186
|
titlePath: result?.titlePath?.length ? result.titlePath : [],
|
|
@@ -180,10 +205,17 @@ const processTestResult = async (visitor, result, originalFileName) => {
|
|
|
180
205
|
...(result?.steps?.filter(notNull)?.map(convertStep) ?? []),
|
|
181
206
|
...(result?.attachments?.filter(notNull)?.map(convertAttachment) ?? []),
|
|
182
207
|
],
|
|
183
|
-
links:
|
|
208
|
+
links: links.map(convertLink),
|
|
184
209
|
labels: result.labels?.filter(notNull)?.map(convertLabel),
|
|
185
210
|
};
|
|
186
|
-
await visitor.visitTestResult(dest, {
|
|
211
|
+
await visitor.visitTestResult(dest, {
|
|
212
|
+
readerId,
|
|
213
|
+
metadata: {
|
|
214
|
+
originalFileName,
|
|
215
|
+
allure2_links: links,
|
|
216
|
+
allure2_top_level_attachment_count: topLevelAttachmentCount,
|
|
217
|
+
},
|
|
218
|
+
});
|
|
187
219
|
};
|
|
188
220
|
const processCheckResult = async (visitor, result, originalFileName) => {
|
|
189
221
|
const tags = Array.isArray(result.tags) ? result.tags.map((tag) => ensureString(tag)).filter(notNull) : [];
|
|
@@ -275,7 +307,12 @@ const processFixtures = async (visitor, fixtures, type, children) => {
|
|
|
275
307
|
if (fixtures) {
|
|
276
308
|
for (const fixture of fixtures) {
|
|
277
309
|
const dist = convertFixture(type, children, fixture);
|
|
278
|
-
await visitor.visitTestFixtureResult(dist, {
|
|
310
|
+
await visitor.visitTestFixtureResult(dist, {
|
|
311
|
+
readerId,
|
|
312
|
+
metadata: {
|
|
313
|
+
allure2_top_level_attachment_count: fixture?.attachments?.filter(notNull).length ?? 0,
|
|
314
|
+
},
|
|
315
|
+
});
|
|
279
316
|
}
|
|
280
317
|
}
|
|
281
318
|
};
|
|
@@ -287,11 +324,19 @@ const processTestResultContainer = async (visitor, result) => {
|
|
|
287
324
|
};
|
|
288
325
|
const processGlobals = async (visitor, globals) => {
|
|
289
326
|
const { attachments = [], errors = [] } = globals;
|
|
327
|
+
const normalizedAttachments = Array.isArray(attachments) ? attachments : [];
|
|
328
|
+
const normalizedErrors = isStringAnyRecordArray(errors) ? errors : [];
|
|
329
|
+
const attachmentTimestamps = Object.fromEntries(normalizedAttachments
|
|
330
|
+
.filter((attachment) => typeof attachment.timestamp === "number" && typeof attachment.source === "string")
|
|
331
|
+
.map((attachment) => [attachment.source, attachment.timestamp]));
|
|
332
|
+
const errorTimestamps = normalizedErrors.map((error) => ensureInt(error.timestamp));
|
|
333
|
+
await visitor.visitMetadata({
|
|
334
|
+
allure2_global_attachment_timestamps: attachmentTimestamps,
|
|
335
|
+
allure2_global_error_timestamps: errorTimestamps,
|
|
336
|
+
}, { readerId });
|
|
290
337
|
await visitor.visitGlobals({
|
|
291
|
-
attachments:
|
|
292
|
-
|
|
293
|
-
: [],
|
|
294
|
-
errors: isStringAnyRecordArray(errors) ? errors.map((error) => convertGlobalError(error)) : [],
|
|
338
|
+
attachments: normalizedAttachments.map((attachment) => convertGlobalAttachment(attachment)),
|
|
339
|
+
errors: normalizedErrors.map((error) => convertGlobalError(error)),
|
|
295
340
|
}, { readerId });
|
|
296
341
|
};
|
|
297
342
|
const convertCheckStatus = (status) => {
|
package/dist/allure2/model.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export interface Attachment {
|
|
|
5
5
|
}
|
|
6
6
|
export interface GlobalAttachment extends Attachment {
|
|
7
7
|
environment?: string;
|
|
8
|
+
timestamp?: number;
|
|
8
9
|
}
|
|
9
10
|
export declare enum Status {
|
|
10
11
|
FAILED = "failed",
|
|
@@ -50,6 +51,7 @@ export interface StatusDetails {
|
|
|
50
51
|
}
|
|
51
52
|
export interface GlobalStatusDetails extends StatusDetails {
|
|
52
53
|
environment?: string;
|
|
54
|
+
timestamp?: number;
|
|
53
55
|
}
|
|
54
56
|
interface ExecutableItem {
|
|
55
57
|
name?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/reader",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.1",
|
|
4
4
|
"description": "Collection of utilities which helps to process different kind of test results as Allure Results",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"lint:fix": "oxlint --import-plugin --fix src test features stories"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@allurereport/core-api": "3.
|
|
30
|
-
"@allurereport/plugin-api": "3.
|
|
31
|
-
"@allurereport/reader-api": "3.
|
|
29
|
+
"@allurereport/core-api": "3.16.1",
|
|
30
|
+
"@allurereport/plugin-api": "3.16.1",
|
|
31
|
+
"@allurereport/reader-api": "3.16.1",
|
|
32
32
|
"fast-xml-parser": "^5.7.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|