playwright-slack-report 1.0.14 → 1.0.16
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/README.md +2 -0
- package/dist/src/ResultsParser.d.ts +4 -1
- package/dist/src/ResultsParser.js +36 -10
- package/dist/src/SlackReporter.js +1 -1
- package/dist/src/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://gitpod.io/#https://github.com/ryanrosello-og/playwright-slack-report)
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+
|
|
5
7
|
Publish your Playwright test results to your favorite Slack channel(s).
|
|
6
8
|
|
|
7
9
|

|
|
@@ -4,9 +4,11 @@ export declare type testResult = {
|
|
|
4
4
|
suiteName: string;
|
|
5
5
|
name: string;
|
|
6
6
|
browser?: string;
|
|
7
|
+
projectName: string;
|
|
7
8
|
endedAt: string;
|
|
8
9
|
reason: string;
|
|
9
10
|
retry: number;
|
|
11
|
+
retries: number;
|
|
10
12
|
startedAt: string;
|
|
11
13
|
status: 'passed' | 'failed' | 'timedOut' | 'skipped';
|
|
12
14
|
attachments?: {
|
|
@@ -28,10 +30,11 @@ export default class ResultsParser {
|
|
|
28
30
|
constructor();
|
|
29
31
|
getParsedResults(): Promise<SummaryResults>;
|
|
30
32
|
getFailures(): Promise<Array<failure>>;
|
|
33
|
+
getTestName(failedTest: any): any;
|
|
31
34
|
updateResults(data: {
|
|
32
35
|
testSuite: any;
|
|
33
36
|
}): void;
|
|
34
|
-
addTestResult(suiteName: any,
|
|
37
|
+
addTestResult(suiteName: any, testCase: any): void;
|
|
35
38
|
safelyDetermineFailure(result: {
|
|
36
39
|
errors: any[];
|
|
37
40
|
error: {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable no-shadow */
|
|
3
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
4
|
/* eslint-disable import/extensions */
|
|
3
5
|
/* eslint-disable no-control-regex */
|
|
4
6
|
/* eslint-disable class-methods-use-this */
|
|
@@ -36,12 +38,10 @@ class ResultsParser {
|
|
|
36
38
|
for (const suite of this.result) {
|
|
37
39
|
for (const test of suite.testSuite.tests) {
|
|
38
40
|
if (test.status === 'failed' || test.status === 'timedOut') {
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
&& f.failureReason === test.reason);
|
|
42
|
-
if (!failureExists) {
|
|
41
|
+
// only flag as failed if the last attempt has failed
|
|
42
|
+
if (test.retries === test.retry) {
|
|
43
43
|
failures.push({
|
|
44
|
-
test: test
|
|
44
|
+
test: this.getTestName(test),
|
|
45
45
|
failureReason: test.reason,
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -50,19 +50,38 @@ class ResultsParser {
|
|
|
50
50
|
}
|
|
51
51
|
return failures;
|
|
52
52
|
}
|
|
53
|
+
getTestName(failedTest) {
|
|
54
|
+
const testName = failedTest.name;
|
|
55
|
+
if (failedTest.browser && failedTest.projectName) {
|
|
56
|
+
if (failedTest.browser === failedTest.projectName) {
|
|
57
|
+
return `${testName} [${failedTest.browser}]`;
|
|
58
|
+
}
|
|
59
|
+
return `${testName} [Project Name: ${failedTest.projectName}] using ${failedTest.browser}`;
|
|
60
|
+
}
|
|
61
|
+
return testName;
|
|
62
|
+
}
|
|
53
63
|
updateResults(data) {
|
|
54
64
|
if (data.testSuite.tests.length > 0) {
|
|
55
65
|
this.result.push(data);
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
|
-
addTestResult(suiteName,
|
|
68
|
+
addTestResult(suiteName, testCase) {
|
|
59
69
|
const testResults = [];
|
|
60
|
-
for (const result of
|
|
70
|
+
for (const result of testCase.results) {
|
|
61
71
|
testResults.push({
|
|
62
72
|
suiteName,
|
|
63
|
-
name:
|
|
73
|
+
name: testCase.title,
|
|
64
74
|
status: result.status,
|
|
75
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
76
|
+
browser: testCase.parent?.parent?._projectConfig?.use?.defaultBrowserType
|
|
77
|
+
? testCase.parent.parent._projectConfig.use.defaultBrowserType
|
|
78
|
+
: '',
|
|
79
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
80
|
+
projectName: testCase.parent?.parent?._projectConfig?.name
|
|
81
|
+
? testCase.parent.parent._projectConfig.name
|
|
82
|
+
: '',
|
|
65
83
|
retry: result.retry,
|
|
84
|
+
retries: testCase.retries,
|
|
66
85
|
startedAt: new Date(result.startTime).toISOString(),
|
|
67
86
|
endedAt: new Date(new Date(result.startTime).getTime() + result.duration).toISOString(),
|
|
68
87
|
reason: this.safelyDetermineFailure(result),
|
|
@@ -78,7 +97,9 @@ class ResultsParser {
|
|
|
78
97
|
}
|
|
79
98
|
safelyDetermineFailure(result) {
|
|
80
99
|
if (result.errors.length > 0) {
|
|
81
|
-
const fullError = result.errors
|
|
100
|
+
const fullError = result.errors
|
|
101
|
+
.map((e) => `${e.message}\r\n${e.stack ? e.stack : ''}\r\n`)
|
|
102
|
+
.join();
|
|
82
103
|
return this.cleanseReason(fullError);
|
|
83
104
|
}
|
|
84
105
|
return `${this.cleanseReason(result.error?.message)} \n ${this.cleanseReason(result.error?.stack)}`;
|
|
@@ -86,7 +107,12 @@ class ResultsParser {
|
|
|
86
107
|
cleanseReason(rawReaseon) {
|
|
87
108
|
// eslint-disable-next-line prefer-regex-literals
|
|
88
109
|
const ansiRegex = new RegExp('([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~])))', 'g');
|
|
89
|
-
|
|
110
|
+
const ansiCleansed = rawReaseon ? rawReaseon.replace(ansiRegex, '') : '';
|
|
111
|
+
const logsStripped = ansiCleansed
|
|
112
|
+
.replace(/============================================================\n/g, '')
|
|
113
|
+
.replace(/============================================================\r\n/g, '')
|
|
114
|
+
.replace(/=========================== logs ===========================\n/g, '');
|
|
115
|
+
return logsStripped;
|
|
90
116
|
}
|
|
91
117
|
}
|
|
92
118
|
exports.default = ResultsParser;
|
|
@@ -37,7 +37,7 @@ class SlackReporter {
|
|
|
37
37
|
resultSummary.meta = this.meta;
|
|
38
38
|
const maxRetry = Math.max(...resultSummary.tests.map((o) => o.retry));
|
|
39
39
|
if (this.sendResults === 'on-failure'
|
|
40
|
-
&& resultSummary.tests.filter((z) => z.status === 'failed' && z.retry === maxRetry).length === 0) {
|
|
40
|
+
&& resultSummary.tests.filter((z) => (z.status === 'failed' || z.status === 'timedOut') && z.retry === maxRetry).length === 0) {
|
|
41
41
|
this.log('⏩ Slack reporter - no failures found');
|
|
42
42
|
return;
|
|
43
43
|
}
|
package/dist/src/index.d.ts
CHANGED
package/package.json
CHANGED