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 CHANGED
@@ -1,4 +1,4 @@
1
- # playwright-slack-report ![Biulds](https://github.com/ryanrosello-og/playwright-slack-report/actions/workflows/playwright.yml/badge.svg) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ryanrosello-og/playwright-slack-report/blob/master/LICENSE) [![Coverage Status](https://coveralls.io/repos/github/ryanrosello-og/playwright-slack-report/badge.svg?branch=main)](https://coveralls.io/github/ryanrosello-og/playwright-slack-report?branch=main)
1
+ # playwright-slack-report ![Builds](https://github.com/ryanrosello-og/playwright-slack-report/actions/workflows/playwright.yml/badge.svg) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ryanrosello-og/playwright-slack-report/blob/master/LICENSE) [![Coverage Status](https://coveralls.io/repos/github/ryanrosello-og/playwright-slack-report/badge.svg?branch=main)](https://coveralls.io/github/ryanrosello-og/playwright-slack-report?branch=main)
2
2
 
3
3
  [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](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
- # ℹ️ How do I find my Slack bot oauth token?
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
  ![Final](https://github.com/ryanrosello-og/playwright-slack-report/blob/main/assets/2022-08-09_5-53-17.png?raw=true)
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
- layout: generateCustomLayout,
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: '*There are too many failures to display*',
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: this.getTestName(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) {
@@ -13,6 +13,7 @@ export default class SlackClient {
13
13
  summaryResults: SummaryResults;
14
14
  customLayout: Function | undefined;
15
15
  fakeRequest?: Function;
16
+ maxNumberOfFailures: number;
16
17
  };
17
18
  }): Promise<Array<{
18
19
  channel: string;
@@ -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`);
@@ -5,6 +5,7 @@ declare class SlackReporter implements Reporter {
5
5
  private slackChannels;
6
6
  private meta;
7
7
  private customLayout;
8
+ private maxNumberOfFailuresToShow;
8
9
  private resultsParser;
9
10
  logs: string[];
10
11
  onBegin(fullConfig: FullConfig, suite: Suite): void;
@@ -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
@@ -28,7 +28,7 @@
28
28
  "lint":"npx eslint . --ext .ts"
29
29
  },
30
30
  "name": "playwright-slack-report",
31
- "version": "1.0.16",
31
+ "version": "1.0.19",
32
32
  "main": "index.js",
33
33
  "types": "dist/index.d.ts",
34
34
  "repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",