@stanterprise/playwright-reporter 0.0.11 → 0.0.12
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/README.md
CHANGED
|
@@ -59,11 +59,24 @@ You can also configure the reporter using environment variables:
|
|
|
59
59
|
|
|
60
60
|
- `STANTERPRISE_GRPC_ADDRESS`: gRPC server address (default: `localhost:50051`)
|
|
61
61
|
- `STANTERPRISE_GRPC_ENABLED`: Enable/disable gRPC reporting (default: `true`)
|
|
62
|
+
- `STANTERPRISE_META_*`: Custom metadata fields for test runs (prefix will be stripped)
|
|
63
|
+
|
|
64
|
+
#### Custom Metadata
|
|
65
|
+
|
|
66
|
+
Any environment variable with the `STANTERPRISE_META_` prefix will be automatically included in the test run metadata. The prefix is stripped from the key name.
|
|
67
|
+
|
|
68
|
+
For example:
|
|
69
|
+
- `STANTERPRISE_META_BUILD_ID=12345` becomes `BUILD_ID: 12345` in metadata
|
|
70
|
+
- `STANTERPRISE_META_BRANCH=main` becomes `BRANCH: main` in metadata
|
|
71
|
+
- `STANTERPRISE_META_COMMIT_SHA=abc123` becomes `COMMIT_SHA: abc123` in metadata
|
|
62
72
|
|
|
63
73
|
Example:
|
|
64
74
|
|
|
65
75
|
```bash
|
|
66
|
-
STANTERPRISE_GRPC_ADDRESS=myserver.com:50051
|
|
76
|
+
STANTERPRISE_GRPC_ADDRESS=myserver.com:50051 \
|
|
77
|
+
STANTERPRISE_META_BUILD_ID=12345 \
|
|
78
|
+
STANTERPRISE_META_BRANCH=main \
|
|
79
|
+
npx playwright test
|
|
67
80
|
```
|
|
68
81
|
|
|
69
82
|
## Configuration Options
|
|
@@ -8,11 +8,18 @@ const utils_1 = require("../utils");
|
|
|
8
8
|
const common_1 = require("@stanterprise/protobuf/testsystem/v1/common");
|
|
9
9
|
function handleOnBeginEvent(config, suite, name, runId, client, options) {
|
|
10
10
|
// Report root suite and all child suites recursively
|
|
11
|
+
const metadataMap = new Map(Object.entries(config.metadata || {}));
|
|
12
|
+
const variables = (0, utils_1.getEnvVariables)();
|
|
13
|
+
// Merge environment variables into metadata
|
|
14
|
+
variables.forEach((value, key) => {
|
|
15
|
+
metadataMap.set(key, value);
|
|
16
|
+
});
|
|
11
17
|
const request = new events_1.ReportRunStartEventRequest({
|
|
12
18
|
run_id: runId,
|
|
13
19
|
name: name,
|
|
14
20
|
test_suites: mapSuites(suite, runId),
|
|
15
21
|
total_tests: suite.allTests().length,
|
|
22
|
+
metadata: metadataMap,
|
|
16
23
|
});
|
|
17
24
|
(0, grpcClient_1.reportUnary)(options, client, "/testsystem.v1.observer.TestEventCollector/ReportRunStart", request, options.grpcTimeout).catch((e) => {
|
|
18
25
|
const details = e instanceof Error ? `${e.message}` : String(e);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves environment variables with the STANTERPRISE_META_ prefix
|
|
3
|
+
* and returns them as a Map with the prefix stripped from keys.
|
|
4
|
+
*
|
|
5
|
+
* For example, STANTERPRISE_META_BUILD_ID=123 becomes BUILD_ID=123 in the metadata.
|
|
6
|
+
*
|
|
7
|
+
* @returns Map of metadata key-value pairs with prefix removed
|
|
8
|
+
*/
|
|
9
|
+
export declare function getEnvVariables(): Map<string, string>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEnvVariables = getEnvVariables;
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves environment variables with the STANTERPRISE_META_ prefix
|
|
6
|
+
* and returns them as a Map with the prefix stripped from keys.
|
|
7
|
+
*
|
|
8
|
+
* For example, STANTERPRISE_META_BUILD_ID=123 becomes BUILD_ID=123 in the metadata.
|
|
9
|
+
*
|
|
10
|
+
* @returns Map of metadata key-value pairs with prefix removed
|
|
11
|
+
*/
|
|
12
|
+
function getEnvVariables() {
|
|
13
|
+
const envValues = process.env;
|
|
14
|
+
const prefix = "STANTERPRISE_META_";
|
|
15
|
+
const filteredEntries = Object.entries(envValues)
|
|
16
|
+
.filter(([key]) => key.startsWith(prefix))
|
|
17
|
+
.map(([key, value]) => {
|
|
18
|
+
// Strip the STANTERPRISE_META_ prefix so metadata keys are cleaner
|
|
19
|
+
const strippedKey = key.substring(prefix.length);
|
|
20
|
+
return [strippedKey, value || ""];
|
|
21
|
+
});
|
|
22
|
+
return new Map(filteredEntries);
|
|
23
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stanterprise/playwright-reporter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
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": {
|