@stanterprise/playwright-reporter 0.0.21 → 0.1.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.
|
@@ -2,4 +2,4 @@ import { FullResult } from "@playwright/test/reporter";
|
|
|
2
2
|
import { StanterpriseReporterOptions } from "../types";
|
|
3
3
|
import * as grpc from "@grpc/grpc-js";
|
|
4
4
|
import { MessageQueue } from "../client/messageQueue";
|
|
5
|
-
export declare function handleOnEndEvent(result: FullResult, runId: string, client: grpc.Client, options: StanterpriseReporterOptions, queue?: MessageQueue): void;
|
|
5
|
+
export declare function handleOnEndEvent(result: FullResult, runId: string, client: grpc.Client, options: StanterpriseReporterOptions, queue?: MessageQueue, metadata?: Record<string, string>): void;
|
|
@@ -19,7 +19,7 @@ function mapTestStatus(status) {
|
|
|
19
19
|
return common_1.TestStatus.UNKNOWN;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function handleOnEndEvent(result, runId, client, options, queue) {
|
|
22
|
+
function handleOnEndEvent(result, runId, client, options, queue, metadata) {
|
|
23
23
|
// Validate and sanitize inputs to prevent serialization failures
|
|
24
24
|
const startTimeMs = result.startTime?.getTime();
|
|
25
25
|
const duration = result.duration;
|
|
@@ -35,6 +35,7 @@ function handleOnEndEvent(result, runId, client, options, queue) {
|
|
|
35
35
|
final_status: mapTestStatus(result.status),
|
|
36
36
|
start_time: (0, utils_1.createTimestampFromMs)(validStartTimeMs),
|
|
37
37
|
duration: (0, utils_1.createDuration)(validDuration),
|
|
38
|
+
metadata: (0, utils_1.toMetadataMap)(metadata || {}),
|
|
38
39
|
});
|
|
39
40
|
(0, grpcClient_1.reportUnary)(options, client, "/testsystem.v1.observer.TestEventCollector/ReportRunEnd", request, options.grpcTimeout, queue).catch((error) => {
|
|
40
41
|
if (error instanceof Error) {
|
package/dist/reporter.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export default class StanterpriseReporter implements Reporter {
|
|
|
6
6
|
private runId;
|
|
7
7
|
private runStartTime;
|
|
8
8
|
private messageQueue;
|
|
9
|
+
private metadata;
|
|
9
10
|
constructor(options?: StanterpriseReporterOptions);
|
|
10
11
|
onBegin(config: FullConfig, suite: Suite): void;
|
|
11
12
|
onExit(): Promise<void>;
|
package/dist/reporter.js
CHANGED
|
@@ -19,6 +19,7 @@ class StanterpriseReporter {
|
|
|
19
19
|
this.runStartTime = new Date();
|
|
20
20
|
// Sequential message queue – guarantees ordered delivery to the server
|
|
21
21
|
this.messageQueue = new messageQueue_1.MessageQueue();
|
|
22
|
+
this.metadata = {};
|
|
22
23
|
this.options = (0, optionsMapper_1.default)(options);
|
|
23
24
|
if (this.options.verbose) {
|
|
24
25
|
console.log("Stanterprise Reporter: Initialized with options:", {
|
|
@@ -34,6 +35,10 @@ class StanterpriseReporter {
|
|
|
34
35
|
(0, debugLogger_1.initDebugFile)(this.options);
|
|
35
36
|
}
|
|
36
37
|
onBegin(config, suite) {
|
|
38
|
+
if (config.shard) {
|
|
39
|
+
this.metadata["shard.current"] = String(config.shard.current);
|
|
40
|
+
this.metadata["shard.total"] = String(config.shard.total);
|
|
41
|
+
}
|
|
37
42
|
// Lazily create the client if enabled.
|
|
38
43
|
if (this.options.grpcEnabled) {
|
|
39
44
|
this.grpcClient = (0, grpcClient_1.default)(this.options);
|
|
@@ -81,7 +86,7 @@ class StanterpriseReporter {
|
|
|
81
86
|
console.log(`Playwright start time: ${result.startTime.toISOString()}`);
|
|
82
87
|
}
|
|
83
88
|
if (this.options.grpcEnabled) {
|
|
84
|
-
(0, handlers_1.handleOnEndEvent)(result, this.runId, this.grpcClient, this.options, this.messageQueue);
|
|
89
|
+
(0, handlers_1.handleOnEndEvent)(result, this.runId, this.grpcClient, this.options, this.messageQueue, this.metadata);
|
|
85
90
|
}
|
|
86
91
|
return Promise.resolve();
|
|
87
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stanterprise/playwright-reporter",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Custom Playwright test reporter that sends test results to Stanterprise via gRPC",
|
|
5
5
|
"homepage": "https://github.com/stanterprise/stanterprise-playwright-reporter#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"@grpc/grpc-js": "^1.14.1",
|
|
54
54
|
"@protobuf-ts/grpc-transport": "^2.11.1",
|
|
55
55
|
"@protobuf-ts/grpcweb-transport": "^2.11.1",
|
|
56
|
-
"@stanterprise/protobuf": "^0.
|
|
56
|
+
"@stanterprise/protobuf": "^0.1.1"
|
|
57
57
|
}
|
|
58
58
|
}
|