@stanterprise/playwright-reporter 0.0.2 → 0.0.6
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 { FullConfig } from "@playwright/test";
|
|
|
2
2
|
import { Suite } from "@playwright/test/reporter";
|
|
3
3
|
import { StanterpriseReporterOptions } from "../types";
|
|
4
4
|
import * as grpc from "@grpc/grpc-js";
|
|
5
|
-
export declare function handleOnBeginEvent(config: FullConfig, suite: Suite, runId: string, client: grpc.Client, options: StanterpriseReporterOptions): void;
|
|
5
|
+
export declare function handleOnBeginEvent(config: FullConfig, suite: Suite, name: string, runId: string, client: grpc.Client, options: StanterpriseReporterOptions): void;
|
|
@@ -5,11 +5,13 @@ const events_1 = require("@stanterprise/protobuf/testsystem/v1/events");
|
|
|
5
5
|
const grpcClient_1 = require("../client/grpcClient");
|
|
6
6
|
const entities_1 = require("@stanterprise/protobuf/testsystem/v1/entities");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
-
function handleOnBeginEvent(config, suite, runId, client, options) {
|
|
8
|
+
function handleOnBeginEvent(config, suite, name, runId, client, options) {
|
|
9
9
|
// Report root suite and all child suites recursively
|
|
10
10
|
const request = new events_1.MapTestRunEventRequest({
|
|
11
11
|
run_id: runId,
|
|
12
|
+
name: name,
|
|
12
13
|
test_suites: mapSuites(suite, runId),
|
|
14
|
+
total_tests: suite.allTests().length,
|
|
13
15
|
});
|
|
14
16
|
(0, grpcClient_1.reportUnary)(options, client, "/testsystem.v1.observer.TestEventCollector/MapTestRun", request, options.grpcTimeout).catch((e) => {
|
|
15
17
|
const details = e instanceof Error ? `${e.message}` : String(e);
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { FullResult } from "@playwright/test/reporter";
|
|
2
|
+
import { StanterpriseReporterOptions } from "../types";
|
|
3
|
+
import * as grpc from "@grpc/grpc-js";
|
|
4
|
+
export declare function handleOnEndEvent(result: FullResult, runId: string, client: grpc.Client, options: StanterpriseReporterOptions): void;
|
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleOnEndEvent = handleOnEndEvent;
|
|
4
|
-
|
|
4
|
+
const grpcClient_1 = require("../client/grpcClient");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const events_1 = require("@stanterprise/protobuf/testsystem/v1/events");
|
|
7
|
+
const common_1 = require("@stanterprise/protobuf/testsystem/v1/common");
|
|
8
|
+
function mapTestStatus(status) {
|
|
9
|
+
switch (status) {
|
|
10
|
+
case "passed":
|
|
11
|
+
return common_1.TestStatus.PASSED;
|
|
12
|
+
case "failed":
|
|
13
|
+
return common_1.TestStatus.FAILED;
|
|
14
|
+
case "timedout":
|
|
15
|
+
return common_1.TestStatus.TIMEDOUT;
|
|
16
|
+
case "interrupted":
|
|
17
|
+
return common_1.TestStatus.INTERRUPTED;
|
|
18
|
+
default:
|
|
19
|
+
return common_1.TestStatus.UNKNOWN;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function handleOnEndEvent(result, runId, client, options) {
|
|
23
|
+
const request = new events_1.TestRunEndEventRequest({
|
|
24
|
+
run_id: runId,
|
|
25
|
+
final_status: mapTestStatus(result.status),
|
|
26
|
+
start_time: (0, utils_1.createTimestampFromMs)(result.startTime.getTime()),
|
|
27
|
+
duration: (0, utils_1.createDuration)(result.duration),
|
|
28
|
+
});
|
|
29
|
+
(0, grpcClient_1.reportUnary)(options, client, "/testsystem.v1.observer.TestEventCollector/ReportEnd", request, options.grpcTimeout).catch((error) => {
|
|
30
|
+
if (error instanceof Error) {
|
|
31
|
+
console.error(`Failed to report end event: ${error.message}`, {
|
|
32
|
+
stack: error.stack,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.error("Failed to report end event: Unknown error type", {
|
|
37
|
+
error,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
package/dist/reporter.js
CHANGED
|
@@ -47,7 +47,7 @@ class StanterpriseReporter {
|
|
|
47
47
|
console.log(`Run started at: ${this.runStartTime.toISOString()}`);
|
|
48
48
|
}
|
|
49
49
|
if (this.options.grpcEnabled) {
|
|
50
|
-
(0, handlers_1.handleOnBeginEvent)(config, suite, this.runId, this.grpcClient, this.options);
|
|
50
|
+
(0, handlers_1.handleOnBeginEvent)(config, suite, process.env.STANTERPRISE_TEST_RUN_NAME || "Playwright Test Run", this.runId, this.grpcClient, this.options);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
async onExit() {
|
|
@@ -69,6 +69,9 @@ class StanterpriseReporter {
|
|
|
69
69
|
console.log(`Run start time: ${this.runStartTime.toISOString()}`);
|
|
70
70
|
console.log(`Playwright start time: ${result.startTime.toISOString()}`);
|
|
71
71
|
}
|
|
72
|
+
if (this.options.grpcEnabled) {
|
|
73
|
+
(0, handlers_1.handleOnEndEvent)(result, this.runId, this.grpcClient, this.options);
|
|
74
|
+
}
|
|
72
75
|
return Promise.resolve();
|
|
73
76
|
}
|
|
74
77
|
onTestBegin(test, result) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stanterprise/playwright-reporter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
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": {
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"main": "dist/index.js",
|
|
17
17
|
"types": "dist/index.d.ts",
|
|
18
18
|
"files": [
|
|
19
|
-
"dist/**/*"
|
|
20
|
-
"README.md"
|
|
19
|
+
"dist/**/*"
|
|
21
20
|
],
|
|
22
21
|
"keywords": [
|
|
23
22
|
"playwright",
|
|
@@ -54,6 +53,6 @@
|
|
|
54
53
|
"@grpc/grpc-js": "^1.14.1",
|
|
55
54
|
"@protobuf-ts/grpc-transport": "^2.11.1",
|
|
56
55
|
"@protobuf-ts/grpcweb-transport": "^2.11.1",
|
|
57
|
-
"@stanterprise/protobuf": "^0.0.
|
|
56
|
+
"@stanterprise/protobuf": "^0.0.18"
|
|
58
57
|
}
|
|
59
58
|
}
|