@testomatio/reporter 2.0.1-beta.5-timestamp → 2.0.1
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 +1 -0
- package/lib/adapter/codecept.d.ts +2 -0
- package/lib/adapter/codecept.js +293 -335
- package/lib/adapter/cucumber/current.d.ts +14 -0
- package/lib/adapter/cucumber/current.js +195 -203
- package/lib/adapter/cucumber/legacy.d.ts +0 -0
- package/lib/adapter/cucumber/legacy.js +130 -155
- package/lib/adapter/cucumber.d.ts +2 -0
- package/lib/adapter/cucumber.js +5 -16
- package/lib/adapter/cypress-plugin/index.d.ts +2 -0
- package/lib/adapter/cypress-plugin/index.js +91 -105
- package/lib/adapter/jasmine.d.ts +11 -0
- package/lib/adapter/jasmine.js +54 -53
- package/lib/adapter/jest.d.ts +13 -0
- package/lib/adapter/jest.js +97 -99
- package/lib/adapter/mocha.d.ts +2 -0
- package/lib/adapter/mocha.js +112 -141
- package/lib/adapter/nightwatch.d.ts +4 -0
- package/lib/adapter/nightwatch.js +80 -0
- package/lib/adapter/playwright.d.ts +14 -0
- package/lib/adapter/playwright.js +199 -231
- package/lib/adapter/vitest.d.ts +35 -0
- package/lib/adapter/vitest.js +150 -149
- package/lib/adapter/webdriver.d.ts +24 -0
- package/lib/adapter/webdriver.js +144 -121
- package/lib/bin/cli.d.ts +2 -0
- package/lib/bin/cli.js +229 -211
- package/lib/bin/reportXml.d.ts +2 -0
- package/lib/bin/reportXml.js +51 -52
- package/lib/bin/startTest.d.ts +2 -0
- package/lib/bin/startTest.js +83 -95
- package/lib/bin/uploadArtifacts.d.ts +2 -0
- package/lib/bin/uploadArtifacts.js +56 -61
- package/lib/client.d.ts +76 -0
- package/lib/client.js +429 -465
- package/lib/config.d.ts +1 -0
- package/lib/config.js +18 -23
- package/lib/constants.d.ts +25 -0
- package/lib/constants.js +50 -44
- package/lib/data-storage.d.ts +34 -0
- package/lib/data-storage.js +216 -188
- package/lib/junit-adapter/adapter.d.ts +9 -0
- package/lib/junit-adapter/adapter.js +17 -20
- package/lib/junit-adapter/csharp.d.ts +5 -0
- package/lib/junit-adapter/csharp.js +28 -14
- package/lib/junit-adapter/index.d.ts +3 -0
- package/lib/junit-adapter/index.js +27 -25
- package/lib/junit-adapter/java.d.ts +5 -0
- package/lib/junit-adapter/java.js +41 -53
- package/lib/junit-adapter/javascript.d.ts +4 -0
- package/lib/junit-adapter/javascript.js +30 -27
- package/lib/junit-adapter/python.d.ts +5 -0
- package/lib/junit-adapter/python.js +38 -37
- package/lib/junit-adapter/ruby.d.ts +4 -0
- package/lib/junit-adapter/ruby.js +11 -8
- package/lib/output.d.ts +11 -0
- package/lib/output.js +44 -52
- package/lib/package.json +3 -0
- package/lib/pipe/bitbucket.d.ts +25 -0
- package/lib/pipe/bitbucket.js +223 -230
- package/lib/pipe/csv.d.ts +47 -0
- package/lib/pipe/csv.js +113 -126
- package/lib/pipe/debug.d.ts +29 -0
- package/lib/pipe/debug.js +125 -99
- package/lib/pipe/github.d.ts +30 -0
- package/lib/pipe/github.js +218 -213
- package/lib/pipe/gitlab.d.ts +25 -0
- package/lib/pipe/gitlab.js +183 -206
- package/lib/pipe/html.d.ts +35 -0
- package/lib/pipe/html.js +258 -321
- package/lib/pipe/index.d.ts +1 -0
- package/lib/pipe/index.js +94 -66
- package/lib/pipe/testomatio.d.ts +71 -0
- package/lib/pipe/testomatio.js +429 -474
- package/lib/replay.d.ts +31 -0
- package/lib/replay.js +255 -0
- package/lib/reporter-functions.d.ts +34 -0
- package/lib/reporter-functions.js +28 -26
- package/lib/reporter.d.ts +232 -0
- package/lib/reporter.js +34 -29
- package/lib/services/artifacts.d.ts +33 -0
- package/lib/services/artifacts.js +55 -51
- package/lib/services/index.d.ts +9 -0
- package/lib/services/index.js +14 -12
- package/lib/services/key-values.d.ts +27 -0
- package/lib/services/key-values.js +56 -53
- package/lib/services/logger.d.ts +64 -0
- package/lib/services/logger.js +226 -245
- package/lib/template/testomatio.hbs +1026 -1366
- package/lib/uploader.d.ts +60 -0
- package/lib/uploader.js +295 -364
- package/lib/utils/pipe_utils.d.ts +41 -0
- package/lib/utils/pipe_utils.js +89 -85
- package/lib/utils/utils.d.ts +54 -0
- package/lib/utils/utils.js +398 -307
- package/lib/xmlReader.d.ts +92 -0
- package/lib/xmlReader.js +525 -532
- package/package.json +64 -21
- package/src/adapter/codecept.js +373 -0
- package/src/adapter/cucumber/current.js +228 -0
- package/src/adapter/cucumber/legacy.js +158 -0
- package/src/adapter/cucumber.js +4 -0
- package/src/adapter/cypress-plugin/index.js +110 -0
- package/src/adapter/jasmine.js +60 -0
- package/src/adapter/jest.js +107 -0
- package/src/adapter/mocha.cjs +2 -0
- package/src/adapter/mocha.js +156 -0
- package/src/adapter/nightwatch.js +88 -0
- package/src/adapter/playwright.js +254 -0
- package/src/adapter/vitest.js +183 -0
- package/src/adapter/webdriver.js +142 -0
- package/src/bin/cli.js +348 -0
- package/src/bin/reportXml.js +77 -0
- package/src/bin/startTest.js +124 -0
- package/src/bin/uploadArtifacts.js +91 -0
- package/src/client.js +515 -0
- package/src/config.js +30 -0
- package/src/constants.js +53 -0
- package/src/data-storage.js +204 -0
- package/src/junit-adapter/adapter.js +23 -0
- package/src/junit-adapter/csharp.js +28 -0
- package/src/junit-adapter/index.js +28 -0
- package/src/junit-adapter/java.js +58 -0
- package/src/junit-adapter/javascript.js +31 -0
- package/src/junit-adapter/python.js +42 -0
- package/src/junit-adapter/ruby.js +10 -0
- package/src/output.js +57 -0
- package/src/pipe/bitbucket.js +252 -0
- package/src/pipe/csv.js +140 -0
- package/src/pipe/debug.js +125 -0
- package/src/pipe/github.js +232 -0
- package/src/pipe/gitlab.js +247 -0
- package/src/pipe/html.js +373 -0
- package/src/pipe/index.js +71 -0
- package/src/pipe/testomatio.js +504 -0
- package/src/replay.js +262 -0
- package/src/reporter-functions.js +55 -0
- package/src/reporter.cjs_decprecated +21 -0
- package/src/reporter.js +33 -0
- package/src/services/artifacts.js +59 -0
- package/src/services/index.js +13 -0
- package/src/services/key-values.js +59 -0
- package/src/services/logger.js +315 -0
- package/src/template/emptyData.svg +23 -0
- package/src/template/testomatio.hbs +1081 -0
- package/src/uploader.js +376 -0
- package/src/utils/pipe_utils.js +119 -0
- package/src/utils/utils.js +416 -0
- package/src/xmlReader.js +614 -0
package/lib/pipe/gitlab.js
CHANGED
|
@@ -1,227 +1,204 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const debug_1 = __importDefault(require("debug"));
|
|
7
|
+
const gaxios_1 = require("gaxios");
|
|
8
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
9
|
+
const humanize_duration_1 = __importDefault(require("humanize-duration"));
|
|
10
|
+
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const constants_js_1 = require("../constants.js");
|
|
13
|
+
const utils_js_1 = require("../utils/utils.js");
|
|
14
|
+
const pipe_utils_js_1 = require("../utils/pipe_utils.js");
|
|
15
|
+
const debug = (0, debug_1.default)('@testomatio/reporter:pipe:gitlab');
|
|
11
16
|
//! GITLAB_PAT environment variable is required for this functionality to work
|
|
12
17
|
//! and your pipeline trigger should be merge_request
|
|
13
|
-
|
|
14
18
|
/**
|
|
15
19
|
* @class GitLabPipe
|
|
16
|
-
* @typedef {import('../../types').Pipe} Pipe
|
|
17
|
-
* @typedef {import('../../types').TestData} TestData
|
|
20
|
+
* @typedef {import('../../types/types.js').Pipe} Pipe
|
|
21
|
+
* @typedef {import('../../types/types.js').TestData} TestData
|
|
18
22
|
*/
|
|
19
23
|
class GitLabPipe {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
constructor(params, store = {}) {
|
|
25
|
+
this.isEnabled = false;
|
|
26
|
+
this.ENV = process.env;
|
|
27
|
+
this.store = store;
|
|
28
|
+
this.tests = [];
|
|
29
|
+
// GitLab PAT looks like glpat-nKGdja3jsG4850sGksh7
|
|
30
|
+
this.token = params.GITLAB_PAT || process.env.GITLAB_PAT || this.ENV.GITLAB_PAT;
|
|
31
|
+
this.hiddenCommentData = `<!--- testomat.io report ${process.env.CI_JOB_NAME || ''} -->`;
|
|
32
|
+
debug(picocolors_1.default.yellow('GitLab Pipe:'), this.token ? 'TOKEN passed' : '*no token*', `Project id: ${this.ENV.CI_PROJECT_ID}, MR id: ${this.ENV.CI_MERGE_REQUEST_IID}`);
|
|
33
|
+
if (!this.ENV.CI_PROJECT_ID || !this.ENV.CI_MERGE_REQUEST_IID) {
|
|
34
|
+
debug(`CI pipeline should be run in Merge Request to have ability to add the report comment.`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!this.token) {
|
|
38
|
+
debug(`Hint: GitLab CI variables are unavailable for unprotected branches by default.`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.isEnabled = true;
|
|
42
|
+
this.client = new gaxios_1.Gaxios({
|
|
43
|
+
baseURL: 'https://gitlab.com/api/v4',
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
debug('GitLab Pipe: Enabled');
|
|
43
49
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const index = this.tests.findIndex(t => isSameTest(t, test));
|
|
59
|
-
// update if they were already added
|
|
60
|
-
if (index >= 0) {
|
|
61
|
-
this.tests[index] = merge(this.tests[index], test);
|
|
62
|
-
return;
|
|
50
|
+
// TODO: to using SET opts as argument => prepareRun(opts)
|
|
51
|
+
async prepareRun() { }
|
|
52
|
+
async createRun() { }
|
|
53
|
+
addTest(test) {
|
|
54
|
+
if (!this.isEnabled)
|
|
55
|
+
return;
|
|
56
|
+
const index = this.tests.findIndex(t => (0, utils_js_1.isSameTest)(t, test));
|
|
57
|
+
// update if they were already added
|
|
58
|
+
if (index >= 0) {
|
|
59
|
+
this.tests[index] = (0, lodash_merge_1.default)(this.tests[index], test);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.tests.push(test);
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const failedCount = this.tests.filter(t => t.status === 'failed').length;
|
|
76
|
-
const skippedCount = this.tests.filter(t => t.status === 'skipped').length;
|
|
77
|
-
|
|
78
|
-
// constructing the table
|
|
79
|
-
let summary = `${this.hiddenCommentData}
|
|
64
|
+
async finishRun(runParams) {
|
|
65
|
+
if (!this.isEnabled)
|
|
66
|
+
return;
|
|
67
|
+
if (runParams.tests)
|
|
68
|
+
runParams.tests.forEach(t => this.addTest(t));
|
|
69
|
+
// ... create a comment on GitLab
|
|
70
|
+
const passedCount = this.tests.filter(t => t.status === 'passed').length;
|
|
71
|
+
const failedCount = this.tests.filter(t => t.status === 'failed').length;
|
|
72
|
+
const skippedCount = this.tests.filter(t => t.status === 'skipped').length;
|
|
73
|
+
// constructing the table
|
|
74
|
+
let summary = `${this.hiddenCommentData}
|
|
80
75
|
|
|
81
|
-
| [](https://testomat.io) | ${statusEmoji(
|
|
82
|
-
runParams.status,
|
|
83
|
-
)} ${runParams.status.toUpperCase()} ${statusEmoji(runParams.status)} |
|
|
76
|
+
| [](https://testomat.io) | ${(0, pipe_utils_js_1.statusEmoji)(runParams.status)} ${runParams.status.toUpperCase()} ${(0, pipe_utils_js_1.statusEmoji)(runParams.status)} |
|
|
84
77
|
| --- | --- |
|
|
85
78
|
| Tests | ✔️ **${this.tests.length}** tests run |
|
|
86
|
-
| Summary | ${statusEmoji('failed')} **${failedCount}** failed; ${statusEmoji(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
parseInt(
|
|
91
|
-
this.tests.reduce((a, t) => a + (t.run_time || 0), 0),
|
|
92
|
-
10,
|
|
93
|
-
),
|
|
94
|
-
{
|
|
95
|
-
maxDecimalPoints: 0,
|
|
96
|
-
},
|
|
97
|
-
)}** |
|
|
79
|
+
| Summary | ${(0, pipe_utils_js_1.statusEmoji)('failed')} **${failedCount}** failed; ${(0, pipe_utils_js_1.statusEmoji)('passed')} **${passedCount}** passed; **${(0, pipe_utils_js_1.statusEmoji)('skipped')}** ${skippedCount} skipped |
|
|
80
|
+
| Duration | 🕐 **${(0, humanize_duration_1.default)(parseInt(this.tests.reduce((a, t) => a + (t.run_time || 0), 0), 10), {
|
|
81
|
+
maxDecimalPoints: 0,
|
|
82
|
+
})}** |
|
|
98
83
|
`;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
84
|
+
if (this.ENV.CI_JOB_NAME && this.ENV.CI_JOB_ID) {
|
|
85
|
+
// eslint-disable-next-line max-len
|
|
86
|
+
summary += `| Job | 👷 [${this.ENV.CI_JOB_ID}](${this.ENV.CI_JOB_URL})<br>Name: **${this.ENV.CI_JOB_NAME}**<br>Stage: **${this.ENV.CI_JOB_STAGE}** | `;
|
|
87
|
+
}
|
|
88
|
+
const failures = this.tests
|
|
89
|
+
.filter(t => t.status === 'failed')
|
|
90
|
+
.slice(0, 20)
|
|
91
|
+
.map(t => {
|
|
92
|
+
let text = `#### ${(0, pipe_utils_js_1.statusEmoji)('failed')} ${(0, pipe_utils_js_1.fullName)(t)} `;
|
|
93
|
+
text += '\n\n';
|
|
94
|
+
if (t.message)
|
|
95
|
+
text += `> ${t.message
|
|
96
|
+
.replace(/[^\x20-\x7E]/g, '')
|
|
97
|
+
.replace((0, utils_js_1.ansiRegExp)(), '')
|
|
98
|
+
.trim()}\n`;
|
|
99
|
+
if (t.stack)
|
|
100
|
+
text += `\`\`\`diff\n${t.stack.replace((0, utils_js_1.ansiRegExp)(), '').trim()}\n\`\`\`\n`;
|
|
101
|
+
if (t.artifacts && t.artifacts.length && !this.ENV.TESTOMATIO_PRIVATE_ARTIFACTS) {
|
|
102
|
+
t.artifacts
|
|
103
|
+
.filter(f => !!f)
|
|
104
|
+
.filter(f => f.endsWith('.png'))
|
|
105
|
+
.forEach(f => {
|
|
106
|
+
if (f.endsWith('.png')) {
|
|
107
|
+
text += `\n`;
|
|
108
|
+
return text;
|
|
109
|
+
}
|
|
110
|
+
text += `[📄 ${path_1.default.basename(f)}](${f})\n`;
|
|
111
|
+
return text;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
text += '\n---\n';
|
|
115
|
+
return text;
|
|
116
|
+
});
|
|
117
|
+
let body = summary;
|
|
118
|
+
if (failures.length) {
|
|
119
|
+
body += `\n<details>\n<summary><h3>🟥 Failures (${failures.length})</h4></summary>\n\n${failures.join('\n')}\n`;
|
|
120
|
+
if (failures.length > 20) {
|
|
121
|
+
body += '\n> Notice\n> Only first 20 failures shown*';
|
|
122
|
+
}
|
|
123
|
+
body += '\n\n</details>';
|
|
124
|
+
}
|
|
125
|
+
if (this.tests.length > 0) {
|
|
126
|
+
body += '\n<details>\n<summary><h3>🐢 Slowest Tests</h3></summary>\n\n';
|
|
127
|
+
body += this.tests
|
|
128
|
+
.sort((a, b) => b?.run_time - a?.run_time)
|
|
129
|
+
.slice(0, 5)
|
|
130
|
+
.map(t => `* ${(0, pipe_utils_js_1.fullName)(t)} (${(0, humanize_duration_1.default)(parseFloat(t.run_time))})`)
|
|
131
|
+
.join('\n');
|
|
132
|
+
body += '\n</details>';
|
|
133
|
+
}
|
|
134
|
+
// eslint-disable-next-line max-len
|
|
135
|
+
const commentsRequestURL = `/projects/${this.ENV.CI_PROJECT_ID}/merge_requests/${this.ENV.CI_MERGE_REQUEST_IID}/notes`;
|
|
136
|
+
// delete previous report
|
|
137
|
+
await deletePreviousReport(this.client, commentsRequestURL, this.hiddenCommentData, this.token);
|
|
138
|
+
// add current report
|
|
139
|
+
debug(`Adding comment via url: ${commentsRequestURL}`);
|
|
140
|
+
try {
|
|
141
|
+
const addCommentResponse = await this.client.request({
|
|
142
|
+
method: 'POST',
|
|
143
|
+
url: commentsRequestURL,
|
|
144
|
+
params: { access_token: this.token },
|
|
145
|
+
data: { body }
|
|
129
146
|
});
|
|
147
|
+
const commentID = addCommentResponse.data.id;
|
|
148
|
+
// eslint-disable-next-line max-len
|
|
149
|
+
const commentURL = `${this.ENV.CI_PROJECT_URL}/-/merge_requests/${this.ENV.CI_MERGE_REQUEST_IID}#note_${commentID}`;
|
|
150
|
+
console.log(constants_js_1.APP_PREFIX, picocolors_1.default.yellow('GitLab'), `Report created: ${picocolors_1.default.magenta(commentURL)}`);
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
console.error(constants_js_1.APP_PREFIX, picocolors_1.default.yellow('GitLab'), `Couldn't create GitLab report\n${err}.
|
|
154
|
+
Request url: ${commentsRequestURL}
|
|
155
|
+
Request data: ${body}`);
|
|
130
156
|
}
|
|
131
|
-
|
|
132
|
-
text += '\n---\n';
|
|
133
|
-
|
|
134
|
-
return text;
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
let body = summary;
|
|
138
|
-
|
|
139
|
-
if (failures.length) {
|
|
140
|
-
body += `\n<details>\n<summary><h3>🟥 Failures (${failures.length})</h4></summary>\n\n${failures.join('\n')}\n`;
|
|
141
|
-
if (failures.length > 20) {
|
|
142
|
-
body += '\n> Notice\n> Only first 20 failures shown*';
|
|
143
|
-
}
|
|
144
|
-
body += '\n\n</details>';
|
|
145
157
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
body += '\n<details>\n<summary><h3>🐢 Slowest Tests</h3></summary>\n\n';
|
|
149
|
-
body += this.tests
|
|
150
|
-
// eslint-disable-next-line no-unsafe-optional-chaining
|
|
151
|
-
.sort((a, b) => b?.run_time - a?.run_time)
|
|
152
|
-
.slice(0, 5)
|
|
153
|
-
.map(t => `* ${fullName(t)} (${humanizeDuration(parseFloat(t.run_time))})`)
|
|
154
|
-
.join('\n');
|
|
155
|
-
body += '\n</details>';
|
|
158
|
+
toString() {
|
|
159
|
+
return 'GitLab Reporter';
|
|
156
160
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// add current report
|
|
165
|
-
debug(`Adding comment via url: ${commentsRequestURL}`);
|
|
166
|
-
|
|
161
|
+
updateRun() { }
|
|
162
|
+
}
|
|
163
|
+
async function deletePreviousReport(client, commentsRequestURL, hiddenCommentData, token) {
|
|
164
|
+
if (process.env.GITLAB_KEEP_OUTDATED_REPORTS)
|
|
165
|
+
return;
|
|
166
|
+
// get comments
|
|
167
|
+
let comments = [];
|
|
167
168
|
try {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
console.log(APP_PREFIX, chalk.yellow('GitLab'), `Report created: ${chalk.magenta(commentURL)}`);
|
|
175
|
-
} catch (err) {
|
|
176
|
-
console.error(
|
|
177
|
-
APP_PREFIX,
|
|
178
|
-
chalk.yellow('GitLab'),
|
|
179
|
-
`Couldn't create GitLab report\n${err}.
|
|
180
|
-
Request url: ${commentsRequestURL}
|
|
181
|
-
Request data: ${body}`,
|
|
182
|
-
);
|
|
169
|
+
const response = await client.request({
|
|
170
|
+
method: 'GET',
|
|
171
|
+
url: commentsRequestURL,
|
|
172
|
+
params: { access_token: token }
|
|
173
|
+
});
|
|
174
|
+
comments = response.data;
|
|
183
175
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (comment.body.includes(hiddenCommentData)) {
|
|
211
|
-
try {
|
|
212
|
-
// delete previous comment
|
|
213
|
-
const deleteCommentURL = `${commentsRequestURL}/${comment.id}?access_token=${token}`;
|
|
214
|
-
await axiosInstance.delete(deleteCommentURL);
|
|
215
|
-
} catch (e) {
|
|
216
|
-
console.warn(`Can't delete previously added comment with testomat.io report. Ignore.`);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// pass next env var if need to clear all previous reports;
|
|
220
|
-
// only the last one is removed by default
|
|
221
|
-
if (!process.env.GITLAB_REMOVE_ALL_OUTDATED_REPORTS) break;
|
|
222
|
-
// TODO: in case of many reports should implement pagination
|
|
176
|
+
catch (e) {
|
|
177
|
+
console.error('Error while attempt to retrieve comments on GitLab Merge Request:\n', e);
|
|
178
|
+
}
|
|
179
|
+
if (!comments.length)
|
|
180
|
+
return;
|
|
181
|
+
for (const comment of comments) {
|
|
182
|
+
// if comment was left by the same workflow
|
|
183
|
+
if (comment.body.includes(hiddenCommentData)) {
|
|
184
|
+
try {
|
|
185
|
+
// delete previous comment
|
|
186
|
+
const deleteCommentURL = `${commentsRequestURL}/${comment.id}`;
|
|
187
|
+
await client.request({
|
|
188
|
+
method: 'DELETE',
|
|
189
|
+
url: deleteCommentURL,
|
|
190
|
+
params: { access_token: token }
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
catch (e) {
|
|
194
|
+
console.warn(`Can't delete previously added comment with testomat.io report. Ignore.`);
|
|
195
|
+
}
|
|
196
|
+
// pass next env var if need to clear all previous reports;
|
|
197
|
+
// only the last one is removed by default
|
|
198
|
+
if (!process.env.GITLAB_REMOVE_ALL_OUTDATED_REPORTS)
|
|
199
|
+
break;
|
|
200
|
+
// TODO: in case of many reports should implement pagination
|
|
201
|
+
}
|
|
223
202
|
}
|
|
224
|
-
}
|
|
225
203
|
}
|
|
226
|
-
|
|
227
204
|
module.exports = GitLabPipe;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default HtmlPipe;
|
|
2
|
+
declare class HtmlPipe {
|
|
3
|
+
constructor(params: any, store?: {});
|
|
4
|
+
store: {};
|
|
5
|
+
title: any;
|
|
6
|
+
apiKey: any;
|
|
7
|
+
isHtml: string;
|
|
8
|
+
isEnabled: boolean;
|
|
9
|
+
htmlOutputPath: string;
|
|
10
|
+
fullHtmlOutputPath: string;
|
|
11
|
+
filenameMsg: string;
|
|
12
|
+
tests: any[];
|
|
13
|
+
htmlReportDir: string;
|
|
14
|
+
htmlReportName: string;
|
|
15
|
+
templateFolderPath: string;
|
|
16
|
+
templateHtmlPath: string;
|
|
17
|
+
createRun(): Promise<void>;
|
|
18
|
+
prepareRun(): Promise<void>;
|
|
19
|
+
updateRun(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Add test data to the result array for saving. As a result of this function, we get a result object to save.
|
|
22
|
+
* @param {import('../../types/types.js').RunData} test - object which includes each test entry.
|
|
23
|
+
*/
|
|
24
|
+
addTest(test: import("../../types/types.js").RunData): void;
|
|
25
|
+
finishRun(runParams: any): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Generates an HTML report based on provided test data and a template.
|
|
28
|
+
* @param {object} opts - Test options used to generate the HTML report:
|
|
29
|
+
* runParams, tests, outputPath, templatePath
|
|
30
|
+
* @returns {void} - This function does not return anything.
|
|
31
|
+
*/
|
|
32
|
+
buildReport(opts: object): void;
|
|
33
|
+
toString(): string;
|
|
34
|
+
#private;
|
|
35
|
+
}
|