Skip to content

Commit 754b802

Browse files
committed
split runtime and globalRuntime invocation
1 parent 6afd14b commit 754b802

File tree

9 files changed

+28
-72
lines changed

9 files changed

+28
-72
lines changed

packages/allure-cypress/src/reporter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,11 @@ export class AllureCypress {
461461

462462
#applyRuntimeApiMessages = (context: SpecContext, message: RuntimeMessage) => {
463463
const rootUuid = this.#resolveRootUuid(context);
464-
if (!rootUuid && !isGlobalRuntimeMessage(message)) {
464+
if (isGlobalRuntimeMessage(message)) {
465+
this.allureRuntime.applyGlobalRuntimeMessages([message]);
465466
return;
466467
}
467468
if (!rootUuid) {
468-
this.allureRuntime.applyGlobalRuntimeMessages([message]);
469469
return;
470470
}
471471
this.allureRuntime.applyRuntimeMessages(rootUuid, [message]);

packages/allure-jasmine/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ export default class AllureJasmineReporter implements jasmine.CustomReporter {
8181

8282
handleAllureRuntimeMessages(message: RuntimeMessage) {
8383
const rootUuid = this.currentAllureFixtureUuid ?? this.currentAllureTestUuid;
84-
if (!rootUuid && !isGlobalRuntimeMessage(message)) {
84+
if (isGlobalRuntimeMessage(message)) {
85+
this.allureRuntime.applyGlobalRuntimeMessages([message]);
8586
return;
8687
}
8788
if (!rootUuid) {
88-
this.allureRuntime.applyGlobalRuntimeMessages([message]);
8989
return;
9090
}
9191
this.allureRuntime.applyRuntimeMessages(rootUuid, [message]);

packages/allure-jest/src/environmentFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ const createJestEnvironment = <T extends typeof JestEnvironment>(Base: T): T =>
7676

7777
handleAllureRuntimeMessage(message: RuntimeMessage) {
7878
const executableUuid = last(this.runContext.executables);
79-
if (!executableUuid && !isGlobalRuntimeMessage(message)) {
79+
if (isGlobalRuntimeMessage(message)) {
80+
this.runtime.applyGlobalRuntimeMessages([message]);
8081
return;
8182
}
8283
if (!executableUuid) {
83-
this.runtime.applyGlobalRuntimeMessages([message]);
8484
return;
8585
}
8686
this.runtime.applyRuntimeMessages(executableUuid, [message]);

packages/allure-js-commons/src/sdk/reporter/ReporterRuntime.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,6 @@ export class ReporterRuntime {
592592
case "attachment_path":
593593
this.#handleAttachmentPathMessage(rootUuid, message.data);
594594
return;
595-
case "global_attachment_content":
596-
this.#handleGlobalAttachmentContentMessage(message.data);
597-
return;
598-
case "global_attachment_path":
599-
this.#handleGlobalAttachmentPathMessage(message.data);
600-
return;
601-
case "global_error":
602-
this.#handleGlobalErrorMessage(message.data);
603-
return;
604595
default:
605596
// eslint-disable-next-line no-console
606597
console.error(`could not apply runtime messages: unknown message ${JSON.stringify(message)}`);

packages/allure-mocha/src/AllureMochaReporter.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ export class AllureMochaReporter extends Mocha.reporters.Base {
8989
}
9090

9191
applyRuntimeMessages = (...message: RuntimeMessage[]) => {
92-
const root = this.currentHook ?? this.currentTest;
93-
if (root) {
94-
this.runtime.applyRuntimeMessages(root, message);
95-
return;
96-
}
97-
9892
const globalMessages = message.filter(isGlobalRuntimeMessage);
9993
if (globalMessages.length) {
10094
this.runtime.applyGlobalRuntimeMessages(globalMessages);
10195
}
96+
97+
const root = this.currentHook ?? this.currentTest;
98+
const scopedMessages = message.filter((m) => !isGlobalRuntimeMessage(m));
99+
if (root && scopedMessages.length) {
100+
this.runtime.applyRuntimeMessages(root, scopedMessages);
101+
}
102102
};
103103

104104
/**

packages/allure-playwright/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
getMessageAndTraceFromError,
2323
getMetadataLabel,
2424
hasLabel,
25+
isGlobalRuntimeMessage,
2526
stripAnsi,
2627
} from "allure-js-commons/sdk";
2728
import {
@@ -701,6 +702,11 @@ export class AllureReporter implements ReporterV2 {
701702
return;
702703
}
703704

705+
if (isGlobalRuntimeMessage(message)) {
706+
this.allureRuntime!.applyGlobalRuntimeMessages([message]);
707+
return;
708+
}
709+
704710
this.allureRuntime!.applyRuntimeMessages(testUuid, [message]);
705711
return;
706712
}

packages/allure-vitest/src/reporter.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { TestModule } from "vitest/node";
33
import type { Reporter } from "vitest/reporters";
44
import { LabelName, Stage, Status } from "allure-js-commons";
55
import type { RuntimeMessage } from "allure-js-commons/sdk";
6-
import { getMessageAndTraceFromError, getStatusFromError } from "allure-js-commons/sdk";
6+
import { getMessageAndTraceFromError, getStatusFromError, isGlobalRuntimeMessage } from "allure-js-commons/sdk";
77
import type { ReporterConfig } from "allure-js-commons/sdk/reporter";
88
import {
99
ReporterRuntime,
@@ -126,7 +126,15 @@ export default class AllureVitestReporter implements Reporter {
126126
});
127127
}
128128

129-
this.allureReporterRuntime!.applyRuntimeMessages(testUuid, allureRuntimeMessages);
129+
const globalMessages = allureRuntimeMessages.filter(isGlobalRuntimeMessage);
130+
if (globalMessages.length) {
131+
this.allureReporterRuntime!.applyGlobalRuntimeMessages(globalMessages);
132+
}
133+
134+
const scopedMessages = allureRuntimeMessages.filter((m) => !isGlobalRuntimeMessage(m));
135+
if (scopedMessages.length) {
136+
this.allureReporterRuntime!.applyRuntimeMessages(testUuid, scopedMessages);
137+
}
130138

131139
switch (task.result?.state) {
132140
case "fail": {

packages/newman-reporter-allure/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ class AllureReporter {
410410
this.allureRuntime.writeScope(this.currentScope);
411411
this.currentScope = undefined;
412412
}
413-
this.allureRuntime.writeGlobals();
414413
}
415414

416415
#pathToItem(item: Item): string[] {

packages/newman-reporter-allure/test/spec/globals.test.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)