playwright-slack-report-burak 2.3.1 → 2.4.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.
@@ -97,7 +97,7 @@ class ResultsParser {
97
97
 
98
98
  if (fs.existsSync(fileToRead)) {
99
99
  const nodeSummary = JSON.parse(fs.readFileSync(fileToRead, 'utf-8'));
100
- summary.total += nodeSummary.total;
100
+ // Don't add the inflated totals - calculate from outcomes instead
101
101
  summary.passed += nodeSummary.passed;
102
102
  summary.failed += nodeSummary.failed;
103
103
  summary.flaky += nodeSummary.flaky;
@@ -106,6 +106,27 @@ class ResultsParser {
106
106
  summary.tests = summary.tests.concat(nodeSummary.tests);
107
107
  }
108
108
  }
109
+
110
+ // Calculate correct total as sum of outcomes (not inflated shard totals)
111
+ summary.total = summary.passed + summary.failed + summary.flaky + summary.skipped;
112
+
113
+ // Deduplicate tests array in case there are duplicates from retries
114
+ if (summary.tests && summary.tests.length > 0) {
115
+ const uniqueTests = new Map();
116
+ for (const test of summary.tests) {
117
+ const key = `${test.suiteName}_${test.name}`;
118
+ // Keep the test with the highest retry number (most recent attempt)
119
+ if (!uniqueTests.has(key) || test.retry > uniqueTests.get(key).retry) {
120
+ uniqueTests.set(key, test);
121
+ }
122
+ }
123
+ const deduplicatedTests = Array.from(uniqueTests.values());
124
+ if (deduplicatedTests.length < summary.tests.length) {
125
+ console.log(`[Fix] Deduplicating merged tests: ${summary.tests.length} → ${deduplicatedTests.length}`);
126
+ summary.tests = deduplicatedTests;
127
+ }
128
+ }
129
+
109
130
  this.mergeReports();
110
131
  }
111
132
  return summary;
@@ -176,27 +197,58 @@ class ResultsParser {
176
197
  }
177
198
  updateResults(data) {
178
199
  if (data.testSuite.tests.length > 0) {
179
- this.result.push(data);
200
+ // Check if we already have this test suite
201
+ const existingSuiteIndex = this.result.findIndex(r => r.testSuite.title === data.testSuite.title);
202
+
203
+ if (existingSuiteIndex >= 0) {
204
+ // Suite exists, need to check for duplicate tests
205
+ const existingSuite = this.result[existingSuiteIndex];
206
+
207
+ for (const newTest of data.testSuite.tests) {
208
+ // Find if this test already exists (by name)
209
+ const existingTestIndex = existingSuite.testSuite.tests.findIndex(
210
+ t => t.name === newTest.name
211
+ );
212
+
213
+ if (existingTestIndex >= 0) {
214
+ // Test exists - replace with newer result (higher retry number)
215
+ if (newTest.retry > existingSuite.testSuite.tests[existingTestIndex].retry) {
216
+ console.log(`[Fix] Updating test "${newTest.name}" from retry ${existingSuite.testSuite.tests[existingTestIndex].retry} to ${newTest.retry}`);
217
+ existingSuite.testSuite.tests[existingTestIndex] = newTest;
218
+ }
219
+ } else {
220
+ // New test, add it
221
+ existingSuite.testSuite.tests.push(newTest);
222
+ }
223
+ }
224
+ } else {
225
+ // New suite, add it
226
+ this.result.push(data);
227
+ }
180
228
  }
181
229
  }
182
230
  addTestResult(suiteName, testCase, projectBrowserMapping) {
183
231
  const testResults = [];
184
232
  const projectSettings = this.determineBrowser(testCase._projectId, projectBrowserMapping);
185
- for (const result of testCase.results) {
186
- testResults.push({
187
- suiteName,
188
- name: testCase.title,
189
- status: result.status,
190
- browser: projectSettings.browser,
191
- projectName: projectSettings.projectName,
192
- retry: result.retry,
193
- retries: testCase.retries,
194
- startedAt: new Date(result.startTime).toISOString(),
195
- endedAt: new Date(new Date(result.startTime).getTime() + result.duration).toISOString(),
196
- reason: this.safelyDetermineFailure(result),
197
- attachments: result.attachments,
198
- });
199
- }
233
+
234
+ // Only add the FINAL result (last retry attempt), not all attempts
235
+ // This prevents counting retry attempts as separate tests
236
+ const finalResult = testCase.results[testCase.results.length - 1];
237
+
238
+ testResults.push({
239
+ suiteName,
240
+ name: testCase.title,
241
+ status: finalResult.status,
242
+ browser: projectSettings.browser,
243
+ projectName: projectSettings.projectName,
244
+ retry: finalResult.retry,
245
+ retries: testCase.retries,
246
+ startedAt: new Date(finalResult.startTime).toISOString(),
247
+ endedAt: new Date(new Date(finalResult.startTime).getTime() + finalResult.duration).toISOString(),
248
+ reason: this.safelyDetermineFailure(finalResult),
249
+ attachments: finalResult.attachments,
250
+ });
251
+
200
252
  this.updateResults({
201
253
  testSuite: {
202
254
  title: suiteName,
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.3.1",
33
+ "version": "2.4.0",
34
34
  "main": "index.js",
35
35
  "types": "dist/index.d.ts",
36
36
  "repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",