playwright-slack-report-burak 1.2.6 → 1.3.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/LayoutGenerator.js +182 -5
- package/dist/src/SlackClient.js +25 -1
- package/dist/src/SlackReporter.js +11 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateFailures = exports.generateFailuresReasons = exports.generateBlocks = void 0;
|
|
3
|
+
exports.generateFailures = exports.generateFailuresReasons = exports.generateProblemCaseList = exports.generateBlocks = void 0;
|
|
4
4
|
const generateBlocks = async (summaryResults, maxNumberOfFailures) => {
|
|
5
5
|
const meta = [];
|
|
6
6
|
const header = {
|
|
@@ -36,10 +36,7 @@ const generateBlocks = async (summaryResults, maxNumberOfFailures) => {
|
|
|
36
36
|
};
|
|
37
37
|
exports.generateBlocks = generateBlocks;
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
Currently unused but can be used to move failed test name list from main
|
|
41
|
-
message to thread when there are too many for the main message.
|
|
42
|
-
*/
|
|
39
|
+
// Became obsolete with the introdıction of generateProblemCaseList()
|
|
43
40
|
const generateFailures = async (summaryResults) => {
|
|
44
41
|
const thread = [];
|
|
45
42
|
const failedNamesTitle = [];
|
|
@@ -110,6 +107,185 @@ const generateFailures = async (summaryResults) => {
|
|
|
110
107
|
];
|
|
111
108
|
};
|
|
112
109
|
|
|
110
|
+
const generateProblemCaseList = async (summaryResults) => {
|
|
111
|
+
const suitesResults = [];
|
|
112
|
+
const failedSuites = [];
|
|
113
|
+
const flakySuites = [];
|
|
114
|
+
const skippedSuites = [];
|
|
115
|
+
const failsList = [];
|
|
116
|
+
const flakyList = [];
|
|
117
|
+
const skipsList = [];
|
|
118
|
+
const failedSuitesTitle = [];
|
|
119
|
+
const flakySuitesTitle = [];
|
|
120
|
+
const skippedSuitesTitle = [];
|
|
121
|
+
const failedNamesTitle = [];
|
|
122
|
+
const flakyNamesTitle = [];
|
|
123
|
+
const skippedNamesTitle = [];
|
|
124
|
+
let previousTestName = undefined;
|
|
125
|
+
let previousSuiteName = undefined;
|
|
126
|
+
|
|
127
|
+
// Create a list for names of test suites with failed test cases
|
|
128
|
+
for (let i = 0; i < summaryResults.failures.length; i += 1) {
|
|
129
|
+
const { suiteName } = summaryResults.failures[i];
|
|
130
|
+
const capitalizedSuiteName = suiteName.charAt(0).toUpperCase() + suiteName.slice(1);
|
|
131
|
+
const parts = capitalizedSuiteName.split('/')[0];
|
|
132
|
+
const backSlashedParts = parts.split('\\')[0];
|
|
133
|
+
if (backSlashedParts !== previousSuiteName) {
|
|
134
|
+
failedSuites.push(backSlashedParts);
|
|
135
|
+
previousSuiteName = backSlashedParts;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
previousSuiteName = undefined;
|
|
139
|
+
|
|
140
|
+
// Create a list for names of test suites with flaky test cases
|
|
141
|
+
for (const result of summaryResults.tests) {
|
|
142
|
+
if (result.retry > 0 && result.status === 'passed') {
|
|
143
|
+
const suiteName = result.suiteName;
|
|
144
|
+
const capitalizedSuiteName = suiteName.charAt(0).toUpperCase() + suiteName.slice(1);
|
|
145
|
+
const parts = capitalizedSuiteName.split('/')[0];
|
|
146
|
+
const backSlashedParts = parts.split('\\')[0];
|
|
147
|
+
if (backSlashedParts !== previousSuiteName) {
|
|
148
|
+
flakySuites.push(backSlashedParts);
|
|
149
|
+
previousSuiteName = backSlashedParts;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
previousSuiteName = undefined;
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
// Create a list for names of test suites with skipped test cases
|
|
157
|
+
for (const result of summaryResults.tests) {
|
|
158
|
+
if (result.status === 'skipped') {
|
|
159
|
+
const suiteName = result.suiteName;
|
|
160
|
+
const capitalizedSuiteName = suiteName.charAt(0).toUpperCase() + suiteName.slice(1);
|
|
161
|
+
const parts = capitalizedSuiteName.split('/')[0];
|
|
162
|
+
const backSlashedParts = parts.split('\\')[0];
|
|
163
|
+
if (backSlashedParts !== previousSuiteName) {
|
|
164
|
+
skippedSuites.push(backSlashedParts);
|
|
165
|
+
previousSuiteName = backSlashedParts;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
previousSuiteName = undefined;
|
|
170
|
+
|
|
171
|
+
// Create a list for names of failed test cases
|
|
172
|
+
for (let i = 0; i < summaryResults.failures.length; i += 1) {
|
|
173
|
+
const { test, suiteName } = summaryResults.failures[i];
|
|
174
|
+
const parts = suiteName.split('/')[suiteName.split('/').length-1].replace('.spec.ts', '');
|
|
175
|
+
const backSlashedParts = parts.split('\\')[parts.split('\\').length-1];
|
|
176
|
+
failsList.push(test.split(' [')[0] + ' (_' + backSlashedParts + '_)');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Create a list for names of flaky test cases
|
|
180
|
+
for (const result of summaryResults.tests) {
|
|
181
|
+
if (result.retry > 0 && result.status === 'passed') {
|
|
182
|
+
const testName = result.name;
|
|
183
|
+
const suiteName = result.suiteName;
|
|
184
|
+
const parts = result.suiteName.split('/')[result.suiteName.split('/').length-1].replace('.spec.ts', '');
|
|
185
|
+
const backSlashedParts = parts.split('\\')[parts.split('\\').length-1];
|
|
186
|
+
if (testName !== previousTestName || (testName === previousSuiteName && suiteName !== previousSuiteName) ) {
|
|
187
|
+
flakyList.push(testName + ' (_' + backSlashedParts + '_)');
|
|
188
|
+
previousTestName = testName;
|
|
189
|
+
previousSuiteName = suiteName;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
previousTestName = undefined;
|
|
194
|
+
previousSuiteName = undefined;
|
|
195
|
+
|
|
196
|
+
// Create a list for names of skipped test cases
|
|
197
|
+
for (const result of summaryResults.tests) {
|
|
198
|
+
if (result.status === 'skipped') {
|
|
199
|
+
const testName = result.name;
|
|
200
|
+
const suiteName = result.suiteName;
|
|
201
|
+
const parts = result.suiteName.split('/')[result.suiteName.split('/').length-1].replace('.spec.ts', '');
|
|
202
|
+
const backSlashedParts = parts.split('\\')[parts.split('\\').length-1];
|
|
203
|
+
if (testName !== previousTestName || (testName === previousSuiteName && suiteName !== previousSuiteName) ) {
|
|
204
|
+
skipsList.push(testName + ' (_' + backSlashedParts + '_)');
|
|
205
|
+
previousTestName = testName;
|
|
206
|
+
previousSuiteName = suiteName;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
previousTestName = undefined;
|
|
211
|
+
previousSuiteName = undefined;
|
|
212
|
+
|
|
213
|
+
// Decide on Titles For Listing Failures, Skips & Flakies
|
|
214
|
+
if (failedSuites.length === 1) {
|
|
215
|
+
failedSuitesTitle[0] = '*Failed Suite:*\n';
|
|
216
|
+
}
|
|
217
|
+
if (failedSuites.length > 1) {
|
|
218
|
+
failedSuitesTitle[0] = '*Failed Suites:*\n';
|
|
219
|
+
}
|
|
220
|
+
if (flakySuites.length === 1) {
|
|
221
|
+
flakySuitesTitle[0] = '\n*Flaky Suite:*\n';
|
|
222
|
+
}
|
|
223
|
+
if (flakySuites.length > 1) {
|
|
224
|
+
flakySuitesTitle[0] = '\n*Flaky Suites:*\n';
|
|
225
|
+
}
|
|
226
|
+
if (skippedSuites.length === 1) {
|
|
227
|
+
skippedSuitesTitle[0] = '\n*Skipped Suite:*\n';
|
|
228
|
+
}
|
|
229
|
+
if (skippedSuites.length > 1) {
|
|
230
|
+
skippedSuitesTitle[0] = '\n*Skipped Suites:*\n';
|
|
231
|
+
}
|
|
232
|
+
if (summaryResults.failed === 1) {
|
|
233
|
+
failedNamesTitle[0] = '\n*Failed Test Case:*\n';
|
|
234
|
+
}
|
|
235
|
+
if (summaryResults.failed > 1) {
|
|
236
|
+
failedNamesTitle[0] = '\n*Failed Test Cases:*\n';
|
|
237
|
+
}
|
|
238
|
+
if (summaryResults.flaky === 1) {
|
|
239
|
+
flakyNamesTitle[0] = '\n*Flaky Test Case:*\n';
|
|
240
|
+
}
|
|
241
|
+
if (summaryResults.flaky > 1) {
|
|
242
|
+
flakyNamesTitle[0] = '\n*Flaky Test Cases:*\n';
|
|
243
|
+
}
|
|
244
|
+
if (summaryResults.skipped === 1) {
|
|
245
|
+
skippedNamesTitle[0] = '\n*Skipped Test Case:*\n';
|
|
246
|
+
}
|
|
247
|
+
if (summaryResults.skipped > 1) {
|
|
248
|
+
skippedNamesTitle[0] = '\n*Skipped Test Cases:*\n';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Push data into array to create the "List of Problematic Test Suites"
|
|
252
|
+
if (summaryResults.tests.length !== summaryResults.passed){
|
|
253
|
+
suitesResults.push({
|
|
254
|
+
type: 'section',
|
|
255
|
+
text: {
|
|
256
|
+
type: 'mrkdwn',
|
|
257
|
+
text:
|
|
258
|
+
`${failedSuitesTitle}${[...new Set(failedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
|
|
259
|
+
`\n${flakySuitesTitle}${[...new Set(flakySuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` +
|
|
260
|
+
`\n${skippedSuitesTitle}${[...new Set(skippedSuites)].map((value, index) => `*${index + 1}.* ${value}`).join('\n')} `,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
type: 'section',
|
|
265
|
+
text: {
|
|
266
|
+
type: 'mrkdwn',
|
|
267
|
+
text:
|
|
268
|
+
`\n${failedNamesTitle}${failsList.map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` + // List of Failed Test Cases
|
|
269
|
+
`\n${flakyNamesTitle}${flakyList.map((value, index) => `*${index + 1}.* ${value}`).join('\n')}` + // List of Flaky Test Cases
|
|
270
|
+
`\n${skippedNamesTitle}${skipsList.map((value, index) => `*${index + 1}.* ${value}`).join('\n')} `, // List of Skipped Test Cases
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
type: 'section',
|
|
275
|
+
text: {
|
|
276
|
+
type: 'mrkdwn',
|
|
277
|
+
text: ` `,
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
type: 'divider',
|
|
282
|
+
},
|
|
283
|
+
)}
|
|
284
|
+
return [
|
|
285
|
+
...suitesResults,
|
|
286
|
+
];
|
|
287
|
+
};
|
|
288
|
+
|
|
113
289
|
const generateFailuresReasons = async (summaryResults) => {
|
|
114
290
|
const failedNamesTitle = [];
|
|
115
291
|
const failsList = [];
|
|
@@ -231,3 +407,4 @@ const generateFailuresReasons = async (summaryResults) => {
|
|
|
231
407
|
};
|
|
232
408
|
exports.generateFailures = generateFailures;
|
|
233
409
|
exports.generateFailuresReasons = generateFailuresReasons;
|
|
410
|
+
exports.generateProblemCaseList = generateProblemCaseList;
|
package/dist/src/SlackClient.js
CHANGED
|
@@ -87,7 +87,31 @@ class SlackClient {
|
|
|
87
87
|
}
|
|
88
88
|
return result;
|
|
89
89
|
}
|
|
90
|
-
async
|
|
90
|
+
async attachDetailsToThreadCases({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
|
|
91
|
+
const result = [];
|
|
92
|
+
const blocks = await (0, LayoutGenerator_1.generateProblemCaseList)(summaryResults, maxNumberOfFailures);
|
|
93
|
+
for (const channel of channelIds) {
|
|
94
|
+
// under test
|
|
95
|
+
let chatResponse;
|
|
96
|
+
if (fakeRequest) {
|
|
97
|
+
chatResponse = await fakeRequest();
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
|
|
101
|
+
}
|
|
102
|
+
if (chatResponse.ok) {
|
|
103
|
+
// eslint-disable-next-line no-console
|
|
104
|
+
console.log(`✅ Message sent to ${channel} within thread ${ts}`);
|
|
105
|
+
result.push({
|
|
106
|
+
channel,
|
|
107
|
+
outcome: `✅ Message sent to ${channel} within thread ${ts}`,
|
|
108
|
+
ts: chatResponse.ts,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
async attachDetailsToThreadReasons({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
|
|
91
115
|
const result = [];
|
|
92
116
|
const blocks = await (0, LayoutGenerator_1.generateFailuresReasons)(summaryResults, maxNumberOfFailures);
|
|
93
117
|
for (const channel of channelIds) {
|
|
@@ -111,7 +111,7 @@ class SlackReporter {
|
|
|
111
111
|
});
|
|
112
112
|
// eslint-disable-next-line no-console
|
|
113
113
|
console.log(JSON.stringify(result, null, 2));
|
|
114
|
-
if (this.showInThread && (resultSummary.failures.length > 0 || resultSummary.skipped > 0)) {
|
|
114
|
+
if (this.showInThread && (resultSummary.failures.length > 0 || resultSummary.skipped > 0 || resultSummary.flakes.length > 0)) {
|
|
115
115
|
/* for (let i = 0; i < result.length; i += 1) {
|
|
116
116
|
// eslint-disable-next-line no-await-in-loop
|
|
117
117
|
await slackClient.attachDetailsToThread({
|
|
@@ -121,6 +121,16 @@ class SlackReporter {
|
|
|
121
121
|
maxNumberOfFailures: this.maxNumberOfFailuresToShow,
|
|
122
122
|
});
|
|
123
123
|
}*/
|
|
124
|
+
for (let i = 0; i < result.length; i += 1) {
|
|
125
|
+
// eslint-disable-next-line no-await-in-loop
|
|
126
|
+
await slackClient.attachDetailsToThreadCases({
|
|
127
|
+
channelIds: [result[i].channel],
|
|
128
|
+
ts: result[i].ts,
|
|
129
|
+
summaryResults: resultSummary,
|
|
130
|
+
maxNumberOfFailures: this.maxNumberOfFailuresToShow,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
124
134
|
for (let i = 0; i < result.length; i += 1) {
|
|
125
135
|
// eslint-disable-next-line no-await-in-loop
|
|
126
136
|
await slackClient.attachDetailsToThreadReasons({
|
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.
|
|
33
|
+
"version": "1.3.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",
|