@testomatio/reporter 2.0.0-beta-esm → 2.0.0-beta.1-xml

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.
Files changed (123) hide show
  1. package/lib/adapter/codecept.d.ts +2 -0
  2. package/lib/adapter/codecept.js +31 -26
  3. package/lib/adapter/cucumber/current.d.ts +14 -0
  4. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  5. package/lib/adapter/cucumber.d.ts +2 -0
  6. package/lib/adapter/cypress-plugin/index.d.ts +2 -0
  7. package/lib/adapter/cypress-plugin/index.js +10 -10
  8. package/lib/adapter/jasmine.d.ts +11 -0
  9. package/lib/adapter/jest.d.ts +13 -0
  10. package/lib/adapter/mocha.d.ts +2 -0
  11. package/lib/adapter/mocha.js +4 -4
  12. package/lib/adapter/nightwatch.d.ts +4 -0
  13. package/lib/adapter/nightwatch.js +80 -0
  14. package/lib/adapter/playwright.d.ts +14 -0
  15. package/lib/adapter/playwright.js +58 -33
  16. package/lib/adapter/vitest.d.ts +35 -0
  17. package/lib/adapter/vitest.js +6 -6
  18. package/lib/adapter/webdriver.d.ts +24 -0
  19. package/lib/adapter/webdriver.js +51 -14
  20. package/lib/bin/cli.d.ts +2 -0
  21. package/lib/bin/cli.js +250 -0
  22. package/lib/bin/reportXml.d.ts +2 -0
  23. package/lib/bin/reportXml.js +15 -11
  24. package/lib/bin/startTest.d.ts +2 -0
  25. package/lib/bin/startTest.js +12 -7
  26. package/lib/bin/uploadArtifacts.d.ts +2 -0
  27. package/lib/bin/uploadArtifacts.js +82 -0
  28. package/lib/client.d.ts +76 -0
  29. package/lib/client.js +128 -53
  30. package/lib/config.d.ts +1 -0
  31. package/lib/config.js +2 -2
  32. package/lib/constants.d.ts +25 -0
  33. package/lib/constants.js +5 -1
  34. package/lib/data-storage.d.ts +34 -0
  35. package/lib/data-storage.js +19 -9
  36. package/lib/junit-adapter/adapter.d.ts +9 -0
  37. package/lib/junit-adapter/csharp.d.ts +5 -0
  38. package/lib/junit-adapter/csharp.js +11 -1
  39. package/lib/junit-adapter/index.d.ts +3 -0
  40. package/lib/junit-adapter/java.d.ts +5 -0
  41. package/lib/junit-adapter/javascript.d.ts +4 -0
  42. package/lib/junit-adapter/python.d.ts +5 -0
  43. package/lib/junit-adapter/ruby.d.ts +4 -0
  44. package/lib/output.d.ts +11 -0
  45. package/lib/package.json +3 -1
  46. package/lib/pipe/bitbucket.d.ts +23 -0
  47. package/lib/pipe/bitbucket.js +19 -9
  48. package/lib/pipe/csv.d.ts +47 -0
  49. package/lib/pipe/csv.js +2 -2
  50. package/lib/pipe/debug.d.ts +29 -0
  51. package/lib/pipe/debug.js +108 -0
  52. package/lib/pipe/github.d.ts +30 -0
  53. package/lib/pipe/github.js +37 -5
  54. package/lib/pipe/gitlab.d.ts +23 -0
  55. package/lib/pipe/gitlab.js +2 -3
  56. package/lib/pipe/html.d.ts +35 -0
  57. package/lib/pipe/html.js +9 -4
  58. package/lib/pipe/index.d.ts +1 -0
  59. package/lib/pipe/index.js +20 -10
  60. package/lib/pipe/testomatio.d.ts +70 -0
  61. package/lib/pipe/testomatio.js +54 -39
  62. package/lib/reporter-functions.d.ts +34 -0
  63. package/lib/reporter-functions.js +17 -7
  64. package/lib/reporter.d.ts +232 -0
  65. package/lib/reporter.js +19 -33
  66. package/lib/services/artifacts.d.ts +33 -0
  67. package/lib/services/index.d.ts +9 -0
  68. package/lib/services/key-values.d.ts +27 -0
  69. package/lib/services/key-values.js +1 -1
  70. package/lib/services/logger.d.ts +64 -0
  71. package/lib/services/logger.js +1 -2
  72. package/lib/template/testomatio.hbs +651 -1366
  73. package/lib/uploader.d.ts +60 -0
  74. package/lib/uploader.js +312 -0
  75. package/lib/utils/pipe_utils.d.ts +41 -0
  76. package/lib/utils/pipe_utils.js +3 -5
  77. package/lib/utils/utils.d.ts +47 -0
  78. package/lib/utils/utils.js +99 -12
  79. package/lib/xmlReader.d.ts +92 -0
  80. package/lib/xmlReader.js +64 -25
  81. package/package.json +19 -13
  82. package/src/adapter/codecept.js +30 -26
  83. package/src/adapter/cypress-plugin/index.js +5 -5
  84. package/src/adapter/mocha.cjs +1 -1
  85. package/src/adapter/mocha.js +4 -4
  86. package/src/adapter/nightwatch.js +88 -0
  87. package/src/adapter/playwright.js +59 -31
  88. package/src/adapter/vitest.js +6 -6
  89. package/src/adapter/webdriver.js +42 -12
  90. package/src/bin/cli.js +303 -0
  91. package/src/bin/reportXml.js +19 -9
  92. package/src/bin/startTest.js +9 -4
  93. package/src/bin/uploadArtifacts.js +91 -0
  94. package/src/client.js +137 -57
  95. package/src/config.js +2 -2
  96. package/src/constants.js +5 -1
  97. package/src/data-storage.js +2 -2
  98. package/src/junit-adapter/csharp.js +13 -1
  99. package/src/pipe/bitbucket.js +2 -2
  100. package/src/pipe/csv.js +3 -3
  101. package/src/pipe/debug.js +104 -0
  102. package/src/pipe/github.js +3 -5
  103. package/src/pipe/gitlab.js +6 -7
  104. package/src/pipe/html.js +14 -7
  105. package/src/pipe/index.js +5 -7
  106. package/src/pipe/testomatio.js +75 -76
  107. package/src/reporter-functions.js +18 -7
  108. package/src/reporter.cjs_decprecated +21 -0
  109. package/src/reporter.js +20 -11
  110. package/src/services/key-values.js +1 -1
  111. package/src/services/logger.js +5 -4
  112. package/src/template/testomatio.hbs +651 -1366
  113. package/src/uploader.js +371 -0
  114. package/src/utils/pipe_utils.js +4 -12
  115. package/src/utils/utils.js +64 -15
  116. package/src/xmlReader.js +76 -26
  117. package/lib/adapter/jasmine/jasmine.js +0 -63
  118. package/lib/adapter/mocha/mocha.js +0 -125
  119. package/lib/fileUploader.js +0 -245
  120. package/lib/utils/chalk.js +0 -10
  121. package/src/fileUploader.js +0 -307
  122. package/src/reporter.cjs +0 -22
  123. package/src/utils/chalk.js +0 -13
@@ -15,12 +15,11 @@ const utils_js_1 = require("../utils/utils.js");
15
15
  const pipe_utils_js_1 = require("../utils/pipe_utils.js");
16
16
  const config_js_1 = require("../config.js");
17
17
  const debug = (0, debug_1.default)('@testomatio/reporter:pipe:testomatio');
18
- if (process.env.TESTOMATIO_RUN) {
19
- // process.env.runId = process.env.TESTOMATIO_RUN;
20
- }
18
+ if (process.env.TESTOMATIO_RUN)
19
+ process.env.runId = process.env.TESTOMATIO_RUN;
21
20
  /**
22
- * @typedef {import('../../types').Pipe} Pipe
23
- * @typedef {import('../../types').TestData} TestData
21
+ * @typedef {import('../../types/types.js').Pipe} Pipe
22
+ * @typedef {import('../../types/types.js').TestData} TestData
24
23
  * @class TestomatioPipe
25
24
  * @implements {Pipe}
26
25
  */
@@ -59,11 +58,13 @@ class TestomatioPipe {
59
58
  this.axios = axios_1.default.create({
60
59
  baseURL: `${this.url.trim()}`,
61
60
  timeout: constants_js_1.AXIOS_TIMEOUT,
62
- proxy: proxy ? {
63
- host: proxy.hostname,
64
- port: parseInt(proxy.port, 10),
65
- protocol: proxy.protocol,
66
- } : false,
61
+ proxy: proxy
62
+ ? {
63
+ host: proxy.hostname,
64
+ port: parseInt(proxy.port, 10),
65
+ protocol: proxy.protocol,
66
+ }
67
+ : false,
67
68
  });
68
69
  // Pass the axios instance to the retry function
69
70
  (0, axios_retry_1.default)(this.axios, {
@@ -94,9 +95,10 @@ class TestomatioPipe {
94
95
  // do not finish this run (for parallel testing)
95
96
  this.proceed = process.env.TESTOMATIO_PROCEED;
96
97
  this.jiraId = process.env.TESTOMATIO_JIRA_ID;
97
- this.runId = params.runId || process.env.runId;
98
+ this.runId = params.runId || process.env.TESTOMATIO_RUN;
98
99
  this.createNewTests = params.createNewTests ?? !!process.env.TESTOMATIO_CREATE;
99
100
  this.hasUnmatchedTests = false;
101
+ this.requestFailures = 0;
100
102
  if (!(0, utils_js_1.isValidUrl)(this.url.trim())) {
101
103
  this.isEnabled = false;
102
104
  console.error(constants_js_1.APP_PREFIX, picocolors_1.default.red(`Error creating report on Testomat.io, report url '${this.url}' is invalid`));
@@ -141,10 +143,9 @@ class TestomatioPipe {
141
143
  */
142
144
  async createRun(params = {}) {
143
145
  this.batch.isEnabled = params.isBatchEnabled ?? this.batch.isEnabled;
144
- debug('Creating run...');
145
146
  if (!this.isEnabled)
146
147
  return;
147
- if (this.batch.isEnabled)
148
+ if (this.batch.isEnabled && this.isEnabled)
148
149
  this.batch.intervalFunction = setInterval(this.#batchUpload, this.batch.intervalTime);
149
150
  let buildUrl = process.env.BUILD_URL || process.env.CI_JOB_URL || process.env.CIRCLE_BUILD_URL;
150
151
  // GitHub Actions Url
@@ -177,12 +178,14 @@ class TestomatioPipe {
177
178
  }).filter(([, value]) => !!value));
178
179
  debug(' >>>>>> Run params', JSON.stringify(runParams, null, 2));
179
180
  if (this.runId) {
181
+ this.store.runId = this.runId;
180
182
  debug(`Run with id ${this.runId} already created, updating...`);
181
183
  const resp = await this.axios.put(`/api/reporter/${this.runId}`, runParams);
182
184
  if (resp.data.artifacts)
183
185
  (0, pipe_utils_js_1.setS3Credentials)(resp.data.artifacts);
184
186
  return;
185
187
  }
188
+ debug('Creating run...');
186
189
  try {
187
190
  const resp = await this.axios.post(`/api/reporter`, runParams, {
188
191
  maxContentLength: Infinity,
@@ -201,37 +204,39 @@ class TestomatioPipe {
201
204
  debug('Run created', this.runId);
202
205
  }
203
206
  catch (err) {
204
- console.error(constants_js_1.APP_PREFIX, 'Error creating Testomat.io report, please check if your API key is valid. Skipping report | ', err?.response?.statusText || err?.status || err.message);
207
+ const errorText = err.response?.data?.message || err.message;
208
+ console.log(errorText || err);
209
+ if (!this.apiKey)
210
+ console.error('Testomat.io API key is not set');
211
+ if (!this.apiKey?.startsWith('tstmt'))
212
+ console.error('Testomat.io API key is invalid');
213
+ 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
214
  printCreateIssue(err);
206
215
  }
207
216
  debug('"createRun" function finished');
208
217
  }
209
218
  /**
210
219
  * Decides whether to skip test reporting in case of too many request failures
211
- * @param {TestData} testData
212
220
  * @returns {boolean}
213
221
  */
214
- #cancelTestReportingInCaseOfTooManyReqFailures(testData) {
215
- if (this.reportingCanceledDueToReqFailures)
216
- return true;
217
- const retriesCountWithinTime = this.retriesTimestamps.filter(timestamp => Date.now() - timestamp < constants_js_1.REPORTER_REQUEST_RETRIES.withinTimeSeconds * 1000).length;
218
- debug(`${retriesCountWithinTime} failed requests within ${constants_js_1.REPORTER_REQUEST_RETRIES.withinTimeSeconds}s`);
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}`);
222
+ #cancelTestReportingInCaseOfTooManyReqFailures() {
223
+ if (!process.env.TESTOMATIO_MAX_REQUEST_FAILURES)
224
+ return;
225
+ const cancelReporting = this.requestFailures >= parseInt(process.env.TESTOMATIO_MAX_REQUEST_FAILURES, 10);
226
+ if (cancelReporting) {
223
227
  this.reportingCanceledDueToReqFailures = true;
224
- this.notReportedTestsCount++;
225
- return true;
228
+ let errorMessage = `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES}`;
229
+ errorMessage += ' requests were failed, reporting to Testomat aborted.';
230
+ console.warn(`${constants_js_1.APP_PREFIX} ${picocolors_1.default.yellow(errorMessage)}`);
226
231
  }
227
- return false;
232
+ return cancelReporting;
228
233
  }
229
234
  #uploadSingleTest = async (data) => {
230
235
  if (!this.isEnabled)
231
236
  return;
232
237
  if (!this.runId)
233
238
  return;
234
- if (this.#cancelTestReportingInCaseOfTooManyReqFailures(data))
239
+ if (this.#cancelTestReportingInCaseOfTooManyReqFailures())
235
240
  return;
236
241
  data.api_key = this.apiKey;
237
242
  data.create = this.createNewTests;
@@ -240,9 +245,9 @@ class TestomatioPipe {
240
245
  }
241
246
  const json = json_cycle_1.default.stringify(data);
242
247
  debug('Adding test', json);
243
- return this.axios
244
- .post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig)
245
- .catch(err => {
248
+ return this.axios.post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig).catch(err => {
249
+ this.requestFailures++;
250
+ this.notReportedTestsCount++;
246
251
  if (err.response) {
247
252
  if (err.response.status >= 400) {
248
253
  const responseData = err.response.data || { message: '' };
@@ -266,6 +271,10 @@ class TestomatioPipe {
266
271
  #batchUpload = async () => {
267
272
  if (!this.batch.isEnabled)
268
273
  return;
274
+ if (!this.batch.tests.length)
275
+ return;
276
+ if (this.#cancelTestReportingInCaseOfTooManyReqFailures())
277
+ return;
269
278
  // prevent infinite loop
270
279
  if (this.batch.numberOfTimesCalledWithoutTests > 10) {
271
280
  debug('📨 Batch upload: no tests to send for 10 times, stopping batch');
@@ -284,6 +293,8 @@ class TestomatioPipe {
284
293
  return this.axios
285
294
  .post(`/api/reporter/${this.runId}/testrun`, { api_key: this.apiKey, tests: testsToSend, batch_index: this.batch.batchIndex }, axiosAddTestrunRequestConfig)
286
295
  .catch(err => {
296
+ this.requestFailures++;
297
+ this.notReportedTestsCount += testsToSend.length;
287
298
  if (err.response) {
288
299
  if (err.response.status >= 400) {
289
300
  const responseData = err.response.data || { message: '' };
@@ -323,15 +334,21 @@ class TestomatioPipe {
323
334
  this.#batchUpload();
324
335
  }
325
336
  /**
326
- * @param {import('../../types').RunData} params
337
+ * @param {import('../../types/types.js').RunData} params
327
338
  * @returns
328
339
  */
329
340
  async finishRun(params) {
330
341
  if (!this.isEnabled)
331
342
  return;
332
- if (this.batch.intervalFunction)
333
- clearInterval(this.batch.intervalFunction);
334
343
  await this.#batchUpload();
344
+ if (this.batch.intervalFunction) {
345
+ clearInterval(this.batch.intervalFunction);
346
+ // this code is required in case test is added after run is finished
347
+ // (e.g. if test has artifacts, add test function will be invoked only after artifacts are uploaded)
348
+ // batch stops working after run is finished; thus, disable it to use single test uploading
349
+ this.batch.intervalFunction = null;
350
+ this.batch.isEnabled = false;
351
+ }
335
352
  debug('Finishing run...');
336
353
  if (this.reportingCanceledDueToReqFailures) {
337
354
  const errorMessage = picocolors_1.default.red(`⚠️ Due to request failures, ${this.notReportedTestsCount} test(s) were not reported to Testomat.io`);
@@ -351,7 +368,9 @@ class TestomatioPipe {
351
368
  if (this.runId && !this.proceed) {
352
369
  await this.axios.put(`/api/reporter/${this.runId}`, {
353
370
  api_key: this.apiKey,
371
+ duration: params.duration,
354
372
  status_event,
373
+ detach: params.detach,
355
374
  tests: params.tests,
356
375
  });
357
376
  if (this.runUrl) {
@@ -368,17 +387,13 @@ class TestomatioPipe {
368
387
  }
369
388
  if (this.hasUnmatchedTests) {
370
389
  console.log('');
371
- // eslint-disable-next-line max-len
372
390
  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
391
  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
392
  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
393
  console.log(constants_js_1.APP_PREFIX, 'If tests were imported but still not matched, assign test IDs to your tests.');
378
394
  console.log(constants_js_1.APP_PREFIX, 'You can do that automatically via command line tools:');
379
395
  console.log(constants_js_1.APP_PREFIX, picocolors_1.default.bold('npx check-tests ... --update-ids'), 'See: https://bit.ly/js-update-ids');
380
396
  console.log(constants_js_1.APP_PREFIX, 'or for Cucumber:');
381
- // eslint-disable-next-line max-len
382
397
  console.log(constants_js_1.APP_PREFIX, picocolors_1.default.bold('npx check-cucumber ... --update-ids'), 'See: https://bit.ly/bdd-update-ids');
383
398
  }
384
399
  }
@@ -400,7 +415,7 @@ function printCreateIssue(err) {
400
415
  process.on('exit', () => {
401
416
  console.log();
402
417
  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'); // eslint-disable-line max-len
418
+ 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
419
  console.log(constants_js_1.APP_PREFIX, 'Provide this information:');
405
420
  console.log('Error:', err.message || err.code);
406
421
  if (!err.config)
@@ -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 {...any} args
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 {*} message
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 {*} keyValue
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 = {
@@ -0,0 +1,232 @@
1
+ export type artifact = typeof import("./reporter-functions.js");
2
+ export const artifact: (data: string | {
3
+ path: string;
4
+ type: string;
5
+ name: string;
6
+ }, context?: any) => void;
7
+ export type log = typeof import("./reporter-functions.js");
8
+ export const log: (...args: any[]) => void;
9
+ export type logger = typeof import("./services/index.js");
10
+ export const logger: {
11
+ "__#12@#originalUserLogger": {
12
+ assert(condition?: boolean, ...data: any[]): void;
13
+ assert(value: any, message?: string, ...optionalParams: any[]): void;
14
+ clear(): void;
15
+ clear(): void;
16
+ count(label?: string): void;
17
+ count(label?: string): void;
18
+ countReset(label?: string): void;
19
+ countReset(label?: string): void;
20
+ debug(...data: any[]): void;
21
+ debug(message?: any, ...optionalParams: any[]): void;
22
+ dir(item?: any, options?: any): void;
23
+ dir(obj: any, options?: import("util").InspectOptions): void;
24
+ dirxml(...data: any[]): void;
25
+ dirxml(...data: any[]): void;
26
+ error(...data: any[]): void;
27
+ error(message?: any, ...optionalParams: any[]): void;
28
+ group(...data: any[]): void;
29
+ group(...label: any[]): void;
30
+ groupCollapsed(...data: any[]): void;
31
+ groupCollapsed(...label: any[]): void;
32
+ groupEnd(): void;
33
+ groupEnd(): void;
34
+ info(...data: any[]): void;
35
+ info(message?: any, ...optionalParams: any[]): void;
36
+ log(...data: any[]): void;
37
+ log(message?: any, ...optionalParams: any[]): void;
38
+ table(tabularData?: any, properties?: string[]): void;
39
+ table(tabularData: any, properties?: readonly string[]): void;
40
+ time(label?: string): void;
41
+ time(label?: string): void;
42
+ timeEnd(label?: string): void;
43
+ timeEnd(label?: string): void;
44
+ timeLog(label?: string, ...data: any[]): void;
45
+ timeLog(label?: string, ...data: any[]): void;
46
+ timeStamp(label?: string): void;
47
+ timeStamp(label?: string): void;
48
+ trace(...data: any[]): void;
49
+ trace(message?: any, ...optionalParams: any[]): void;
50
+ warn(...data: any[]): void;
51
+ warn(message?: any, ...optionalParams: any[]): void;
52
+ Console: console.ConsoleConstructor;
53
+ profile(label?: string): void;
54
+ profileEnd(label?: string): void;
55
+ };
56
+ "__#12@#userLoggerWithOverridenMethods": any;
57
+ logLevel: string;
58
+ step(strings: any, ...values: any[]): void;
59
+ getLogs(context: string): string[];
60
+ "__#12@#stringifyLogs"(...args: any[]): string;
61
+ _templateLiteralLog(strings: any, ...args: any[]): void;
62
+ "__#12@#logWrapper"(argsArray: any, level: any): void;
63
+ assert(...args: any[]): void;
64
+ debug(...args: any[]): void;
65
+ error(...args: any[]): void;
66
+ info(...args: any[]): void;
67
+ log(...args: any[]): void;
68
+ trace(...args: any[]): void;
69
+ warn(...args: any[]): void;
70
+ intercept(userLogger: any): void;
71
+ stopInterception(): void;
72
+ configure(config?: {
73
+ logLevel?: string;
74
+ prettyObjects?: boolean;
75
+ }): void;
76
+ prettyObjects: boolean;
77
+ };
78
+ export type meta = typeof import("./reporter-functions.js");
79
+ export const meta: (keyValue: {
80
+ [key: string]: string;
81
+ } | string, value?: string | null) => void;
82
+ export type step = typeof import("./reporter-functions.js");
83
+ export const step: (message: string) => void;
84
+ declare namespace _default {
85
+ let testomatioLogger: {
86
+ "__#12@#originalUserLogger": {
87
+ assert(condition?: boolean, ...data: any[]): void;
88
+ assert(value: any, message?: string, ...optionalParams: any[]): void;
89
+ clear(): void;
90
+ clear(): void;
91
+ count(label?: string): void;
92
+ count(label?: string): void;
93
+ countReset(label?: string): void;
94
+ countReset(label?: string): void;
95
+ debug(...data: any[]): void;
96
+ debug(message?: any, ...optionalParams: any[]): void;
97
+ dir(item?: any, options?: any): void;
98
+ dir(obj: any, options?: import("util").InspectOptions): void;
99
+ dirxml(...data: any[]): void;
100
+ dirxml(...data: any[]): void;
101
+ error(...data: any[]): void;
102
+ error(message?: any, ...optionalParams: any[]): void;
103
+ group(...data: any[]): void;
104
+ group(...label: any[]): void;
105
+ groupCollapsed(...data: any[]): void;
106
+ groupCollapsed(...label: any[]): void;
107
+ groupEnd(): void;
108
+ groupEnd(): void;
109
+ info(...data: any[]): void;
110
+ info(message?: any, ...optionalParams: any[]): void;
111
+ log(...data: any[]): void;
112
+ log(message?: any, ...optionalParams: any[]): void;
113
+ table(tabularData?: any, properties?: string[]): void;
114
+ table(tabularData: any, properties?: readonly string[]): void;
115
+ time(label?: string): void;
116
+ time(label?: string): void;
117
+ timeEnd(label?: string): void;
118
+ timeEnd(label?: string): void;
119
+ timeLog(label?: string, ...data: any[]): void;
120
+ timeLog(label?: string, ...data: any[]): void;
121
+ timeStamp(label?: string): void;
122
+ timeStamp(label?: string): void;
123
+ trace(...data: any[]): void;
124
+ trace(message?: any, ...optionalParams: any[]): void;
125
+ warn(...data: any[]): void;
126
+ warn(message?: any, ...optionalParams: any[]): void;
127
+ Console: console.ConsoleConstructor;
128
+ profile(label?: string): void;
129
+ profileEnd(label?: string): void;
130
+ };
131
+ "__#12@#userLoggerWithOverridenMethods": any;
132
+ logLevel: string;
133
+ step(strings: any, ...values: any[]): void;
134
+ getLogs(context: string): string[];
135
+ "__#12@#stringifyLogs"(...args: any[]): string;
136
+ _templateLiteralLog(strings: any, ...args: any[]): void;
137
+ "__#12@#logWrapper"(argsArray: any, level: any): void;
138
+ assert(...args: any[]): void;
139
+ debug(...args: any[]): void;
140
+ error(...args: any[]): void;
141
+ info(...args: any[]): void;
142
+ log(...args: any[]): void;
143
+ trace(...args: any[]): void;
144
+ warn(...args: any[]): void;
145
+ intercept(userLogger: any): void;
146
+ stopInterception(): void;
147
+ configure(config?: {
148
+ logLevel?: string;
149
+ prettyObjects?: boolean;
150
+ }): void;
151
+ prettyObjects: boolean;
152
+ };
153
+ let artifact: (data: string | {
154
+ path: string;
155
+ type: string;
156
+ name: string;
157
+ }, context?: any) => void;
158
+ let log: (...args: any[]) => void;
159
+ let logger: {
160
+ "__#12@#originalUserLogger": {
161
+ assert(condition?: boolean, ...data: any[]): void;
162
+ assert(value: any, message?: string, ...optionalParams: any[]): void;
163
+ clear(): void;
164
+ clear(): void;
165
+ count(label?: string): void;
166
+ count(label?: string): void;
167
+ countReset(label?: string): void;
168
+ countReset(label?: string): void;
169
+ debug(...data: any[]): void;
170
+ debug(message?: any, ...optionalParams: any[]): void;
171
+ dir(item?: any, options?: any): void;
172
+ dir(obj: any, options?: import("util").InspectOptions): void;
173
+ dirxml(...data: any[]): void;
174
+ dirxml(...data: any[]): void;
175
+ error(...data: any[]): void;
176
+ error(message?: any, ...optionalParams: any[]): void;
177
+ group(...data: any[]): void;
178
+ group(...label: any[]): void;
179
+ groupCollapsed(...data: any[]): void;
180
+ groupCollapsed(...label: any[]): void;
181
+ groupEnd(): void;
182
+ groupEnd(): void;
183
+ info(...data: any[]): void;
184
+ info(message?: any, ...optionalParams: any[]): void;
185
+ log(...data: any[]): void;
186
+ log(message?: any, ...optionalParams: any[]): void;
187
+ table(tabularData?: any, properties?: string[]): void;
188
+ table(tabularData: any, properties?: readonly string[]): void;
189
+ time(label?: string): void;
190
+ time(label?: string): void;
191
+ timeEnd(label?: string): void;
192
+ timeEnd(label?: string): void;
193
+ timeLog(label?: string, ...data: any[]): void;
194
+ timeLog(label?: string, ...data: any[]): void;
195
+ timeStamp(label?: string): void;
196
+ timeStamp(label?: string): void;
197
+ trace(...data: any[]): void;
198
+ trace(message?: any, ...optionalParams: any[]): void;
199
+ warn(...data: any[]): void;
200
+ warn(message?: any, ...optionalParams: any[]): void;
201
+ Console: console.ConsoleConstructor;
202
+ profile(label?: string): void;
203
+ profileEnd(label?: string): void;
204
+ };
205
+ "__#12@#userLoggerWithOverridenMethods": any;
206
+ logLevel: string;
207
+ step(strings: any, ...values: any[]): void;
208
+ getLogs(context: string): string[];
209
+ "__#12@#stringifyLogs"(...args: any[]): string;
210
+ _templateLiteralLog(strings: any, ...args: any[]): void;
211
+ "__#12@#logWrapper"(argsArray: any, level: any): void;
212
+ assert(...args: any[]): void;
213
+ debug(...args: any[]): void;
214
+ error(...args: any[]): void;
215
+ info(...args: any[]): void;
216
+ log(...args: any[]): void;
217
+ trace(...args: any[]): void;
218
+ warn(...args: any[]): void;
219
+ intercept(userLogger: any): void;
220
+ stopInterception(): void;
221
+ configure(config?: {
222
+ logLevel?: string;
223
+ prettyObjects?: boolean;
224
+ }): void;
225
+ prettyObjects: boolean;
226
+ };
227
+ let meta: (keyValue: {
228
+ [key: string]: string;
229
+ } | string, value?: string | null) => void;
230
+ let step: (message: string) => void;
231
+ }
232
+ export default _default;
package/lib/reporter.js CHANGED
@@ -1,49 +1,35 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.step = exports.meta = exports.logger = exports.log = exports.artifact = void 0;
30
- const client_js_1 = __importDefault(require("./client.js"));
31
- const TRConstants = __importStar(require("./constants.js"));
7
+ // import TestomatClient from './client.js';
8
+ // import * as TRConstants from './constants.js';
32
9
  const index_js_1 = require("./services/index.js");
33
10
  const reporter_functions_js_1 = __importDefault(require("./reporter-functions.js"));
11
+ exports.artifact = reporter_functions_js_1.default.artifact;
12
+ exports.log = reporter_functions_js_1.default.log;
13
+ exports.logger = index_js_1.services.logger;
14
+ exports.meta = reporter_functions_js_1.default.keyValue;
15
+ exports.step = reporter_functions_js_1.default.step;
16
+ /**
17
+ * @typedef {import('./reporter-functions.js')} artifact
18
+ * @typedef {import('./reporter-functions.js')} log
19
+ * @typedef {import('./services/index.js')} logger
20
+ * @typedef {import('./reporter-functions.js')} meta
21
+ * @typedef {import('./reporter-functions.js')} step
22
+ */
34
23
  module.exports = {
35
- // TODO: deprecate in future; use log or testomat.log
24
+ /**
25
+ * @deprecated Use `log` or `testomat.log`
26
+ */
36
27
  testomatioLogger: index_js_1.services.logger,
37
28
  artifact: reporter_functions_js_1.default.artifact,
38
29
  log: reporter_functions_js_1.default.log,
39
30
  logger: index_js_1.services.logger,
40
31
  meta: reporter_functions_js_1.default.keyValue,
41
32
  step: reporter_functions_js_1.default.step,
42
- TestomatClient: client_js_1.default,
43
- TRConstants,
33
+ // TestomatClient,
34
+ // TRConstants,
44
35
  };
45
- exports.artifact = reporter_functions_js_1.default.artifact;
46
- exports.log = reporter_functions_js_1.default.log;
47
- exports.logger = index_js_1.services.logger;
48
- exports.meta = reporter_functions_js_1.default.keyValue;
49
- exports.step = reporter_functions_js_1.default.step;
@@ -0,0 +1,33 @@
1
+ export const artifactStorage: ArtifactStorage;
2
+ /**
3
+ * Artifact storage is supposed to store file paths
4
+ */
5
+ declare class ArtifactStorage {
6
+ static "__#13@#instance": any;
7
+ /**
8
+ * Singleton
9
+ * @returns {ArtifactStorage}
10
+ */
11
+ static getInstance(): ArtifactStorage;
12
+ /**
13
+ * Stores path to file as artifact and uploads it to the S3 storage
14
+ * @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
15
+ * @param {*} context testId or test title
16
+ */
17
+ put(data: string | {
18
+ path: string;
19
+ type: string;
20
+ name: string;
21
+ }, context?: any): void;
22
+ /**
23
+ * Returns list of artifacts to upload
24
+ * @param {*} context testId or test context from test runner
25
+ * @returns {(string | {path: string, type: string, name: string})[]}
26
+ */
27
+ get(context: any): (string | {
28
+ path: string;
29
+ type: string;
30
+ name: string;
31
+ })[];
32
+ }
33
+ export {};
@@ -0,0 +1,9 @@
1
+ export namespace services {
2
+ export { logger };
3
+ export { artifactStorage as artifacts };
4
+ export { keyValueStorage as keyValues };
5
+ export function setContext(context: any): void;
6
+ }
7
+ import { logger } from './logger.js';
8
+ import { artifactStorage } from './artifacts.js';
9
+ import { keyValueStorage } from './key-values.js';