playwright-network-metrics 0.2.1 → 0.2.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 +3 -1
- package/dist/index.js +7 -1
- package/dist/index.mjs +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ The `defineNetworkMetricsFixture` function and `NetworkMetricsReporter` accept a
|
|
|
70
70
|
| Option | Type | Default | Description |
|
|
71
71
|
| ------------------- | -------------------- | ------------------------------------- | ---------------------------------------------------- |
|
|
72
72
|
| `outDir` | `string` | `"playwright-report/network-metrics"` | Directory where the reports will be written. |
|
|
73
|
-
| `html` | `boolean` | `
|
|
73
|
+
| `html` | `boolean` | `true` | Whether to generate an interactive HTML report. |
|
|
74
74
|
| `urlMatch` | `string \| string[]` | `"**"` | Glob pattern(s) to match URLs (e.g., `**/api/**`). |
|
|
75
75
|
| `resourceTypes` | `string[]` | `[...]` | List of resource types to track. |
|
|
76
76
|
| `redactQueryParams` | `string[]` | `[]` | List of query parameters to redact from stored URLs. |
|
|
@@ -78,6 +78,8 @@ The `defineNetworkMetricsFixture` function and `NetworkMetricsReporter` accept a
|
|
|
78
78
|
| `routeGroupRules` | `array` | `[]` | Rules for grouping URLs into logical categories. |
|
|
79
79
|
| `routeGroupFn` | `function` | `undefined` | Custom hook for route grouping. |
|
|
80
80
|
|
|
81
|
+
> **Note**: If the `PLAYWRIGHT_REPORT_FOLDER` environment variable is set, the reporter will automatically adjust the output directory to be distinct inside that folder (e.g. `${PLAYWRIGHT_REPORT_FOLDER}/network-metrics`).
|
|
82
|
+
|
|
81
83
|
### Custom Route Grouping
|
|
82
84
|
|
|
83
85
|
You can provide custom rules to group similar URLs together:
|
package/dist/index.js
CHANGED
|
@@ -89,7 +89,7 @@ var NetworkMetricsCollector = class {
|
|
|
89
89
|
*/
|
|
90
90
|
async handleRequestFinished(request) {
|
|
91
91
|
if (!this.shouldTrack(request)) return;
|
|
92
|
-
const response = await request.response();
|
|
92
|
+
const response = await request.response().catch(() => null);
|
|
93
93
|
if (!response) return;
|
|
94
94
|
this.addMetric(request, response);
|
|
95
95
|
}
|
|
@@ -624,6 +624,12 @@ var NetworkMetricsReporter = class {
|
|
|
624
624
|
html: true
|
|
625
625
|
};
|
|
626
626
|
onBegin(config) {
|
|
627
|
+
if (process.env.PLAYWRIGHT_REPORT_FOLDER) {
|
|
628
|
+
this.config.outDir = import_node_path.default.join(
|
|
629
|
+
process.env.PLAYWRIGHT_REPORT_FOLDER,
|
|
630
|
+
"network-metrics"
|
|
631
|
+
);
|
|
632
|
+
}
|
|
627
633
|
const reporterEntry = config.reporter.find(
|
|
628
634
|
([name]) => name.includes("playwright-network-metrics")
|
|
629
635
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -51,7 +51,7 @@ var NetworkMetricsCollector = class {
|
|
|
51
51
|
*/
|
|
52
52
|
async handleRequestFinished(request) {
|
|
53
53
|
if (!this.shouldTrack(request)) return;
|
|
54
|
-
const response = await request.response();
|
|
54
|
+
const response = await request.response().catch(() => null);
|
|
55
55
|
if (!response) return;
|
|
56
56
|
this.addMetric(request, response);
|
|
57
57
|
}
|
|
@@ -586,6 +586,12 @@ var NetworkMetricsReporter = class {
|
|
|
586
586
|
html: true
|
|
587
587
|
};
|
|
588
588
|
onBegin(config) {
|
|
589
|
+
if (process.env.PLAYWRIGHT_REPORT_FOLDER) {
|
|
590
|
+
this.config.outDir = path.join(
|
|
591
|
+
process.env.PLAYWRIGHT_REPORT_FOLDER,
|
|
592
|
+
"network-metrics"
|
|
593
|
+
);
|
|
594
|
+
}
|
|
589
595
|
const reporterEntry = config.reporter.find(
|
|
590
596
|
([name]) => name.includes("playwright-network-metrics")
|
|
591
597
|
);
|
package/package.json
CHANGED