ci-slack-reporter 1.0.9-a3 → 1.0.9-a5
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/index.js +15 -15
- package/package.json +1 -1
package/index.js
CHANGED
@@ -21,7 +21,7 @@ const fails_only_webhook = process.env.CI_SLACK_REPORTER_FAILS_ONLY_WEBHOOK && n
|
|
21
21
|
|
22
22
|
const webhook = new IncomingWebhook(process.env.CI_SLACK_REPORTER_WEBHOOK);
|
23
23
|
|
24
|
-
let out;
|
24
|
+
let out = {};
|
25
25
|
|
26
26
|
// this reporter outputs test results, indenting two spaces per suite
|
27
27
|
class MyReporter {
|
@@ -31,9 +31,9 @@ class MyReporter {
|
|
31
31
|
|
32
32
|
runner
|
33
33
|
.once(EVENT_RUN_BEGIN, () => {
|
34
|
-
console.log(
|
34
|
+
console.log(`⚡runner ${runner.file}`);
|
35
35
|
|
36
|
-
out = {
|
36
|
+
out[runner.file] = {
|
37
37
|
attachments: [
|
38
38
|
{
|
39
39
|
"color": "#ff0000",
|
@@ -55,12 +55,12 @@ class MyReporter {
|
|
55
55
|
]
|
56
56
|
};
|
57
57
|
if (process.env.CI_SLACK_REPORTER_ICON_URL) {
|
58
|
-
out.icon_url = process.env.CI_SLACK_REPORTER_ICON_URL;
|
58
|
+
out[runner.file].icon_url = process.env.CI_SLACK_REPORTER_ICON_URL;
|
59
59
|
} else {
|
60
|
-
out.icon_emoji = ":robot:"
|
60
|
+
out[runner.file].icon_emoji = ":robot:"
|
61
61
|
}
|
62
62
|
|
63
|
-
out.username = process.env.CI_SLACK_REPORTER_USERNAME || 'Autotester'
|
63
|
+
out[runner.file].username = process.env.CI_SLACK_REPORTER_USERNAME || 'Autotester'
|
64
64
|
|
65
65
|
})
|
66
66
|
.on(EVENT_SUITE_BEGIN, () => {
|
@@ -72,7 +72,7 @@ class MyReporter {
|
|
72
72
|
.on(EVENT_TEST_PASS, test => {
|
73
73
|
// Test#fullTitle() returns the suite name(s)
|
74
74
|
// prepended to the test title
|
75
|
-
out.attachments[0].blocks.push({
|
75
|
+
out[runner.file].attachments[0].blocks.push({
|
76
76
|
"type": "section",
|
77
77
|
"text": {
|
78
78
|
"type": "plain_text",
|
@@ -82,7 +82,7 @@ class MyReporter {
|
|
82
82
|
})
|
83
83
|
})
|
84
84
|
.on(EVENT_TEST_FAIL, (test, err) => {
|
85
|
-
out.attachments[0].blocks.push({
|
85
|
+
out[runner.file].attachments[0].blocks.push({
|
86
86
|
"type": "section",
|
87
87
|
"text": {
|
88
88
|
"type": "plain_text",
|
@@ -93,7 +93,7 @@ class MyReporter {
|
|
93
93
|
})
|
94
94
|
.once(EVENT_RUN_END, () => {
|
95
95
|
if (process.env.CI_SLACK_REPORTER_VIDEO_URL && stats.failures) {
|
96
|
-
out.attachments[0].blocks[2].accessory = {
|
96
|
+
out[runner.file].attachments[0].blocks[2].accessory = {
|
97
97
|
"type": "button",
|
98
98
|
"text": {
|
99
99
|
"type": "plain_text",
|
@@ -106,16 +106,16 @@ class MyReporter {
|
|
106
106
|
}
|
107
107
|
}
|
108
108
|
|
109
|
-
out.attachments[0].blocks[0].text.text = `Tests finished ${stats.passes}/${stats.passes + stats.failures}`;
|
110
|
-
out.attachments[0].color = stats.failures ? "#a30200" : "#2eb886";
|
111
|
-
webhook.
|
112
|
-
|
109
|
+
out[runner.file].attachments[0].blocks[0].text.text = `Tests finished ${stats.passes}/${stats.passes + stats.failures}`;
|
110
|
+
out[runner.file].attachments[0].color = stats.failures ? "#a30200" : "#2eb886";
|
111
|
+
console.log(`⚡ webhook send ${runner.file}`, JSON.stringify(out[runner.file]));
|
112
|
+
webhook.send(out[runner.file]);
|
113
113
|
|
114
114
|
if (stats.failures) {
|
115
|
-
out.attachments[0].blocks = out.attachments[0].blocks.filter(el => {
|
115
|
+
out[runner.file].attachments[0].blocks = out[runner.file].attachments[0].blocks.filter(el => {
|
116
116
|
return !el?.text?.text?.startsWith(":white")
|
117
117
|
})
|
118
|
-
fails_only_webhook?.send(out)
|
118
|
+
fails_only_webhook?.send(out[runner.file])
|
119
119
|
}
|
120
120
|
});
|
121
121
|
}
|