@allurereport/plugin-allure2 3.2.0 → 3.4.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.
- package/dist/generators.d.ts +3 -1
- package/dist/generators.js +23 -13
- package/dist/model.d.ts +1 -0
- package/dist/plugin.js +6 -18
- package/dist/tree.js +1 -1
- package/dist/writer.js +10 -10
- package/package.json +18 -29
package/dist/generators.d.ts
CHANGED
|
@@ -3,13 +3,15 @@ import type { ReportFiles, ResultFile } from "@allurereport/plugin-api";
|
|
|
3
3
|
import type { Allure2ExecutorInfo, Allure2TestResult } from "./model.js";
|
|
4
4
|
import type { Allure2DataWriter, ReportFile } from "./writer.js";
|
|
5
5
|
export type TemplateManifest = Record<string, string>;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const getPackageRoot: () => Promise<string>;
|
|
7
|
+
export declare const readTemplateManifest: (packageRoot: string, singleFileMode?: boolean) => Promise<TemplateManifest>;
|
|
7
8
|
export declare const readManifestEntry: (options: {
|
|
8
9
|
fileName: string;
|
|
9
10
|
singleFile?: boolean;
|
|
10
11
|
mimeType: string;
|
|
11
12
|
reportFiles: ReportFiles;
|
|
12
13
|
inserter: (content: string) => string;
|
|
14
|
+
packageRoot: string;
|
|
13
15
|
}) => Promise<string>;
|
|
14
16
|
export declare const generateStaticFiles: (payload: {
|
|
15
17
|
allureVersion: string;
|
package/dist/generators.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createBaseUrlScript, createFaviconLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, } from "@allurereport/core-api";
|
|
2
|
-
import Handlebars from "handlebars";
|
|
3
1
|
import { readFile } from "node:fs/promises";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { createBaseUrlScript, createFaviconLinkTag, createReportDataScript, stringifyForInlineScript, createScriptTag, createStylesLinkTag, } from "@allurereport/core-api";
|
|
5
|
+
import { findUp } from "find-up";
|
|
6
|
+
import Handlebars from "handlebars";
|
|
6
7
|
import { byLabels, collapseTree, createTree, createWidget } from "./tree.js";
|
|
7
8
|
import { updateStatistic, updateTime } from "./utils.js";
|
|
8
|
-
const require = createRequire(import.meta.url);
|
|
9
9
|
const template = `<!DOCTYPE html>
|
|
10
10
|
<html dir="ltr" lang="{{reportLanguage}}">
|
|
11
11
|
<head>
|
|
@@ -45,14 +45,20 @@ const template = `<!DOCTYPE html>
|
|
|
45
45
|
</body>
|
|
46
46
|
</html>
|
|
47
47
|
`;
|
|
48
|
-
export const
|
|
49
|
-
const
|
|
50
|
-
|
|
48
|
+
export const getPackageRoot = async () => {
|
|
49
|
+
const packageJsonPath = await findUp("package.json", {
|
|
50
|
+
cwd: dirname(fileURLToPath(import.meta.url)),
|
|
51
|
+
});
|
|
52
|
+
return dirname(packageJsonPath);
|
|
53
|
+
};
|
|
54
|
+
export const readTemplateManifest = async (packageRoot, singleFileMode) => {
|
|
55
|
+
const templateManifestPath = join(packageRoot, "static", singleFileMode ? "single" : "multi", "manifest.json");
|
|
56
|
+
const templateManifest = await readFile(templateManifestPath, { encoding: "utf-8" });
|
|
51
57
|
return JSON.parse(templateManifest);
|
|
52
58
|
};
|
|
53
59
|
export const readManifestEntry = async (options) => {
|
|
54
|
-
const { fileName, singleFile, mimeType, inserter, reportFiles } = options;
|
|
55
|
-
const filePath =
|
|
60
|
+
const { fileName, singleFile, mimeType, inserter, reportFiles, packageRoot } = options;
|
|
61
|
+
const filePath = join(packageRoot, "static", singleFile ? "single" : "multi", fileName);
|
|
56
62
|
const scriptContentBuffer = await readFile(filePath);
|
|
57
63
|
if (singleFile) {
|
|
58
64
|
return inserter(`data:${mimeType};base64,${scriptContentBuffer.toString("base64")}`);
|
|
@@ -61,14 +67,14 @@ export const readManifestEntry = async (options) => {
|
|
|
61
67
|
return inserter(fileName);
|
|
62
68
|
};
|
|
63
69
|
export const generateStaticFiles = async (payload) => {
|
|
70
|
+
const packageRoot = await getPackageRoot();
|
|
64
71
|
const { reportName, reportLanguage, singleFile, reportFiles, reportDataFiles, reportUuid, allureVersion } = payload;
|
|
65
72
|
const compile = Handlebars.compile(template);
|
|
66
|
-
const manifest = await readTemplateManifest(singleFile);
|
|
73
|
+
const manifest = await readTemplateManifest(packageRoot, singleFile);
|
|
67
74
|
const headTags = [];
|
|
68
75
|
const bodyTags = [];
|
|
69
76
|
for (const key in manifest) {
|
|
70
77
|
const fileName = manifest[key];
|
|
71
|
-
const filePath = require.resolve(join("@allurereport/web-allure2/dist", singleFile ? "single" : "multi", fileName));
|
|
72
78
|
if (key === "favicon.ico") {
|
|
73
79
|
const tag = await readManifestEntry({
|
|
74
80
|
fileName,
|
|
@@ -76,6 +82,7 @@ export const generateStaticFiles = async (payload) => {
|
|
|
76
82
|
reportFiles,
|
|
77
83
|
inserter: createFaviconLinkTag,
|
|
78
84
|
mimeType: "image/x-icon",
|
|
85
|
+
packageRoot,
|
|
79
86
|
});
|
|
80
87
|
headTags.push(tag);
|
|
81
88
|
continue;
|
|
@@ -87,6 +94,7 @@ export const generateStaticFiles = async (payload) => {
|
|
|
87
94
|
reportFiles,
|
|
88
95
|
inserter: createStylesLinkTag,
|
|
89
96
|
mimeType: "text/css",
|
|
97
|
+
packageRoot,
|
|
90
98
|
});
|
|
91
99
|
headTags.push(tag);
|
|
92
100
|
continue;
|
|
@@ -98,6 +106,7 @@ export const generateStaticFiles = async (payload) => {
|
|
|
98
106
|
reportFiles,
|
|
99
107
|
inserter: createScriptTag,
|
|
100
108
|
mimeType: "text/javascript",
|
|
109
|
+
packageRoot,
|
|
101
110
|
});
|
|
102
111
|
bodyTags.push(tag);
|
|
103
112
|
continue;
|
|
@@ -105,6 +114,7 @@ export const generateStaticFiles = async (payload) => {
|
|
|
105
114
|
if (singleFile) {
|
|
106
115
|
continue;
|
|
107
116
|
}
|
|
117
|
+
const filePath = join(packageRoot, "static", singleFile ? "single" : "multi", fileName);
|
|
108
118
|
const fileContent = await readFile(filePath);
|
|
109
119
|
await reportFiles.addFile(basename(filePath), fileContent);
|
|
110
120
|
}
|
|
@@ -118,7 +128,7 @@ export const generateStaticFiles = async (payload) => {
|
|
|
118
128
|
headTags: headTags.join("\n"),
|
|
119
129
|
bodyTags: bodyTags.join("\n"),
|
|
120
130
|
reportFilesScript: createReportDataScript(reportDataFiles),
|
|
121
|
-
reportOptions:
|
|
131
|
+
reportOptions: stringifyForInlineScript(reportOptions),
|
|
122
132
|
analyticsEnable: true,
|
|
123
133
|
allureVersion,
|
|
124
134
|
reportLanguage,
|
package/dist/model.d.ts
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -4,8 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _Allure2Plugin_generate;
|
|
7
|
-
import {
|
|
8
|
-
import { convertToSummaryTestResult, preciseTreeLabels, } from "@allurereport/plugin-api";
|
|
7
|
+
import { createPluginSummary, preciseTreeLabels, } from "@allurereport/plugin-api";
|
|
9
8
|
import { convertTestResult } from "./converters.js";
|
|
10
9
|
import { generateAttachmentsData, generateCategoriesData, generateDefaultWidgetData, generateEmptyTrendData, generateEnvironmentJson, generateExecutorJson, generatePackagesData, generateStaticFiles, generateSummaryJson, generateTestResults, generateTimelineData, generateTree, generateTrendData, } from "./generators.js";
|
|
11
10
|
import { InMemoryReportDataWriter, ReportFileDataWriter } from "./writer.js";
|
|
@@ -74,29 +73,18 @@ export class Allure2Plugin {
|
|
|
74
73
|
};
|
|
75
74
|
}
|
|
76
75
|
async info(context, store) {
|
|
77
|
-
|
|
78
|
-
const newTrs = await store.allNewTestResults();
|
|
79
|
-
const retryTrs = allTrs.filter((tr) => !!tr?.retries?.length);
|
|
80
|
-
const flakyTrs = allTrs.filter((tr) => !!tr?.flaky);
|
|
81
|
-
const duration = allTrs.reduce((acc, { duration: trDuration = 0 }) => acc + trDuration, 0);
|
|
82
|
-
const worstStatus = getWorstStatus(allTrs.map(({ status }) => status));
|
|
83
|
-
const createdAt = allTrs.reduce((acc, { stop }) => Math.max(acc, stop || 0), 0);
|
|
84
|
-
return {
|
|
76
|
+
return createPluginSummary({
|
|
85
77
|
name: this.options.reportName || context.reportName,
|
|
86
|
-
stats: await store.testsStatistic(),
|
|
87
|
-
status: worstStatus ?? "passed",
|
|
88
|
-
duration,
|
|
89
|
-
createdAt,
|
|
90
78
|
plugin: "Allure2",
|
|
91
|
-
newTests: newTrs.map(convertToSummaryTestResult),
|
|
92
|
-
flakyTests: flakyTrs.map(convertToSummaryTestResult),
|
|
93
|
-
retryTests: retryTrs.map(convertToSummaryTestResult),
|
|
94
79
|
meta: {
|
|
95
80
|
reportId: context.reportUuid,
|
|
96
81
|
singleFile: this.options.singleFile ?? false,
|
|
97
82
|
withTestResultsLinks: true,
|
|
98
83
|
},
|
|
99
|
-
|
|
84
|
+
history: context.history,
|
|
85
|
+
ci: context.ci,
|
|
86
|
+
store,
|
|
87
|
+
});
|
|
100
88
|
}
|
|
101
89
|
}
|
|
102
90
|
_Allure2Plugin_generate = new WeakMap();
|
package/dist/tree.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { byStatistic, compareBy } from "@allurereport/core-api";
|
|
2
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { byStatistic, compareBy } from "@allurereport/core-api";
|
|
3
3
|
import { calculateStatisticByLeafs } from "./utils.js";
|
|
4
4
|
const rootNodeUid = "__ROOT__";
|
|
5
5
|
const createLeaf = (endNode, test) => {
|
package/dist/writer.js
CHANGED
|
@@ -5,8 +5,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _InMemoryReportDataWriter_data;
|
|
7
7
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { resolve } from "node:path";
|
|
9
|
+
import { joinPosixPath } from "@allurereport/core-api";
|
|
10
10
|
export class FileSystemReportDataWriter {
|
|
11
11
|
constructor(output) {
|
|
12
12
|
this.output = output;
|
|
@@ -37,19 +37,19 @@ export class InMemoryReportDataWriter {
|
|
|
37
37
|
_InMemoryReportDataWriter_data.set(this, {});
|
|
38
38
|
}
|
|
39
39
|
async writeData(fileName, data) {
|
|
40
|
-
const dist =
|
|
40
|
+
const dist = joinPosixPath("data", fileName);
|
|
41
41
|
__classPrivateFieldGet(this, _InMemoryReportDataWriter_data, "f")[dist] = Buffer.from(JSON.stringify(data), "utf-8");
|
|
42
42
|
}
|
|
43
43
|
async writeWidget(fileName, data) {
|
|
44
|
-
const dist =
|
|
44
|
+
const dist = joinPosixPath("widgets", fileName);
|
|
45
45
|
__classPrivateFieldGet(this, _InMemoryReportDataWriter_data, "f")[dist] = Buffer.from(JSON.stringify(data), "utf-8");
|
|
46
46
|
}
|
|
47
47
|
async writeTestCase(test) {
|
|
48
|
-
const dist =
|
|
48
|
+
const dist = joinPosixPath("data", "test-cases", `${test.uid}.json`);
|
|
49
49
|
__classPrivateFieldGet(this, _InMemoryReportDataWriter_data, "f")[dist] = Buffer.from(JSON.stringify(test), "utf-8");
|
|
50
50
|
}
|
|
51
51
|
async writeAttachment(fileName, file) {
|
|
52
|
-
const dist =
|
|
52
|
+
const dist = joinPosixPath("data", "attachments", fileName);
|
|
53
53
|
const content = await file.asBuffer();
|
|
54
54
|
if (content) {
|
|
55
55
|
__classPrivateFieldGet(this, _InMemoryReportDataWriter_data, "f")[dist] = content;
|
|
@@ -68,19 +68,19 @@ export class ReportFileDataWriter {
|
|
|
68
68
|
this.reportFiles = reportFiles;
|
|
69
69
|
}
|
|
70
70
|
async writeData(fileName, data) {
|
|
71
|
-
await this.reportFiles.addFile(
|
|
71
|
+
await this.reportFiles.addFile(joinPosixPath("data", fileName), Buffer.from(JSON.stringify(data), "utf-8"));
|
|
72
72
|
}
|
|
73
73
|
async writeWidget(fileName, data) {
|
|
74
|
-
await this.reportFiles.addFile(
|
|
74
|
+
await this.reportFiles.addFile(joinPosixPath("widgets", fileName), Buffer.from(JSON.stringify(data), "utf-8"));
|
|
75
75
|
}
|
|
76
76
|
async writeAttachment(source, file) {
|
|
77
77
|
const contentBuffer = await file.asBuffer();
|
|
78
78
|
if (!contentBuffer) {
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
await this.reportFiles.addFile(
|
|
81
|
+
await this.reportFiles.addFile(joinPosixPath("data", "attachments", source), contentBuffer);
|
|
82
82
|
}
|
|
83
83
|
async writeTestCase(test) {
|
|
84
|
-
await this.reportFiles.addFile(
|
|
84
|
+
await this.reportFiles.addFile(joinPosixPath("data", "test-cases", `${test.uid}.json`), Buffer.from(JSON.stringify(test), "utf8"));
|
|
85
85
|
}
|
|
86
86
|
}
|
package/package.json
CHANGED
|
@@ -1,55 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/plugin-allure2",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "The classic version of Allure HTML report",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
7
|
-
"
|
|
8
|
-
"report",
|
|
7
|
+
"html",
|
|
9
8
|
"plugin",
|
|
10
|
-
"
|
|
9
|
+
"report",
|
|
10
|
+
"testing"
|
|
11
11
|
],
|
|
12
|
-
"repository": "https://github.com/allure-framework/allure3",
|
|
13
12
|
"license": "Apache-2.0",
|
|
14
13
|
"author": "Qameta Software",
|
|
14
|
+
"repository": "https://github.com/allure-framework/allure3",
|
|
15
|
+
"files": [
|
|
16
|
+
"./dist"
|
|
17
|
+
],
|
|
15
18
|
"type": "module",
|
|
16
|
-
"exports": {
|
|
17
|
-
".": "./dist/index.js"
|
|
18
|
-
},
|
|
19
19
|
"main": "./dist/index.js",
|
|
20
20
|
"module": "./dist/index.js",
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
|
-
"
|
|
23
|
-
"./dist"
|
|
24
|
-
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./dist/index.js"
|
|
24
|
+
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "run clean && tsc --project ./tsconfig.json",
|
|
27
27
|
"clean": "rimraf ./dist",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
28
|
+
"test": "rimraf ./out && vitest run",
|
|
29
|
+
"lint": "oxlint --import-plugin src test features stories",
|
|
30
|
+
"lint:fix": "oxlint --import-plugin --fix src test features stories"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@allurereport/core-api": "3.
|
|
34
|
-
"@allurereport/plugin-api": "3.
|
|
35
|
-
"
|
|
36
|
-
"handlebars": "^4.7.
|
|
33
|
+
"@allurereport/core-api": "3.4.0",
|
|
34
|
+
"@allurereport/plugin-api": "3.4.0",
|
|
35
|
+
"find-up": "^8.0.0",
|
|
36
|
+
"handlebars": "^4.7.9"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@stylistic/eslint-plugin": "^2.6.1",
|
|
40
|
-
"@types/eslint": "^8.56.11",
|
|
41
39
|
"@types/node": "^20.17.9",
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
43
|
-
"@typescript-eslint/parser": "^8.0.0",
|
|
44
40
|
"@vitest/runner": "^2.1.9",
|
|
45
41
|
"allure-vitest": "^3.3.3",
|
|
46
|
-
"eslint": "^8.57.0",
|
|
47
|
-
"eslint-config-prettier": "^9.1.0",
|
|
48
|
-
"eslint-plugin-import": "^2.29.1",
|
|
49
|
-
"eslint-plugin-jsdoc": "^50.0.0",
|
|
50
|
-
"eslint-plugin-n": "^17.10.1",
|
|
51
|
-
"eslint-plugin-no-null": "^1.0.2",
|
|
52
|
-
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
53
42
|
"rimraf": "^6.0.1",
|
|
54
43
|
"typescript": "^5.6.3",
|
|
55
44
|
"vitest": "^2.1.9"
|