playwright-slack-report 1.0.16 → 1.0.18
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 +7 -0
- package/dist/src/LayoutGenerator.d.ts +1 -1
- package/dist/src/LayoutGenerator.js +2 -3
- package/dist/src/ResultsParser.d.ts +1 -1
- package/dist/src/ResultsParser.js +2 -2
- package/dist/src/SlackClient.d.ts +1 -0
- package/dist/src/SlackClient.js +1 -1
- package/dist/src/SlackReporter.d.ts +1 -0
- package/dist/src/SlackReporter.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -104,6 +104,7 @@ An example advanced configuration is shown below:
|
|
|
104
104
|
sendResults: "always", // "always" , "on-failure", "off"
|
|
105
105
|
},
|
|
106
106
|
layout: generateCustomLayout,
|
|
107
|
+
maxNumberOfFailuresToShow: 4,
|
|
107
108
|
meta: [
|
|
108
109
|
{
|
|
109
110
|
key: 'BUILD_NUMBER',
|
|
@@ -113,6 +114,10 @@ An example advanced configuration is shown below:
|
|
|
113
114
|
key: 'WHATEVER_ENV_VARIABLE',
|
|
114
115
|
value: process.env.SOME_ENV_VARIABLE, // depending on your CI environment, this can be the branch name, build id, etc
|
|
115
116
|
},
|
|
117
|
+
{
|
|
118
|
+
key: 'HTML Results',
|
|
119
|
+
value: '<https://your-build-artifacts.my.company.dev/pw/23887/playwright-report/index.html|📊>',
|
|
120
|
+
},
|
|
116
121
|
],
|
|
117
122
|
],
|
|
118
123
|
],
|
|
@@ -128,6 +133,8 @@ Can either be *"always"*, *"on-failure"* or *"off"*, this configuration is requi
|
|
|
128
133
|
### **layout**
|
|
129
134
|
A function that returns a layout object, this configuration is optional. See section below for more details.
|
|
130
135
|
* meta - an array of meta data to be sent to Slack, this configuration is optional.
|
|
136
|
+
### **maxNumberOfFailuresToShow**
|
|
137
|
+
Limits the number of failures shown in the Slack message, defaults to 10.
|
|
131
138
|
|
|
132
139
|
**Examples:**
|
|
133
140
|
```typescript
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { KnownBlock, Block } from '@slack/types';
|
|
2
2
|
import { SummaryResults } from '.';
|
|
3
|
-
declare const generateBlocks: (summaryResults: SummaryResults) => Promise<Array<KnownBlock | Block>>;
|
|
3
|
+
declare const generateBlocks: (summaryResults: SummaryResults, maxNumberOfFailures: number) => Promise<Array<KnownBlock | Block>>;
|
|
4
4
|
export default generateBlocks;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const generateBlocks = async (summaryResults) => {
|
|
4
|
-
const maxNumberOfFailures = 10;
|
|
3
|
+
const generateBlocks = async (summaryResults, maxNumberOfFailures) => {
|
|
5
4
|
const maxNumberOfFailureLength = 650;
|
|
6
5
|
const fails = [];
|
|
7
6
|
const meta = [];
|
|
@@ -39,7 +38,7 @@ const generateBlocks = async (summaryResults) => {
|
|
|
39
38
|
type: 'section',
|
|
40
39
|
text: {
|
|
41
40
|
type: 'mrkdwn',
|
|
42
|
-
text:
|
|
41
|
+
text: `*There are too many failures to display - ${fails.length} out of ${summaryResults.failures.length} failures shown*`,
|
|
43
42
|
},
|
|
44
43
|
});
|
|
45
44
|
break;
|
|
@@ -30,7 +30,7 @@ export default class ResultsParser {
|
|
|
30
30
|
constructor();
|
|
31
31
|
getParsedResults(): Promise<SummaryResults>;
|
|
32
32
|
getFailures(): Promise<Array<failure>>;
|
|
33
|
-
getTestName(failedTest: any): any;
|
|
33
|
+
static getTestName(failedTest: any): any;
|
|
34
34
|
updateResults(data: {
|
|
35
35
|
testSuite: any;
|
|
36
36
|
}): void;
|
|
@@ -41,7 +41,7 @@ class ResultsParser {
|
|
|
41
41
|
// only flag as failed if the last attempt has failed
|
|
42
42
|
if (test.retries === test.retry) {
|
|
43
43
|
failures.push({
|
|
44
|
-
test:
|
|
44
|
+
test: ResultsParser.getTestName(test),
|
|
45
45
|
failureReason: test.reason,
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -50,7 +50,7 @@ class ResultsParser {
|
|
|
50
50
|
}
|
|
51
51
|
return failures;
|
|
52
52
|
}
|
|
53
|
-
getTestName(failedTest) {
|
|
53
|
+
static getTestName(failedTest) {
|
|
54
54
|
const testName = failedTest.name;
|
|
55
55
|
if (failedTest.browser && failedTest.projectName) {
|
|
56
56
|
if (failedTest.browser === failedTest.projectName) {
|
package/dist/src/SlackClient.js
CHANGED
|
@@ -12,7 +12,7 @@ class SlackClient {
|
|
|
12
12
|
blocks = options.customLayout(options.summaryResults);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
|
-
blocks = await (0, LayoutGenerator_1.default)(options.summaryResults);
|
|
15
|
+
blocks = await (0, LayoutGenerator_1.default)(options.summaryResults, options.maxNumberOfFailures);
|
|
16
16
|
}
|
|
17
17
|
if (!options.channelIds) {
|
|
18
18
|
throw new Error(`Channel ids [${options.channelIds}] is not valid`);
|
|
@@ -9,6 +9,7 @@ class SlackReporter {
|
|
|
9
9
|
slackChannels = [];
|
|
10
10
|
meta = [];
|
|
11
11
|
customLayout;
|
|
12
|
+
maxNumberOfFailuresToShow;
|
|
12
13
|
resultsParser;
|
|
13
14
|
logs = [];
|
|
14
15
|
onBegin(fullConfig, suite) {
|
|
@@ -20,6 +21,7 @@ class SlackReporter {
|
|
|
20
21
|
this.sendResults = slackReporterConfig.sendResults || 'always';
|
|
21
22
|
this.customLayout = slackReporterConfig.layout;
|
|
22
23
|
this.slackChannels = slackReporterConfig.channels;
|
|
24
|
+
this.maxNumberOfFailuresToShow = slackReporterConfig.maxNumberOfFailuresToShow || 10;
|
|
23
25
|
}
|
|
24
26
|
this.resultsParser = new ResultsParser_1.default();
|
|
25
27
|
}
|
|
@@ -49,6 +51,7 @@ class SlackReporter {
|
|
|
49
51
|
channelIds: this.slackChannels,
|
|
50
52
|
summaryResults: resultSummary,
|
|
51
53
|
customLayout: this.customLayout,
|
|
54
|
+
maxNumberOfFailures: this.maxNumberOfFailuresToShow,
|
|
52
55
|
},
|
|
53
56
|
});
|
|
54
57
|
// eslint-disable-next-line no-console
|
package/package.json
CHANGED