@stanterprise/playwright-reporter 0.1.0 → 0.1.2
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
|
@@ -49,7 +49,7 @@ export default defineConfig({
|
|
|
49
49
|
grpcMaxMessageSize: 104857600, // Max message size (100MB default)
|
|
50
50
|
maxAttachmentSize: 10485760, // Max attachment size (10MB default)
|
|
51
51
|
verbose: false, // Enable verbose logging
|
|
52
|
-
debug: false,
|
|
52
|
+
debug: false, // Enable debug mode (writes gRPC messages to JSONL file)
|
|
53
53
|
debugFile: "stanterprise-debug.jsonl", // Path for debug JSONL output
|
|
54
54
|
},
|
|
55
55
|
],
|
|
@@ -63,6 +63,7 @@ export default defineConfig({
|
|
|
63
63
|
You can also configure the reporter using environment variables:
|
|
64
64
|
|
|
65
65
|
- `STANTERPRISE_GRPC_ADDRESS`: gRPC server address (default: `localhost:50051`)
|
|
66
|
+
- `STANTERPRISE_GRPC_HOST`: gRPC server host
|
|
66
67
|
- `STANTERPRISE_GRPC_ENABLED`: Enable/disable gRPC reporting (default: `true`)
|
|
67
68
|
- `STANTERPRISE_META_*`: Custom metadata fields for test runs (prefix will be stripped)
|
|
68
69
|
- `STANTERPRISE_DEBUG`: Enable debug mode — captures outgoing gRPC messages to a JSONL file (default: `false`; case-insensitive: `"true"`, `"TRUE"`, `"True"` all work)
|
|
@@ -89,18 +90,20 @@ npx playwright test
|
|
|
89
90
|
|
|
90
91
|
## Configuration Options
|
|
91
92
|
|
|
92
|
-
| Option | Type | Default
|
|
93
|
-
| -------------------- | ------- |
|
|
94
|
-
| `grpcAddress` | string | `localhost:50051`
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
93
|
+
| Option | Type | Default | Description |
|
|
94
|
+
| -------------------- | ------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
95
|
+
| `grpcAddress` | string | `localhost:50051` | Full gRPC server address. Takes precedence over `grpcHost` and `grpcPort`. |
|
|
96
|
+
| `grpcHost` | string | | gRPC server host. Used when `grpcAddress` is not provided. Combined with `grpcPort` to form the address. |
|
|
97
|
+
| `grpcPort` | number | `50051` | gRPC server port. Used when `grpcAddress` is not provided. Combined with `grpcHost` to form the address. |
|
|
98
|
+
| `grpcEnabled` | boolean | `true` | Enable/disable gRPC reporting |
|
|
99
|
+
| `grpcTimeout` | number | `1000` | Timeout for gRPC calls in milliseconds |
|
|
100
|
+
| `grpcMaxMessageSize` | number | `104857600` | Max message size in bytes (100MB default) |
|
|
101
|
+
| `maxAttachmentSize` | number | `10485760` | Max attachment content size in bytes (10MB default) |
|
|
102
|
+
| `verbose` | boolean | `false` | Enable verbose logging |
|
|
103
|
+
| `grpcMaxRetries` | number | `3` | Maximum number of retry attempts for failed gRPC calls |
|
|
104
|
+
| `grpcRetryDelay` | number | `100` | Initial delay for retries in ms (uses exponential backoff) |
|
|
105
|
+
| `debug` | boolean | `false` | Enable debug mode — writes all outgoing gRPC messages to a JSONL file. **Warning:** output may include sensitive request payloads and grow very large. Use only in controlled environments. |
|
|
106
|
+
| `debugFile` | string | `stanterprise-debug.jsonl` | File path for debug JSONL output. Parent directories are created automatically if they do not exist. |
|
|
104
107
|
|
|
105
108
|
### Retry Configuration
|
|
106
109
|
|
|
@@ -112,10 +115,11 @@ The reporter automatically retries failed gRPC calls for transient errors using
|
|
|
112
115
|
**Exponential backoff formula**: `grpcRetryDelay * (2 ^ attemptNumber)`
|
|
113
116
|
|
|
114
117
|
Example with default settings (`grpcRetryDelay: 100`, `grpcMaxRetries: 3`):
|
|
118
|
+
|
|
115
119
|
- Initial attempt: Immediate
|
|
116
|
-
- Retry 1: Wait 100ms (100
|
|
117
|
-
- Retry 2: Wait 200ms (100
|
|
118
|
-
- Retry 3: Wait 400ms (100
|
|
120
|
+
- Retry 1: Wait 100ms (100 \* 2^0)
|
|
121
|
+
- Retry 2: Wait 200ms (100 \* 2^1)
|
|
122
|
+
- Retry 3: Wait 400ms (100 \* 2^2)
|
|
119
123
|
|
|
120
124
|
```typescript
|
|
121
125
|
export default defineConfig({
|
|
@@ -123,9 +127,9 @@ export default defineConfig({
|
|
|
123
127
|
[
|
|
124
128
|
"stanterprise-playwright-reporter",
|
|
125
129
|
{
|
|
126
|
-
grpcMaxRetries: 5,
|
|
127
|
-
grpcRetryDelay: 200,
|
|
128
|
-
verbose: true,
|
|
130
|
+
grpcMaxRetries: 5, // Try up to 5 times
|
|
131
|
+
grpcRetryDelay: 200, // Start with 200ms delay
|
|
132
|
+
verbose: true, // Log retry attempts
|
|
129
133
|
},
|
|
130
134
|
],
|
|
131
135
|
],
|
|
@@ -136,7 +140,7 @@ To disable retries:
|
|
|
136
140
|
|
|
137
141
|
```typescript
|
|
138
142
|
{
|
|
139
|
-
grpcMaxRetries: 0
|
|
143
|
+
grpcMaxRetries: 0; // No retries, fail fast
|
|
140
144
|
}
|
|
141
145
|
```
|
|
142
146
|
|
|
@@ -9,6 +9,7 @@ const utils_2 = require("../utils");
|
|
|
9
9
|
function handleOnStepEndEvent(test, result, step, runId, client, options, queue) {
|
|
10
10
|
// Map step error to status
|
|
11
11
|
const stepStatus = (0, utils_1.mapStepStatus)(!!step.error);
|
|
12
|
+
const attachments = (0, utils_1.processAttachments)(result, options.maxAttachmentSize || 10485760);
|
|
12
13
|
// Build metadata from step annotations
|
|
13
14
|
const metadata = (0, utils_1.buildStepMetadata)(step);
|
|
14
15
|
const stepId = (0, utils_2.generateStepId)(step, test);
|
|
@@ -52,6 +53,7 @@ function handleOnStepEndEvent(test, result, step, runId, client, options, queue)
|
|
|
52
53
|
: undefined,
|
|
53
54
|
worker_index: result.workerIndex.toString(),
|
|
54
55
|
retry_index: result.retry,
|
|
56
|
+
attachments: attachments,
|
|
55
57
|
}),
|
|
56
58
|
});
|
|
57
59
|
// Fire-and-forget to avoid slowing tests
|
package/dist/types.d.ts
CHANGED
|
@@ -10,6 +10,19 @@ export interface StanterpriseReporterOptions {
|
|
|
10
10
|
* @default "localhost:50051" or process.env.STANTERPRISE_GRPC_ADDRESS
|
|
11
11
|
*/
|
|
12
12
|
grpcAddress?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional separate host for gRPC when `grpcAddress` is not provided.
|
|
15
|
+
* This allows specifying gRPC connection details separately from other potential uses of `grpcAddress`.
|
|
16
|
+
* If `grpcAddress` is provided, it takes precedence over this field.
|
|
17
|
+
*/
|
|
18
|
+
grpcHost?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional separate port for gRPC when `grpcAddress` is not provided.
|
|
21
|
+
* This allows specifying gRPC connection details separately from other potential uses of `grpcAddress`.
|
|
22
|
+
* If `grpcAddress` is provided, it takes precedence over this field.
|
|
23
|
+
* @default 50051
|
|
24
|
+
*/
|
|
25
|
+
grpcPort?: number;
|
|
13
26
|
/**
|
|
14
27
|
* Whether gRPC reporting is enabled
|
|
15
28
|
* @default true or process.env.STANTERPRISE_GRPC_ENABLED !== "false"
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility functions for processing test attachments
|
|
3
3
|
*/
|
|
4
|
-
import type { TestResult } from "@playwright/test/reporter";
|
|
4
|
+
import type { TestResult, TestStep } from "@playwright/test/reporter";
|
|
5
5
|
import { common } from "@stanterprise/protobuf";
|
|
6
6
|
declare const Attachment: typeof common.v1.common.Attachment;
|
|
7
7
|
/**
|
|
8
8
|
* Process Playwright test attachments into protobuf Attachment objects
|
|
9
|
-
* @param result Test result containing attachments
|
|
9
|
+
* @param result Test result or test step containing attachments
|
|
10
10
|
* @param maxAttachmentSize Maximum size for attachment content (default 1MB, reduced from 10MB)
|
|
11
11
|
*/
|
|
12
|
-
export declare function processAttachments(result: TestResult, maxAttachmentSize?: number): InstanceType<typeof Attachment>[];
|
|
12
|
+
export declare function processAttachments(result: TestResult | TestStep, maxAttachmentSize?: number): InstanceType<typeof Attachment>[];
|
|
13
13
|
/**
|
|
14
14
|
* Extract error information from test results
|
|
15
15
|
*/
|
|
@@ -10,11 +10,10 @@ const Attachment = protobuf_1.common.v1.common.Attachment;
|
|
|
10
10
|
const BYTES_PER_MB = 1048576;
|
|
11
11
|
/**
|
|
12
12
|
* Process Playwright test attachments into protobuf Attachment objects
|
|
13
|
-
* @param result Test result containing attachments
|
|
13
|
+
* @param result Test result or test step containing attachments
|
|
14
14
|
* @param maxAttachmentSize Maximum size for attachment content (default 1MB, reduced from 10MB)
|
|
15
15
|
*/
|
|
16
|
-
function processAttachments(result, maxAttachmentSize = 1048576
|
|
17
|
-
) {
|
|
16
|
+
function processAttachments(result, maxAttachmentSize = 1048576) {
|
|
18
17
|
const attachments = [];
|
|
19
18
|
if (!result.attachments || result.attachments.length === 0) {
|
|
20
19
|
return attachments;
|
|
@@ -8,19 +8,16 @@ exports.default = defineOptions;
|
|
|
8
8
|
*/
|
|
9
9
|
function defineOptions(providedOptions) {
|
|
10
10
|
const result = {};
|
|
11
|
-
result.grpcAddress =
|
|
12
|
-
providedOptions.grpcAddress ||
|
|
13
|
-
process.env.STANTERPRISE_GRPC_ADDRESS ||
|
|
14
|
-
"localhost:50051";
|
|
11
|
+
result.grpcAddress = identifyAddress(providedOptions);
|
|
15
12
|
result.grpcEnabled =
|
|
16
13
|
providedOptions.grpcEnabled ??
|
|
17
14
|
(process.env.STANTERPRISE_GRPC_ENABLED || "true").toLowerCase() !== "false";
|
|
18
|
-
result.grpcTimeout = providedOptions.grpcTimeout
|
|
19
|
-
result.grpcMaxMessageSize = providedOptions.grpcMaxMessageSize
|
|
20
|
-
result.maxAttachmentSize = providedOptions.maxAttachmentSize
|
|
21
|
-
result.verbose = providedOptions.verbose
|
|
15
|
+
result.grpcTimeout = providedOptions.grpcTimeout ?? 1000;
|
|
16
|
+
result.grpcMaxMessageSize = providedOptions.grpcMaxMessageSize ?? 104857600;
|
|
17
|
+
result.maxAttachmentSize = providedOptions.maxAttachmentSize ?? 10485760;
|
|
18
|
+
result.verbose = providedOptions.verbose ?? false;
|
|
22
19
|
result.grpcMaxRetries = providedOptions.grpcMaxRetries ?? 3;
|
|
23
|
-
result.grpcRetryDelay = providedOptions.grpcRetryDelay
|
|
20
|
+
result.grpcRetryDelay = providedOptions.grpcRetryDelay ?? 100;
|
|
24
21
|
result.debug =
|
|
25
22
|
providedOptions.debug ??
|
|
26
23
|
(process.env.STANTERPRISE_DEBUG || "").toLowerCase() === "true";
|
|
@@ -30,3 +27,22 @@ function defineOptions(providedOptions) {
|
|
|
30
27
|
"stanterprise-debug.jsonl";
|
|
31
28
|
return result;
|
|
32
29
|
}
|
|
30
|
+
function identifyAddress(providedOptions) {
|
|
31
|
+
if (providedOptions.grpcAddress) {
|
|
32
|
+
return providedOptions.grpcAddress;
|
|
33
|
+
}
|
|
34
|
+
if (process.env.STANTERPRISE_GRPC_ADDRESS) {
|
|
35
|
+
return process.env.STANTERPRISE_GRPC_ADDRESS;
|
|
36
|
+
}
|
|
37
|
+
if (process.env.STANTERPRISE_GRPC_HOST) {
|
|
38
|
+
const host = process.env.STANTERPRISE_GRPC_HOST;
|
|
39
|
+
const port = process.env.STANTERPRISE_GRPC_PORT || "50051";
|
|
40
|
+
return `${host}:${port}`;
|
|
41
|
+
}
|
|
42
|
+
if (providedOptions.grpcHost) {
|
|
43
|
+
const host = providedOptions.grpcHost;
|
|
44
|
+
const port = providedOptions.grpcPort ?? 50051;
|
|
45
|
+
return `${host}:${port}`;
|
|
46
|
+
}
|
|
47
|
+
return "localhost:50051";
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stanterprise/playwright-reporter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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.1.
|
|
56
|
+
"@stanterprise/protobuf": "^0.1.2"
|
|
57
57
|
}
|
|
58
58
|
}
|