@allurereport/plugin-allure2 3.0.0-beta.9 → 3.0.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.
@@ -1,4 +1,4 @@
1
- import { createBaseUrlScript, createFaviconLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, } from "@allurereport/web-commons";
1
+ import { createBaseUrlScript, createFaviconLinkTag, createReportDataScript, createScriptTag, createStylesLinkTag, } from "@allurereport/core-api";
2
2
  import Handlebars from "handlebars";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { createRequire } from "node:module";
@@ -113,19 +113,29 @@ export const generateStaticFiles = async (payload) => {
113
113
  reportLanguage: reportLanguage ?? "en",
114
114
  createdAt: Date.now(),
115
115
  };
116
- const html = compile({
117
- headTags: headTags.join("\n"),
118
- bodyTags: bodyTags.join("\n"),
119
- reportFilesScript: createReportDataScript(reportDataFiles),
120
- reportOptions: JSON.stringify(reportOptions),
121
- analyticsEnable: true,
122
- allureVersion,
123
- reportLanguage,
124
- reportUuid,
125
- reportName,
126
- singleFile,
127
- });
128
- await reportFiles.addFile("index.html", Buffer.from(html, "utf8"));
116
+ try {
117
+ const html = compile({
118
+ headTags: headTags.join("\n"),
119
+ bodyTags: bodyTags.join("\n"),
120
+ reportFilesScript: createReportDataScript(reportDataFiles),
121
+ reportOptions: JSON.stringify(reportOptions),
122
+ analyticsEnable: true,
123
+ allureVersion,
124
+ reportLanguage,
125
+ reportUuid,
126
+ reportName,
127
+ singleFile,
128
+ });
129
+ await reportFiles.addFile("index.html", Buffer.from(html, "utf8"));
130
+ }
131
+ catch (err) {
132
+ if (err instanceof RangeError) {
133
+ console.error("The report is too large to be generated in the single file mode!");
134
+ process.exit(1);
135
+ return;
136
+ }
137
+ throw err;
138
+ }
129
139
  };
130
140
  export const generateTree = async (writer, name, labelNames, tests) => {
131
141
  const fileName = `${name}.json`;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Allure2Plugin } from "./plugin.js";
2
- export default Allure2Plugin;
1
+ export type { Allure2PluginOptions } from "./model.js";
2
+ export { Allure2Plugin as default } from "./plugin.js";
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- import { Allure2Plugin } from "./plugin.js";
2
- export default Allure2Plugin;
1
+ export { Allure2Plugin as default } from "./plugin.js";
package/dist/plugin.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { type AllureStore, type Plugin, type PluginContext } from "@allurereport/plugin-api";
1
+ import { type AllureStore, type Plugin, type PluginContext, type PluginSummary } from "@allurereport/plugin-api";
2
2
  import type { Allure2PluginOptions } from "./model.js";
3
3
  export declare class Allure2Plugin implements Plugin {
4
4
  #private;
5
5
  readonly options: Allure2PluginOptions;
6
6
  constructor(options?: Allure2PluginOptions);
7
+ info(context: PluginContext, store: AllureStore): Promise<PluginSummary>;
7
8
  update: (context: PluginContext, store: AllureStore) => Promise<void>;
8
9
  done: (context: PluginContext, store: AllureStore) => Promise<void>;
9
10
  }
package/dist/plugin.js CHANGED
@@ -4,7 +4,8 @@ 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 { preciseTreeLabels } from "@allurereport/plugin-api";
7
+ import { getWorstStatus } from "@allurereport/core-api";
8
+ import { convertToSummaryTestResult, preciseTreeLabels, } from "@allurereport/plugin-api";
8
9
  import { convertTestResult } from "./converters.js";
9
10
  import { generateAttachmentsData, generateCategoriesData, generateDefaultWidgetData, generateEmptyTrendData, generateEnvironmentJson, generateExecutorJson, generatePackagesData, generateStaticFiles, generateSummaryJson, generateTestResults, generateTimelineData, generateTree, generateTrendData, } from "./generators.js";
10
11
  import { InMemoryReportDataWriter, ReportFileDataWriter } from "./writer.js";
@@ -23,7 +24,7 @@ export class Allure2Plugin {
23
24
  for (const value of tests) {
24
25
  const fixtures = await store.fixturesByTrId(value.id);
25
26
  const retries = await store.retriesByTrId(value.id);
26
- const history = await store.historyByTrId(value.id);
27
+ const history = (await store.historyByTrId(value.id)) ?? [];
27
28
  const allure2TestResult = convertTestResult({
28
29
  attachmentMap,
29
30
  fixtures,
@@ -72,5 +73,30 @@ export class Allure2Plugin {
72
73
  await this.update(context, store);
73
74
  };
74
75
  }
76
+ async info(context, store) {
77
+ const allTrs = await store.allTestResults();
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 {
85
+ name: this.options.reportName || context.reportName,
86
+ stats: await store.testsStatistic(),
87
+ status: worstStatus ?? "passed",
88
+ duration,
89
+ createdAt,
90
+ plugin: "Allure2",
91
+ newTests: newTrs.map(convertToSummaryTestResult),
92
+ flakyTests: flakyTrs.map(convertToSummaryTestResult),
93
+ retryTests: retryTrs.map(convertToSummaryTestResult),
94
+ meta: {
95
+ reportId: context.reportUuid,
96
+ singleFile: this.options.singleFile ?? false,
97
+ withTestResultsLinks: true,
98
+ },
99
+ };
100
+ }
75
101
  }
76
102
  _Allure2Plugin_generate = new WeakMap();
package/dist/writer.js CHANGED
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
6
6
  var _InMemoryReportDataWriter_data;
7
7
  import { mkdir, writeFile } from "node:fs/promises";
8
8
  import { join, resolve } from "node:path";
9
+ import { join as joinPosix } from "node:path/posix";
9
10
  export class FileSystemReportDataWriter {
10
11
  constructor(output) {
11
12
  this.output = output;
@@ -67,19 +68,19 @@ export class ReportFileDataWriter {
67
68
  this.reportFiles = reportFiles;
68
69
  }
69
70
  async writeData(fileName, data) {
70
- await this.reportFiles.addFile(join("data", fileName), Buffer.from(JSON.stringify(data), "utf-8"));
71
+ await this.reportFiles.addFile(joinPosix("data", fileName), Buffer.from(JSON.stringify(data), "utf-8"));
71
72
  }
72
73
  async writeWidget(fileName, data) {
73
- await this.reportFiles.addFile(join("widgets", fileName), Buffer.from(JSON.stringify(data), "utf-8"));
74
+ await this.reportFiles.addFile(joinPosix("widgets", fileName), Buffer.from(JSON.stringify(data), "utf-8"));
74
75
  }
75
76
  async writeAttachment(source, file) {
76
77
  const contentBuffer = await file.asBuffer();
77
78
  if (!contentBuffer) {
78
79
  return;
79
80
  }
80
- await this.reportFiles.addFile(join("data", "attachments", source), contentBuffer);
81
+ await this.reportFiles.addFile(joinPosix("data", "attachments", source), contentBuffer);
81
82
  }
82
83
  async writeTestCase(test) {
83
- await this.reportFiles.addFile(join("data", "test-cases", `${test.uid}.json`), Buffer.from(JSON.stringify(test), "utf8"));
84
+ await this.reportFiles.addFile(joinPosix("data", "test-cases", `${test.uid}.json`), Buffer.from(JSON.stringify(test), "utf8"));
84
85
  }
85
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-allure2",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0",
4
4
  "description": "The classic version of Allure HTML report",
5
5
  "keywords": [
6
6
  "allure",
@@ -30,10 +30,9 @@
30
30
  "test": "rimraf ./out && vitest run"
31
31
  },
32
32
  "dependencies": {
33
- "@allurereport/core-api": "3.0.0-beta.9",
34
- "@allurereport/plugin-api": "3.0.0-beta.9",
35
- "@allurereport/web-allure2": "3.0.0-beta.9",
36
- "@allurereport/web-commons": "3.0.0-beta.9",
33
+ "@allurereport/core-api": "3.0.0",
34
+ "@allurereport/plugin-api": "3.0.0",
35
+ "@allurereport/web-allure2": "3.0.0",
37
36
  "handlebars": "^4.7.8"
38
37
  },
39
38
  "devDependencies": {
@@ -42,8 +41,8 @@
42
41
  "@types/node": "^20.17.9",
43
42
  "@typescript-eslint/eslint-plugin": "^8.0.0",
44
43
  "@typescript-eslint/parser": "^8.0.0",
45
- "@vitest/runner": "^2.1.8",
46
- "allure-vitest": "^3.0.9",
44
+ "@vitest/runner": "^2.1.9",
45
+ "allure-vitest": "^3.3.3",
47
46
  "eslint": "^8.57.0",
48
47
  "eslint-config-prettier": "^9.1.0",
49
48
  "eslint-plugin-import": "^2.29.1",
@@ -53,6 +52,6 @@
53
52
  "eslint-plugin-prefer-arrow": "^1.2.3",
54
53
  "rimraf": "^6.0.1",
55
54
  "typescript": "^5.6.3",
56
- "vitest": "^2.1.8"
55
+ "vitest": "^2.1.9"
57
56
  }
58
57
  }