@empiricalrun/playwright-utils 0.66.2 → 0.66.4

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.
@@ -0,0 +1,2 @@
1
+ export declare function localRunId(): string | undefined;
2
+ //# sourceMappingURL=local-run-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-run-id.d.ts","sourceRoot":"","sources":["../src/local-run-id.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,IAAI,MAAM,GAAG,SAAS,CAO/C"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.localRunId = localRunId;
4
+ const LOCAL_RUN_PREFIX_ENV = "EMPIRICAL_LOCAL_RUN_PREFIX";
5
+ const LOCAL_RUN_ID_ENV = "EMPIRICAL_LOCAL_RUN_ID";
6
+ function localRunId() {
7
+ const prefix = process.env[LOCAL_RUN_PREFIX_ENV];
8
+ if (!prefix) {
9
+ return undefined;
10
+ }
11
+ process.env[LOCAL_RUN_ID_ENV] ??= `${prefix}-${process.pid}`;
12
+ return process.env[LOCAL_RUN_ID_ENV];
13
+ }
@@ -1,4 +1,4 @@
1
- import type { FullConfig, FullResult, Reporter, TestCase, TestResult } from "@playwright/test/reporter";
1
+ import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult } from "@playwright/test/reporter";
2
2
  declare class EmpiricalReporter implements Reporter {
3
3
  private _currentWorkingDir;
4
4
  private _outputDirs;
@@ -9,9 +9,12 @@ declare class EmpiricalReporter implements Reporter {
9
9
  private _uploader;
10
10
  private _attachmentCleanup;
11
11
  private _maxFailures;
12
+ private _suite;
13
+ private _reportPaths;
12
14
  constructor();
13
- onBegin(config: FullConfig): void;
15
+ onBegin(config: FullConfig, suite: Suite): void;
14
16
  private _piSandboxLog;
17
+ private _attachmentWithPath;
15
18
  private enqueTestAttachmentUploadTask;
16
19
  private _shardIndex;
17
20
  onTestBegin(test: TestCase, result: TestResult): void;
@@ -1 +1 @@
1
- {"version":3,"file":"empirical-reporter.d.ts","sourceRoot":"","sources":["../../src/reporter/empirical-reporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AAyBnC,cAAM,iBAAkB,YAAW,QAAQ;IACzC,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,YAAY,CAAgD;IACpE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,gBAAgB,CAAkC;IAC1D,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,kBAAkB,CAA2B;IACrD,OAAO,CAAC,YAAY,CAAqB;IAEzC,cAEC;IAED,OAAO,CAAC,MAAM,EAAE,UAAU,QAKzB;IAED,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,6BAA6B,CAuCnC;IAEF,OAAO,CAAC,WAAW;IAMnB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,QAyB7C;IAED,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,QA4I3C;IAEK,KAAK,CAAC,MAAM,EAAE,UAAU,iBAkH7B;IAED,OAAO,CAAC,qBAAqB;YAkBf,gBAAgB;YAOhB,iBAAiB;CAqChC;eAEc,iBAAiB"}
1
+ {"version":3,"file":"empirical-reporter.d.ts","sourceRoot":"","sources":["../../src/reporter/empirical-reporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AAiCnC,cAAM,iBAAkB,YAAW,QAAQ;IACzC,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,YAAY,CAAgD;IACpE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,gBAAgB,CAAkC;IAC1D,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,kBAAkB,CAA2B;IACrD,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,YAAY,CAElB;IAEF,cAEC;IAED,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,QAUvC;IAED,OAAO,CAAC,aAAa;YAUP,mBAAmB;IAoBjC,OAAO,CAAC,6BAA6B,CAiCnC;IAEF,OAAO,CAAC,WAAW;IAMnB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,QAyB7C;IAED,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,QA4I3C;IAEK,KAAK,CAAC,MAAM,EAAE,UAAU,iBA4H7B;IAED,OAAO,CAAC,qBAAqB;YAkBf,gBAAgB;YAOhB,iBAAiB;CAqChC;eAEc,iBAAiB"}
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fs_1 = __importDefault(require("fs"));
7
+ const os_1 = __importDefault(require("os"));
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const logger_1 = require("../logger");
9
10
  const telemetry_1 = require("../telemetry");
@@ -12,6 +13,8 @@ const attachment_key_1 = require("./attachment-key");
12
13
  const blob_utils_1 = require("./blob-utils");
13
14
  const failing_line_1 = require("./failing-line");
14
15
  const incremental_blob_reporter_1 = require("./incremental-blob-reporter");
16
+ const local_run_report_1 = require("./local-run-report");
17
+ const report_paths_1 = require("./report-paths");
15
18
  const reporter_state_1 = require("./reporter-state");
16
19
  const uploader_1 = require("./uploader");
17
20
  const util_1 = require("./util");
@@ -25,12 +28,17 @@ class EmpiricalReporter {
25
28
  _uploader = null;
26
29
  _attachmentCleanup = new attachment_cleanup_1.AttachmentCleanup();
27
30
  _maxFailures;
31
+ _suite;
32
+ _reportPaths = (0, report_paths_1.defaultReportPaths)(this._currentWorkingDir);
28
33
  constructor() {
29
34
  this._uploader = (0, uploader_1.getUploader)();
30
35
  }
31
- onBegin(config) {
36
+ onBegin(config, suite) {
32
37
  this._maxFailures = config.maxFailures;
38
+ this._suite = suite;
33
39
  this._outputDirs = (0, attachment_key_1.sortOutputDirs)(config.projects.map((project) => project.outputDir));
40
+ this._reportPaths = (0, report_paths_1.resolveReportPaths)(config, this._currentWorkingDir);
41
+ this._piSandboxLog(`[Empirical Reporter] Local report: ${this._reportPaths.htmlDir}, test output: ${this._outputDirs.join(", ")}`);
34
42
  }
35
43
  _piSandboxLog(message) {
36
44
  const runningInsidePiSandbox = process.env.RUNNING_INSIDE_PI_SANDBOX === "true";
@@ -39,14 +47,26 @@ class EmpiricalReporter {
39
47
  }
40
48
  console.log(message);
41
49
  }
50
+ async _attachmentWithPath(test, attachment) {
51
+ const { name, contentType } = attachment;
52
+ if (attachment.path) {
53
+ return { name, contentType, path: attachment.path };
54
+ }
55
+ if (!attachment.body) {
56
+ return undefined;
57
+ }
58
+ const outputDir = test.parent.project()?.outputDir ?? os_1.default.tmpdir();
59
+ const bodyPath = await (0, util_1.writeBodyAttachment)(outputDir, {
60
+ name,
61
+ contentType,
62
+ body: attachment.body,
63
+ });
64
+ return { name, contentType, path: bodyPath };
65
+ }
42
66
  enqueTestAttachmentUploadTask = async (attachment, keepHot) => {
43
67
  if (!this._uploader) {
44
68
  return;
45
69
  }
46
- if (!attachment.path) {
47
- logger_1.logger.warn(`[Empirical Reporter] Skipping attachment without path: ${attachment.name}`);
48
- return;
49
- }
50
70
  const exists = await (0, util_1.checkFileExistsAsync)(attachment.path);
51
71
  if (!exists) {
52
72
  logger_1.logger.error(`[Empirical Reporter] Attachment does not exist: ${attachment.path}`);
@@ -96,15 +116,16 @@ class EmpiricalReporter {
96
116
  if (!this._uploader) {
97
117
  return;
98
118
  }
99
- if (!process.env.TEST_RUN_GITHUB_ACTION_ID) {
100
- logger_1.logger.debug("[Empirical Reporter] TEST_RUN_GITHUB_ACTION_ID is not set");
101
- return;
102
- }
119
+ const runId = process.env.TEST_RUN_GITHUB_ACTION_ID;
103
120
  const retryIndex = this._testRetryCounts.get(test.id) ?? 0;
104
121
  this._testRetryCounts.set(test.id, retryIndex + 1);
105
122
  try {
106
- const attachmentPromises = result.attachments.map(async (attachment) => {
123
+ const attachmentPromises = result.attachments.map(async (original) => {
107
124
  try {
125
+ const attachment = await this._attachmentWithPath(test, original);
126
+ if (!attachment) {
127
+ return undefined;
128
+ }
108
129
  const fileMap = await this.enqueTestAttachmentUploadTask(attachment, result.status === "passed");
109
130
  if (!fileMap) {
110
131
  logger_1.logger.error(`No upload result for ${attachment.name}`);
@@ -115,10 +136,6 @@ class EmpiricalReporter {
115
136
  logger_1.logger.error(`No url in file map for ${attachment.name}`);
116
137
  return undefined;
117
138
  }
118
- if (!attachment.path) {
119
- logger_1.logger.error(`No path in attachment for ${attachment.name}`);
120
- return undefined;
121
- }
122
139
  if (this._hasSharding) {
123
140
  const key = (0, blob_utils_1.makeAttachmentKey)(test.id, retryIndex, attachment.name);
124
141
  this._attachmentUrlMap.set(key, url);
@@ -135,11 +152,11 @@ class EmpiricalReporter {
135
152
  };
136
153
  }
137
154
  catch (err) {
138
- logger_1.logger.error(`[Empirical Reporter] Error uploading attachment ${attachment.name} for test ${test.title}:`, err);
155
+ logger_1.logger.error(`[Empirical Reporter] Error uploading attachment ${original.name} for test ${test.title}:`, err);
139
156
  return undefined;
140
157
  }
141
158
  });
142
- const testCaseRunEventTask = async () => {
159
+ const testCaseRunEventTask = async (runId) => {
143
160
  const uploadedAttachments = await Promise.all(attachmentPromises);
144
161
  const successfulAttachments = uploadedAttachments.filter((a) => a !== undefined);
145
162
  try {
@@ -188,7 +205,7 @@ class EmpiricalReporter {
188
205
  },
189
206
  projectName,
190
207
  attachments: successfulAttachments,
191
- runId: process.env.TEST_RUN_GITHUB_ACTION_ID,
208
+ runId,
192
209
  failingLine,
193
210
  shardIndex,
194
211
  maxFailures: this._maxFailures,
@@ -199,7 +216,9 @@ class EmpiricalReporter {
199
216
  logger_1.logger.error(`[Empirical Reporter] Error sending test case event for: ${test.title}:`, error);
200
217
  }
201
218
  };
202
- this._pendingTestCaseEvents.push(testCaseRunEventTask());
219
+ this._pendingTestCaseEvents.push(runId
220
+ ? testCaseRunEventTask(runId)
221
+ : Promise.all(attachmentPromises).then(() => undefined));
203
222
  }
204
223
  catch (error) {
205
224
  logger_1.logger.error(`[Empirical Reporter] Error in onTestEnd for ${test.title}:`, error);
@@ -216,18 +235,19 @@ class EmpiricalReporter {
216
235
  logger_1.logger.info(`[Empirical Reporter] Test run completed with status: ${result.status}`);
217
236
  logger_1.logger.debug(`[Empirical Reporter] State: cwd=${this._currentWorkingDir}, hasSharding=${this._hasSharding}`);
218
237
  const startTime = Date.now();
219
- const reportDir = path_1.default.join(this._currentWorkingDir, "playwright-report");
220
- const jsonFilePath = path_1.default.join(reportDir, "summary.json");
221
- const htmlFilePath = path_1.default.join(reportDir, "index.html");
238
+ const jsonFilePath = this._reportPaths.summaryJson;
239
+ const htmlFilePath = path_1.default.join(this._reportPaths.htmlDir, "index.html");
222
240
  const jsonExists = fs_1.default.existsSync(jsonFilePath);
223
241
  const htmlExists = fs_1.default.existsSync(htmlFilePath);
224
242
  if (!htmlExists || !jsonExists) {
225
243
  this._logReportDirContents();
226
244
  }
245
+ let htmlReportUrl = null;
246
+ let summaryJsonUrl = null;
227
247
  if (htmlExists && jsonExists) {
228
248
  logger_1.logger.debug("[Empirical Reporter] Patching HTML with attachment URLs");
229
249
  await (0, util_1.updateHtmlZipFileAttachmentPaths)(jsonFilePath, htmlFilePath, this._outputDirs);
230
- const htmlReportUrl = await this._uploader.uploadFile(htmlFilePath, "index.html");
250
+ htmlReportUrl = await this._uploader.uploadFile(htmlFilePath, "index.html");
231
251
  this._piSandboxLog(`[Empirical Reporter] HTML report URL: ${htmlReportUrl}`);
232
252
  }
233
253
  else if (!htmlExists) {
@@ -236,23 +256,33 @@ class EmpiricalReporter {
236
256
  if (jsonExists) {
237
257
  logger_1.logger.debug("[Empirical Reporter] Patching summary.json with attachment URLs");
238
258
  await (0, util_1.updateSummaryJsonAttachmentPaths)(jsonFilePath, this._outputDirs, `${this._uploader.urlPrefix}/data`);
239
- const summaryJsonUrl = await this._uploader.uploadFile(jsonFilePath, "summary.json");
259
+ summaryJsonUrl = await this._uploader.uploadFile(jsonFilePath, "summary.json");
240
260
  this._piSandboxLog(`[Empirical Reporter] summary.json URL: ${summaryJsonUrl}`);
241
261
  }
242
262
  else {
243
263
  logger_1.logger.error(`[Empirical Reporter] summary.json not found at: ${jsonFilePath}`);
244
264
  }
245
- const traceFilePath = path_1.default.join(this._currentWorkingDir, "playwright-report/trace");
265
+ const traceFilePath = path_1.default.join(this._reportPaths.htmlDir, "trace");
246
266
  const traceExists = await (0, util_1.checkFileExistsAsync)(traceFilePath);
247
267
  if (traceExists) {
248
268
  logger_1.logger.debug("[Empirical Reporter] Uploading Trace folder");
249
269
  await this._uploader.uploadDirectory(traceFilePath, "trace");
250
270
  }
251
271
  else {
252
- logger_1.logger.debug(`[Empirical Reporter] playwright-report/trace does not exist at: ${traceFilePath}`);
272
+ logger_1.logger.debug(`[Empirical Reporter] trace folder does not exist at: ${traceFilePath}`);
253
273
  }
254
274
  await this._uploader.waitForUploads();
255
275
  await Promise.allSettled(this._pendingTestCaseEvents);
276
+ if (this._suite) {
277
+ await (0, local_run_report_1.reportLocalRun)({
278
+ suite: this._suite,
279
+ result,
280
+ reportUrl: htmlReportUrl,
281
+ summaryUrl: summaryJsonUrl,
282
+ outputDirs: this._outputDirs,
283
+ reportDir: this._reportPaths.htmlDir,
284
+ });
285
+ }
256
286
  if (this._hasSharding) {
257
287
  const blobDir = path_1.default.join(this._currentWorkingDir, "blob-report");
258
288
  logger_1.logger.info(`[Empirical Reporter] Sharding enabled, checking for blob-report at: ${blobDir}`);
@@ -274,13 +304,13 @@ class EmpiricalReporter {
274
304
  }
275
305
  _logReportDirContents() {
276
306
  try {
277
- const reportDir = path_1.default.join(this._currentWorkingDir, "playwright-report");
307
+ const reportDir = this._reportPaths.htmlDir;
278
308
  if (fs_1.default.existsSync(reportDir)) {
279
309
  const reportFiles = fs_1.default.readdirSync(reportDir);
280
- logger_1.logger.info(`[Empirical Reporter] Files in playwright-report: ${reportFiles.join(", ")}`);
310
+ logger_1.logger.info(`[Empirical Reporter] Files in ${reportDir}: ${reportFiles.join(", ")}`);
281
311
  }
282
312
  else {
283
- logger_1.logger.warn(`[Empirical Reporter] playwright-report directory does not exist`);
313
+ logger_1.logger.warn(`[Empirical Reporter] Report directory does not exist: ${reportDir}`);
284
314
  }
285
315
  }
286
316
  catch (e) {
@@ -72,16 +72,18 @@ export declare function setupParityFixture(suite: string): Promise<{
72
72
  export interface CleanRunResult extends RunResult {
73
73
  exitCode: number | null;
74
74
  }
75
- export declare function runPlaywrightClean(ctx: ParityTestContext, opts: {
75
+ export declare function runPlaywrightClean(ctx: Pick<ParityTestContext, "tempDir">, opts: {
76
76
  workers: number;
77
77
  shard?: {
78
78
  current: number;
79
79
  total: number;
80
80
  };
81
+ env?: NodeJS.ProcessEnv;
81
82
  }): Promise<CleanRunResult>;
82
83
  export declare function mergeBlobDirToSummary(cwd: string, blobDir: string, outputName: string): Record<string, unknown>;
83
84
  export interface DashboardStub {
84
85
  testCaseEvents: () => Array<Record<string, any>>;
86
+ localRuns: () => Array<Record<string, any>>;
85
87
  completedUploadPaths: () => string[];
86
88
  env: NodeJS.ProcessEnv;
87
89
  close: () => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../../src/reporter/harness.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,cAAc;IAC7B,O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ClB,GAAG,OAAO,CAAC,aAAa,CAAC,CAmF9B"}
@@ -282,6 +282,7 @@ async function runPlaywrightClean(ctx, opts) {
282
282
  SHARD_INDEX: opts.shard ? undefined : "1",
283
283
  TOTAL_SHARDS: opts.shard ? undefined : "1",
284
284
  FORCE_COLOR: "0",
285
+ ...opts.env,
285
286
  },
286
287
  stdio: ["pipe", "pipe", "pipe"],
287
288
  });
@@ -313,6 +314,7 @@ function mergeBlobDirToSummary(cwd, blobDir, outputName) {
313
314
  }
314
315
  async function startDashboardStub({ slowUploadPathSuffix, slowUploadMs = 0, } = {}) {
315
316
  const events = [];
317
+ const localRuns = [];
316
318
  const completedUploadPaths = [];
317
319
  const respondToUpload = (req, res, uploadPath) => {
318
320
  completedUploadPaths.push(uploadPath);
@@ -338,6 +340,10 @@ async function startDashboardStub({ slowUploadPathSuffix, slowUploadMs = 0, } =
338
340
  events.push(body.data);
339
341
  }
340
342
  }
343
+ if (req.method === "POST" &&
344
+ req.url === "/api/test-reports/local-runs") {
345
+ localRuns.push(JSON.parse(Buffer.concat(chunks).toString("utf8")));
346
+ }
341
347
  res.writeHead(200, { "content-type": "application/json" });
342
348
  res.end("{}");
343
349
  return;
@@ -352,6 +358,7 @@ async function startDashboardStub({ slowUploadPathSuffix, slowUploadMs = 0, } =
352
358
  const url = `http://127.0.0.1:${server.address().port}`;
353
359
  return {
354
360
  testCaseEvents: () => [...events],
361
+ localRuns: () => [...localRuns],
355
362
  completedUploadPaths: () => [...completedUploadPaths],
356
363
  env: {
357
364
  PROJECT_NAME: "reporter-test",
@@ -0,0 +1,10 @@
1
+ import type { FullResult, Suite } from "@playwright/test/reporter";
2
+ export declare function reportLocalRun({ suite, result, reportUrl, summaryUrl, outputDirs, reportDir, }: {
3
+ suite: Suite;
4
+ result: FullResult;
5
+ reportUrl: string | null;
6
+ summaryUrl: string | null;
7
+ outputDirs: string[];
8
+ reportDir: string;
9
+ }): Promise<void>;
10
+ //# sourceMappingURL=local-run-report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-run-report.d.ts","sourceRoot":"","sources":["../../src/reporter/local-run-report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAsBnE,wBAAsB,cAAc,CAAC,EACnC,KAAK,EACL,MAAM,EACN,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE;IACD,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhB"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reportLocalRun = reportLocalRun;
4
+ const api_worker_client_1 = require("../api-worker-client");
5
+ const local_run_id_1 = require("../local-run-id");
6
+ const logger_1 = require("../logger");
7
+ function countOutcomes(suite) {
8
+ const counts = { passed: 0, failed: 0, flaky: 0, skipped: 0 };
9
+ for (const test of suite.allTests()) {
10
+ const outcome = test.outcome();
11
+ if (outcome === "expected") {
12
+ counts.passed++;
13
+ }
14
+ else if (outcome === "unexpected") {
15
+ counts.failed++;
16
+ }
17
+ else if (outcome === "flaky") {
18
+ counts.flaky++;
19
+ }
20
+ else {
21
+ counts.skipped++;
22
+ }
23
+ }
24
+ return counts;
25
+ }
26
+ async function reportLocalRun({ suite, result, reportUrl, summaryUrl, outputDirs, reportDir, }) {
27
+ const runId = (0, local_run_id_1.localRunId)();
28
+ const toolCallId = process.env.EMPIRICAL_TOOL_CALL_ID;
29
+ if (!runId || !toolCallId || !process.env.EMPIRICALRUN_API_KEY) {
30
+ return;
31
+ }
32
+ try {
33
+ await new api_worker_client_1.ApiWorkerClient().reportLocalTestRun({
34
+ tool_call_id: toolCallId,
35
+ run_id: runId,
36
+ status: result.status,
37
+ counts: countOutcomes(suite),
38
+ report_url: reportUrl,
39
+ summary_url: summaryUrl,
40
+ output_dirs: outputDirs,
41
+ report_dir: reportDir,
42
+ });
43
+ }
44
+ catch (error) {
45
+ logger_1.logger.warn(`[Empirical Reporter] Could not report local run ${runId} to the session:`, error);
46
+ }
47
+ }
@@ -0,0 +1,8 @@
1
+ import type { FullConfig } from "@playwright/test/reporter";
2
+ export type ReportPaths = {
3
+ htmlDir: string;
4
+ summaryJson: string;
5
+ };
6
+ export declare function defaultReportPaths(cwd: string): ReportPaths;
7
+ export declare function resolveReportPaths(config: FullConfig, cwd: string): ReportPaths;
8
+ //# sourceMappingURL=report-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-paths.d.ts","sourceRoot":"","sources":["../../src/reporter/report-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AA0DnE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAG3D;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,MAAM,GACV,WAAW,CASb"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.defaultReportPaths = defaultReportPaths;
7
+ exports.resolveReportPaths = resolveReportPaths;
8
+ const path_1 = __importDefault(require("path"));
9
+ const util_1 = require("./util");
10
+ function reporterOptions(config, name) {
11
+ const entry = config.reporter.find(([reporterName]) => reporterName === name);
12
+ return entry ? (entry[1] ?? {}) : undefined;
13
+ }
14
+ function resolveFromEnv(name) {
15
+ const value = process.env[name];
16
+ return value ? path_1.default.resolve(value) : undefined;
17
+ }
18
+ function htmlDir(options, configDir) {
19
+ return (resolveFromEnv("PLAYWRIGHT_HTML_OUTPUT_DIR") ??
20
+ resolveFromEnv("PLAYWRIGHT_HTML_REPORT") ??
21
+ (0, util_1.resolveReporterOutputPath)("playwright-report", configDir, options.outputFolder));
22
+ }
23
+ function jsonFile(options, configDir) {
24
+ const file = resolveFromEnv("PLAYWRIGHT_JSON_OUTPUT_FILE") ??
25
+ (options.outputFile
26
+ ? path_1.default.resolve(configDir, options.outputFile)
27
+ : undefined);
28
+ if (file) {
29
+ return file;
30
+ }
31
+ const name = process.env.PLAYWRIGHT_JSON_OUTPUT_NAME ?? options.fileName;
32
+ if (!name) {
33
+ return undefined;
34
+ }
35
+ const dir = resolveFromEnv("PLAYWRIGHT_JSON_OUTPUT_DIR") ??
36
+ (options.outputDir
37
+ ? path_1.default.resolve(configDir, options.outputDir)
38
+ : configDir);
39
+ return path_1.default.resolve(dir, name);
40
+ }
41
+ function defaultReportPaths(cwd) {
42
+ const htmlDir = path_1.default.join(cwd, "playwright-report");
43
+ return { htmlDir, summaryJson: path_1.default.join(htmlDir, "summary.json") };
44
+ }
45
+ function resolveReportPaths(config, cwd) {
46
+ const configDir = config.configFile ? path_1.default.dirname(config.configFile) : cwd;
47
+ const defaults = defaultReportPaths(cwd);
48
+ const html = reporterOptions(config, "html");
49
+ const json = reporterOptions(config, "json");
50
+ return {
51
+ htmlDir: html ? htmlDir(html, configDir) : defaults.htmlDir,
52
+ summaryJson: (json && jsonFile(json, configDir)) ?? defaults.summaryJson,
53
+ };
54
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/reporter/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAElB,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,eAA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e,EAAE,MAAM,EACvB,YAAY,CAAC,EAAE,kBAAkB,GAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAyCxB;IAEK,eAAe,CACnB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC,CAyBf;IAEK,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAyBpC;CACF;AAID,wBAAgB,WAAW,IAAI,QAAQ,GAAG,IAAI,CAM7C;AAED,wBAAgB,cAAc,IAAI,QAAQ,GAAG,IAAI,CAiEhD"}
@@ -9,6 +9,7 @@ exports.createUploader = createUploader;
9
9
  const r2_uploader_1 = require("@empiricalrun/r2-uploader");
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const api_worker_client_1 = require("../api-worker-client");
12
+ const local_run_id_1 = require("../local-run-id");
12
13
  const logger_1 = require("../logger");
13
14
  const presigned_upload_1 = require("./presigned-upload");
14
15
  const R2_REPORTS_BASE_URL = "https://reports-r2.empirical.run";
@@ -169,7 +170,8 @@ function createUploader() {
169
170
  logger_1.logger.debug("[Uploader] Reporter disabled for --list command");
170
171
  return null;
171
172
  }
172
- if (!process.env.PROJECT_NAME || !process.env.TEST_RUN_GITHUB_ACTION_ID) {
173
+ const runId = process.env.TEST_RUN_GITHUB_ACTION_ID ?? (0, local_run_id_1.localRunId)();
174
+ if (!process.env.PROJECT_NAME || !runId) {
173
175
  logger_1.logger.debug("[Uploader] PROJECT_NAME and TEST_RUN_GITHUB_ACTION_ID must be set");
174
176
  return null;
175
177
  }
@@ -179,7 +181,7 @@ function createUploader() {
179
181
  return null;
180
182
  }
181
183
  if (backend === "r2" && process.env.REPORT_UPLOAD_PRESIGNED === "true") {
182
- return createPresignedUploader(process.env.PROJECT_NAME, process.env.TEST_RUN_GITHUB_ACTION_ID);
184
+ return createPresignedUploader(process.env.PROJECT_NAME, runId);
183
185
  }
184
186
  const enableS3 = backend === "s3";
185
187
  const credentials = Uploader.getCredentialsFromEnv(enableS3);
@@ -214,7 +216,7 @@ function createUploader() {
214
216
  }
215
217
  return new Uploader({
216
218
  projectSlug: process.env.PROJECT_NAME,
217
- runId: process.env.TEST_RUN_GITHUB_ACTION_ID,
219
+ runId,
218
220
  baseUrl,
219
221
  uploadBucket,
220
222
  credentials,
@@ -13,6 +13,11 @@ export declare function normalizeAndSaveAttachment(outputPath: string, name: str
13
13
  body?: Buffer | undefined;
14
14
  contentType: string;
15
15
  }>;
16
+ export declare function writeBodyAttachment(outputDir: string, attachment: {
17
+ name: string;
18
+ contentType: string;
19
+ body: Buffer;
20
+ }): Promise<string>;
16
21
  export declare function suitesAndProjectForTest(test: TestCase): {
17
22
  suites: string[];
18
23
  projectName: string;
@@ -23,5 +28,5 @@ export declare function safelySerialiseJSON(obj: any, keyFilter?: (key: string)
23
28
  export declare function updateHtmlZipFileAttachmentPaths(jsonFilePath: string, htmlFilePath: string, outputDirs: string[]): Promise<void>;
24
29
  export declare function buildTestAttachmentMapFromSummary(summaryJsonFilePath: string, outputDirs: string[], doNotNormalize?: boolean): TestAttachmentMap;
25
30
  export declare function checkFileExistsAsync(filePath: string): Promise<boolean>;
26
- export declare function updateSummaryJsonAttachmentPaths(filePath: string, outputDirs: string[], urlPrefix: string): Promise<PlaywrightJSONReport | undefined>;
31
+ export declare function updateSummaryJsonAttachmentPaths(filePath: string, outputDirs: string[], urlPrefix: string): Promise<PlaywrightJSONReport>;
27
32
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/reporter/util.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAQhE,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,UAAU,IAAI,oBAAoB,EAElC,QAAQ,EACT,MAAM,2BAA2B,CAAC;AA2BnC,wBAAgB,kBAAkB,CAAC,UAAU,E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EAAE,QAAQ;IAmBlD,MAAM;IACN,WAAW;EAEd;AAED,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAED,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAoBf;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GACnC,GAAG,CAIL;AAED,wBAAsB,gCAAgC,CACpD,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAAE,iBAkFrB;AAED,wBAAgB,iCAAiC,CAC/C,mBAAmB,EAAE,MAAM,EAC3B,UAAU,EAAE,MAAM,EAAE,EACpB,cAAc,GAAE,OAAe,GAC9B,iBAAiB,CAkBnB;AAED,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO7E;AAED,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAAE,EACpB,SAAS,EAAE,MAAM,iCAyBlB"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getPackageJsonPath = getPackageJsonPath;
7
7
  exports.resolveReporterOutputPath = resolveReporterOutputPath;
8
8
  exports.normalizeAndSaveAttachment = normalizeAndSaveAttachment;
9
+ exports.writeBodyAttachment = writeBodyAttachment;
9
10
  exports.suitesAndProjectForTest = suitesAndProjectForTest;
10
11
  exports.sendTestCaseUpdateToDashboard = sendTestCaseUpdateToDashboard;
11
12
  exports.sendTestCaseBeginToDashboard = sendTestCaseBeginToDashboard;
@@ -101,6 +102,13 @@ async function normalizeAndSaveAttachment(outputPath, name, options = {}) {
101
102
  };
102
103
  }
103
104
  }
105
+ async function writeBodyAttachment(outputDir, attachment) {
106
+ const extension = mime_1.default.getExtension(attachment.contentType);
107
+ const dest = path_1.default.join(outputDir, "body-attachments", calculateSha1(attachment.body), sanitizeForFilePath(attachment.name) + (extension ? `.${extension}` : ""));
108
+ await fs_1.default.promises.mkdir(path_1.default.dirname(dest), { recursive: true });
109
+ await fs_1.default.promises.writeFile(dest, attachment.body);
110
+ return dest;
111
+ }
104
112
  function suitesAndProjectForTest(test) {
105
113
  let rawSuites = [];
106
114
  if (test.parent) {
@@ -259,10 +267,6 @@ async function checkFileExistsAsync(filePath) {
259
267
  }
260
268
  }
261
269
  async function updateSummaryJsonAttachmentPaths(filePath, outputDirs, urlPrefix) {
262
- if (!process.env.PROJECT_NAME || !process.env.TEST_RUN_GITHUB_ACTION_ID) {
263
- console.error("PROJECT_NAME and TEST_RUN_GITHUB_ACTION_ID must be set");
264
- return;
265
- }
266
270
  const summaryJson = JSON.parse(await fs_1.default.promises.readFile(filePath, "utf8"));
267
271
  (0, reporter_1.traverseJsonReportSuites)(summaryJson, (spec) => {
268
272
  for (const test of spec.tests) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.66.2",
3
+ "version": "0.66.4",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "author": "Empirical Team <hey@empirical.run>",
36
36
  "devDependencies": {
37
- "@playwright/test": "1.63.0",
37
+ "@playwright/test": "1.64.1",
38
38
  "@types/async-retry": "^1.4.8",
39
39
  "@types/authenticator": "^1.1.4",
40
40
  "@types/console-log-level": "^1.4.5",
@@ -42,10 +42,10 @@
42
42
  "@types/node": "^22",
43
43
  "@types/serve-handler": "^6.1.4",
44
44
  "openapi-typescript": "7.6.1",
45
- "playwright-core": "1.63.0",
45
+ "playwright-core": "1.64.1",
46
46
  "serve-handler": "^6.1.6",
47
47
  "typescript": "7.0.2",
48
- "@empiricalrun/shared-types": "0.24.0"
48
+ "@empiricalrun/shared-types": "0.24.3"
49
49
  },
50
50
  "dependencies": {
51
51
  "async-retry": "^1.3.3",