@allurereport/core 3.18.0 → 3.19.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/config.js +15 -0
- package/dist/history.js +7 -5
- package/dist/qualityGate/qualityGate.js +1 -1
- package/dist/qualityGate/rules.js +9 -4
- package/dist/report.js +22 -9
- package/dist/store/convert.d.ts +0 -1
- package/dist/store/convert.js +71 -58
- package/dist/store/retrySubstore.d.ts +1 -3
- package/dist/store/retrySubstore.js +0 -14
- package/dist/store/store.d.ts +4 -2
- package/dist/store/store.js +159 -152
- package/dist/utils/event.d.ts +1 -1
- package/dist/utils/event.js +9 -4
- package/dist/utils/flaky.d.ts +2 -2
- package/dist/utils/flaky.js +36 -8
- package/dist/utils/realtimeChannel.d.ts +1 -0
- package/dist/utils/realtimeChannel.js +2 -2
- package/package.json +21 -21
package/dist/utils/event.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 _RealtimeEventsDispatcher_emitter, _RealtimeSubscriber_instances, _RealtimeSubscriber_emitter, _RealtimeSubscriber_handlers, _RealtimeSubscriber_onEvent, _RealtimeSubscriber_onBatchedEvent, _RealtimeSubscriber_createBatchHandler, _RealtimeSubscriber_runBatchHandler, _RealtimeSubscriber_disposeBatchHandler;
|
|
12
|
+
var _RealtimeEventsDispatcher_emitter, _RealtimeSubscriber_instances, _RealtimeSubscriber_emitter, _RealtimeSubscriber_beforeTestResults, _RealtimeSubscriber_handlers, _RealtimeSubscriber_onEvent, _RealtimeSubscriber_onBatchedEvent, _RealtimeSubscriber_createBatchHandler, _RealtimeSubscriber_runBatchHandler, _RealtimeSubscriber_disposeBatchHandler;
|
|
13
13
|
import console from "node:console";
|
|
14
14
|
import { setTimeout } from "node:timers/promises";
|
|
15
15
|
export var RealtimeEvents;
|
|
@@ -77,11 +77,13 @@ export class RealtimeEventsDispatcher {
|
|
|
77
77
|
}
|
|
78
78
|
_RealtimeEventsDispatcher_emitter = new WeakMap();
|
|
79
79
|
export class RealtimeSubscriber {
|
|
80
|
-
constructor(emitter) {
|
|
80
|
+
constructor(emitter, beforeTestResults) {
|
|
81
81
|
_RealtimeSubscriber_instances.add(this);
|
|
82
82
|
_RealtimeSubscriber_emitter.set(this, void 0);
|
|
83
|
+
_RealtimeSubscriber_beforeTestResults.set(this, void 0);
|
|
83
84
|
_RealtimeSubscriber_handlers.set(this, []);
|
|
84
85
|
__classPrivateFieldSet(this, _RealtimeSubscriber_emitter, emitter, "f");
|
|
86
|
+
__classPrivateFieldSet(this, _RealtimeSubscriber_beforeTestResults, beforeTestResults, "f");
|
|
85
87
|
}
|
|
86
88
|
onGlobalAttachment(listener) {
|
|
87
89
|
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onEvent).call(this, RealtimeEvents.GlobalAttachment, listener);
|
|
@@ -105,7 +107,10 @@ export class RealtimeSubscriber {
|
|
|
105
107
|
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onEvent).call(this, RealtimeEvents.QualityGateResults, listener);
|
|
106
108
|
}
|
|
107
109
|
onTestResults(listener, options = {}) {
|
|
108
|
-
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onBatchedEvent).call(this, RealtimeEvents.TestResult,
|
|
110
|
+
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onBatchedEvent).call(this, RealtimeEvents.TestResult, (trIds) => {
|
|
111
|
+
__classPrivateFieldGet(this, _RealtimeSubscriber_beforeTestResults, "f")?.call(this);
|
|
112
|
+
return listener(trIds);
|
|
113
|
+
}, options);
|
|
109
114
|
}
|
|
110
115
|
onTestFixtureResults(listener, options = {}) {
|
|
111
116
|
return __classPrivateFieldGet(this, _RealtimeSubscriber_instances, "m", _RealtimeSubscriber_onBatchedEvent).call(this, RealtimeEvents.TestFixtureResult, listener, options);
|
|
@@ -121,7 +126,7 @@ export class RealtimeSubscriber {
|
|
|
121
126
|
__classPrivateFieldSet(this, _RealtimeSubscriber_handlers, [], "f");
|
|
122
127
|
}
|
|
123
128
|
}
|
|
124
|
-
_RealtimeSubscriber_emitter = new WeakMap(), _RealtimeSubscriber_handlers = new WeakMap(), _RealtimeSubscriber_instances = new WeakSet(), _RealtimeSubscriber_onEvent = function _RealtimeSubscriber_onEvent(event, listener) {
|
|
129
|
+
_RealtimeSubscriber_emitter = new WeakMap(), _RealtimeSubscriber_beforeTestResults = new WeakMap(), _RealtimeSubscriber_handlers = new WeakMap(), _RealtimeSubscriber_instances = new WeakSet(), _RealtimeSubscriber_onEvent = function _RealtimeSubscriber_onEvent(event, listener) {
|
|
125
130
|
const handler = createListenerHandler(listener);
|
|
126
131
|
__classPrivateFieldGet(this, _RealtimeSubscriber_emitter, "f").on(event, handler);
|
|
127
132
|
return () => {
|
package/dist/utils/flaky.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const
|
|
1
|
+
import { type FlakyDetectionConfig, type HistoryTestResult, type TestResult } from "@allurereport/core-api";
|
|
2
|
+
export declare const createFlakyDetector: ({ historyDepth, includePassedTests, }?: FlakyDetectionConfig) => ((tr: TestResult, history: HistoryTestResult[]) => boolean);
|
package/dist/utils/flaky.js
CHANGED
|
@@ -1,12 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import { DEFAULT_ENVIRONMENT, } from "@allurereport/core-api";
|
|
2
|
+
const DEFAULT_HISTORY_DEPTH = 5;
|
|
3
|
+
const TRANSITION_HALF_LIFE = 2;
|
|
4
|
+
const STABILITY_PRIOR_WEIGHT = 3;
|
|
5
|
+
const FLAKY_SCORE_THRESHOLD = 30;
|
|
2
6
|
const badStatuses = ["failed", "broken"];
|
|
3
|
-
const
|
|
4
|
-
|
|
7
|
+
const isFlakyByWeightedTransitions = (tr, history, historyDepth, includePassedTests) => {
|
|
8
|
+
const currentPassed = tr.status === "passed";
|
|
9
|
+
const isEligibleStatus = badStatuses.includes(tr.status) || (includePassedTests && currentPassed);
|
|
10
|
+
if (historyDepth === -1 || !isEligibleStatus) {
|
|
5
11
|
return false;
|
|
6
12
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
let previousPassed = currentPassed;
|
|
14
|
+
let comparisons = 0;
|
|
15
|
+
let weightedTransitions = 0;
|
|
16
|
+
let totalWeight = 0;
|
|
17
|
+
for (const result of history) {
|
|
18
|
+
if (historyDepth !== 0 && comparisons >= historyDepth) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
if (result.id === tr.id ||
|
|
22
|
+
(result.environment ?? DEFAULT_ENVIRONMENT) !== (tr.environment ?? DEFAULT_ENVIRONMENT) ||
|
|
23
|
+
(result.status !== "passed" && !badStatuses.includes(result.status))) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const passed = result.status === "passed";
|
|
27
|
+
const weight = 2 ** (-comparisons / TRANSITION_HALF_LIFE);
|
|
28
|
+
if (passed !== previousPassed) {
|
|
29
|
+
weightedTransitions += weight;
|
|
30
|
+
}
|
|
31
|
+
totalWeight += weight;
|
|
32
|
+
previousPassed = passed;
|
|
33
|
+
comparisons++;
|
|
34
|
+
}
|
|
35
|
+
const score = (100 * weightedTransitions) / (STABILITY_PRIOR_WEIGHT + totalWeight);
|
|
36
|
+
return score >= FLAKY_SCORE_THRESHOLD;
|
|
37
|
+
};
|
|
38
|
+
export const createFlakyDetector = ({ historyDepth = DEFAULT_HISTORY_DEPTH, includePassedTests = false, } = {}) => {
|
|
39
|
+
return (tr, history) => isFlakyByWeightedTransitions(tr, history, historyDepth, includePassedTests);
|
|
11
40
|
};
|
|
12
|
-
export const isFlaky = (tr, history) => tr.flaky || isAllureClassicFlaky(tr, history);
|
|
@@ -7,10 +7,10 @@ var _RealtimeChannel_emitter;
|
|
|
7
7
|
import { EventEmitter } from "node:events";
|
|
8
8
|
import { RealtimeEvents, RealtimeEventsDispatcher, RealtimeSubscriber } from "./event.js";
|
|
9
9
|
export class RealtimeChannel {
|
|
10
|
-
constructor() {
|
|
10
|
+
constructor(beforeTestResults) {
|
|
11
11
|
_RealtimeChannel_emitter.set(this, new EventEmitter());
|
|
12
12
|
this.dispatcher = new RealtimeEventsDispatcher(__classPrivateFieldGet(this, _RealtimeChannel_emitter, "f"));
|
|
13
|
-
this.subscriber = new RealtimeSubscriber(__classPrivateFieldGet(this, _RealtimeChannel_emitter, "f"));
|
|
13
|
+
this.subscriber = new RealtimeSubscriber(__classPrivateFieldGet(this, _RealtimeChannel_emitter, "f"), beforeTestResults);
|
|
14
14
|
}
|
|
15
15
|
onResultLikeChanged(listener) {
|
|
16
16
|
__classPrivateFieldGet(this, _RealtimeChannel_emitter, "f").on(RealtimeEvents.TestResult, listener);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"description": "Collection of generic Allure utilities used across the entire project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -25,26 +25,26 @@
|
|
|
25
25
|
"lint:fix": "oxlint --import-plugin --fix src test features stories"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@allurereport/ci": "3.
|
|
29
|
-
"@allurereport/cli-commons": "3.
|
|
30
|
-
"@allurereport/core-api": "3.
|
|
31
|
-
"@allurereport/plugin-agent": "3.
|
|
32
|
-
"@allurereport/plugin-allure2": "3.
|
|
33
|
-
"@allurereport/plugin-api": "3.
|
|
34
|
-
"@allurereport/plugin-awesome": "3.
|
|
35
|
-
"@allurereport/plugin-classic": "3.
|
|
36
|
-
"@allurereport/plugin-csv": "3.
|
|
37
|
-
"@allurereport/plugin-dashboard": "3.
|
|
38
|
-
"@allurereport/plugin-jira": "3.
|
|
39
|
-
"@allurereport/plugin-log": "3.
|
|
40
|
-
"@allurereport/plugin-progress": "3.
|
|
41
|
-
"@allurereport/plugin-slack": "3.
|
|
42
|
-
"@allurereport/plugin-testops": "3.
|
|
43
|
-
"@allurereport/plugin-testplan": "3.
|
|
44
|
-
"@allurereport/reader": "3.
|
|
45
|
-
"@allurereport/reader-api": "3.
|
|
46
|
-
"@allurereport/service": "3.
|
|
47
|
-
"@allurereport/summary": "3.
|
|
28
|
+
"@allurereport/ci": "3.19.0",
|
|
29
|
+
"@allurereport/cli-commons": "3.19.0",
|
|
30
|
+
"@allurereport/core-api": "3.19.0",
|
|
31
|
+
"@allurereport/plugin-agent": "3.19.0",
|
|
32
|
+
"@allurereport/plugin-allure2": "3.19.0",
|
|
33
|
+
"@allurereport/plugin-api": "3.19.0",
|
|
34
|
+
"@allurereport/plugin-awesome": "3.19.0",
|
|
35
|
+
"@allurereport/plugin-classic": "3.19.0",
|
|
36
|
+
"@allurereport/plugin-csv": "3.19.0",
|
|
37
|
+
"@allurereport/plugin-dashboard": "3.19.0",
|
|
38
|
+
"@allurereport/plugin-jira": "3.19.0",
|
|
39
|
+
"@allurereport/plugin-log": "3.19.0",
|
|
40
|
+
"@allurereport/plugin-progress": "3.19.0",
|
|
41
|
+
"@allurereport/plugin-slack": "3.19.0",
|
|
42
|
+
"@allurereport/plugin-testops": "3.19.0",
|
|
43
|
+
"@allurereport/plugin-testplan": "3.19.0",
|
|
44
|
+
"@allurereport/reader": "3.19.0",
|
|
45
|
+
"@allurereport/reader-api": "3.19.0",
|
|
46
|
+
"@allurereport/service": "3.19.0",
|
|
47
|
+
"@allurereport/summary": "3.19.0",
|
|
48
48
|
"glob": "^13.0.6",
|
|
49
49
|
"handlebars": "^4.7.9",
|
|
50
50
|
"jiti": "^2.5.1",
|