@allurereport/core 3.0.0-beta.6 → 3.0.0-beta.8
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/api.d.ts +2 -1
- package/dist/config.d.ts +5 -1
- package/dist/config.js +32 -5
- package/dist/history.js +1 -1
- package/dist/report.js +7 -2
- package/dist/store/convert.js +9 -6
- package/dist/store/store.d.ts +7 -2
- package/dist/store/store.js +20 -3
- package/package.json +14 -14
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HistoryDataPoint, KnownTestFailure } from "@allurereport/core-api";
|
|
2
|
-
import type { Plugin, QualityGateConfig, ReportFiles } from "@allurereport/plugin-api";
|
|
2
|
+
import type { DefaultLabelsConfig, Plugin, QualityGateConfig, ReportFiles } from "@allurereport/plugin-api";
|
|
3
3
|
import type { ResultsReader } from "@allurereport/reader-api";
|
|
4
4
|
export interface FullConfig {
|
|
5
5
|
name: string;
|
|
@@ -13,6 +13,7 @@ export interface FullConfig {
|
|
|
13
13
|
knownIssuesPath: string;
|
|
14
14
|
known?: KnownTestFailure[];
|
|
15
15
|
qualityGate?: QualityGateConfig;
|
|
16
|
+
defaultLabels?: DefaultLabelsConfig;
|
|
16
17
|
realTime?: any;
|
|
17
18
|
}
|
|
18
19
|
export interface PluginInstance {
|
package/dist/config.d.ts
CHANGED
|
@@ -8,7 +8,11 @@ export interface ConfigOverride {
|
|
|
8
8
|
historyPath?: string;
|
|
9
9
|
knownIssuesPath?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const validateConfig: (config: Config) => {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
fields: string[];
|
|
14
|
+
};
|
|
12
15
|
export declare const loadConfig: (configPath: string) => Promise<Config>;
|
|
13
16
|
export declare const resolveConfig: (config: Config, override?: ConfigOverride) => Promise<FullConfig>;
|
|
17
|
+
export declare const readConfig: (cwd?: string, configPath?: string, override?: ConfigOverride) => Promise<FullConfig>;
|
|
14
18
|
export declare const resolvePlugin: (path: string) => Promise<any>;
|
package/dist/config.js
CHANGED
|
@@ -38,22 +38,44 @@ export const findConfig = async (cwd, configPath) => {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
export const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
export const validateConfig = (config) => {
|
|
42
|
+
const supportedFields = [
|
|
43
|
+
"name",
|
|
44
|
+
"output",
|
|
45
|
+
"historyPath",
|
|
46
|
+
"knownIssuesPath",
|
|
47
|
+
"qualityGate",
|
|
48
|
+
"plugins",
|
|
49
|
+
"defaultLabels",
|
|
50
|
+
];
|
|
51
|
+
const unsupportedFields = Object.keys(config).filter((key) => !supportedFields.includes(key));
|
|
52
|
+
return {
|
|
53
|
+
valid: unsupportedFields.length === 0,
|
|
54
|
+
fields: unsupportedFields,
|
|
55
|
+
};
|
|
45
56
|
};
|
|
46
57
|
export const loadConfig = async (configPath) => {
|
|
47
58
|
return (await import(normalizeImportPath(configPath))).default;
|
|
48
59
|
};
|
|
49
60
|
export const resolveConfig = async (config, override = {}) => {
|
|
61
|
+
const validationResult = validateConfig(config);
|
|
62
|
+
if (!validationResult.valid) {
|
|
63
|
+
throw new Error(`The provided Allure config contains unsupported fields: ${validationResult.fields.join(", ")}`);
|
|
64
|
+
}
|
|
50
65
|
const name = override.name ?? config.name ?? "Allure Report";
|
|
51
66
|
const historyPath = resolve(override.historyPath ?? config.historyPath ?? "./.allure/history.jsonl");
|
|
52
67
|
const knownIssuesPath = resolve(override.knownIssuesPath ?? config.knownIssuesPath ?? "./allure/known.json");
|
|
53
68
|
const output = resolve(override.output ?? config.output ?? "./allure-report");
|
|
54
69
|
const history = await readHistory(historyPath);
|
|
55
70
|
const known = await readKnownIssues(knownIssuesPath);
|
|
56
|
-
const
|
|
71
|
+
const plugins = Object.keys(config?.plugins ?? {}).length === 0
|
|
72
|
+
? {
|
|
73
|
+
awesome: {
|
|
74
|
+
options: {},
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
: config.plugins;
|
|
78
|
+
const pluginInstances = await resolvePlugins(plugins);
|
|
57
79
|
return {
|
|
58
80
|
name,
|
|
59
81
|
reportFiles: new FileSystemReportFiles(output),
|
|
@@ -66,6 +88,11 @@ export const resolveConfig = async (config, override = {}) => {
|
|
|
66
88
|
qualityGate: config.qualityGate,
|
|
67
89
|
};
|
|
68
90
|
};
|
|
91
|
+
export const readConfig = async (cwd = process.cwd(), configPath, override) => {
|
|
92
|
+
const cfg = await findConfig(cwd, configPath);
|
|
93
|
+
const config = cfg ? await loadConfig(cfg) : { ...defaultConfig };
|
|
94
|
+
return await resolveConfig(config, override);
|
|
95
|
+
};
|
|
69
96
|
export const resolvePlugin = async (path) => {
|
|
70
97
|
if (!path.startsWith("@allurereport/plugin-")) {
|
|
71
98
|
try {
|
package/dist/history.js
CHANGED
|
@@ -4,7 +4,7 @@ import { isFileNotFoundError } from "./utils/misc.js";
|
|
|
4
4
|
const createHistoryItems = (testResults) => {
|
|
5
5
|
return testResults
|
|
6
6
|
.filter((tr) => tr.historyId)
|
|
7
|
-
.map(({ id, name, fullName, historyId, status, message, trace, start, stop, duration }) => {
|
|
7
|
+
.map(({ id, name, fullName, historyId, status, error: { message, trace } = {}, start, stop, duration }) => {
|
|
8
8
|
return {
|
|
9
9
|
id,
|
|
10
10
|
name,
|
package/dist/report.js
CHANGED
|
@@ -159,7 +159,7 @@ export class AllureReport {
|
|
|
159
159
|
this.validate = async () => {
|
|
160
160
|
await __classPrivateFieldGet(this, _AllureReport_qualityGate, "f").validate(__classPrivateFieldGet(this, _AllureReport_store, "f"));
|
|
161
161
|
};
|
|
162
|
-
const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], history, known, reportFiles, qualityGate, realTime, appendHistory, historyPath, } = opts;
|
|
162
|
+
const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], history, known, reportFiles, qualityGate, realTime, appendHistory, historyPath, defaultLabels = {}, } = opts;
|
|
163
163
|
__classPrivateFieldSet(this, _AllureReport_reportUuid, randomUUID(), "f");
|
|
164
164
|
__classPrivateFieldSet(this, _AllureReport_reportName, name, "f");
|
|
165
165
|
__classPrivateFieldSet(this, _AllureReport_eventEmitter, new EventEmitter(), "f");
|
|
@@ -167,7 +167,12 @@ export class AllureReport {
|
|
|
167
167
|
__classPrivateFieldSet(this, _AllureReport_realTime, realTime, "f");
|
|
168
168
|
__classPrivateFieldSet(this, _AllureReport_appendHistory, appendHistory ?? true, "f");
|
|
169
169
|
__classPrivateFieldSet(this, _AllureReport_historyPath, historyPath, "f");
|
|
170
|
-
__classPrivateFieldSet(this, _AllureReport_store, new DefaultAllureStore(
|
|
170
|
+
__classPrivateFieldSet(this, _AllureReport_store, new DefaultAllureStore({
|
|
171
|
+
history,
|
|
172
|
+
known,
|
|
173
|
+
eventEmitter: __classPrivateFieldGet(this, _AllureReport_eventEmitter, "f"),
|
|
174
|
+
defaultLabels,
|
|
175
|
+
}), "f");
|
|
171
176
|
__classPrivateFieldSet(this, _AllureReport_readers, [...readers], "f");
|
|
172
177
|
__classPrivateFieldSet(this, _AllureReport_plugins, [...plugins], "f");
|
|
173
178
|
__classPrivateFieldSet(this, _AllureReport_reportFiles, reportFiles, "f");
|
package/dist/store/convert.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { notNull } from "@allurereport/core-api";
|
|
2
|
-
import { findByLabelName } from "@allurereport/core-api";
|
|
1
|
+
import { findByLabelName, notNull } from "@allurereport/core-api";
|
|
3
2
|
import { md5 } from "@allurereport/plugin-api";
|
|
4
3
|
import { extension, lookupContentType } from "@allurereport/reader-api";
|
|
5
4
|
import MarkdownIt from "markdown-it";
|
|
@@ -14,8 +13,10 @@ export const testFixtureResultRawToState = (stateData, raw, context) => {
|
|
|
14
13
|
type: raw.type,
|
|
15
14
|
name,
|
|
16
15
|
status: raw.status ?? defaultStatus,
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
error: {
|
|
17
|
+
message: raw.message,
|
|
18
|
+
trace: raw.trace,
|
|
19
|
+
},
|
|
19
20
|
...processTimings(raw),
|
|
20
21
|
steps: convertSteps(stateData, raw.steps),
|
|
21
22
|
sourceMetadata: {
|
|
@@ -38,8 +39,10 @@ export const testResultRawToState = (stateData, raw, context) => {
|
|
|
38
39
|
fullName: raw.fullName,
|
|
39
40
|
historyId: calculateHistoryId(testCase, parameters),
|
|
40
41
|
status: raw.status ?? defaultStatus,
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
error: {
|
|
43
|
+
message: raw.message,
|
|
44
|
+
trace: raw.trace,
|
|
45
|
+
},
|
|
43
46
|
...processTimings(raw),
|
|
44
47
|
description: raw.description,
|
|
45
48
|
descriptionHtml: raw.descriptionHtml ?? markdownToHtml(raw.description),
|
package/dist/store/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AttachmentLink, HistoryDataPoint, HistoryTestResult, KnownTestFailure, Statistic, TestCase, TestFixtureResult, TestResult } from "@allurereport/core-api";
|
|
2
|
-
import type { AllureStore, ResultFile } from "@allurereport/plugin-api";
|
|
2
|
+
import type { AllureStore, DefaultLabelsConfig, ResultFile } from "@allurereport/plugin-api";
|
|
3
3
|
import type { RawFixtureResult, RawMetadata, RawTestResult, ReaderContext, ResultsVisitor } from "@allurereport/reader-api";
|
|
4
4
|
import type { EventEmitter } from "node:events";
|
|
5
5
|
import type { AllureStoreEvents } from "../utils/event.js";
|
|
@@ -12,7 +12,12 @@ export declare class DefaultAllureStore implements AllureStore, ResultsVisitor {
|
|
|
12
12
|
readonly indexAttachmentByFixture: Map<string, AttachmentLink[]>;
|
|
13
13
|
readonly indexFixturesByTestResult: Map<string, TestFixtureResult[]>;
|
|
14
14
|
readonly indexKnownByHistoryId: Map<string, KnownTestFailure[]>;
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(params?: {
|
|
16
|
+
history?: HistoryDataPoint[];
|
|
17
|
+
known?: KnownTestFailure[];
|
|
18
|
+
eventEmitter?: EventEmitter<AllureStoreEvents>;
|
|
19
|
+
defaultLabels?: DefaultLabelsConfig;
|
|
20
|
+
});
|
|
16
21
|
visitTestResult(raw: RawTestResult, context: ReaderContext): Promise<void>;
|
|
17
22
|
visitTestFixtureResult(result: RawFixtureResult, context: ReaderContext): Promise<void>;
|
|
18
23
|
visitAttachmentFile(resultFile: ResultFile, context: ReaderContext): Promise<void>;
|
package/dist/store/store.js
CHANGED
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _DefaultAllureStore_testResults, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_known, _DefaultAllureStore_fixtures, _DefaultAllureStore_eventEmitter;
|
|
12
|
+
var _DefaultAllureStore_testResults, _DefaultAllureStore_attachments, _DefaultAllureStore_attachmentContents, _DefaultAllureStore_testCases, _DefaultAllureStore_metadata, _DefaultAllureStore_history, _DefaultAllureStore_known, _DefaultAllureStore_fixtures, _DefaultAllureStore_defaultLabels, _DefaultAllureStore_eventEmitter;
|
|
13
13
|
import { compareBy, nullsLast, ordinal, reverse } from "@allurereport/core-api";
|
|
14
14
|
import { md5 } from "@allurereport/plugin-api";
|
|
15
15
|
import { testFixtureResultRawToState, testResultRawToState } from "./convert.js";
|
|
@@ -23,7 +23,7 @@ const index = (indexMap, key, ...items) => {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
export class DefaultAllureStore {
|
|
26
|
-
constructor(
|
|
26
|
+
constructor(params) {
|
|
27
27
|
_DefaultAllureStore_testResults.set(this, void 0);
|
|
28
28
|
_DefaultAllureStore_attachments.set(this, void 0);
|
|
29
29
|
_DefaultAllureStore_attachmentContents.set(this, void 0);
|
|
@@ -32,6 +32,7 @@ export class DefaultAllureStore {
|
|
|
32
32
|
_DefaultAllureStore_history.set(this, void 0);
|
|
33
33
|
_DefaultAllureStore_known.set(this, void 0);
|
|
34
34
|
_DefaultAllureStore_fixtures.set(this, void 0);
|
|
35
|
+
_DefaultAllureStore_defaultLabels.set(this, {});
|
|
35
36
|
_DefaultAllureStore_eventEmitter.set(this, void 0);
|
|
36
37
|
this.indexTestResultByTestCase = new Map();
|
|
37
38
|
this.indexLatestTestResultByHistoryId = new Map();
|
|
@@ -40,6 +41,7 @@ export class DefaultAllureStore {
|
|
|
40
41
|
this.indexAttachmentByFixture = new Map();
|
|
41
42
|
this.indexFixturesByTestResult = new Map();
|
|
42
43
|
this.indexKnownByHistoryId = new Map();
|
|
44
|
+
const { history = [], known = [], eventEmitter, defaultLabels } = params ?? {};
|
|
43
45
|
__classPrivateFieldSet(this, _DefaultAllureStore_testResults, new Map(), "f");
|
|
44
46
|
__classPrivateFieldSet(this, _DefaultAllureStore_attachments, new Map(), "f");
|
|
45
47
|
__classPrivateFieldSet(this, _DefaultAllureStore_attachmentContents, new Map(), "f");
|
|
@@ -50,6 +52,7 @@ export class DefaultAllureStore {
|
|
|
50
52
|
__classPrivateFieldSet(this, _DefaultAllureStore_known, [...known], "f");
|
|
51
53
|
__classPrivateFieldGet(this, _DefaultAllureStore_known, "f").forEach((ktf) => index(this.indexKnownByHistoryId, ktf.historyId, ktf));
|
|
52
54
|
__classPrivateFieldSet(this, _DefaultAllureStore_eventEmitter, eventEmitter, "f");
|
|
55
|
+
__classPrivateFieldSet(this, _DefaultAllureStore_defaultLabels, defaultLabels ?? {}, "f");
|
|
53
56
|
}
|
|
54
57
|
async visitTestResult(raw, context) {
|
|
55
58
|
const attachmentLinks = [];
|
|
@@ -58,6 +61,20 @@ export class DefaultAllureStore {
|
|
|
58
61
|
attachments: __classPrivateFieldGet(this, _DefaultAllureStore_attachments, "f"),
|
|
59
62
|
visitAttachmentLink: (link) => attachmentLinks.push(link),
|
|
60
63
|
}, raw, context);
|
|
64
|
+
const defaultLabelsNames = Object.keys(__classPrivateFieldGet(this, _DefaultAllureStore_defaultLabels, "f"));
|
|
65
|
+
if (defaultLabelsNames.length) {
|
|
66
|
+
defaultLabelsNames.forEach((labelName) => {
|
|
67
|
+
if (!testResult.labels.find((label) => label.name === labelName)) {
|
|
68
|
+
const defaultLabelValue = __classPrivateFieldGet(this, _DefaultAllureStore_defaultLabels, "f")[labelName];
|
|
69
|
+
[].concat(defaultLabelValue).forEach((labelValue) => {
|
|
70
|
+
testResult.labels.push({
|
|
71
|
+
name: labelName,
|
|
72
|
+
value: labelValue,
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
61
78
|
__classPrivateFieldGet(this, _DefaultAllureStore_testResults, "f").set(testResult.id, testResult);
|
|
62
79
|
if (testResult.historyId) {
|
|
63
80
|
const maybeOther = this.indexLatestTestResultByHistoryId.get(testResult.historyId);
|
|
@@ -234,4 +251,4 @@ export class DefaultAllureStore {
|
|
|
234
251
|
}, { total: all.length });
|
|
235
252
|
}
|
|
236
253
|
}
|
|
237
|
-
_DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_known = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_eventEmitter = new WeakMap();
|
|
254
|
+
_DefaultAllureStore_testResults = new WeakMap(), _DefaultAllureStore_attachments = new WeakMap(), _DefaultAllureStore_attachmentContents = new WeakMap(), _DefaultAllureStore_testCases = new WeakMap(), _DefaultAllureStore_metadata = new WeakMap(), _DefaultAllureStore_history = new WeakMap(), _DefaultAllureStore_known = new WeakMap(), _DefaultAllureStore_fixtures = new WeakMap(), _DefaultAllureStore_defaultLabels = new WeakMap(), _DefaultAllureStore_eventEmitter = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.8",
|
|
4
4
|
"description": "Collection of generic Allure utilities used across the entire project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"test": "vitest run"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@allurereport/core-api": "3.0.0-beta.
|
|
29
|
-
"@allurereport/plugin-api": "3.0.0-beta.
|
|
30
|
-
"@allurereport/plugin-awesome": "3.0.0-beta.
|
|
31
|
-
"@allurereport/plugin-classic": "3.0.0-beta.
|
|
32
|
-
"@allurereport/plugin-csv": "3.0.0-beta.
|
|
33
|
-
"@allurereport/plugin-log": "3.0.0-beta.
|
|
34
|
-
"@allurereport/plugin-progress": "3.0.0-beta.
|
|
35
|
-
"@allurereport/plugin-slack": "3.0.0-beta.
|
|
36
|
-
"@allurereport/plugin-testplan": "3.0.0-beta.
|
|
37
|
-
"@allurereport/reader": "3.0.0-beta.
|
|
38
|
-
"@allurereport/reader-api": "3.0.0-beta.
|
|
28
|
+
"@allurereport/core-api": "3.0.0-beta.8",
|
|
29
|
+
"@allurereport/plugin-api": "3.0.0-beta.8",
|
|
30
|
+
"@allurereport/plugin-awesome": "3.0.0-beta.8",
|
|
31
|
+
"@allurereport/plugin-classic": "3.0.0-beta.8",
|
|
32
|
+
"@allurereport/plugin-csv": "3.0.0-beta.8",
|
|
33
|
+
"@allurereport/plugin-log": "3.0.0-beta.8",
|
|
34
|
+
"@allurereport/plugin-progress": "3.0.0-beta.8",
|
|
35
|
+
"@allurereport/plugin-slack": "3.0.0-beta.8",
|
|
36
|
+
"@allurereport/plugin-testplan": "3.0.0-beta.8",
|
|
37
|
+
"@allurereport/reader": "3.0.0-beta.8",
|
|
38
|
+
"@allurereport/reader-api": "3.0.0-beta.8",
|
|
39
39
|
"markdown-it": "^14.1.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@typescript-eslint/parser": "^8.0.0",
|
|
48
48
|
"@vitest/runner": "^2.1.8",
|
|
49
49
|
"@vitest/snapshot": "^2.1.8",
|
|
50
|
-
"allure-js-commons": "^3.0.
|
|
51
|
-
"allure-vitest": "^3.0.
|
|
50
|
+
"allure-js-commons": "^3.0.9",
|
|
51
|
+
"allure-vitest": "^3.0.9",
|
|
52
52
|
"eslint": "^8.57.0",
|
|
53
53
|
"eslint-config-prettier": "^9.1.0",
|
|
54
54
|
"eslint-plugin-import": "^2.29.1",
|