playwright-slack-report-burak 2.3.1 → 2.4.1
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/src/ResultsParser.js +69 -20
- package/package.json +1 -1
|
@@ -87,8 +87,6 @@ class ResultsParser {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
console.log('Contents of playwright-report for node', this.shardIndex, ':', fs.readdirSync(summariesDir));
|
|
91
|
-
|
|
92
90
|
if (this.shardIndex === 0 && this.allNodeSummaryFilesExist() && this.allBlobZipsExist()) {
|
|
93
91
|
// Merge all node summaries into the final summary
|
|
94
92
|
for (let i = 0; i < this.totalShardCount; i++) {
|
|
@@ -97,7 +95,7 @@ class ResultsParser {
|
|
|
97
95
|
|
|
98
96
|
if (fs.existsSync(fileToRead)) {
|
|
99
97
|
const nodeSummary = JSON.parse(fs.readFileSync(fileToRead, 'utf-8'));
|
|
100
|
-
|
|
98
|
+
// Don't add the inflated totals - calculate from outcomes instead
|
|
101
99
|
summary.passed += nodeSummary.passed;
|
|
102
100
|
summary.failed += nodeSummary.failed;
|
|
103
101
|
summary.flaky += nodeSummary.flaky;
|
|
@@ -106,6 +104,27 @@ class ResultsParser {
|
|
|
106
104
|
summary.tests = summary.tests.concat(nodeSummary.tests);
|
|
107
105
|
}
|
|
108
106
|
}
|
|
107
|
+
|
|
108
|
+
// Calculate correct total as sum of outcomes (not inflated shard totals)
|
|
109
|
+
summary.total = summary.passed + summary.failed + summary.flaky + summary.skipped;
|
|
110
|
+
|
|
111
|
+
// Deduplicate tests array in case there are duplicates from retries
|
|
112
|
+
if (summary.tests && summary.tests.length > 0) {
|
|
113
|
+
const uniqueTests = new Map();
|
|
114
|
+
for (const test of summary.tests) {
|
|
115
|
+
const key = `${test.suiteName}_${test.name}`;
|
|
116
|
+
// Keep the test with the highest retry number (most recent attempt)
|
|
117
|
+
if (!uniqueTests.has(key) || test.retry > uniqueTests.get(key).retry) {
|
|
118
|
+
uniqueTests.set(key, test);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const deduplicatedTests = Array.from(uniqueTests.values());
|
|
122
|
+
if (deduplicatedTests.length < summary.tests.length) {
|
|
123
|
+
console.log(`[Fix] Deduplicating merged tests: ${summary.tests.length} → ${deduplicatedTests.length}`);
|
|
124
|
+
summary.tests = deduplicatedTests;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
109
128
|
this.mergeReports();
|
|
110
129
|
}
|
|
111
130
|
return summary;
|
|
@@ -176,27 +195,58 @@ class ResultsParser {
|
|
|
176
195
|
}
|
|
177
196
|
updateResults(data) {
|
|
178
197
|
if (data.testSuite.tests.length > 0) {
|
|
179
|
-
this
|
|
198
|
+
// Check if we already have this test suite
|
|
199
|
+
const existingSuiteIndex = this.result.findIndex(r => r.testSuite.title === data.testSuite.title);
|
|
200
|
+
|
|
201
|
+
if (existingSuiteIndex >= 0) {
|
|
202
|
+
// Suite exists, need to check for duplicate tests
|
|
203
|
+
const existingSuite = this.result[existingSuiteIndex];
|
|
204
|
+
|
|
205
|
+
for (const newTest of data.testSuite.tests) {
|
|
206
|
+
// Find if this test already exists (by name)
|
|
207
|
+
const existingTestIndex = existingSuite.testSuite.tests.findIndex(
|
|
208
|
+
t => t.name === newTest.name
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
if (existingTestIndex >= 0) {
|
|
212
|
+
// Test exists - replace with newer result (higher retry number)
|
|
213
|
+
if (newTest.retry > existingSuite.testSuite.tests[existingTestIndex].retry) {
|
|
214
|
+
console.log(`[Fix] Updating test "${newTest.name}" from retry ${existingSuite.testSuite.tests[existingTestIndex].retry} to ${newTest.retry}`);
|
|
215
|
+
existingSuite.testSuite.tests[existingTestIndex] = newTest;
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
// New test, add it
|
|
219
|
+
existingSuite.testSuite.tests.push(newTest);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
} else {
|
|
223
|
+
// New suite, add it
|
|
224
|
+
this.result.push(data);
|
|
225
|
+
}
|
|
180
226
|
}
|
|
181
227
|
}
|
|
182
228
|
addTestResult(suiteName, testCase, projectBrowserMapping) {
|
|
183
229
|
const testResults = [];
|
|
184
230
|
const projectSettings = this.determineBrowser(testCase._projectId, projectBrowserMapping);
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
231
|
+
|
|
232
|
+
// Only add the FINAL result (last retry attempt), not all attempts
|
|
233
|
+
// This prevents counting retry attempts as separate tests
|
|
234
|
+
const finalResult = testCase.results[testCase.results.length - 1];
|
|
235
|
+
|
|
236
|
+
testResults.push({
|
|
237
|
+
suiteName,
|
|
238
|
+
name: testCase.title,
|
|
239
|
+
status: finalResult.status,
|
|
240
|
+
browser: projectSettings.browser,
|
|
241
|
+
projectName: projectSettings.projectName,
|
|
242
|
+
retry: finalResult.retry,
|
|
243
|
+
retries: testCase.retries,
|
|
244
|
+
startedAt: new Date(finalResult.startTime).toISOString(),
|
|
245
|
+
endedAt: new Date(new Date(finalResult.startTime).getTime() + finalResult.duration).toISOString(),
|
|
246
|
+
reason: this.safelyDetermineFailure(finalResult),
|
|
247
|
+
attachments: finalResult.attachments,
|
|
248
|
+
});
|
|
249
|
+
|
|
200
250
|
this.updateResults({
|
|
201
251
|
testSuite: {
|
|
202
252
|
title: suiteName,
|
|
@@ -336,7 +386,6 @@ class ResultsParser {
|
|
|
336
386
|
}
|
|
337
387
|
}
|
|
338
388
|
console.log('Reports merged successfully.');
|
|
339
|
-
console.log('Contents of playwright-report:', fs.readdirSync('./playwright-report'));
|
|
340
389
|
} catch (error) {
|
|
341
390
|
// Log a warning instead of throwing an error
|
|
342
391
|
console.warn('Warning: Failed to merge reports. This may not affect the overall process.', error.message);
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"lint-fix": "npx eslint . --ext .ts --fix"
|
|
31
31
|
},
|
|
32
32
|
"name": "playwright-slack-report-burak",
|
|
33
|
-
"version": "2.
|
|
33
|
+
"version": "2.4.1",
|
|
34
34
|
"main": "index.js",
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",
|