@piwitests/reporter 0.11.0 → 0.13.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.
Files changed (77) hide show
  1. package/dist/global-setup-module.d.ts +2 -1
  2. package/dist/global-setup-module.js +432 -3
  3. package/dist/index.d.ts +204 -8
  4. package/dist/index.js +4724 -23
  5. package/dist/internal/capture/attachments.d.ts +9 -3
  6. package/dist/internal/capture/attachments.js +46 -20
  7. package/dist/internal/capture/capture-fixtures.d.ts +110 -7
  8. package/dist/internal/capture/capture-fixtures.js +2227 -639
  9. package/dist/internal/capture/inspect-on-failure.d.ts +50 -0
  10. package/dist/internal/capture/inspect-on-failure.js +66 -0
  11. package/dist/internal/capture/locator-healing.d.ts +33 -131
  12. package/dist/internal/capture/locator-healing.js +602 -711
  13. package/dist/internal/capture/pick-on-failure.d.ts +198 -0
  14. package/dist/internal/capture/pick-on-failure.js +1203 -0
  15. package/package.json +9 -4
  16. package/dist/internal/collect/error-text.d.ts +0 -18
  17. package/dist/internal/collect/error-text.js +0 -79
  18. package/dist/internal/collect/metadata-collector.d.ts +0 -32
  19. package/dist/internal/collect/metadata-collector.js +0 -246
  20. package/dist/internal/collect/skip-classify.d.ts +0 -27
  21. package/dist/internal/collect/skip-classify.js +0 -40
  22. package/dist/internal/collect/step-analyzer.d.ts +0 -103
  23. package/dist/internal/collect/step-analyzer.js +0 -221
  24. package/dist/internal/config/env.d.ts +0 -45
  25. package/dist/internal/config/env.js +0 -153
  26. package/dist/internal/files/compression.d.ts +0 -5
  27. package/dist/internal/files/compression.js +0 -69
  28. package/dist/internal/files/file-handler.d.ts +0 -38
  29. package/dist/internal/files/file-handler.js +0 -198
  30. package/dist/internal/streaming/crash-recovery.d.ts +0 -23
  31. package/dist/internal/streaming/crash-recovery.js +0 -106
  32. package/dist/internal/streaming/stream-buffer.d.ts +0 -17
  33. package/dist/internal/streaming/stream-buffer.js +0 -102
  34. package/dist/internal/streaming/stream-manager.d.ts +0 -88
  35. package/dist/internal/streaming/stream-manager.js +0 -395
  36. package/dist/internal/submit/run-submitter.d.ts +0 -67
  37. package/dist/internal/submit/run-submitter.js +0 -190
  38. package/dist/internal/submit/serializer.d.ts +0 -45
  39. package/dist/internal/submit/serializer.js +0 -107
  40. package/dist/internal/submit/uploader.d.ts +0 -89
  41. package/dist/internal/submit/uploader.js +0 -226
  42. package/dist/internal/support/ci.d.ts +0 -2
  43. package/dist/internal/support/ci.js +0 -32
  44. package/dist/internal/support/cli-filters.d.ts +0 -1
  45. package/dist/internal/support/cli-filters.js +0 -51
  46. package/dist/internal/support/errors.d.ts +0 -8
  47. package/dist/internal/support/errors.js +0 -15
  48. package/dist/internal/support/instance-id.d.ts +0 -4
  49. package/dist/internal/support/instance-id.js +0 -48
  50. package/dist/internal/support/limiter.d.ts +0 -2
  51. package/dist/internal/support/limiter.js +0 -27
  52. package/dist/internal/support/logger.d.ts +0 -26
  53. package/dist/internal/support/logger.js +0 -43
  54. package/dist/internal/support/reporter-version.d.ts +0 -2
  55. package/dist/internal/support/reporter-version.js +0 -54
  56. package/dist/internal/support/setup-file.d.ts +0 -13
  57. package/dist/internal/support/setup-file.js +0 -61
  58. package/dist/internal/support/source-snippet.d.ts +0 -12
  59. package/dist/internal/support/source-snippet.js +0 -97
  60. package/dist/internal/support/worker-index.d.ts +0 -7
  61. package/dist/internal/support/worker-index.js +0 -14
  62. package/dist/internal/transport/http-client.d.ts +0 -52
  63. package/dist/internal/transport/http-client.js +0 -201
  64. package/dist/public/config-wrapper.d.ts +0 -21
  65. package/dist/public/config-wrapper.js +0 -64
  66. package/dist/public/global-setup.d.ts +0 -13
  67. package/dist/public/global-setup.js +0 -146
  68. package/dist/public/options.d.ts +0 -78
  69. package/dist/public/options.js +0 -2
  70. package/dist/public/reporter.d.ts +0 -68
  71. package/dist/public/reporter.js +0 -376
  72. package/dist/types/collected.d.ts +0 -96
  73. package/dist/types/collected.js +0 -10
  74. package/dist/types/wire.d.ts +0 -174
  75. package/dist/types/wire.js +0 -14
  76. package/dist/types.d.ts +0 -11
  77. package/dist/types.js +0 -27
@@ -1,221 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.categorizeStep = categorizeStep;
4
- exports.flattenSteps = flattenSteps;
5
- exports.collectStepMetrics = collectStepMetrics;
6
- exports.percentile = percentile;
7
- exports.computePerformanceSummary = computePerformanceSummary;
8
- exports.extractTestStepEvents = extractTestStepEvents;
9
- exports.extractWaitEvents = extractWaitEvents;
10
- /**
11
- * Categorise a Playwright step into `navigation`, `action`, `input`,
12
- * `assertion`, `wait`, `api`, `hook`, or `other`.
13
- *
14
- * Supports two title formats:
15
- * - Legacy api-path titles ("page.goto", "locator.click", "page.waitForTimeout")
16
- * - Modern human-readable titles introduced in newer Playwright versions
17
- * ("Navigate to \"{url}\"", "Click", "Wait for timeout", "Wait for load state").
18
- * Hook/fixture/expect steps are detected via Playwright's own `category`.
19
- */
20
- function categorizeStep(title, pwCategory) {
21
- if (!title)
22
- return 'other';
23
- if (pwCategory === 'hook' || pwCategory === 'fixture')
24
- return pwCategory;
25
- if (pwCategory === 'expect')
26
- return 'assertion';
27
- const lower = title.toLowerCase();
28
- // Waits — modern "Wait for timeout/function/selector/state/navigation/load state/url/event"
29
- // and legacy "*.waitFor*" (locator.waitFor, page.waitForLoadState, frame.waitForTimeout, ...).
30
- if (lower.startsWith('wait for') ||
31
- lower.startsWith('locator.waitfor') ||
32
- lower.startsWith('page.waitfor') ||
33
- lower.startsWith('frame.waitfor'))
34
- return 'wait';
35
- // Navigation — modern "Navigate to ...", "Go back", "Go forward", "Reload"; legacy "page.goto" etc.
36
- if (lower.startsWith('navigate to') ||
37
- lower.startsWith('go back') ||
38
- lower.startsWith('go forward') ||
39
- lower.startsWith('reload') ||
40
- lower.startsWith('page.goto') ||
41
- lower.startsWith('page.reload') ||
42
- lower.startsWith('page.goback') ||
43
- lower.startsWith('page.goforward'))
44
- return 'navigation';
45
- // Actions — clicks, taps, checks, selects, hovers
46
- if (lower.startsWith('click') ||
47
- lower.startsWith('double click') ||
48
- lower.startsWith('check') ||
49
- lower.startsWith('uncheck') ||
50
- lower.startsWith('tap') ||
51
- lower.startsWith('hover') ||
52
- lower.startsWith('select option') ||
53
- lower.startsWith('drag') ||
54
- lower.startsWith('locator.click') ||
55
- lower.startsWith('locator.dblclick') ||
56
- lower.startsWith('locator.check') ||
57
- lower.startsWith('locator.uncheck') ||
58
- lower.startsWith('locator.selectoption') ||
59
- lower.startsWith('locator.tap'))
60
- return 'action';
61
- // Input — fill, type, press, insert text, set input files
62
- if (lower.startsWith('fill ') ||
63
- lower === 'fill' ||
64
- lower.startsWith('type') ||
65
- lower.startsWith('press') ||
66
- lower.startsWith('insert ') ||
67
- lower.startsWith('set input files') ||
68
- lower.startsWith('locator.fill') ||
69
- lower.startsWith('locator.type') ||
70
- lower.startsWith('locator.press') ||
71
- lower.startsWith('locator.clear') ||
72
- lower.startsWith('locator.setinputfiles'))
73
- return 'input';
74
- // Assertions — legacy "expect..." titles (modern ones caught via pwCategory above)
75
- if (lower.startsWith('expect') || lower.startsWith('locator.expect') || lower.startsWith('page.expect'))
76
- return 'assertion';
77
- if (lower.startsWith('apirequestcontext') || lower.startsWith('apiresponse'))
78
- return 'api';
79
- if (lower === 'before hooks' || lower === 'after hooks' || lower.startsWith('fixture:'))
80
- return 'hook';
81
- return 'other';
82
- }
83
- /** Recursively flatten a nested step tree into a flat list. Uses Playwright's built-in category when available. */
84
- function flattenSteps(steps) {
85
- const result = [];
86
- for (const step of steps) {
87
- const flat = {
88
- title: step.title,
89
- duration: step.duration,
90
- category: categorizeStep(step.title, step.category),
91
- };
92
- if (step.error?.message) {
93
- flat.error = { message: step.error.message };
94
- flat.failed = true;
95
- }
96
- result.push(flat);
97
- if (step.steps?.length > 0)
98
- result.push(...flattenSteps(step.steps));
99
- }
100
- return result;
101
- }
102
- /** Collect step metrics (flat steps, slowest step, navigation stats) from a Playwright step array */
103
- function collectStepMetrics(steps) {
104
- const flatSteps = flattenSteps(steps);
105
- const totalStepDuration = steps.reduce((sum, s) => sum + (s.duration || 0), 0);
106
- let slowestStep = null;
107
- for (const s of flatSteps) {
108
- if (!slowestStep || s.duration > slowestStep.duration)
109
- slowestStep = { title: s.title, duration: s.duration };
110
- }
111
- const navSteps = flatSteps.filter((s) => s.category === 'navigation');
112
- const waitSteps = flatSteps.filter((s) => s.category === 'wait');
113
- const waitTotalDuration = waitSteps.reduce((sum, s) => sum + (s.duration || 0), 0);
114
- return {
115
- steps: flatSteps,
116
- totalStepDuration,
117
- slowestStep,
118
- navigationCount: navSteps.length,
119
- navigationTotalDuration: navSteps.reduce((sum, s) => sum + (s.duration || 0), 0),
120
- waitTotalDuration,
121
- waitCount: waitSteps.length,
122
- };
123
- }
124
- /** Calculate the p-th percentile from a sorted array of numbers */
125
- function percentile(sortedArr, p) {
126
- if (sortedArr.length === 0)
127
- return 0;
128
- const index = Math.ceil((p / 100) * sortedArr.length) - 1;
129
- return sortedArr[Math.max(0, index)];
130
- }
131
- /** Compute run-level performance summary (averages, percentiles, slowest tests) from all test cases */
132
- function computePerformanceSummary(testCases) {
133
- const durations = testCases.filter((tc) => tc.duration != null).map((tc) => tc.duration);
134
- if (durations.length === 0)
135
- return {};
136
- const sorted = [...durations].sort((a, b) => a - b);
137
- const sum = durations.reduce((a, b) => a + b, 0);
138
- const result = {
139
- avgTestDuration: Math.round(sum / durations.length),
140
- p50TestDuration: percentile(sorted, 50),
141
- p90TestDuration: percentile(sorted, 90),
142
- p95TestDuration: percentile(sorted, 95),
143
- slowestTests: [...testCases]
144
- .filter((tc) => tc.duration != null)
145
- .sort((a, b) => b.duration - a.duration)
146
- .slice(0, 5)
147
- .map((tc) => ({ title: tc.title, duration: tc.duration })),
148
- };
149
- let totalNavDur = 0;
150
- let totalNavCount = 0;
151
- for (const tc of testCases) {
152
- if (tc.performanceMetrics) {
153
- totalNavDur += tc.performanceMetrics.navigationTotalDuration || 0;
154
- totalNavCount += tc.performanceMetrics.navigationCount || 0;
155
- }
156
- }
157
- result.totalNavigationDuration = totalNavDur;
158
- result.avgNavigationDuration = totalNavCount > 0 ? Math.round(totalNavDur / totalNavCount) : 0;
159
- let totalWasted = 0;
160
- for (const tc of testCases) {
161
- if (tc.performanceMetrics) {
162
- totalWasted += tc.performanceMetrics.waitTotalDuration || 0;
163
- }
164
- }
165
- result.totalWastedTimeMs = totalWasted;
166
- return result;
167
- }
168
- /**
169
- * Extract hook and fixture step events with absolute timings from a Playwright
170
- * step tree. These are used by the WorkersTimeline to render hook segments.
171
- *
172
- * Returns only top-level hook/fixture steps (beforeEach, afterEach, fixture
173
- * setup/teardown) — their sub-steps are included implicitly in their duration.
174
- */
175
- function extractTestStepEvents(steps, _testStartTime) {
176
- const events = [];
177
- for (const step of steps) {
178
- const cat = categorizeStep(step.title, step.category);
179
- if (cat !== 'hook' && cat !== 'fixture')
180
- continue;
181
- if (!step.startTime)
182
- continue;
183
- const startedAt = step.startTime instanceof Date ? step.startTime.getTime() : step.startTime;
184
- events.push({
185
- title: step.title,
186
- category: cat,
187
- startedAt,
188
- duration: step.duration || 0,
189
- status: step.error ? 'failed' : 'passed',
190
- location: step.location ? `${step.location.file}:${step.location.line}:${step.location.column}` : null,
191
- });
192
- }
193
- return events;
194
- }
195
- /**
196
- * Recursively extract wait-category steps from the Playwright step tree
197
- * with absolute timings. These are rendered as semi-transparent amber bars
198
- * on WorkersTimeline to visualize wasted time.
199
- */
200
- function extractWaitEvents(steps, insideWait = false) {
201
- const events = [];
202
- for (const step of steps) {
203
- const cat = categorizeStep(step.title, step.category);
204
- const isWait = cat === 'wait';
205
- if (isWait && !insideWait && step.startTime) {
206
- const startedAt = step.startTime instanceof Date ? step.startTime.getTime() : step.startTime;
207
- events.push({
208
- title: step.title,
209
- category: 'wait',
210
- startedAt,
211
- duration: step.duration || 0,
212
- status: 'wasted',
213
- location: step.location ? `${step.location.file}:${step.location.line}:${step.location.column}` : null,
214
- });
215
- }
216
- if (step.steps?.length > 0) {
217
- events.push(...extractWaitEvents(step.steps, insideWait || isWait));
218
- }
219
- }
220
- return events;
221
- }
@@ -1,45 +0,0 @@
1
- import type { PiwiDashboardOptions } from '../../public/options.js';
2
- /**
3
- * Single source of truth for the `PIWI_*` env-var → option mapping. Both
4
- * `resolveOptions` (env → option) and `applyOptionsToEnv` (option → env, used
5
- * by `wrapConfig` to bridge into the global-setup process) read these names so
6
- * the mapping lives in exactly one place.
7
- */
8
- export declare const PIWI_ENV_KEYS: {
9
- readonly serverUrl: "PIWI_DASHBOARD_URL";
10
- readonly projectName: "PIWI_PROJECT_NAME";
11
- readonly verbose: "PIWI_VERBOSE";
12
- readonly apiKey: "PIWI_API_KEY";
13
- readonly username: "PIWI_USERNAME";
14
- readonly password: "PIWI_PASSWORD";
15
- readonly environment: "PIWI_ENVIRONMENT";
16
- readonly label: "PIWI_LABEL";
17
- readonly runLabel: "PIWI_RUN_LABEL";
18
- readonly streaming: "PIWI_STREAMING";
19
- readonly streamingBatchSize: "PIWI_STREAMING_BATCH_SIZE";
20
- readonly streamingBatchDelay: "PIWI_STREAMING_BATCH_DELAY";
21
- readonly liveFileUploads: "PIWI_LIVE_FILE_UPLOADS";
22
- readonly uploadTraces: "PIWI_UPLOAD_TRACES";
23
- readonly uploadReport: "PIWI_UPLOAD_REPORT";
24
- readonly captureLocators: "PIWI_CAPTURE_LOCATORS";
25
- };
26
- /**
27
- * Merge raw user options with defaults, reading from `PIWI_*` env vars when
28
- * options are not provided.
29
- *
30
- * Env semantics: env vars fill in values the caller didn't provide (fallback).
31
- * They're applied to `raw` *before* the `DEFAULTS` merge so a built-in default
32
- * never masks an env var (`PIWI_PROJECT_NAME` would otherwise be masked by the
33
- * `default-project` default).
34
- *
35
- * One preserved quirk: `PIWI_VERBOSE` wins over both the default *and* an
36
- * explicit user option.
37
- */
38
- export declare function resolveOptions(raw: Record<string, any>): PiwiDashboardOptions;
39
- /**
40
- * Write the options that the isolated `global-setup-module` process needs into
41
- * `PIWI_*` env vars. `wrapConfig` calls this so the global setup (which runs
42
- * `resolveOptions({})` in a separate module) picks up the same server/auth
43
- * config the reporter instance uses. Only writes values that are actually set.
44
- */
45
- export declare function applyOptionsToEnv(options: PiwiDashboardOptions): void;
@@ -1,153 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PIWI_ENV_KEYS = void 0;
4
- exports.resolveOptions = resolveOptions;
5
- exports.applyOptionsToEnv = applyOptionsToEnv;
6
- /**
7
- * Built-in option defaults, merged *under* any user-provided or env-derived
8
- * value (see `resolveOptions`).
9
- */
10
- const DEFAULTS = {
11
- projectName: 'default-project',
12
- uploadTraces: true,
13
- uploadReport: true,
14
- liveFileUploads: true,
15
- collectScmInfo: true,
16
- collectCiInfo: true,
17
- collectPerformanceMetrics: true,
18
- captureLocators: true,
19
- streaming: true,
20
- streamingBatchSize: 5,
21
- streamingBatchDelay: 2000,
22
- username: null,
23
- password: null,
24
- apiKey: null,
25
- verbose: false,
26
- };
27
- /**
28
- * Single source of truth for the `PIWI_*` env-var → option mapping. Both
29
- * `resolveOptions` (env → option) and `applyOptionsToEnv` (option → env, used
30
- * by `wrapConfig` to bridge into the global-setup process) read these names so
31
- * the mapping lives in exactly one place.
32
- */
33
- exports.PIWI_ENV_KEYS = {
34
- serverUrl: 'PIWI_DASHBOARD_URL',
35
- projectName: 'PIWI_PROJECT_NAME',
36
- verbose: 'PIWI_VERBOSE',
37
- apiKey: 'PIWI_API_KEY',
38
- username: 'PIWI_USERNAME',
39
- password: 'PIWI_PASSWORD',
40
- environment: 'PIWI_ENVIRONMENT',
41
- label: 'PIWI_LABEL',
42
- runLabel: 'PIWI_RUN_LABEL',
43
- streaming: 'PIWI_STREAMING',
44
- streamingBatchSize: 'PIWI_STREAMING_BATCH_SIZE',
45
- streamingBatchDelay: 'PIWI_STREAMING_BATCH_DELAY',
46
- liveFileUploads: 'PIWI_LIVE_FILE_UPLOADS',
47
- uploadTraces: 'PIWI_UPLOAD_TRACES',
48
- uploadReport: 'PIWI_UPLOAD_REPORT',
49
- captureLocators: 'PIWI_CAPTURE_LOCATORS',
50
- };
51
- function readBool(val) {
52
- if (val === undefined)
53
- return undefined;
54
- return val === 'true';
55
- }
56
- /**
57
- * Declarative env → option fallback table. `resolveOptions` walks this instead
58
- * of repeating ~15 near-identical merge lines, so adding an env-backed option
59
- * means adding one row.
60
- *
61
- * Guard semantics (preserved from the original hand-written merges):
62
- * - `string` / `number`: a *truthy* env value fills the option, so an empty
63
- * string is ignored.
64
- * - `bool`: any *defined* env value fills it (via `readBool`), so
65
- * `PIWI_STREAMING=false` actually disables streaming.
66
- *
67
- * `verbose` is intentionally absent — it *overrides* rather than falls back, and
68
- * is applied after the `DEFAULTS` merge in `resolveOptions`.
69
- */
70
- const ENV_FALLBACK_SPECS = [
71
- { option: 'serverUrl', env: exports.PIWI_ENV_KEYS.serverUrl, kind: 'string' },
72
- { option: 'projectName', env: exports.PIWI_ENV_KEYS.projectName, kind: 'string' },
73
- { option: 'apiKey', env: exports.PIWI_ENV_KEYS.apiKey, kind: 'string' },
74
- { option: 'username', env: exports.PIWI_ENV_KEYS.username, kind: 'string' },
75
- { option: 'password', env: exports.PIWI_ENV_KEYS.password, kind: 'string' },
76
- { option: 'environment', env: exports.PIWI_ENV_KEYS.environment, kind: 'string' },
77
- { option: 'label', env: exports.PIWI_ENV_KEYS.label, kind: 'string' },
78
- { option: 'runLabel', env: exports.PIWI_ENV_KEYS.runLabel, kind: 'string' },
79
- { option: 'streaming', env: exports.PIWI_ENV_KEYS.streaming, kind: 'bool' },
80
- { option: 'streamingBatchSize', env: exports.PIWI_ENV_KEYS.streamingBatchSize, kind: 'number' },
81
- { option: 'streamingBatchDelay', env: exports.PIWI_ENV_KEYS.streamingBatchDelay, kind: 'number' },
82
- { option: 'liveFileUploads', env: exports.PIWI_ENV_KEYS.liveFileUploads, kind: 'bool' },
83
- { option: 'uploadTraces', env: exports.PIWI_ENV_KEYS.uploadTraces, kind: 'bool' },
84
- { option: 'uploadReport', env: exports.PIWI_ENV_KEYS.uploadReport, kind: 'bool' },
85
- { option: 'captureLocators', env: exports.PIWI_ENV_KEYS.captureLocators, kind: 'bool' },
86
- ];
87
- /**
88
- * Merge raw user options with defaults, reading from `PIWI_*` env vars when
89
- * options are not provided.
90
- *
91
- * Env semantics: env vars fill in values the caller didn't provide (fallback).
92
- * They're applied to `raw` *before* the `DEFAULTS` merge so a built-in default
93
- * never masks an env var (`PIWI_PROJECT_NAME` would otherwise be masked by the
94
- * `default-project` default).
95
- *
96
- * One preserved quirk: `PIWI_VERBOSE` wins over both the default *and* an
97
- * explicit user option.
98
- */
99
- function resolveOptions(raw) {
100
- const env = process.env;
101
- const mergedRaw = { ...raw };
102
- for (const spec of ENV_FALLBACK_SPECS) {
103
- if (mergedRaw[spec.option] !== undefined)
104
- continue;
105
- const value = env[spec.env];
106
- if (spec.kind === 'bool') {
107
- if (value !== undefined)
108
- mergedRaw[spec.option] = readBool(value);
109
- }
110
- else if (value) {
111
- mergedRaw[spec.option] = spec.kind === 'number' ? Number(value) : value;
112
- }
113
- }
114
- const opts = { ...DEFAULTS, ...mergedRaw };
115
- // Preserved quirk: PIWI_VERBOSE wins over both default and user option.
116
- if (env[exports.PIWI_ENV_KEYS.verbose] !== undefined)
117
- opts.verbose = env[exports.PIWI_ENV_KEYS.verbose] === 'true';
118
- return opts;
119
- }
120
- /**
121
- * Write the options that the isolated `global-setup-module` process needs into
122
- * `PIWI_*` env vars. `wrapConfig` calls this so the global setup (which runs
123
- * `resolveOptions({})` in a separate module) picks up the same server/auth
124
- * config the reporter instance uses. Only writes values that are actually set.
125
- */
126
- function applyOptionsToEnv(options) {
127
- const env = process.env;
128
- if (options.serverUrl !== undefined)
129
- env[exports.PIWI_ENV_KEYS.serverUrl] = options.serverUrl;
130
- if (options.projectName !== undefined)
131
- env[exports.PIWI_ENV_KEYS.projectName] = options.projectName;
132
- if (options.verbose !== undefined)
133
- env[exports.PIWI_ENV_KEYS.verbose] = String(options.verbose);
134
- if (options.apiKey)
135
- env[exports.PIWI_ENV_KEYS.apiKey] = options.apiKey;
136
- if (options.username)
137
- env[exports.PIWI_ENV_KEYS.username] = options.username;
138
- if (options.password)
139
- env[exports.PIWI_ENV_KEYS.password] = options.password;
140
- if (options.environment)
141
- env[exports.PIWI_ENV_KEYS.environment] = options.environment;
142
- if (options.label)
143
- env[exports.PIWI_ENV_KEYS.label] = options.label;
144
- if (options.runLabel)
145
- env[exports.PIWI_ENV_KEYS.runLabel] = options.runLabel;
146
- // Locator capture is part of performance-metric collection; switch it off in
147
- // the worker when either flag is disabled so the fixture skips the per-action
148
- // cost. Only an explicit `true` overrides the unset (default-on) state.
149
- if (options.captureLocators === false || options.collectPerformanceMetrics === false)
150
- env[exports.PIWI_ENV_KEYS.captureLocators] = 'false';
151
- else if (options.captureLocators === true)
152
- env[exports.PIWI_ENV_KEYS.captureLocators] = 'true';
153
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Recursively read a directory and pack all files into a gzip-compressed
3
- * archive (a concatenation of length-prefixed path+content pairs).
4
- */
5
- export declare function compressDirectory(sourceDir: string): Promise<Buffer>;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.compressDirectory = compressDirectory;
37
- const fs = __importStar(require("node:fs"));
38
- const path = __importStar(require("node:path"));
39
- const zlib = __importStar(require("node:zlib"));
40
- const node_util_1 = require("node:util");
41
- const gzipAsync = (0, node_util_1.promisify)(zlib.gzip);
42
- /**
43
- * Recursively read a directory and pack all files into a gzip-compressed
44
- * archive (a concatenation of length-prefixed path+content pairs).
45
- */
46
- async function compressDirectory(sourceDir) {
47
- const files = [];
48
- function collect(dir, baseDir = '') {
49
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
50
- const full = path.join(dir, entry.name);
51
- const rel = path.join(baseDir, entry.name);
52
- if (entry.isDirectory())
53
- collect(full, rel);
54
- else if (entry.isFile())
55
- files.push({ path: rel, content: fs.readFileSync(full) });
56
- }
57
- }
58
- collect(sourceDir);
59
- const parts = [];
60
- for (const f of files) {
61
- const pb = Buffer.from(f.path, 'utf8');
62
- const plb = Buffer.allocUnsafe(4);
63
- plb.writeUInt32LE(pb.length, 0);
64
- const clb = Buffer.allocUnsafe(4);
65
- clb.writeUInt32LE(f.content.length, 0);
66
- parts.push(plb, pb, clb, f.content);
67
- }
68
- return await gzipAsync(Buffer.concat(parts), { level: 5 });
69
- }
@@ -1,38 +0,0 @@
1
- import { Logger } from '../support/logger.js';
2
- import type { CollectedTestCase, RawAttachment, TraceHashInfo } from '../../types.js';
3
- /**
4
- * File-system helpers for discovering report directories, trace files, and
5
- * test attachments, as well as compressing report directories and computing
6
- * trace-file hashes for deduplication.
7
- */
8
- export declare class FileHandler {
9
- private readonly logger;
10
- constructor(logger?: Logger);
11
- /** Locate a Playwright HTML report directory containing `index.html`. Optionally override the search path. */
12
- findHTMLReportDirectory(customDir?: string): string | null;
13
- /** Check if `dir` exists and is a directory; also checks `path.join(process.cwd(), dir)` */
14
- findReportDirectory(dir: string): string | null;
15
- /** Gzip-compress an entire report directory into a single buffer. Returns `null` on failure. */
16
- compressReportDirectory(reportDir: string): Promise<Buffer | null>;
17
- /** Return resolved paths for all trace attachments on a test case */
18
- findTraceFiles(testCase: CollectedTestCase): string[];
19
- /** Return all non-trace, non-internal attachments from a test case. Skips `trace` and `piwi-*` attachments. */
20
- findAllAttachments(testCase: CollectedTestCase): Array<{
21
- name: string;
22
- path: string;
23
- contentType: string;
24
- originalName: string;
25
- }>;
26
- /** Mapping of well-known report type names to their default output directories */
27
- getDefaultReportDirs(): Record<string, string>;
28
- /** Parse Piwi-internal attachment bodies (`piwi-network`, `piwi-web-vitals`, `piwi-console`, `piwi-aria-snapshot`) into structured fields on the test case */
29
- parsePerformanceAttachments(testCase: CollectedTestCase, attachments: RawAttachment[]): void;
30
- /** Compute SHA-256 hash and size for a single test case's trace file. Returns `null` when the case has no trace on disk. */
31
- computeSingleTraceHash(testCase: CollectedTestCase): Promise<TraceHashInfo | null>;
32
- /** Ask the server which trace hashes it already has, returning the set of hashes that are missing */
33
- checkMissingTraces(httpClient: {
34
- postJSON(path: string, payload: any, auth?: string | null): Promise<any>;
35
- }, projectName: string, traceHashMap: Map<number, {
36
- hash: string;
37
- }>, auth: string | null): Promise<Set<string>>;
38
- }