playwright-slack-report 1.0.16 → 1.0.19
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 +32 -15
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# playwright-slack-report  [](https://github.com/ryanrosello-og/playwright-slack-report/blob/master/LICENSE) [](https://coveralls.io/github/ryanrosello-og/playwright-slack-report?branch=main)
|
|
2
2
|
|
|
3
3
|
[](https://gitpod.io/#https://github.com/ryanrosello-og/playwright-slack-report)
|
|
4
4
|
|
|
@@ -47,7 +47,12 @@ Run your tests by providing your` SLACK_BOT_USER_OAUTH_TOKEN` as an environment
|
|
|
47
47
|
|
|
48
48
|
`SLACK_BOT_USER_OAUTH_TOKEN=[your Slack bot user OAUTH token] npx playwright test`
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
> **NOTE:** The Slack channel that you specify will need to be *public*, this app will not be able to publish messages to private channels.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary><b>🔎 How do I find my Slack bot oauth token?</b></summary>
|
|
51
56
|
|
|
52
57
|
You will need to have Slack administrator rights to perform the steps below.
|
|
53
58
|
|
|
@@ -86,6 +91,10 @@ The final step will be to copy the generated Bot User OAuth Token aka `SLACK_BOT
|
|
|
86
91
|
|
|
87
92
|

|
|
88
93
|
|
|
94
|
+
</details>
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
89
98
|
# ⚙️ Configuration
|
|
90
99
|
|
|
91
100
|
An example advanced configuration is shown below:
|
|
@@ -102,18 +111,24 @@ An example advanced configuration is shown below:
|
|
|
102
111
|
{
|
|
103
112
|
channels: ["pw-tests", "ci"], // provide one or more Slack channels
|
|
104
113
|
sendResults: "always", // "always" , "on-failure", "off"
|
|
114
|
+
layout: generateCustomLayout,
|
|
115
|
+
maxNumberOfFailuresToShow: 4,
|
|
116
|
+
meta: [
|
|
117
|
+
{
|
|
118
|
+
key: 'BUILD_NUMBER',
|
|
119
|
+
value: '323332-2341',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
key: 'WHATEVER_ENV_VARIABLE',
|
|
123
|
+
value: process.env.SOME_ENV_VARIABLE, // depending on your CI environment, this can be the branch name, build id, etc
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
key: 'HTML Results',
|
|
127
|
+
value: '<https://your-build-artifacts.my.company.dev/pw/23887/playwright-report/index.html|📊>',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
105
130
|
},
|
|
106
|
-
|
|
107
|
-
meta: [
|
|
108
|
-
{
|
|
109
|
-
key: 'BUILD_NUMBER',
|
|
110
|
-
value: '323332-2341',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
key: 'WHATEVER_ENV_VARIABLE',
|
|
114
|
-
value: process.env.SOME_ENV_VARIABLE, // depending on your CI environment, this can be the branch name, build id, etc
|
|
115
|
-
},
|
|
116
|
-
],
|
|
131
|
+
|
|
117
132
|
],
|
|
118
133
|
],
|
|
119
134
|
```
|
|
@@ -128,6 +143,8 @@ Can either be *"always"*, *"on-failure"* or *"off"*, this configuration is requi
|
|
|
128
143
|
### **layout**
|
|
129
144
|
A function that returns a layout object, this configuration is optional. See section below for more details.
|
|
130
145
|
* meta - an array of meta data to be sent to Slack, this configuration is optional.
|
|
146
|
+
### **maxNumberOfFailuresToShow**
|
|
147
|
+
Limits the number of failures shown in the Slack message, defaults to 10.
|
|
131
148
|
|
|
132
149
|
**Examples:**
|
|
133
150
|
```typescript
|
|
@@ -184,9 +201,9 @@ In your, `playwright.confing.ts` file, add your function into the config.
|
|
|
184
201
|
{
|
|
185
202
|
channels: ["pw-tests", "ci"], // provide one or more Slack channels
|
|
186
203
|
sendResults: "always", // "always" , "on-failure", "off"
|
|
204
|
+
layout: generateCustomLayout,
|
|
205
|
+
...
|
|
187
206
|
},
|
|
188
|
-
layout: generateCustomLayout,
|
|
189
|
-
...
|
|
190
207
|
],
|
|
191
208
|
],
|
|
192
209
|
```
|
|
@@ -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