playwright-slack-report-burak 1.2.0
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/LICENSE +21 -0
- package/README.md +614 -0
- package/dist/src/LayoutGenerator.d.ts +5 -0
- package/dist/src/LayoutGenerator.js +68 -0
- package/dist/src/ResultsParser.d.ts +62 -0
- package/dist/src/ResultsParser.js +187 -0
- package/dist/src/SlackClient.d.ts +37 -0
- package/dist/src/SlackClient.js +101 -0
- package/dist/src/SlackReporter.d.ts +30 -0
- package/dist/src/SlackReporter.js +189 -0
- package/dist/src/SlackWebhookClient.d.ts +15 -0
- package/dist/src/SlackWebhookClient.js +42 -0
- package/dist/src/custom_block/my_block.d.ts +4 -0
- package/dist/src/custom_block/my_block.js +87 -0
- package/dist/src/custom_block/simple.d.ts +3 -0
- package/dist/src/custom_block/simple.js +16 -0
- package/dist/src/custom_block/simple_with_meta.d.ts +3 -0
- package/dist/src/custom_block/simple_with_meta.js +30 -0
- package/dist/src/index.d.ts +54 -0
- package/dist/src/index.js +2 -0
- package/package.json +48 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const generateCustomLayout = (summaryResults) => {
|
|
4
|
+
const maxNumberOfFailures = 10;
|
|
5
|
+
const maxNumberOfFailureLength = 650;
|
|
6
|
+
const fails = [];
|
|
7
|
+
const meta = [];
|
|
8
|
+
for (let i = 0; i < summaryResults.failures.length; i += 1) {
|
|
9
|
+
const { failureReason, test } = summaryResults.failures[i];
|
|
10
|
+
const formattedFailure = failureReason
|
|
11
|
+
.substring(0, maxNumberOfFailureLength)
|
|
12
|
+
.split('\n')
|
|
13
|
+
.map((l) => `>${l}`)
|
|
14
|
+
.join('\n');
|
|
15
|
+
fails.push({
|
|
16
|
+
type: 'section',
|
|
17
|
+
text: {
|
|
18
|
+
type: 'mrkdwn',
|
|
19
|
+
text: `*${test}*
|
|
20
|
+
\n\n${formattedFailure}`,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
if (i > maxNumberOfFailures) {
|
|
24
|
+
fails.push({
|
|
25
|
+
type: 'section',
|
|
26
|
+
text: {
|
|
27
|
+
type: 'mrkdwn',
|
|
28
|
+
text: '*⚠️ There are too many failures to display, view the full results in BuildKite*',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (summaryResults.meta) {
|
|
35
|
+
for (let i = 0; i < summaryResults.meta.length; i += 1) {
|
|
36
|
+
const { key, value } = summaryResults.meta[i];
|
|
37
|
+
meta.push({
|
|
38
|
+
type: 'section',
|
|
39
|
+
text: {
|
|
40
|
+
type: 'mrkdwn',
|
|
41
|
+
text: `\n*${key}* :\t${value}`,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const testWithStringAttachment = summaryResults.tests.filter((t) => t.attachments)[0];
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
type: 'section',
|
|
50
|
+
text: {
|
|
51
|
+
type: 'mrkdwn',
|
|
52
|
+
text: '**Thisi is cusomter block**',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'section',
|
|
57
|
+
text: {
|
|
58
|
+
type: 'mrkdwn',
|
|
59
|
+
text: `**The first test is:**\n${summaryResults.tests[0].name}`,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'section',
|
|
64
|
+
text: {
|
|
65
|
+
type: 'mrkdwn',
|
|
66
|
+
text: `**Test with attachment:**\n${testWithStringAttachment?.attachments
|
|
67
|
+
?.filter((a) => a.contentType === 'text/plain')
|
|
68
|
+
.map((a) => a.body?.toString())}`,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
...meta,
|
|
72
|
+
{
|
|
73
|
+
type: 'section',
|
|
74
|
+
text: {
|
|
75
|
+
type: 'mrkdwn',
|
|
76
|
+
text: `:white_check_mark: *${summaryResults.passed}* Tests ran successfully \n\n :red_circle: *${summaryResults.failed}* Tests failed \n\n ${summaryResults.skipped > 0
|
|
77
|
+
? `:fast_forward: *${summaryResults.skipped}* skipped`
|
|
78
|
+
: ''} \n\n `,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'divider',
|
|
83
|
+
},
|
|
84
|
+
...fails,
|
|
85
|
+
];
|
|
86
|
+
};
|
|
87
|
+
exports.default = generateCustomLayout;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function generateCustomLayoutSimpleExample(summaryResults) {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
type: 'section',
|
|
7
|
+
text: {
|
|
8
|
+
type: 'mrkdwn',
|
|
9
|
+
text: summaryResults.failed === 0
|
|
10
|
+
? ':tada: All tests passed!'
|
|
11
|
+
: `😭${summaryResults.failed} failure(s) out of ${summaryResults.tests.length} tests`,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
exports.default = generateCustomLayoutSimpleExample;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function generateCustomLayoutSimpleMeta(summaryResults) {
|
|
4
|
+
const meta = [];
|
|
5
|
+
if (summaryResults.meta) {
|
|
6
|
+
for (let i = 0; i < summaryResults.meta.length; i += 1) {
|
|
7
|
+
const { key, value } = summaryResults.meta[i];
|
|
8
|
+
meta.push({
|
|
9
|
+
type: 'section',
|
|
10
|
+
text: {
|
|
11
|
+
type: 'mrkdwn',
|
|
12
|
+
text: `\n*${key}* :\t${value}`,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
type: 'section',
|
|
20
|
+
text: {
|
|
21
|
+
type: 'mrkdwn',
|
|
22
|
+
text: summaryResults.failed === 0
|
|
23
|
+
? ':tada: All tests passed!'
|
|
24
|
+
: `😭${summaryResults.failed} failure(s) out of ${summaryResults.tests.length} tests`,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
...meta,
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
exports.default = generateCustomLayoutSimpleMeta;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare type SummaryResults = {
|
|
3
|
+
passed: number;
|
|
4
|
+
failed: number;
|
|
5
|
+
flaky: number | undefined;
|
|
6
|
+
skipped: number;
|
|
7
|
+
failures: Array<failure>;
|
|
8
|
+
skippers: Array<skipper>;
|
|
9
|
+
flakers: Array<flaker>;
|
|
10
|
+
meta?: Array<{
|
|
11
|
+
key: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}>;
|
|
14
|
+
tests: Array<{
|
|
15
|
+
suiteName: string;
|
|
16
|
+
name: string;
|
|
17
|
+
browser?: string;
|
|
18
|
+
projectName?: string;
|
|
19
|
+
endedAt: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
retry: number;
|
|
22
|
+
startedAt: string;
|
|
23
|
+
status: 'passed' | 'failed' | 'timedOut' | 'skipped';
|
|
24
|
+
attachments?: {
|
|
25
|
+
body: string | undefined | Buffer;
|
|
26
|
+
contentType: string;
|
|
27
|
+
name: string;
|
|
28
|
+
path: string;
|
|
29
|
+
}[];
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
export declare type failure = {
|
|
33
|
+
test: string;
|
|
34
|
+
failureReason: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export declare type skipper = {
|
|
38
|
+
test: string;
|
|
39
|
+
skipperReason: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export declare type flaker = {
|
|
43
|
+
test: string;
|
|
44
|
+
flakerReason: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export declare type flaky = {
|
|
48
|
+
test: string;
|
|
49
|
+
retry: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export declare type pass = {
|
|
53
|
+
test: string;
|
|
54
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@slack/web-api": "^6.8.1",
|
|
4
|
+
"@slack/webhook": "^6.1.0",
|
|
5
|
+
"https-proxy-agent": "^7.0.1"
|
|
6
|
+
},
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@playwright/test": "^1.23.3",
|
|
9
|
+
"@slack/types": "^2.7.0",
|
|
10
|
+
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
11
|
+
"@typescript-eslint/parser": "^5.30.6",
|
|
12
|
+
"dotenv": "^16.0.1",
|
|
13
|
+
"eslint": "^7.32.0 || ^8.2.0",
|
|
14
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
15
|
+
"eslint-config-node": "^4.1.0",
|
|
16
|
+
"eslint-config-prettier": "^8.5.0",
|
|
17
|
+
"eslint-plugin-import": "^2.25.2",
|
|
18
|
+
"eslint-plugin-node": "^11.1.0",
|
|
19
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
20
|
+
"nyc": "^15.1.0",
|
|
21
|
+
"prettier": "^2.7.1",
|
|
22
|
+
"ts-sinon": "^2.0.2",
|
|
23
|
+
"typescript": "^4.7.4"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prettier": "prettier --write --loglevel warn \"**/**/*.ts\"",
|
|
27
|
+
"pw": "nyc playwright test && nyc report --reporter=lcov",
|
|
28
|
+
"build": "tsc -p ./tsconfig.json",
|
|
29
|
+
"lint": "npx eslint . --ext .ts",
|
|
30
|
+
"lint-fix": "npx eslint . --ext .ts --fix"
|
|
31
|
+
},
|
|
32
|
+
"name": "playwright-slack-report-burak",
|
|
33
|
+
"version": "1.2.00",
|
|
34
|
+
"main": "index.js",
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
36
|
+
"repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",
|
|
37
|
+
"author": "Burak B. <burak.boluk@hotmail.com>",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"files": [
|
|
40
|
+
"/dist/src"
|
|
41
|
+
],
|
|
42
|
+
"keywords": [
|
|
43
|
+
"slack",
|
|
44
|
+
"report",
|
|
45
|
+
"playwright",
|
|
46
|
+
"typescript"
|
|
47
|
+
]
|
|
48
|
+
}
|