playwright-slack-report 1.1.15 → 1.1.17
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 +24 -6
- package/dist/src/SlackClient.d.ts +3 -3
- package/dist/src/SlackClient.js +3 -3
- package/dist/src/SlackReporter.d.ts +2 -1
- package/dist/src/SlackReporter.js +8 -3
- package/package.json +15 -9
package/README.md
CHANGED
|
@@ -129,7 +129,7 @@ An example advanced configuration is shown below:
|
|
|
129
129
|
],
|
|
130
130
|
slackOAuthToken: 'YOUR_SLACK_OAUTH_TOKEN',
|
|
131
131
|
slackLogLevel: LogLevel.DEBUG,
|
|
132
|
-
|
|
132
|
+
disableUnfurl: true,
|
|
133
133
|
showInThread: true,
|
|
134
134
|
},
|
|
135
135
|
|
|
@@ -154,8 +154,14 @@ Limits the number of failures shown in the Slack message, defaults to 10.
|
|
|
154
154
|
### **slackOAuthToken**
|
|
155
155
|
Instead of providing an environment variable `SLACK_BOT_USER_OAUTH_TOKEN` you can specify the token in the config in the `slackOAuthToken` field.
|
|
156
156
|
### **slackLogLevel** (default LogLevel.DEBUG)
|
|
157
|
-
This option allows you to control slack client severity levels for log entries. It accepts a value from @slack/web-api `LogLevel` enum
|
|
158
|
-
|
|
157
|
+
This option allows you to control slack client severity levels for log entries. It accepts a value from @slack/web-api `LogLevel` enum:
|
|
158
|
+
- ERROR
|
|
159
|
+
- WARN
|
|
160
|
+
- INFO
|
|
161
|
+
- DEBUG
|
|
162
|
+
|
|
163
|
+
Example: `slackLogLevel: "ERROR",` will only log errors to the console.
|
|
164
|
+
### **disableUnfurl** (default: true)
|
|
159
165
|
Enable or disable unfurling of links in Slack messages.
|
|
160
166
|
### **showInThread** (default: false)
|
|
161
167
|
Instructs the reporter to show the failure details in a thread instead of the main channel.
|
|
@@ -327,7 +333,7 @@ Generates the following message in Slack:
|
|
|
327
333
|

|
|
328
334
|
|
|
329
335
|
|
|
330
|
-
**Example 3: -
|
|
336
|
+
**Example 3: - With screenshots and/or recorded videos (using AWS S3)**
|
|
331
337
|
|
|
332
338
|
In your, `playwright.config.ts` file, add these params (Make sure you use **layoutAsync** rather than **layout**):
|
|
333
339
|
|
|
@@ -461,7 +467,19 @@ export async function generateCustomLayoutAsync (summaryResults: SummaryResults)
|
|
|
461
467
|
|
|
462
468
|
```
|
|
463
469
|
|
|
464
|
-
**
|
|
470
|
+
**Example 4: - Upload the attachments to directly to Slack**
|
|
471
|
+
|
|
472
|
+
To enable this functionality, make sure the slackbot user has the following additional scopes:
|
|
473
|
+
- `files:write`
|
|
474
|
+
- `files:read`
|
|
475
|
+
|
|
476
|
+
You will need to re-install the app and re-invite the bot into the channel.
|
|
477
|
+
|
|
478
|
+
The value of the channel_id should be the channel id of the channel you want to upload the file to. This channel id can be found in the url when you are in the channel. e.g.
|
|
479
|
+
|
|
480
|
+
**https://app.slack.com/client/T02RVEEFPDH/C05H7TKVDUK**
|
|
481
|
+
|
|
482
|
+
^ the bit starting with 'C...' is your channel id. In this case, the channel id is `C05H7TKVDUK`
|
|
465
483
|
|
|
466
484
|
```typescript
|
|
467
485
|
...
|
|
@@ -471,7 +489,7 @@ const slackClient = new web_api_1.WebClient(process.env.SLACK_BOT_USER_OAUTH_TOK
|
|
|
471
489
|
async function uploadFile(filePath) {
|
|
472
490
|
try {
|
|
473
491
|
const result = await slackClient.files.uploadV2({
|
|
474
|
-
|
|
492
|
+
channel_id: 'C05H7TKVDUK', << this is the channel id not channel name! ☠️
|
|
475
493
|
file: fs.createReadStream(filePath),
|
|
476
494
|
filename: filePath.split('/').at(-1),
|
|
477
495
|
});
|
|
@@ -16,7 +16,7 @@ export default class SlackClient {
|
|
|
16
16
|
maxNumberOfFailures: number;
|
|
17
17
|
slackOAuthToken?: string;
|
|
18
18
|
slackLogLevel?: LogLevel;
|
|
19
|
-
|
|
19
|
+
disableUnfurl?: boolean;
|
|
20
20
|
summaryResults: SummaryResults;
|
|
21
21
|
showInThread: boolean;
|
|
22
22
|
};
|
|
@@ -25,12 +25,12 @@ export default class SlackClient {
|
|
|
25
25
|
outcome: string;
|
|
26
26
|
ts: string;
|
|
27
27
|
}>>;
|
|
28
|
-
attachDetailsToThread({ channelIds, ts, summaryResults, maxNumberOfFailures,
|
|
28
|
+
attachDetailsToThread({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }: {
|
|
29
29
|
channelIds: Array<string>;
|
|
30
30
|
ts: string;
|
|
31
31
|
summaryResults: SummaryResults;
|
|
32
32
|
maxNumberOfFailures: number;
|
|
33
|
-
|
|
33
|
+
disableUnfurl?: boolean;
|
|
34
34
|
fakeRequest?: Function;
|
|
35
35
|
}): Promise<any[]>;
|
|
36
36
|
static doPostRequest(slackWebClient: WebClient, channel: string, blocks: Array<KnownBlock | Block>, unfurl: boolean, threadTimestamp?: string): Promise<ChatPostMessageResponse>;
|
package/dist/src/SlackClient.js
CHANGED
|
@@ -26,7 +26,7 @@ class SlackClient {
|
|
|
26
26
|
throw new Error(`Channel ids [${options.channelIds}] is not valid`);
|
|
27
27
|
}
|
|
28
28
|
const result = [];
|
|
29
|
-
const unfurl = options.
|
|
29
|
+
const unfurl = !options.disableUnfurl;
|
|
30
30
|
for (const channel of options.channelIds) {
|
|
31
31
|
let chatResponse;
|
|
32
32
|
try {
|
|
@@ -63,7 +63,7 @@ class SlackClient {
|
|
|
63
63
|
}
|
|
64
64
|
return result;
|
|
65
65
|
}
|
|
66
|
-
async attachDetailsToThread({ channelIds, ts, summaryResults, maxNumberOfFailures,
|
|
66
|
+
async attachDetailsToThread({ channelIds, ts, summaryResults, maxNumberOfFailures, disableUnfurl, fakeRequest, }) {
|
|
67
67
|
const result = [];
|
|
68
68
|
const blocks = await (0, LayoutGenerator_1.generateFailures)(summaryResults, maxNumberOfFailures);
|
|
69
69
|
for (const channel of channelIds) {
|
|
@@ -73,7 +73,7 @@ class SlackClient {
|
|
|
73
73
|
chatResponse = await fakeRequest();
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
|
-
chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks,
|
|
76
|
+
chatResponse = await SlackClient.doPostRequest(this.slackWebClient, channel, blocks, disableUnfurl, ts);
|
|
77
77
|
}
|
|
78
78
|
if (chatResponse.ok) {
|
|
79
79
|
// eslint-disable-next-line no-console
|
|
@@ -10,7 +10,7 @@ declare class SlackReporter implements Reporter {
|
|
|
10
10
|
private slackChannels;
|
|
11
11
|
private slackLogLevel;
|
|
12
12
|
private slackOAuthToken;
|
|
13
|
-
private
|
|
13
|
+
private disableUnfurl;
|
|
14
14
|
private suite;
|
|
15
15
|
logs: string[];
|
|
16
16
|
onBegin(fullConfig: FullConfig, suite: Suite): void;
|
|
@@ -21,5 +21,6 @@ declare class SlackReporter implements Reporter {
|
|
|
21
21
|
message?: string;
|
|
22
22
|
};
|
|
23
23
|
log(message: string | undefined): void;
|
|
24
|
+
printsToStdio(): boolean;
|
|
24
25
|
}
|
|
25
26
|
export default SlackReporter;
|
|
@@ -14,7 +14,7 @@ class SlackReporter {
|
|
|
14
14
|
slackChannels = [];
|
|
15
15
|
slackLogLevel;
|
|
16
16
|
slackOAuthToken;
|
|
17
|
-
|
|
17
|
+
disableUnfurl;
|
|
18
18
|
suite;
|
|
19
19
|
logs = [];
|
|
20
20
|
onBegin(fullConfig, suite) {
|
|
@@ -29,8 +29,9 @@ class SlackReporter {
|
|
|
29
29
|
this.slackChannels = slackReporterConfig.channels;
|
|
30
30
|
this.maxNumberOfFailuresToShow = slackReporterConfig.maxNumberOfFailuresToShow || 10;
|
|
31
31
|
this.slackOAuthToken = slackReporterConfig.slackOAuthToken || undefined;
|
|
32
|
-
this.
|
|
32
|
+
this.disableUnfurl = slackReporterConfig.disableUnfurl || false;
|
|
33
33
|
this.showInThread = slackReporterConfig.showInThread || false;
|
|
34
|
+
this.slackLogLevel = slackReporterConfig.slackLogLevel || web_api_1.LogLevel.DEBUG;
|
|
34
35
|
}
|
|
35
36
|
this.resultsParser = new ResultsParser_1.default();
|
|
36
37
|
}
|
|
@@ -62,7 +63,7 @@ class SlackReporter {
|
|
|
62
63
|
customLayout: this.customLayout,
|
|
63
64
|
customLayoutAsync: this.customLayoutAsync,
|
|
64
65
|
maxNumberOfFailures: this.maxNumberOfFailuresToShow,
|
|
65
|
-
|
|
66
|
+
disableUnfurl: this.disableUnfurl,
|
|
66
67
|
summaryResults: resultSummary,
|
|
67
68
|
showInThread: this.showInThread,
|
|
68
69
|
},
|
|
@@ -126,5 +127,9 @@ class SlackReporter {
|
|
|
126
127
|
this.logs.push(message);
|
|
127
128
|
}
|
|
128
129
|
}
|
|
130
|
+
// eslint-disable-next-line class-methods-use-this
|
|
131
|
+
printsToStdio() {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
129
134
|
}
|
|
130
135
|
exports.default = SlackReporter;
|
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@slack/web-api": "^6.
|
|
3
|
+
"@slack/web-api": "^6.8.1"
|
|
4
4
|
},
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@playwright/test": "^1.23.3",
|
|
7
|
-
"dotenv": "^16.0.1",
|
|
8
|
-
"playwright": "^1.23.3",
|
|
9
|
-
"typescript": "^4.7.4",
|
|
10
7
|
"@slack/types": "^2.7.0",
|
|
11
8
|
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
12
9
|
"@typescript-eslint/parser": "^5.30.6",
|
|
10
|
+
"dotenv": "^16.0.1",
|
|
13
11
|
"eslint": "^7.32.0 || ^8.2.0",
|
|
14
12
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
15
13
|
"eslint-config-node": "^4.1.0",
|
|
@@ -19,21 +17,29 @@
|
|
|
19
17
|
"eslint-plugin-prettier": "^4.2.1",
|
|
20
18
|
"nyc": "^15.1.0",
|
|
21
19
|
"prettier": "^2.7.1",
|
|
22
|
-
"ts-mockito": "^2.6.1"
|
|
20
|
+
"ts-mockito": "^2.6.1",
|
|
21
|
+
"typescript": "^4.7.4"
|
|
23
22
|
},
|
|
24
23
|
"scripts": {
|
|
25
24
|
"prettier": "prettier --write --loglevel warn \"**/**/*.ts\"",
|
|
26
25
|
"pw": "nyc playwright test && nyc report --reporter=lcov",
|
|
27
26
|
"build": "tsc -p ./tsconfig.json",
|
|
28
|
-
"lint":"npx eslint . --ext .ts"
|
|
27
|
+
"lint": "npx eslint . --ext .ts"
|
|
29
28
|
},
|
|
30
29
|
"name": "playwright-slack-report",
|
|
31
|
-
"version": "1.1.
|
|
30
|
+
"version": "1.1.17",
|
|
32
31
|
"main": "index.js",
|
|
33
32
|
"types": "dist/index.d.ts",
|
|
34
33
|
"repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",
|
|
35
34
|
"author": "Ryan Rosello <ryanrosello@hotmail.com>",
|
|
36
35
|
"license": "MIT",
|
|
37
|
-
"files": [
|
|
38
|
-
|
|
36
|
+
"files": [
|
|
37
|
+
"/dist/src"
|
|
38
|
+
],
|
|
39
|
+
"keywords": [
|
|
40
|
+
"slack",
|
|
41
|
+
"report",
|
|
42
|
+
"playwright",
|
|
43
|
+
"typescript"
|
|
44
|
+
]
|
|
39
45
|
}
|