@testomatio/reporter 2.0.0-beta-esm → 2.0.0-beta.1-gaxios
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/lib/adapter/codecept.d.ts +2 -0
- package/lib/adapter/codecept.js +31 -26
- package/lib/adapter/cucumber/current.d.ts +14 -0
- package/lib/adapter/cucumber/legacy.d.ts +0 -0
- package/lib/adapter/cucumber.d.ts +2 -0
- package/lib/adapter/cypress-plugin/index.d.ts +2 -0
- package/lib/adapter/cypress-plugin/index.js +10 -10
- package/lib/adapter/jasmine.d.ts +11 -0
- package/lib/adapter/jest.d.ts +13 -0
- package/lib/adapter/mocha.d.ts +2 -0
- package/lib/adapter/mocha.js +4 -4
- 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 +58 -33
- package/lib/adapter/vitest.d.ts +35 -0
- package/lib/adapter/vitest.js +6 -6
- package/lib/adapter/webdriver.d.ts +24 -0
- package/lib/adapter/webdriver.js +51 -14
- package/lib/bin/cli.d.ts +2 -0
- package/lib/bin/cli.js +249 -0
- package/lib/bin/reportXml.d.ts +2 -0
- package/lib/bin/reportXml.js +11 -9
- package/lib/bin/startTest.d.ts +2 -0
- package/lib/bin/startTest.js +9 -5
- package/lib/bin/uploadArtifacts.d.ts +2 -0
- package/lib/bin/uploadArtifacts.js +81 -0
- package/lib/client.d.ts +76 -0
- package/lib/client.js +128 -53
- package/lib/config.d.ts +1 -0
- package/lib/config.js +2 -2
- package/lib/constants.d.ts +25 -0
- package/lib/constants.js +5 -1
- package/lib/data-storage.d.ts +34 -0
- package/lib/data-storage.js +19 -9
- package/lib/junit-adapter/adapter.d.ts +9 -0
- package/lib/junit-adapter/csharp.d.ts +4 -0
- package/lib/junit-adapter/index.d.ts +3 -0
- package/lib/junit-adapter/java.d.ts +5 -0
- package/lib/junit-adapter/javascript.d.ts +4 -0
- package/lib/junit-adapter/python.d.ts +5 -0
- package/lib/junit-adapter/ruby.d.ts +4 -0
- package/lib/output.d.ts +11 -0
- package/lib/package.json +3 -1
- package/lib/pipe/bitbucket.d.ts +25 -0
- package/lib/pipe/bitbucket.js +40 -28
- package/lib/pipe/csv.d.ts +47 -0
- package/lib/pipe/csv.js +2 -2
- package/lib/pipe/debug.d.ts +29 -0
- package/lib/pipe/debug.js +108 -0
- package/lib/pipe/github.d.ts +30 -0
- package/lib/pipe/github.js +37 -5
- package/lib/pipe/gitlab.d.ts +25 -0
- package/lib/pipe/gitlab.js +29 -11
- package/lib/pipe/html.d.ts +35 -0
- package/lib/pipe/html.js +9 -4
- package/lib/pipe/index.d.ts +1 -0
- package/lib/pipe/index.js +20 -10
- package/lib/pipe/testomatio.d.ts +71 -0
- package/lib/pipe/testomatio.js +117 -92
- package/lib/reporter-functions.d.ts +34 -0
- package/lib/reporter-functions.js +17 -7
- package/lib/reporter.d.ts +232 -0
- package/lib/reporter.js +19 -33
- package/lib/services/artifacts.d.ts +33 -0
- package/lib/services/index.d.ts +9 -0
- package/lib/services/key-values.d.ts +27 -0
- package/lib/services/key-values.js +1 -1
- package/lib/services/logger.d.ts +64 -0
- package/lib/services/logger.js +1 -2
- package/lib/template/testomatio.hbs +651 -1366
- package/lib/uploader.d.ts +60 -0
- package/lib/uploader.js +312 -0
- package/lib/utils/pipe_utils.d.ts +41 -0
- package/lib/utils/pipe_utils.js +3 -5
- package/lib/utils/utils.d.ts +45 -0
- package/lib/utils/utils.js +81 -10
- package/lib/xmlReader.d.ts +92 -0
- package/lib/xmlReader.js +28 -16
- package/package.json +19 -14
- package/src/adapter/codecept.js +30 -26
- package/src/adapter/cypress-plugin/index.js +5 -5
- package/src/adapter/mocha.cjs +1 -1
- package/src/adapter/mocha.js +4 -4
- package/src/adapter/nightwatch.js +88 -0
- package/src/adapter/playwright.js +59 -31
- package/src/adapter/vitest.js +6 -6
- package/src/adapter/webdriver.js +41 -11
- package/src/bin/cli.js +302 -0
- package/src/bin/reportXml.js +15 -8
- package/src/bin/startTest.js +7 -3
- package/src/bin/uploadArtifacts.js +90 -0
- package/src/client.js +137 -57
- package/src/config.js +2 -2
- package/src/constants.js +5 -1
- package/src/data-storage.js +2 -2
- package/src/pipe/bitbucket.js +24 -26
- package/src/pipe/csv.js +3 -3
- package/src/pipe/debug.js +104 -0
- package/src/pipe/github.js +3 -5
- package/src/pipe/gitlab.js +33 -15
- package/src/pipe/html.js +14 -7
- package/src/pipe/index.js +5 -7
- package/src/pipe/testomatio.js +156 -158
- package/src/reporter-functions.js +18 -7
- package/src/reporter.cjs_decprecated +21 -0
- package/src/reporter.js +20 -11
- package/src/services/key-values.js +1 -1
- package/src/services/logger.js +5 -4
- package/src/template/testomatio.hbs +651 -1366
- package/src/uploader.js +371 -0
- package/src/utils/pipe_utils.js +4 -12
- package/src/utils/utils.js +50 -14
- package/src/xmlReader.js +32 -18
- package/lib/adapter/jasmine/jasmine.js +0 -63
- package/lib/adapter/mocha/mocha.js +0 -125
- package/lib/fileUploader.js +0 -245
- package/lib/utils/chalk.js +0 -10
- package/src/fileUploader.js +0 -307
- package/src/reporter.cjs +0 -22
- package/src/utils/chalk.js +0 -13
package/lib/pipe/testomatio.js
CHANGED
|
@@ -5,22 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const debug_1 = __importDefault(require("debug"));
|
|
7
7
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
|
-
|
|
9
|
-
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
10
|
-
// Default axios instance
|
|
11
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const gaxios_1 = require("gaxios");
|
|
12
9
|
const json_cycle_1 = __importDefault(require("json-cycle"));
|
|
13
10
|
const constants_js_1 = require("../constants.js");
|
|
14
11
|
const utils_js_1 = require("../utils/utils.js");
|
|
15
12
|
const pipe_utils_js_1 = require("../utils/pipe_utils.js");
|
|
16
13
|
const config_js_1 = require("../config.js");
|
|
17
14
|
const debug = (0, debug_1.default)('@testomatio/reporter:pipe:testomatio');
|
|
18
|
-
if (process.env.TESTOMATIO_RUN)
|
|
19
|
-
|
|
20
|
-
}
|
|
15
|
+
if (process.env.TESTOMATIO_RUN)
|
|
16
|
+
process.env.runId = process.env.TESTOMATIO_RUN;
|
|
21
17
|
/**
|
|
22
|
-
* @typedef {import('../../types').Pipe} Pipe
|
|
23
|
-
* @typedef {import('../../types').TestData} TestData
|
|
18
|
+
* @typedef {import('../../types/types.js').Pipe} Pipe
|
|
19
|
+
* @typedef {import('../../types/types.js').TestData} TestData
|
|
24
20
|
* @class TestomatioPipe
|
|
25
21
|
* @implements {Pipe}
|
|
26
22
|
*/
|
|
@@ -55,48 +51,39 @@ class TestomatioPipe {
|
|
|
55
51
|
this.groupTitle = params.groupTitle || process.env.TESTOMATIO_RUNGROUP_TITLE;
|
|
56
52
|
this.env = process.env.TESTOMATIO_ENV;
|
|
57
53
|
this.label = process.env.TESTOMATIO_LABEL;
|
|
58
|
-
// Create a new instance of
|
|
59
|
-
this.
|
|
54
|
+
// Create a new instance of gaxios with a custom config
|
|
55
|
+
this.client = new gaxios_1.Gaxios({
|
|
60
56
|
baseURL: `${this.url.trim()}`,
|
|
61
57
|
timeout: constants_js_1.AXIOS_TIMEOUT,
|
|
62
|
-
proxy: proxy ?
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(0, axios_retry_1.default)(this.axios, {
|
|
70
|
-
// do not use retries for unit tests
|
|
71
|
-
retries: constants_js_1.REPORTER_REQUEST_RETRIES.retriesPerRequest, // Number of retries
|
|
72
|
-
shouldResetTimeout: true,
|
|
73
|
-
retryCondition: error => {
|
|
74
|
-
if (!error.response)
|
|
75
|
-
return false;
|
|
76
|
-
switch (error.response?.status) {
|
|
77
|
-
case 400: // Bad request (probably wrong API key)
|
|
78
|
-
case 404: // Test not matched
|
|
79
|
-
case 429: // Rate limit exceeded
|
|
80
|
-
case 500: // Internal server error
|
|
58
|
+
proxy: proxy ? proxy.toString() : undefined,
|
|
59
|
+
retry: true,
|
|
60
|
+
retryConfig: {
|
|
61
|
+
retry: constants_js_1.REPORTER_REQUEST_RETRIES.retriesPerRequest,
|
|
62
|
+
retryDelay: constants_js_1.REPORTER_REQUEST_RETRIES.retryTimeout,
|
|
63
|
+
shouldRetry: (error) => {
|
|
64
|
+
if (!error.response)
|
|
81
65
|
return false;
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
switch (error.response?.status) {
|
|
67
|
+
case 400: // Bad request (probably wrong API key)
|
|
68
|
+
case 404: // Test not matched
|
|
69
|
+
case 429: // Rate limit exceeded
|
|
70
|
+
case 500: // Internal server error
|
|
71
|
+
return false;
|
|
72
|
+
default:
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return error.response?.status >= 401; // Retry on 401+ and 5xx
|
|
84
76
|
}
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
retryDelay: () => constants_js_1.REPORTER_REQUEST_RETRIES.retryTimeout, // sum = 15sec
|
|
88
|
-
onRetry: async (retryCount, error) => {
|
|
89
|
-
this.retriesTimestamps.push(Date.now());
|
|
90
|
-
debug(`${error.message || `Request failed ${error.status}`}. Retry #${retryCount} ...`);
|
|
91
|
-
},
|
|
77
|
+
}
|
|
92
78
|
});
|
|
93
79
|
this.isEnabled = true;
|
|
94
80
|
// do not finish this run (for parallel testing)
|
|
95
81
|
this.proceed = process.env.TESTOMATIO_PROCEED;
|
|
96
82
|
this.jiraId = process.env.TESTOMATIO_JIRA_ID;
|
|
97
|
-
this.runId = params.runId || process.env.
|
|
83
|
+
this.runId = params.runId || process.env.TESTOMATIO_RUN;
|
|
98
84
|
this.createNewTests = params.createNewTests ?? !!process.env.TESTOMATIO_CREATE;
|
|
99
85
|
this.hasUnmatchedTests = false;
|
|
86
|
+
this.requestFailures = 0;
|
|
100
87
|
if (!(0, utils_js_1.isValidUrl)(this.url.trim())) {
|
|
101
88
|
this.isEnabled = false;
|
|
102
89
|
console.error(constants_js_1.APP_PREFIX, picocolors_1.default.red(`Error creating report on Testomat.io, report url '${this.url}' is invalid`));
|
|
@@ -122,11 +109,14 @@ class TestomatioPipe {
|
|
|
122
109
|
if (!q) {
|
|
123
110
|
return;
|
|
124
111
|
}
|
|
125
|
-
const resp = await this.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
112
|
+
const resp = await this.client.request({
|
|
113
|
+
method: 'GET',
|
|
114
|
+
url: '/api/test_grep',
|
|
115
|
+
params: q
|
|
116
|
+
});
|
|
117
|
+
if (Array.isArray(resp.data?.tests) && resp.data?.tests?.length > 0) {
|
|
118
|
+
(0, utils_js_1.foundedTestLog)(constants_js_1.APP_PREFIX, resp.data.tests);
|
|
119
|
+
return resp.data.tests;
|
|
130
120
|
}
|
|
131
121
|
console.log(constants_js_1.APP_PREFIX, `⛔ No tests found for your --filter --> ${type}=${id}`);
|
|
132
122
|
}
|
|
@@ -141,15 +131,13 @@ class TestomatioPipe {
|
|
|
141
131
|
*/
|
|
142
132
|
async createRun(params = {}) {
|
|
143
133
|
this.batch.isEnabled = params.isBatchEnabled ?? this.batch.isEnabled;
|
|
144
|
-
debug('Creating run...');
|
|
145
134
|
if (!this.isEnabled)
|
|
146
135
|
return;
|
|
147
|
-
if (this.batch.isEnabled)
|
|
136
|
+
if (this.batch.isEnabled && this.isEnabled)
|
|
148
137
|
this.batch.intervalFunction = setInterval(this.#batchUpload, this.batch.intervalTime);
|
|
149
138
|
let buildUrl = process.env.BUILD_URL || process.env.CI_JOB_URL || process.env.CIRCLE_BUILD_URL;
|
|
150
139
|
// GitHub Actions Url
|
|
151
140
|
if (!buildUrl && process.env.GITHUB_RUN_ID) {
|
|
152
|
-
// eslint-disable-next-line max-len
|
|
153
141
|
buildUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
|
|
154
142
|
}
|
|
155
143
|
// Azure DevOps Url
|
|
@@ -177,17 +165,27 @@ class TestomatioPipe {
|
|
|
177
165
|
}).filter(([, value]) => !!value));
|
|
178
166
|
debug(' >>>>>> Run params', JSON.stringify(runParams, null, 2));
|
|
179
167
|
if (this.runId) {
|
|
168
|
+
this.store.runId = this.runId;
|
|
180
169
|
debug(`Run with id ${this.runId} already created, updating...`);
|
|
181
|
-
const resp = await this.
|
|
170
|
+
const resp = await this.client.request({
|
|
171
|
+
method: 'PUT',
|
|
172
|
+
url: `/api/reporter/${this.runId}`,
|
|
173
|
+
data: runParams
|
|
174
|
+
});
|
|
182
175
|
if (resp.data.artifacts)
|
|
183
176
|
(0, pipe_utils_js_1.setS3Credentials)(resp.data.artifacts);
|
|
184
177
|
return;
|
|
185
178
|
}
|
|
179
|
+
debug('Creating run...');
|
|
186
180
|
try {
|
|
187
|
-
const resp = await this.
|
|
181
|
+
const resp = await this.client.request({
|
|
182
|
+
method: 'POST',
|
|
183
|
+
url: '/api/reporter',
|
|
184
|
+
data: runParams,
|
|
188
185
|
maxContentLength: Infinity,
|
|
189
|
-
|
|
186
|
+
responseType: 'json'
|
|
190
187
|
});
|
|
188
|
+
debug('Run created!', resp);
|
|
191
189
|
this.runId = resp.data.uid;
|
|
192
190
|
this.runUrl = `${this.url}/${resp.data.url.split('/').splice(3).join('/')}`;
|
|
193
191
|
this.runPublicUrl = resp.data.public_url;
|
|
@@ -201,37 +199,40 @@ class TestomatioPipe {
|
|
|
201
199
|
debug('Run created', this.runId);
|
|
202
200
|
}
|
|
203
201
|
catch (err) {
|
|
204
|
-
|
|
202
|
+
const errorText = err.response?.data?.message || err.message;
|
|
203
|
+
debug('Error creating run', errorText || err);
|
|
204
|
+
console.log(errorText || err);
|
|
205
|
+
if (!this.apiKey)
|
|
206
|
+
console.error('Testomat.io API key is not set');
|
|
207
|
+
if (!this.apiKey?.startsWith('tstmt'))
|
|
208
|
+
console.error('Testomat.io API key is invalid');
|
|
209
|
+
console.error(constants_js_1.APP_PREFIX, 'Error creating Testomat.io report (see details above), please check if your API key is valid. Skipping report');
|
|
205
210
|
printCreateIssue(err);
|
|
206
211
|
}
|
|
207
212
|
debug('"createRun" function finished');
|
|
208
213
|
}
|
|
209
214
|
/**
|
|
210
215
|
* Decides whether to skip test reporting in case of too many request failures
|
|
211
|
-
* @param {TestData} testData
|
|
212
216
|
* @returns {boolean}
|
|
213
217
|
*/
|
|
214
|
-
#cancelTestReportingInCaseOfTooManyReqFailures(
|
|
215
|
-
if (
|
|
216
|
-
return
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
if (retriesCountWithinTime > constants_js_1.REPORTER_REQUEST_RETRIES.maxTotalRetries) {
|
|
220
|
-
const errorMessage = picocolors_1.default.yellow(`${retriesCountWithinTime} requests were failed within ${constants_js_1.REPORTER_REQUEST_RETRIES.withinTimeSeconds}s,\
|
|
221
|
-
reporting for test "${testData.title}" to Testomat is skipped`);
|
|
222
|
-
console.warn(`${constants_js_1.APP_PREFIX} ${errorMessage}`);
|
|
218
|
+
#cancelTestReportingInCaseOfTooManyReqFailures() {
|
|
219
|
+
if (!process.env.TESTOMATIO_MAX_REQUEST_FAILURES)
|
|
220
|
+
return;
|
|
221
|
+
const cancelReporting = this.requestFailures >= parseInt(process.env.TESTOMATIO_MAX_REQUEST_FAILURES, 10);
|
|
222
|
+
if (cancelReporting) {
|
|
223
223
|
this.reportingCanceledDueToReqFailures = true;
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
let errorMessage = `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES}`;
|
|
225
|
+
errorMessage += ' requests were failed, reporting to Testomat aborted.';
|
|
226
|
+
console.warn(`${constants_js_1.APP_PREFIX} ${picocolors_1.default.yellow(errorMessage)}`);
|
|
226
227
|
}
|
|
227
|
-
return
|
|
228
|
+
return cancelReporting;
|
|
228
229
|
}
|
|
229
230
|
#uploadSingleTest = async (data) => {
|
|
230
231
|
if (!this.isEnabled)
|
|
231
232
|
return;
|
|
232
233
|
if (!this.runId)
|
|
233
234
|
return;
|
|
234
|
-
if (this.#cancelTestReportingInCaseOfTooManyReqFailures(
|
|
235
|
+
if (this.#cancelTestReportingInCaseOfTooManyReqFailures())
|
|
235
236
|
return;
|
|
236
237
|
data.api_key = this.apiKey;
|
|
237
238
|
data.create = this.createNewTests;
|
|
@@ -240,9 +241,17 @@ class TestomatioPipe {
|
|
|
240
241
|
}
|
|
241
242
|
const json = json_cycle_1.default.stringify(data);
|
|
242
243
|
debug('Adding test', json);
|
|
243
|
-
return this.
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
return this.client.request({
|
|
245
|
+
method: 'POST',
|
|
246
|
+
url: `/api/reporter/${this.runId}/testrun`,
|
|
247
|
+
data: json,
|
|
248
|
+
headers: {
|
|
249
|
+
'Content-Type': 'application/json',
|
|
250
|
+
},
|
|
251
|
+
maxContentLength: Infinity
|
|
252
|
+
}).catch(err => {
|
|
253
|
+
this.requestFailures++;
|
|
254
|
+
this.notReportedTestsCount++;
|
|
246
255
|
if (err.response) {
|
|
247
256
|
if (err.response.status >= 400) {
|
|
248
257
|
const responseData = err.response.data || { message: '' };
|
|
@@ -266,6 +275,10 @@ class TestomatioPipe {
|
|
|
266
275
|
#batchUpload = async () => {
|
|
267
276
|
if (!this.batch.isEnabled)
|
|
268
277
|
return;
|
|
278
|
+
if (!this.batch.tests.length)
|
|
279
|
+
return;
|
|
280
|
+
if (this.#cancelTestReportingInCaseOfTooManyReqFailures())
|
|
281
|
+
return;
|
|
269
282
|
// prevent infinite loop
|
|
270
283
|
if (this.batch.numberOfTimesCalledWithoutTests > 10) {
|
|
271
284
|
debug('📨 Batch upload: no tests to send for 10 times, stopping batch');
|
|
@@ -281,9 +294,21 @@ class TestomatioPipe {
|
|
|
281
294
|
// get tests from batch and clear batch
|
|
282
295
|
const testsToSend = this.batch.tests.splice(0);
|
|
283
296
|
debug('📨 Batch upload', testsToSend.length, 'tests');
|
|
284
|
-
return this.
|
|
285
|
-
|
|
286
|
-
|
|
297
|
+
return this.client.request({
|
|
298
|
+
method: 'POST',
|
|
299
|
+
url: `/api/reporter/${this.runId}/testrun`,
|
|
300
|
+
data: {
|
|
301
|
+
api_key: this.apiKey,
|
|
302
|
+
tests: testsToSend,
|
|
303
|
+
batch_index: this.batch.batchIndex
|
|
304
|
+
},
|
|
305
|
+
headers: {
|
|
306
|
+
'Content-Type': 'application/json',
|
|
307
|
+
},
|
|
308
|
+
maxContentLength: Infinity
|
|
309
|
+
}).catch(err => {
|
|
310
|
+
this.requestFailures++;
|
|
311
|
+
this.notReportedTestsCount += testsToSend.length;
|
|
287
312
|
if (err.response) {
|
|
288
313
|
if (err.response.status >= 400) {
|
|
289
314
|
const responseData = err.response.data || { message: '' };
|
|
@@ -323,15 +348,21 @@ class TestomatioPipe {
|
|
|
323
348
|
this.#batchUpload();
|
|
324
349
|
}
|
|
325
350
|
/**
|
|
326
|
-
* @param {import('../../types').RunData} params
|
|
351
|
+
* @param {import('../../types/types.js').RunData} params
|
|
327
352
|
* @returns
|
|
328
353
|
*/
|
|
329
354
|
async finishRun(params) {
|
|
330
355
|
if (!this.isEnabled)
|
|
331
356
|
return;
|
|
332
|
-
if (this.batch.intervalFunction)
|
|
333
|
-
clearInterval(this.batch.intervalFunction);
|
|
334
357
|
await this.#batchUpload();
|
|
358
|
+
if (this.batch.intervalFunction) {
|
|
359
|
+
clearInterval(this.batch.intervalFunction);
|
|
360
|
+
// this code is required in case test is added after run is finished
|
|
361
|
+
// (e.g. if test has artifacts, add test function will be invoked only after artifacts are uploaded)
|
|
362
|
+
// batch stops working after run is finished; thus, disable it to use single test uploading
|
|
363
|
+
this.batch.intervalFunction = null;
|
|
364
|
+
this.batch.isEnabled = false;
|
|
365
|
+
}
|
|
335
366
|
debug('Finishing run...');
|
|
336
367
|
if (this.reportingCanceledDueToReqFailures) {
|
|
337
368
|
const errorMessage = picocolors_1.default.red(`⚠️ Due to request failures, ${this.notReportedTestsCount} test(s) were not reported to Testomat.io`);
|
|
@@ -349,10 +380,16 @@ class TestomatioPipe {
|
|
|
349
380
|
status_event += '_parallel';
|
|
350
381
|
try {
|
|
351
382
|
if (this.runId && !this.proceed) {
|
|
352
|
-
await this.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
383
|
+
await this.client.request({
|
|
384
|
+
method: 'PUT',
|
|
385
|
+
url: `/api/reporter/${this.runId}`,
|
|
386
|
+
data: {
|
|
387
|
+
api_key: this.apiKey,
|
|
388
|
+
duration: params.duration,
|
|
389
|
+
status_event,
|
|
390
|
+
detach: params.detach,
|
|
391
|
+
tests: params.tests,
|
|
392
|
+
}
|
|
356
393
|
});
|
|
357
394
|
if (this.runUrl) {
|
|
358
395
|
console.log(constants_js_1.APP_PREFIX, '📊 Report Saved. Report URL:', picocolors_1.default.magenta(this.runUrl));
|
|
@@ -368,17 +405,13 @@ class TestomatioPipe {
|
|
|
368
405
|
}
|
|
369
406
|
if (this.hasUnmatchedTests) {
|
|
370
407
|
console.log('');
|
|
371
|
-
// eslint-disable-next-line max-len
|
|
372
408
|
console.log(constants_js_1.APP_PREFIX, picocolors_1.default.yellow(picocolors_1.default.bold('⚠️ Some reported tests were not found in Testomat.io project')));
|
|
373
|
-
// eslint-disable-next-line max-len
|
|
374
409
|
console.log(constants_js_1.APP_PREFIX, `If you use Testomat.io as a reporter only, please re-run tests using ${picocolors_1.default.bold('TESTOMATIO_CREATE=1')}`);
|
|
375
|
-
// eslint-disable-next-line max-len
|
|
376
410
|
console.log(constants_js_1.APP_PREFIX, `But to keep your tests consistent it is recommended to ${picocolors_1.default.bold('import tests first')}`);
|
|
377
411
|
console.log(constants_js_1.APP_PREFIX, 'If tests were imported but still not matched, assign test IDs to your tests.');
|
|
378
412
|
console.log(constants_js_1.APP_PREFIX, 'You can do that automatically via command line tools:');
|
|
379
413
|
console.log(constants_js_1.APP_PREFIX, picocolors_1.default.bold('npx check-tests ... --update-ids'), 'See: https://bit.ly/js-update-ids');
|
|
380
414
|
console.log(constants_js_1.APP_PREFIX, 'or for Cucumber:');
|
|
381
|
-
// eslint-disable-next-line max-len
|
|
382
415
|
console.log(constants_js_1.APP_PREFIX, picocolors_1.default.bold('npx check-cucumber ... --update-ids'), 'See: https://bit.ly/bdd-update-ids');
|
|
383
416
|
}
|
|
384
417
|
}
|
|
@@ -400,7 +433,7 @@ function printCreateIssue(err) {
|
|
|
400
433
|
process.on('exit', () => {
|
|
401
434
|
console.log();
|
|
402
435
|
console.log(constants_js_1.APP_PREFIX, 'There was an error reporting to Testomat.io:');
|
|
403
|
-
console.log(constants_js_1.APP_PREFIX, 'If you think this is a bug please create an issue: https://github.com/testomatio/reporter/issues/new');
|
|
436
|
+
console.log(constants_js_1.APP_PREFIX, 'If you think this is a bug please create an issue: https://github.com/testomatio/reporter/issues/new');
|
|
404
437
|
console.log(constants_js_1.APP_PREFIX, 'Provide this information:');
|
|
405
438
|
console.log('Error:', err.message || err.code);
|
|
406
439
|
if (!err.config)
|
|
@@ -412,12 +445,4 @@ function printCreateIssue(err) {
|
|
|
412
445
|
console.log('```');
|
|
413
446
|
});
|
|
414
447
|
}
|
|
415
|
-
const axiosAddTestrunRequestConfig = {
|
|
416
|
-
maxContentLength: Infinity,
|
|
417
|
-
maxBodyLength: Infinity,
|
|
418
|
-
headers: {
|
|
419
|
-
// Overwrite Axios's automatically set Content-Type
|
|
420
|
-
'Content-Type': 'application/json',
|
|
421
|
-
},
|
|
422
|
-
};
|
|
423
448
|
module.exports = TestomatioPipe;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export { saveArtifact as artifact };
|
|
3
|
+
export { logMessage as log };
|
|
4
|
+
export { addStep as step };
|
|
5
|
+
export { setKeyValue as keyValue };
|
|
6
|
+
}
|
|
7
|
+
export default _default;
|
|
8
|
+
/**
|
|
9
|
+
* Stores path to file as artifact and uploads it to the S3 storage
|
|
10
|
+
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
11
|
+
*/
|
|
12
|
+
declare function saveArtifact(data: string | {
|
|
13
|
+
path: string;
|
|
14
|
+
type: string;
|
|
15
|
+
name: string;
|
|
16
|
+
}, context?: any): void;
|
|
17
|
+
/**
|
|
18
|
+
* Attach log message(s) to the test report
|
|
19
|
+
* @param string
|
|
20
|
+
*/
|
|
21
|
+
declare function logMessage(...args: any[]): void;
|
|
22
|
+
/**
|
|
23
|
+
* Similar to "log" function but marks message in report as a step
|
|
24
|
+
* @param {string} message
|
|
25
|
+
*/
|
|
26
|
+
declare function addStep(message: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Add key-value pair(s) to the test report
|
|
29
|
+
* @param {{[key: string]: string} | string} keyValue object { key: value } (multiple props allowed) or key (string)
|
|
30
|
+
* @param {string?} value
|
|
31
|
+
*/
|
|
32
|
+
declare function setKeyValue(keyValue: {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
} | string, value?: string | null): void;
|
|
@@ -1,37 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const index_js_1 = require("./services/index.js");
|
|
4
|
-
const playwright_js_1 = require("./adapter/playwright.js");
|
|
5
|
-
if (process.env.PLAYWRIGHT_TEST_BASE_URL)
|
|
6
|
-
(0, playwright_js_1.initPlaywrightForStorage)();
|
|
7
4
|
/**
|
|
8
5
|
* Stores path to file as artifact and uploads it to the S3 storage
|
|
9
6
|
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
10
7
|
*/
|
|
11
8
|
function saveArtifact(data, context = null) {
|
|
9
|
+
if (process.env.IS_PLAYWRIGHT)
|
|
10
|
+
throw new Error(`This function is not available in Playwright framework.
|
|
11
|
+
/Playwright supports artifacts out of the box`);
|
|
12
12
|
if (!data)
|
|
13
13
|
return;
|
|
14
14
|
index_js_1.services.artifacts.put(data, context);
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Attach log message(s) to the test report
|
|
18
|
-
* @param
|
|
18
|
+
* @param string
|
|
19
19
|
*/
|
|
20
20
|
function logMessage(...args) {
|
|
21
|
+
if (process.env.IS_PLAYWRIGHT)
|
|
22
|
+
throw new Error('This function is not available in Playwright framework');
|
|
21
23
|
index_js_1.services.logger._templateLiteralLog(...args);
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Similar to "log" function but marks message in report as a step
|
|
25
|
-
* @param {
|
|
27
|
+
* @param {string} message
|
|
26
28
|
*/
|
|
27
29
|
function addStep(message) {
|
|
30
|
+
if (process.env.IS_PLAYWRIGHT)
|
|
31
|
+
throw new Error('This function is not available in Playwright framework. Use playwright steps');
|
|
28
32
|
index_js_1.services.logger.step(message);
|
|
29
33
|
}
|
|
30
34
|
/**
|
|
31
35
|
* Add key-value pair(s) to the test report
|
|
32
|
-
* @param {
|
|
36
|
+
* @param {{[key: string]: string} | string} keyValue object { key: value } (multiple props allowed) or key (string)
|
|
37
|
+
* @param {string?} value
|
|
33
38
|
*/
|
|
34
|
-
function setKeyValue(keyValue) {
|
|
39
|
+
function setKeyValue(keyValue, value = null) {
|
|
40
|
+
if (process.env.IS_PLAYWRIGHT)
|
|
41
|
+
throw new Error('This function is not available in Playwright framework. Use test tag instead.');
|
|
42
|
+
if (typeof keyValue === 'string') {
|
|
43
|
+
keyValue = { [keyValue]: value };
|
|
44
|
+
}
|
|
35
45
|
index_js_1.services.keyValues.put(keyValue);
|
|
36
46
|
}
|
|
37
47
|
module.exports = {
|