@checkly/playwright-reporter 0.1.7 → 0.1.9
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/dist/index.d.ts +6 -0
- package/dist/index.js +64 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -200,6 +200,12 @@ declare class ChecklyReporter implements Reporter {
|
|
|
200
200
|
* Traverses the report structure and matches by test ID + retry
|
|
201
201
|
*/
|
|
202
202
|
private injectDataIntoReport;
|
|
203
|
+
/**
|
|
204
|
+
* Reconstructs config.projects and test.projectId from test data
|
|
205
|
+
* This is necessary for blob merge scenarios where Playwright's JSON reporter
|
|
206
|
+
* doesn't populate projects array or projectId fields
|
|
207
|
+
*/
|
|
208
|
+
private reconstructProjectsFromTests;
|
|
203
209
|
/**
|
|
204
210
|
* Uploads test results to Checkly API
|
|
205
211
|
*/
|
package/dist/index.js
CHANGED
|
@@ -83,6 +83,15 @@ var AssetCollector = class {
|
|
|
83
83
|
if (testResultsIndex !== -1) {
|
|
84
84
|
return normalizedPath.substring(testResultsIndex);
|
|
85
85
|
}
|
|
86
|
+
const blobResourcesMatch = normalizedPath.match(/.*?[\w-]*blob-report[\w-]*\/resources\/(.+)$/);
|
|
87
|
+
if (blobResourcesMatch) {
|
|
88
|
+
return `test-results/resources/${blobResourcesMatch[1]}`;
|
|
89
|
+
}
|
|
90
|
+
const resourcesIndex = normalizedPath.indexOf("/resources/");
|
|
91
|
+
if (resourcesIndex !== -1) {
|
|
92
|
+
const filename = normalizedPath.split("/").pop() || "";
|
|
93
|
+
return `test-results/resources/${filename}`;
|
|
94
|
+
}
|
|
86
95
|
const parts = normalizedPath.split("/");
|
|
87
96
|
if (parts.length >= 2) {
|
|
88
97
|
return `test-results/${parts.slice(-2).join("/")}`;
|
|
@@ -332,15 +341,17 @@ var Zipper = class {
|
|
|
332
341
|
}
|
|
333
342
|
/**
|
|
334
343
|
* Normalizes attachment paths by extracting the relevant snapshot directory portion.
|
|
335
|
-
* Supports Playwright's default and common custom snapshot directory patterns
|
|
344
|
+
* Supports Playwright's default and common custom snapshot directory patterns,
|
|
345
|
+
* as well as blob merge resource paths.
|
|
336
346
|
*
|
|
337
347
|
* Priority order (first match wins):
|
|
338
348
|
* 1. test-results/ (highest priority, existing behavior)
|
|
339
|
-
* 2.
|
|
340
|
-
* 3.
|
|
341
|
-
* 4.
|
|
342
|
-
* 5.
|
|
343
|
-
* 6.
|
|
349
|
+
* 2. blob-reports/resources/ (blob merge extraction paths)
|
|
350
|
+
* 3. snapshots directories (Playwright default pattern)
|
|
351
|
+
* 4. __screenshots__/ (common custom pattern)
|
|
352
|
+
* 5. __snapshots__/ (common custom pattern)
|
|
353
|
+
* 6. screenshots/ (simple custom pattern)
|
|
354
|
+
* 7. snapshots/ (simple custom pattern)
|
|
344
355
|
*
|
|
345
356
|
* @param attachmentPath - Absolute or relative path to attachment
|
|
346
357
|
* @returns Normalized path starting from the matched directory, or original path if no match
|
|
@@ -351,6 +362,16 @@ var Zipper = class {
|
|
|
351
362
|
if (testResultsIndex !== -1) {
|
|
352
363
|
return normalizedPath.substring(testResultsIndex);
|
|
353
364
|
}
|
|
365
|
+
const blobResourcesMatch = normalizedPath.match(/.*?([\w-]*blob-report[\w-]*\/resources\/.+)$/);
|
|
366
|
+
if (blobResourcesMatch) {
|
|
367
|
+
const filename = normalizedPath.split("/").pop() || "";
|
|
368
|
+
return `test-results/resources/${filename}`;
|
|
369
|
+
}
|
|
370
|
+
const resourcesIndex = normalizedPath.indexOf("/resources/");
|
|
371
|
+
if (resourcesIndex !== -1) {
|
|
372
|
+
const filename = normalizedPath.split("/").pop() || "";
|
|
373
|
+
return `test-results/resources/${filename}`;
|
|
374
|
+
}
|
|
354
375
|
const snapshotsIndex = normalizedPath.indexOf("-snapshots/");
|
|
355
376
|
if (snapshotsIndex !== -1) {
|
|
356
377
|
const pathBeforeSnapshots = normalizedPath.substring(0, snapshotsIndex);
|
|
@@ -970,6 +991,43 @@ var ChecklyReporter = class {
|
|
|
970
991
|
for (const suite of report.suites) {
|
|
971
992
|
processSuite(suite);
|
|
972
993
|
}
|
|
994
|
+
this.reconstructProjectsFromTests(report);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Reconstructs config.projects and test.projectId from test data
|
|
998
|
+
* This is necessary for blob merge scenarios where Playwright's JSON reporter
|
|
999
|
+
* doesn't populate projects array or projectId fields
|
|
1000
|
+
*/
|
|
1001
|
+
reconstructProjectsFromTests(report) {
|
|
1002
|
+
const projectNames = /* @__PURE__ */ new Set();
|
|
1003
|
+
const collectProjectNames = (suite) => {
|
|
1004
|
+
for (const spec of suite.specs) {
|
|
1005
|
+
for (const test of spec.tests) {
|
|
1006
|
+
const testAny = test;
|
|
1007
|
+
if (testAny.projectName) {
|
|
1008
|
+
projectNames.add(testAny.projectName);
|
|
1009
|
+
}
|
|
1010
|
+
if (testAny.projectName && !testAny.projectId) {
|
|
1011
|
+
testAny.projectId = testAny.projectName;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
if (suite.suites) {
|
|
1016
|
+
for (const nestedSuite of suite.suites) {
|
|
1017
|
+
collectProjectNames(nestedSuite);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
for (const suite of report.suites) {
|
|
1022
|
+
collectProjectNames(suite);
|
|
1023
|
+
}
|
|
1024
|
+
const configAny = report.config;
|
|
1025
|
+
if ((!configAny.projects || configAny.projects.length === 0) && projectNames.size > 0) {
|
|
1026
|
+
configAny.projects = Array.from(projectNames).map((name) => ({
|
|
1027
|
+
id: name,
|
|
1028
|
+
name
|
|
1029
|
+
}));
|
|
1030
|
+
}
|
|
973
1031
|
}
|
|
974
1032
|
/**
|
|
975
1033
|
* Uploads test results to Checkly API
|
package/package.json
CHANGED