@testomatio/reporter 2.0.0-beta-esm → 2.0.1-beta-esm
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 -24
- 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 +11 -9
- 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 -3
- 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 +34 -6
- package/lib/bin/cli.d.ts +2 -0
- package/lib/bin/cli.js +228 -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 +111 -45
- package/lib/config.d.ts +1 -0
- 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 +2 -2
- 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 +23 -0
- package/lib/pipe/bitbucket.js +2 -2
- 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 +2 -2
- package/lib/pipe/gitlab.d.ts +23 -0
- package/lib/pipe/gitlab.js +2 -2
- package/lib/pipe/html.d.ts +34 -0
- package/lib/pipe/html.js +8 -1
- package/lib/pipe/index.d.ts +1 -0
- package/lib/pipe/index.js +3 -3
- package/lib/pipe/testomatio.d.ts +70 -0
- package/lib/pipe/testomatio.js +50 -30
- 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/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 +69 -2
- package/lib/xmlReader.d.ts +92 -0
- package/lib/xmlReader.js +22 -12
- package/package.json +15 -9
- package/src/adapter/codecept.js +30 -24
- package/src/adapter/cypress-plugin/index.js +5 -3
- package/src/adapter/mocha.cjs +1 -1
- package/src/adapter/mocha.js +4 -3
- package/src/adapter/playwright.js +59 -31
- package/src/adapter/vitest.js +6 -6
- package/src/adapter/webdriver.js +41 -10
- package/src/bin/cli.js +280 -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 -56
- package/src/constants.js +5 -1
- package/src/data-storage.js +2 -2
- package/src/pipe/bitbucket.js +2 -2
- package/src/pipe/csv.js +3 -3
- package/src/pipe/debug.js +104 -0
- package/src/pipe/github.js +2 -3
- package/src/pipe/gitlab.js +6 -6
- package/src/pipe/html.js +11 -3
- package/src/pipe/index.js +5 -7
- package/src/pipe/testomatio.js +72 -67
- 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 +4 -2
- 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 +48 -6
- package/src/xmlReader.js +26 -15
- 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/src/pipe/testomatio.js
CHANGED
|
@@ -11,18 +11,17 @@ import JsonCycle from 'json-cycle';
|
|
|
11
11
|
import { APP_PREFIX, STATUS, AXIOS_TIMEOUT, REPORTER_REQUEST_RETRIES } from '../constants.js';
|
|
12
12
|
import { isValidUrl, foundedTestLog } from '../utils/utils.js';
|
|
13
13
|
import { parseFilterParams, generateFilterRequestParams, setS3Credentials } from '../utils/pipe_utils.js';
|
|
14
|
-
import {config} from '../config.js';
|
|
14
|
+
import { config } from '../config.js';
|
|
15
15
|
|
|
16
16
|
const debug = createDebugMessages('@testomatio/reporter:pipe:testomatio');
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
if (process.env.TESTOMATIO_RUN) {
|
|
20
19
|
// process.env.runId = process.env.TESTOMATIO_RUN;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
|
-
* @typedef {import('../../types').Pipe} Pipe
|
|
25
|
-
* @typedef {import('../../types').TestData} TestData
|
|
23
|
+
* @typedef {import('../../types/types.js').Pipe} Pipe
|
|
24
|
+
* @typedef {import('../../types/types.js').TestData} TestData
|
|
26
25
|
* @class TestomatioPipe
|
|
27
26
|
* @implements {Pipe}
|
|
28
27
|
*/
|
|
@@ -64,11 +63,13 @@ class TestomatioPipe {
|
|
|
64
63
|
this.axios = axios.create({
|
|
65
64
|
baseURL: `${this.url.trim()}`,
|
|
66
65
|
timeout: AXIOS_TIMEOUT,
|
|
67
|
-
proxy: proxy
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
proxy: proxy
|
|
67
|
+
? {
|
|
68
|
+
host: proxy.hostname,
|
|
69
|
+
port: parseInt(proxy.port, 10),
|
|
70
|
+
protocol: proxy.protocol,
|
|
71
|
+
}
|
|
72
|
+
: false,
|
|
72
73
|
});
|
|
73
74
|
|
|
74
75
|
// Pass the axios instance to the retry function
|
|
@@ -104,6 +105,7 @@ class TestomatioPipe {
|
|
|
104
105
|
this.runId = params.runId || process.env.runId;
|
|
105
106
|
this.createNewTests = params.createNewTests ?? !!process.env.TESTOMATIO_CREATE;
|
|
106
107
|
this.hasUnmatchedTests = false;
|
|
108
|
+
this.requestFailures = 0;
|
|
107
109
|
|
|
108
110
|
if (!isValidUrl(this.url.trim())) {
|
|
109
111
|
this.isEnabled = false;
|
|
@@ -155,9 +157,9 @@ class TestomatioPipe {
|
|
|
155
157
|
*/
|
|
156
158
|
async createRun(params = {}) {
|
|
157
159
|
this.batch.isEnabled = params.isBatchEnabled ?? this.batch.isEnabled;
|
|
158
|
-
debug('Creating run...');
|
|
159
160
|
if (!this.isEnabled) return;
|
|
160
|
-
if (this.batch.isEnabled
|
|
161
|
+
if (this.batch.isEnabled && this.isEnabled)
|
|
162
|
+
this.batch.intervalFunction = setInterval(this.#batchUpload, this.batch.intervalTime);
|
|
161
163
|
|
|
162
164
|
let buildUrl = process.env.BUILD_URL || process.env.CI_JOB_URL || process.env.CIRCLE_BUILD_URL;
|
|
163
165
|
|
|
@@ -197,12 +199,14 @@ class TestomatioPipe {
|
|
|
197
199
|
debug(' >>>>>> Run params', JSON.stringify(runParams, null, 2));
|
|
198
200
|
|
|
199
201
|
if (this.runId) {
|
|
202
|
+
this.store.runId = this.runId;
|
|
200
203
|
debug(`Run with id ${this.runId} already created, updating...`);
|
|
201
204
|
const resp = await this.axios.put(`/api/reporter/${this.runId}`, runParams);
|
|
202
205
|
if (resp.data.artifacts) setS3Credentials(resp.data.artifacts);
|
|
203
206
|
return;
|
|
204
207
|
}
|
|
205
208
|
|
|
209
|
+
debug('Creating run...');
|
|
206
210
|
try {
|
|
207
211
|
const resp = await this.axios.post(`/api/reporter`, runParams, {
|
|
208
212
|
maxContentLength: Infinity,
|
|
@@ -222,10 +226,14 @@ class TestomatioPipe {
|
|
|
222
226
|
process.env.runId = this.runId;
|
|
223
227
|
debug('Run created', this.runId);
|
|
224
228
|
} catch (err) {
|
|
229
|
+
const errorText = err.response?.data?.message || err.message;
|
|
230
|
+
console.log(errorText || err);
|
|
231
|
+
if (!this.apiKey) console.error('Testomat.io API key is not set');
|
|
232
|
+
if (!this.apiKey?.startsWith('tstmt')) console.error('Testomat.io API key is invalid');
|
|
233
|
+
|
|
225
234
|
console.error(
|
|
226
235
|
APP_PREFIX,
|
|
227
|
-
'Error creating Testomat.io report, please check if your API key is valid. Skipping report
|
|
228
|
-
err?.response?.statusText || err?.status || err.message,
|
|
236
|
+
'Error creating Testomat.io report (see details above), please check if your API key is valid. Skipping report',
|
|
229
237
|
);
|
|
230
238
|
printCreateIssue(err);
|
|
231
239
|
}
|
|
@@ -234,37 +242,25 @@ class TestomatioPipe {
|
|
|
234
242
|
|
|
235
243
|
/**
|
|
236
244
|
* Decides whether to skip test reporting in case of too many request failures
|
|
237
|
-
* @param {TestData} testData
|
|
238
245
|
* @returns {boolean}
|
|
239
246
|
*/
|
|
240
|
-
#cancelTestReportingInCaseOfTooManyReqFailures(
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
const retriesCountWithinTime = this.retriesTimestamps.filter(
|
|
244
|
-
timestamp => Date.now() - timestamp < REPORTER_REQUEST_RETRIES.withinTimeSeconds * 1000,
|
|
245
|
-
).length;
|
|
246
|
-
debug(`${retriesCountWithinTime} failed requests within ${REPORTER_REQUEST_RETRIES.withinTimeSeconds}s`);
|
|
247
|
-
|
|
248
|
-
if (retriesCountWithinTime > REPORTER_REQUEST_RETRIES.maxTotalRetries) {
|
|
249
|
-
const errorMessage = pc.yellow(
|
|
250
|
-
`${retriesCountWithinTime} requests were failed within ${REPORTER_REQUEST_RETRIES.withinTimeSeconds}s,\
|
|
251
|
-
reporting for test "${testData.title}" to Testomat is skipped`,
|
|
252
|
-
);
|
|
253
|
-
console.warn(`${APP_PREFIX} ${errorMessage}`);
|
|
247
|
+
#cancelTestReportingInCaseOfTooManyReqFailures() {
|
|
248
|
+
if (!process.env.TESTOMATIO_MAX_REQUEST_FAILURES) return;
|
|
254
249
|
|
|
250
|
+
const cancelReporting = this.requestFailures >= parseInt(process.env.TESTOMATIO_MAX_REQUEST_FAILURES, 10);
|
|
251
|
+
if (cancelReporting) {
|
|
255
252
|
this.reportingCanceledDueToReqFailures = true;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
253
|
+
let errorMessage = `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES}`;
|
|
254
|
+
errorMessage += ' requests were failed, reporting to Testomat aborted.';
|
|
255
|
+
console.warn(`${APP_PREFIX} ${pc.yellow(errorMessage)}`);
|
|
259
256
|
}
|
|
260
|
-
|
|
261
|
-
return false;
|
|
257
|
+
return cancelReporting;
|
|
262
258
|
}
|
|
263
259
|
|
|
264
260
|
#uploadSingleTest = async data => {
|
|
265
261
|
if (!this.isEnabled) return;
|
|
266
262
|
if (!this.runId) return;
|
|
267
|
-
if (this.#cancelTestReportingInCaseOfTooManyReqFailures(
|
|
263
|
+
if (this.#cancelTestReportingInCaseOfTooManyReqFailures()) return;
|
|
268
264
|
|
|
269
265
|
data.api_key = this.apiKey;
|
|
270
266
|
data.create = this.createNewTests;
|
|
@@ -277,40 +273,41 @@ class TestomatioPipe {
|
|
|
277
273
|
|
|
278
274
|
debug('Adding test', json);
|
|
279
275
|
|
|
280
|
-
return this.axios
|
|
281
|
-
|
|
282
|
-
.
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
console.log(
|
|
287
|
-
APP_PREFIX,
|
|
288
|
-
pc.yellow(`Warning: ${responseData.message} (${err.response.status})`),
|
|
289
|
-
pc.gray(data?.title || ''),
|
|
290
|
-
);
|
|
291
|
-
if (err.response?.data?.message?.includes('could not be matched')) {
|
|
292
|
-
this.hasUnmatchedTests = true;
|
|
293
|
-
}
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
276
|
+
return this.axios.post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig).catch(err => {
|
|
277
|
+
this.requestFailures++;
|
|
278
|
+
this.notReportedTestsCount++;
|
|
279
|
+
if (err.response) {
|
|
280
|
+
if (err.response.status >= 400) {
|
|
281
|
+
const responseData = err.response.data || { message: '' };
|
|
296
282
|
console.log(
|
|
297
283
|
APP_PREFIX,
|
|
298
|
-
pc.yellow(`Warning: ${
|
|
299
|
-
|
|
284
|
+
pc.yellow(`Warning: ${responseData.message} (${err.response.status})`),
|
|
285
|
+
pc.gray(data?.title || ''),
|
|
300
286
|
);
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
287
|
+
if (err.response?.data?.message?.includes('could not be matched')) {
|
|
288
|
+
this.hasUnmatchedTests = true;
|
|
289
|
+
}
|
|
290
|
+
return;
|
|
304
291
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
292
|
+
console.log(
|
|
293
|
+
APP_PREFIX,
|
|
294
|
+
pc.yellow(`Warning: ${data?.title || ''} (${err.response?.status})`),
|
|
295
|
+
`Report couldn't be processed: ${err?.response?.data?.message}`,
|
|
296
|
+
);
|
|
297
|
+
printCreateIssue(err);
|
|
298
|
+
} else {
|
|
299
|
+
console.log(APP_PREFIX, pc.blue(data?.title || ''), "Report couldn't be processed", err);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
};
|
|
308
303
|
|
|
309
304
|
/**
|
|
310
305
|
* Uploads tests as a batch (multiple tests at once). Intended to be used with a setInterval
|
|
311
306
|
*/
|
|
312
307
|
#batchUpload = async () => {
|
|
313
308
|
if (!this.batch.isEnabled) return;
|
|
309
|
+
if (!this.batch.tests.length) return;
|
|
310
|
+
if (this.#cancelTestReportingInCaseOfTooManyReqFailures()) return;
|
|
314
311
|
// prevent infinite loop
|
|
315
312
|
if (this.batch.numberOfTimesCalledWithoutTests > 10) {
|
|
316
313
|
debug('📨 Batch upload: no tests to send for 10 times, stopping batch');
|
|
@@ -322,7 +319,7 @@ class TestomatioPipe {
|
|
|
322
319
|
this.batch.numberOfTimesCalledWithoutTests++;
|
|
323
320
|
return;
|
|
324
321
|
}
|
|
325
|
-
|
|
322
|
+
|
|
326
323
|
this.batch.batchIndex++;
|
|
327
324
|
// get tests from batch and clear batch
|
|
328
325
|
const testsToSend = this.batch.tests.splice(0);
|
|
@@ -335,6 +332,8 @@ class TestomatioPipe {
|
|
|
335
332
|
axiosAddTestrunRequestConfig,
|
|
336
333
|
)
|
|
337
334
|
.catch(err => {
|
|
335
|
+
this.requestFailures++;
|
|
336
|
+
this.notReportedTestsCount += testsToSend.length;
|
|
338
337
|
if (err.response) {
|
|
339
338
|
if (err.response.status >= 400) {
|
|
340
339
|
const responseData = err.response.data || { message: '' };
|
|
@@ -380,14 +379,21 @@ class TestomatioPipe {
|
|
|
380
379
|
}
|
|
381
380
|
|
|
382
381
|
/**
|
|
383
|
-
* @param {import('../../types').RunData} params
|
|
382
|
+
* @param {import('../../types/types.js').RunData} params
|
|
384
383
|
* @returns
|
|
385
384
|
*/
|
|
386
385
|
async finishRun(params) {
|
|
387
386
|
if (!this.isEnabled) return;
|
|
388
|
-
|
|
389
|
-
if (this.batch.intervalFunction) clearInterval(this.batch.intervalFunction);
|
|
387
|
+
|
|
390
388
|
await this.#batchUpload();
|
|
389
|
+
if (this.batch.intervalFunction) {
|
|
390
|
+
clearInterval(this.batch.intervalFunction);
|
|
391
|
+
// this code is required in case test is added after run is finished
|
|
392
|
+
// (e.g. if test has artifacts, add test function will be invoked only after artifacts are uploaded)
|
|
393
|
+
// batch stops working after run is finished; thus, disable it to use single test uploading
|
|
394
|
+
this.batch.intervalFunction = null;
|
|
395
|
+
this.batch.isEnabled = false;
|
|
396
|
+
}
|
|
391
397
|
|
|
392
398
|
debug('Finishing run...');
|
|
393
399
|
|
|
@@ -411,7 +417,9 @@ class TestomatioPipe {
|
|
|
411
417
|
if (this.runId && !this.proceed) {
|
|
412
418
|
await this.axios.put(`/api/reporter/${this.runId}`, {
|
|
413
419
|
api_key: this.apiKey,
|
|
420
|
+
duration: params.duration,
|
|
414
421
|
status_event,
|
|
422
|
+
detach: params.detach,
|
|
415
423
|
tests: params.tests,
|
|
416
424
|
});
|
|
417
425
|
if (this.runUrl) {
|
|
@@ -426,6 +434,7 @@ class TestomatioPipe {
|
|
|
426
434
|
console.log(APP_PREFIX, `📊 ${notFinishedMessage}. Report URL: ${pc.magenta(this.runUrl)}`);
|
|
427
435
|
console.log(APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx start-test-run --finish`);
|
|
428
436
|
}
|
|
437
|
+
|
|
429
438
|
if (this.hasUnmatchedTests) {
|
|
430
439
|
console.log('');
|
|
431
440
|
// eslint-disable-next-line max-len
|
|
@@ -445,11 +454,7 @@ class TestomatioPipe {
|
|
|
445
454
|
console.log(APP_PREFIX, pc.bold('npx check-tests ... --update-ids'), 'See: https://bit.ly/js-update-ids');
|
|
446
455
|
console.log(APP_PREFIX, 'or for Cucumber:');
|
|
447
456
|
// eslint-disable-next-line max-len
|
|
448
|
-
console.log(
|
|
449
|
-
APP_PREFIX,
|
|
450
|
-
pc.bold('npx check-cucumber ... --update-ids'),
|
|
451
|
-
'See: https://bit.ly/bdd-update-ids',
|
|
452
|
-
);
|
|
457
|
+
console.log(APP_PREFIX, pc.bold('npx check-cucumber ... --update-ids'), 'See: https://bit.ly/bdd-update-ids');
|
|
453
458
|
}
|
|
454
459
|
} catch (err) {
|
|
455
460
|
console.log(APP_PREFIX, 'Error updating status, skipping...', err);
|
|
@@ -1,38 +1,49 @@
|
|
|
1
1
|
import { services } from './services/index.js';
|
|
2
|
-
import { initPlaywrightForStorage } from './adapter/playwright.js';
|
|
3
|
-
|
|
4
|
-
if (process.env.PLAYWRIGHT_TEST_BASE_URL) initPlaywrightForStorage();
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
4
|
* Stores path to file as artifact and uploads it to the S3 storage
|
|
8
5
|
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
9
6
|
*/
|
|
10
7
|
function saveArtifact(data, context = null) {
|
|
8
|
+
if (process.env.IS_PLAYWRIGHT)
|
|
9
|
+
throw new Error(`This function is not available in Playwright framework.
|
|
10
|
+
/Playwright supports artifacts out of the box`);
|
|
11
11
|
if (!data) return;
|
|
12
12
|
services.artifacts.put(data, context);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Attach log message(s) to the test report
|
|
17
|
-
* @param
|
|
17
|
+
* @param string
|
|
18
18
|
*/
|
|
19
19
|
function logMessage(...args) {
|
|
20
|
+
if (process.env.IS_PLAYWRIGHT) throw new Error('This function is not available in Playwright framework');
|
|
20
21
|
services.logger._templateLiteralLog(...args);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Similar to "log" function but marks message in report as a step
|
|
25
|
-
* @param {
|
|
26
|
+
* @param {string} message
|
|
26
27
|
*/
|
|
27
28
|
function addStep(message) {
|
|
29
|
+
if (process.env.IS_PLAYWRIGHT)
|
|
30
|
+
throw new Error('This function is not available in Playwright framework. Use playwright steps');
|
|
31
|
+
|
|
28
32
|
services.logger.step(message);
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
/**
|
|
32
36
|
* Add key-value pair(s) to the test report
|
|
33
|
-
* @param {
|
|
37
|
+
* @param {{[key: string]: string} | string} keyValue object { key: value } (multiple props allowed) or key (string)
|
|
38
|
+
* @param {string?} value
|
|
34
39
|
*/
|
|
35
|
-
function setKeyValue(keyValue) {
|
|
40
|
+
function setKeyValue(keyValue, value = null) {
|
|
41
|
+
if (process.env.IS_PLAYWRIGHT)
|
|
42
|
+
throw new Error('This function is not available in Playwright framework. Use test tag instead.');
|
|
43
|
+
|
|
44
|
+
if (typeof keyValue === 'string') {
|
|
45
|
+
keyValue = { [keyValue]: value };
|
|
46
|
+
}
|
|
36
47
|
services.keyValues.put(keyValue);
|
|
37
48
|
}
|
|
38
49
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// const _reporter = require('../lib/reporter.js');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// /**
|
|
5
|
+
// * @typedef {import('../lib/reporter-functions.js').saveArtifact} artifact
|
|
6
|
+
// * @typedef {import('../lib/reporter-functions.js').log} log
|
|
7
|
+
// * @typedef {import('../lib/reporter-functions.js').logger} logger
|
|
8
|
+
// * @typedef {import('../lib/reporter-functions.js')} meta
|
|
9
|
+
// * @typedef {import('../lib/reporter-functions.js')} step
|
|
10
|
+
// *
|
|
11
|
+
// * "Reporter" type which is object containing all types from the above
|
|
12
|
+
// * @typedef {{artifact: artifact, log: log, logger: logger, meta: meta, step: step, }} Reporter
|
|
13
|
+
// */
|
|
14
|
+
|
|
15
|
+
// // const reporter = _reporter;
|
|
16
|
+
|
|
17
|
+
// /**
|
|
18
|
+
// * @type {Reporter}
|
|
19
|
+
// */
|
|
20
|
+
// const reporter = _reporter;
|
|
21
|
+
// module.exports = reporter;
|
package/src/reporter.js
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
import TestomatClient from './client.js';
|
|
2
|
-
import * as TRConstants from './constants.js';
|
|
1
|
+
// import TestomatClient from './client.js';
|
|
2
|
+
// import * as TRConstants from './constants.js';
|
|
3
3
|
import { services } from './services/index.js';
|
|
4
4
|
import reporterFunctions from './reporter-functions.js';
|
|
5
5
|
|
|
6
|
+
export const artifact = reporterFunctions.artifact;
|
|
7
|
+
export const log = reporterFunctions.log;
|
|
8
|
+
export const logger = services.logger;
|
|
9
|
+
export const meta = reporterFunctions.keyValue;
|
|
10
|
+
export const step = reporterFunctions.step;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {import('./reporter-functions.js')} artifact
|
|
14
|
+
* @typedef {import('./reporter-functions.js')} log
|
|
15
|
+
* @typedef {import('./services/index.js')} logger
|
|
16
|
+
* @typedef {import('./reporter-functions.js')} meta
|
|
17
|
+
* @typedef {import('./reporter-functions.js')} step
|
|
18
|
+
*/
|
|
6
19
|
export default {
|
|
7
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `log` or `testomat.log`
|
|
22
|
+
*/
|
|
8
23
|
testomatioLogger: services.logger,
|
|
9
24
|
|
|
10
25
|
artifact: reporterFunctions.artifact,
|
|
@@ -13,12 +28,6 @@ export default {
|
|
|
13
28
|
meta: reporterFunctions.keyValue,
|
|
14
29
|
step: reporterFunctions.step,
|
|
15
30
|
|
|
16
|
-
TestomatClient,
|
|
17
|
-
TRConstants,
|
|
31
|
+
// TestomatClient,
|
|
32
|
+
// TRConstants,
|
|
18
33
|
};
|
|
19
|
-
|
|
20
|
-
export const artifact = reporterFunctions.artifact;
|
|
21
|
-
export const log = reporterFunctions.log;
|
|
22
|
-
export const logger = services.logger;
|
|
23
|
-
export const meta = reporterFunctions.keyValue;
|
|
24
|
-
export const step = reporterFunctions.step;
|
|
@@ -18,7 +18,7 @@ class KeyValueStorage {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Stores key-value pair and passes it to reporter
|
|
21
|
-
* @param {{key: string}} keyValue - key-value pair(s) as object
|
|
21
|
+
* @param {{[key: string]: string}} keyValue - key-value pair(s) as object
|
|
22
22
|
* @param {*} context - full test title
|
|
23
23
|
*/
|
|
24
24
|
put(keyValue, context = null) {
|
package/src/services/logger.js
CHANGED
|
@@ -45,8 +45,10 @@ class Logger {
|
|
|
45
45
|
logLevel = process?.env?.LOG_LEVEL?.toUpperCase() || 'ALL';
|
|
46
46
|
|
|
47
47
|
constructor() {
|
|
48
|
-
if (
|
|
49
|
-
|
|
48
|
+
if (
|
|
49
|
+
!dataStorage.isFileStorage ||
|
|
50
|
+
(process.env.TESTOMATIO_INTERCEPT_CONSOLE_LOGS && process.env.TESTOMATIO_INTERCEPT_CONSOLE_LOGS !== 'false')
|
|
51
|
+
)
|
|
50
52
|
this.intercept(console);
|
|
51
53
|
}
|
|
52
54
|
|