playwright-slack-report-burak 1.2.3 → 1.2.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.
@@ -114,17 +114,90 @@ const generateFailuresReasons = async (summaryResults) => {
114
114
  const failedNamesTitle = [];
115
115
  const failsList = [];
116
116
 
117
- for (let i = 0; i < summaryResults.failures.length; i += 1) {
118
- const { failureReason, test, suiteName } = summaryResults.failures[i];
119
- const parts = suiteName.split('/')[suiteName.split('/').length-1].replace('.spec.ts', '');
120
- const backSlashedParts = parts.split('\\')[parts.split('\\').length-1];
121
- failsList.push({
122
- type: 'section',
123
- text: {
124
- type: 'mrkdwn',
125
- text: `${i+1}. ${test.split(' [')[0]} (${backSlashedParts})\n\`\`\`${failureReason}\`\`\``,
126
- },
127
- });
117
+ for (let i = 0; i <= summaryResults.failures.length; i += 1) {
118
+ if (summaryResults.failures.length <=3) {
119
+ if (i === summaryResults.failures.length) {
120
+ break;
121
+ }
122
+ const { failureReason, test, suiteName } = summaryResults.failures[i];
123
+ const parts = suiteName.split('/')[suiteName.split('/').length-1].replace('.spec.ts', '');
124
+ const backSlashedParts = parts.split('\\')[parts.split('\\').length-1];
125
+ failsList.push({
126
+ type: 'section',
127
+ text: {
128
+ type: 'mrkdwn',
129
+ text: `${i+1}. ${test.split(' [')[0]} (${backSlashedParts})\n\`\`\`${failureReason}\`\`\``,
130
+ },
131
+ });
132
+ } else if (3 < summaryResults.failures.length < 25) {
133
+ const { failureReason, test, suiteName } = summaryResults.failures[i];
134
+ const parts = suiteName.split('/')[suiteName.split('/').length-1].replace('.spec.ts', '');
135
+ const backSlashedParts = parts.split('\\')[parts.split('\\').length-1];
136
+ failsList.push({
137
+ type: 'section',
138
+ text: {
139
+ type: 'mrkdwn',
140
+ text: `${i+1}. ${test.split(' [')[0]} (${backSlashedParts})\n\`\`\`${failureReason.split('\n')[0]}\`\`\``,
141
+ },
142
+ });
143
+ if (i === summaryResults.failures.length) {
144
+ fails.push({
145
+ type: 'section',
146
+ text: {
147
+ type: 'mrkdwn',
148
+ text: '⚠️ *There are too many failures to display in full detail. '+
149
+ 'You can view more on CircleCI* ⚠️',
150
+ },
151
+ },
152
+ {
153
+ type: 'actions',
154
+ elements: [
155
+ {
156
+ type: 'button',
157
+ text: {
158
+ type: 'plain_text',
159
+ text: 'Go to Build Details'
160
+ },
161
+ url: process.env.CIRCLE_BUILD_URL
162
+ }
163
+ ]
164
+ });
165
+ }
166
+ } else if (summaryResults.failures.length >= 25) {
167
+ const { failureReason, test, suiteName } = summaryResults.failures[i];
168
+ const parts = suiteName.split('/')[suiteName.split('/').length-1].replace('.spec.ts', '');
169
+ const backSlashedParts = parts.split('\\')[parts.split('\\').length-1];
170
+ failsList.push({
171
+ type: 'section',
172
+ text: {
173
+ type: 'mrkdwn',
174
+ text: `${i+1}. ${test.split(' [')[0]} (${backSlashedParts})\n\`\`\`${failureReason.split('\n')[0]}\`\`\``,
175
+ },
176
+ });
177
+ if (i > 24) {
178
+ fails.push({
179
+ type: 'section',
180
+ text: {
181
+ type: 'mrkdwn',
182
+ text: '⚠️ *There are too many failures to display here '+
183
+ 'You can view more on CircleCI* ⚠️',
184
+ },
185
+ },
186
+ {
187
+ type: 'actions',
188
+ elements: [
189
+ {
190
+ type: 'button',
191
+ text: {
192
+ type: 'plain_text',
193
+ text: 'Go to Build Details'
194
+ },
195
+ url: process.env.CIRCLE_BUILD_URL
196
+ }
197
+ ]
198
+ });
199
+ }
200
+ }
128
201
  }
129
202
 
130
203
  // Decide on Titles For Listing Failures & Skips
@@ -62,7 +62,7 @@ class ResultsParser {
62
62
  const flaky = [];
63
63
  for (const suite of this.result) {
64
64
  for (const test of suite.testSuite.tests) {
65
- if (test.status === 'passed' && test.retry > 0) {
65
+ if (this.separateFlakyTests && test.status === 'passed' && test.retry > 0) {
66
66
  flaky.push({
67
67
  test: ResultsParser.getTestName(test),
68
68
  retry: test.retry,
@@ -76,10 +76,18 @@ class ResultsParser {
76
76
  const passes = [];
77
77
  for (const suite of this.result) {
78
78
  for (const test of suite.testSuite.tests) {
79
- if (test.status === 'passed' && test.retry === 0) {
80
- passes.push({
81
- test: ResultsParser.getTestName(test),
82
- });
79
+ if (this.separateFlakyTests) {
80
+ if (test.status === 'passed' && test.retry === 0) {
81
+ passes.push({
82
+ test: ResultsParser.getTestName(test),
83
+ });
84
+ }
85
+ } else {
86
+ if (test.status === 'passed') {
87
+ passes.push({
88
+ test: ResultsParser.getTestName(test),
89
+ });
90
+ }
83
91
  }
84
92
  }
85
93
  }
@@ -159,7 +167,9 @@ class ResultsParser {
159
167
  }
160
168
  /** removes tests from the passed array that only passed on a retry (flaky).
161
169
  * Does not modify param passed, returns a new passed array. */
162
- doSeparateFlakyTests(passes, flakes) {
170
+ /** Cuurently unused. Instead, we check the seperateflaky flag while
171
+ * passed array. */
172
+ /*doSeparateFlakyTests(passes, flakes) {
163
173
  const _passes = new Map();
164
174
  for (const pass of passes) {
165
175
  _passes.set(pass.test, pass);
@@ -168,6 +178,6 @@ class ResultsParser {
168
178
  _passes.delete(flake.test);
169
179
  }
170
180
  return [..._passes.values()];
171
- }
181
+ }*/
172
182
  }
173
183
  exports.default = ResultsParser;
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": "1.2.3",
33
+ "version": "1.2.4",
34
34
  "main": "index.js",
35
35
  "types": "dist/index.d.ts",
36
36
  "repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",