playwright-slack-report 1.1.16 → 1.1.20
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 +28 -4
- package/dist/src/SlackReporter.d.ts +2 -0
- package/dist/src/SlackReporter.js +10 -0
- package/package.json +16 -9
package/README.md
CHANGED
|
@@ -154,7 +154,13 @@ 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
|
|
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.
|
|
158
164
|
### **disableUnfurl** (default: true)
|
|
159
165
|
Enable or disable unfurling of links in Slack messages.
|
|
160
166
|
### **showInThread** (default: false)
|
|
@@ -162,6 +168,12 @@ Instructs the reporter to show the failure details in a thread instead of the ma
|
|
|
162
168
|
|
|
163
169
|

|
|
164
170
|
|
|
171
|
+
### **proxy** (optional)
|
|
172
|
+
String representation of your proxy server.
|
|
173
|
+
*Example*:
|
|
174
|
+
|
|
175
|
+
`proxy: "http://proxy.mycompany.com:8080",`
|
|
176
|
+
|
|
165
177
|
### **meta** (default: empty array)
|
|
166
178
|
The meta data to be sent to Slack. This is useful for providing additional context to your test run.
|
|
167
179
|
|
|
@@ -327,7 +339,7 @@ Generates the following message in Slack:
|
|
|
327
339
|

|
|
328
340
|
|
|
329
341
|
|
|
330
|
-
**Example 3: -
|
|
342
|
+
**Example 3: - With screenshots and/or recorded videos (using AWS S3)**
|
|
331
343
|
|
|
332
344
|
In your, `playwright.config.ts` file, add these params (Make sure you use **layoutAsync** rather than **layout**):
|
|
333
345
|
|
|
@@ -461,7 +473,19 @@ export async function generateCustomLayoutAsync (summaryResults: SummaryResults)
|
|
|
461
473
|
|
|
462
474
|
```
|
|
463
475
|
|
|
464
|
-
**
|
|
476
|
+
**Example 4: - Upload the attachments to directly to Slack**
|
|
477
|
+
|
|
478
|
+
To enable this functionality, make sure the slackbot user has the following additional scopes:
|
|
479
|
+
- `files:write`
|
|
480
|
+
- `files:read`
|
|
481
|
+
|
|
482
|
+
You will need to re-install the app and re-invite the bot into the channel.
|
|
483
|
+
|
|
484
|
+
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.
|
|
485
|
+
|
|
486
|
+
**https://app.slack.com/client/T02RVEEFPDH/C05H7TKVDUK**
|
|
487
|
+
|
|
488
|
+
^ the bit starting with 'C...' is your channel id. In this case, the channel id is `C05H7TKVDUK`
|
|
465
489
|
|
|
466
490
|
```typescript
|
|
467
491
|
...
|
|
@@ -471,7 +495,7 @@ const slackClient = new web_api_1.WebClient(process.env.SLACK_BOT_USER_OAUTH_TOK
|
|
|
471
495
|
async function uploadFile(filePath) {
|
|
472
496
|
try {
|
|
473
497
|
const result = await slackClient.files.uploadV2({
|
|
474
|
-
|
|
498
|
+
channel_id: 'C05H7TKVDUK', << this is the channel id not channel name! ☠️
|
|
475
499
|
file: fs.createReadStream(filePath),
|
|
476
500
|
filename: filePath.split('/').at(-1),
|
|
477
501
|
});
|
|
@@ -11,6 +11,7 @@ declare class SlackReporter implements Reporter {
|
|
|
11
11
|
private slackLogLevel;
|
|
12
12
|
private slackOAuthToken;
|
|
13
13
|
private disableUnfurl;
|
|
14
|
+
private proxy;
|
|
14
15
|
private suite;
|
|
15
16
|
logs: string[];
|
|
16
17
|
onBegin(fullConfig: FullConfig, suite: Suite): void;
|
|
@@ -21,5 +22,6 @@ declare class SlackReporter implements Reporter {
|
|
|
21
22
|
message?: string;
|
|
22
23
|
};
|
|
23
24
|
log(message: string | undefined): void;
|
|
25
|
+
printsToStdio(): boolean;
|
|
24
26
|
}
|
|
25
27
|
export default SlackReporter;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const web_api_1 = require("@slack/web-api");
|
|
4
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
4
5
|
const ResultsParser_1 = require("./ResultsParser");
|
|
5
6
|
const SlackClient_1 = require("./SlackClient");
|
|
6
7
|
class SlackReporter {
|
|
@@ -15,6 +16,7 @@ class SlackReporter {
|
|
|
15
16
|
slackLogLevel;
|
|
16
17
|
slackOAuthToken;
|
|
17
18
|
disableUnfurl;
|
|
19
|
+
proxy;
|
|
18
20
|
suite;
|
|
19
21
|
logs = [];
|
|
20
22
|
onBegin(fullConfig, suite) {
|
|
@@ -31,6 +33,8 @@ class SlackReporter {
|
|
|
31
33
|
this.slackOAuthToken = slackReporterConfig.slackOAuthToken || undefined;
|
|
32
34
|
this.disableUnfurl = slackReporterConfig.disableUnfurl || false;
|
|
33
35
|
this.showInThread = slackReporterConfig.showInThread || false;
|
|
36
|
+
this.slackLogLevel = slackReporterConfig.slackLogLevel || web_api_1.LogLevel.DEBUG;
|
|
37
|
+
this.proxy = slackReporterConfig.proxy || undefined;
|
|
34
38
|
}
|
|
35
39
|
this.resultsParser = new ResultsParser_1.default();
|
|
36
40
|
}
|
|
@@ -53,8 +57,10 @@ class SlackReporter {
|
|
|
53
57
|
this.log('⏩ Slack reporter - no failures found');
|
|
54
58
|
return;
|
|
55
59
|
}
|
|
60
|
+
const agent = this.proxy ? new https_proxy_agent_1.HttpsProxyAgent(this.proxy) : undefined;
|
|
56
61
|
const slackClient = new SlackClient_1.default(new web_api_1.WebClient(this.slackOAuthToken || process.env.SLACK_BOT_USER_OAUTH_TOKEN, {
|
|
57
62
|
logLevel: this.slackLogLevel || web_api_1.LogLevel.DEBUG,
|
|
63
|
+
agent,
|
|
58
64
|
}));
|
|
59
65
|
const result = await slackClient.sendMessage({
|
|
60
66
|
options: {
|
|
@@ -126,5 +132,9 @@ class SlackReporter {
|
|
|
126
132
|
this.logs.push(message);
|
|
127
133
|
}
|
|
128
134
|
}
|
|
135
|
+
// eslint-disable-next-line class-methods-use-this
|
|
136
|
+
printsToStdio() {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
129
139
|
}
|
|
130
140
|
exports.default = SlackReporter;
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@slack/web-api": "^6.
|
|
3
|
+
"@slack/web-api": "^6.8.1",
|
|
4
|
+
"https-proxy-agent": "^7.0.1"
|
|
4
5
|
},
|
|
5
6
|
"devDependencies": {
|
|
6
7
|
"@playwright/test": "^1.23.3",
|
|
7
|
-
"dotenv": "^16.0.1",
|
|
8
|
-
"playwright": "^1.23.3",
|
|
9
|
-
"typescript": "^4.7.4",
|
|
10
8
|
"@slack/types": "^2.7.0",
|
|
11
9
|
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
12
10
|
"@typescript-eslint/parser": "^5.30.6",
|
|
11
|
+
"dotenv": "^16.0.1",
|
|
13
12
|
"eslint": "^7.32.0 || ^8.2.0",
|
|
14
13
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
15
14
|
"eslint-config-node": "^4.1.0",
|
|
@@ -19,21 +18,29 @@
|
|
|
19
18
|
"eslint-plugin-prettier": "^4.2.1",
|
|
20
19
|
"nyc": "^15.1.0",
|
|
21
20
|
"prettier": "^2.7.1",
|
|
22
|
-
"ts-mockito": "^2.6.1"
|
|
21
|
+
"ts-mockito": "^2.6.1",
|
|
22
|
+
"typescript": "^4.7.4"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"prettier": "prettier --write --loglevel warn \"**/**/*.ts\"",
|
|
26
26
|
"pw": "nyc playwright test && nyc report --reporter=lcov",
|
|
27
27
|
"build": "tsc -p ./tsconfig.json",
|
|
28
|
-
"lint":"npx eslint . --ext .ts"
|
|
28
|
+
"lint": "npx eslint . --ext .ts"
|
|
29
29
|
},
|
|
30
30
|
"name": "playwright-slack-report",
|
|
31
|
-
"version": "1.1.
|
|
31
|
+
"version": "1.1.20",
|
|
32
32
|
"main": "index.js",
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",
|
|
35
35
|
"author": "Ryan Rosello <ryanrosello@hotmail.com>",
|
|
36
36
|
"license": "MIT",
|
|
37
|
-
"files": [
|
|
38
|
-
|
|
37
|
+
"files": [
|
|
38
|
+
"/dist/src"
|
|
39
|
+
],
|
|
40
|
+
"keywords": [
|
|
41
|
+
"slack",
|
|
42
|
+
"report",
|
|
43
|
+
"playwright",
|
|
44
|
+
"typescript"
|
|
45
|
+
]
|
|
39
46
|
}
|