@testomatio/reporter 2.0.1-beta.5-timestamp → 2.0.1-beta.7

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 (152) hide show
  1. package/README.md +1 -0
  2. package/lib/adapter/codecept.d.ts +2 -0
  3. package/lib/adapter/codecept.js +297 -335
  4. package/lib/adapter/cucumber/current.d.ts +14 -0
  5. package/lib/adapter/cucumber/current.js +195 -203
  6. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  7. package/lib/adapter/cucumber/legacy.js +130 -155
  8. package/lib/adapter/cucumber.d.ts +2 -0
  9. package/lib/adapter/cucumber.js +5 -16
  10. package/lib/adapter/cypress-plugin/index.d.ts +2 -0
  11. package/lib/adapter/cypress-plugin/index.js +91 -105
  12. package/lib/adapter/jasmine.d.ts +11 -0
  13. package/lib/adapter/jasmine.js +54 -53
  14. package/lib/adapter/jest.d.ts +13 -0
  15. package/lib/adapter/jest.js +97 -99
  16. package/lib/adapter/mocha.d.ts +2 -0
  17. package/lib/adapter/mocha.js +112 -141
  18. package/lib/adapter/nightwatch.d.ts +4 -0
  19. package/lib/adapter/nightwatch.js +80 -0
  20. package/lib/adapter/playwright.d.ts +14 -0
  21. package/lib/adapter/playwright.js +208 -231
  22. package/lib/adapter/vitest.d.ts +35 -0
  23. package/lib/adapter/vitest.js +150 -149
  24. package/lib/adapter/webdriver.d.ts +24 -0
  25. package/lib/adapter/webdriver.js +144 -121
  26. package/lib/bin/cli.d.ts +2 -0
  27. package/lib/bin/cli.js +229 -211
  28. package/lib/bin/reportXml.d.ts +2 -0
  29. package/lib/bin/reportXml.js +51 -52
  30. package/lib/bin/startTest.d.ts +2 -0
  31. package/lib/bin/startTest.js +83 -95
  32. package/lib/bin/uploadArtifacts.d.ts +2 -0
  33. package/lib/bin/uploadArtifacts.js +56 -61
  34. package/lib/client.d.ts +76 -0
  35. package/lib/client.js +431 -465
  36. package/lib/config.d.ts +1 -0
  37. package/lib/config.js +18 -23
  38. package/lib/constants.d.ts +25 -0
  39. package/lib/constants.js +50 -44
  40. package/lib/data-storage.d.ts +34 -0
  41. package/lib/data-storage.js +216 -188
  42. package/lib/junit-adapter/adapter.d.ts +9 -0
  43. package/lib/junit-adapter/adapter.js +17 -20
  44. package/lib/junit-adapter/csharp.d.ts +5 -0
  45. package/lib/junit-adapter/csharp.js +28 -14
  46. package/lib/junit-adapter/index.d.ts +3 -0
  47. package/lib/junit-adapter/index.js +27 -25
  48. package/lib/junit-adapter/java.d.ts +5 -0
  49. package/lib/junit-adapter/java.js +41 -53
  50. package/lib/junit-adapter/javascript.d.ts +4 -0
  51. package/lib/junit-adapter/javascript.js +30 -27
  52. package/lib/junit-adapter/python.d.ts +5 -0
  53. package/lib/junit-adapter/python.js +38 -37
  54. package/lib/junit-adapter/ruby.d.ts +4 -0
  55. package/lib/junit-adapter/ruby.js +11 -8
  56. package/lib/output.d.ts +11 -0
  57. package/lib/output.js +44 -52
  58. package/lib/package.json +3 -0
  59. package/lib/pipe/bitbucket.d.ts +25 -0
  60. package/lib/pipe/bitbucket.js +223 -230
  61. package/lib/pipe/csv.d.ts +47 -0
  62. package/lib/pipe/csv.js +113 -126
  63. package/lib/pipe/debug.d.ts +29 -0
  64. package/lib/pipe/debug.js +125 -99
  65. package/lib/pipe/github.d.ts +30 -0
  66. package/lib/pipe/github.js +218 -213
  67. package/lib/pipe/gitlab.d.ts +25 -0
  68. package/lib/pipe/gitlab.js +183 -206
  69. package/lib/pipe/html.d.ts +35 -0
  70. package/lib/pipe/html.js +258 -321
  71. package/lib/pipe/index.d.ts +1 -0
  72. package/lib/pipe/index.js +94 -66
  73. package/lib/pipe/testomatio.d.ts +71 -0
  74. package/lib/pipe/testomatio.js +429 -474
  75. package/lib/replay.d.ts +31 -0
  76. package/lib/replay.js +255 -0
  77. package/lib/reporter-functions.d.ts +41 -0
  78. package/lib/reporter-functions.js +64 -26
  79. package/lib/reporter.d.ts +235 -0
  80. package/lib/reporter.js +37 -29
  81. package/lib/services/artifacts.d.ts +33 -0
  82. package/lib/services/artifacts.js +55 -51
  83. package/lib/services/index.d.ts +11 -0
  84. package/lib/services/index.js +16 -12
  85. package/lib/services/key-values.d.ts +27 -0
  86. package/lib/services/key-values.js +56 -53
  87. package/lib/services/labels.d.ts +22 -0
  88. package/lib/services/labels.js +62 -0
  89. package/lib/services/logger.d.ts +64 -0
  90. package/lib/services/logger.js +226 -245
  91. package/lib/template/testomatio.hbs +1026 -1366
  92. package/lib/uploader.d.ts +60 -0
  93. package/lib/uploader.js +295 -364
  94. package/lib/utils/pipe_utils.d.ts +41 -0
  95. package/lib/utils/pipe_utils.js +89 -85
  96. package/lib/utils/utils.d.ts +54 -0
  97. package/lib/utils/utils.js +398 -307
  98. package/lib/xmlReader.d.ts +92 -0
  99. package/lib/xmlReader.js +525 -532
  100. package/package.json +64 -21
  101. package/src/adapter/codecept.js +377 -0
  102. package/src/adapter/cucumber/current.js +228 -0
  103. package/src/adapter/cucumber/legacy.js +158 -0
  104. package/src/adapter/cucumber.js +4 -0
  105. package/src/adapter/cypress-plugin/index.js +110 -0
  106. package/src/adapter/jasmine.js +60 -0
  107. package/src/adapter/jest.js +107 -0
  108. package/src/adapter/mocha.cjs +2 -0
  109. package/src/adapter/mocha.js +156 -0
  110. package/src/adapter/nightwatch.js +88 -0
  111. package/src/adapter/playwright.js +258 -0
  112. package/src/adapter/vitest.js +183 -0
  113. package/src/adapter/webdriver.js +142 -0
  114. package/src/bin/cli.js +348 -0
  115. package/src/bin/reportXml.js +77 -0
  116. package/src/bin/startTest.js +124 -0
  117. package/src/bin/uploadArtifacts.js +91 -0
  118. package/src/client.js +519 -0
  119. package/src/config.js +30 -0
  120. package/src/constants.js +53 -0
  121. package/src/data-storage.js +204 -0
  122. package/src/junit-adapter/adapter.js +23 -0
  123. package/src/junit-adapter/csharp.js +28 -0
  124. package/src/junit-adapter/index.js +28 -0
  125. package/src/junit-adapter/java.js +58 -0
  126. package/src/junit-adapter/javascript.js +31 -0
  127. package/src/junit-adapter/python.js +42 -0
  128. package/src/junit-adapter/ruby.js +10 -0
  129. package/src/output.js +57 -0
  130. package/src/pipe/bitbucket.js +252 -0
  131. package/src/pipe/csv.js +140 -0
  132. package/src/pipe/debug.js +125 -0
  133. package/src/pipe/github.js +232 -0
  134. package/src/pipe/gitlab.js +247 -0
  135. package/src/pipe/html.js +373 -0
  136. package/src/pipe/index.js +71 -0
  137. package/src/pipe/testomatio.js +504 -0
  138. package/src/replay.js +262 -0
  139. package/src/reporter-functions.js +96 -0
  140. package/src/reporter.cjs_decprecated +21 -0
  141. package/src/reporter.js +36 -0
  142. package/src/services/artifacts.js +59 -0
  143. package/src/services/index.js +15 -0
  144. package/src/services/key-values.js +59 -0
  145. package/src/services/labels.js +59 -0
  146. package/src/services/logger.js +315 -0
  147. package/src/template/emptyData.svg +23 -0
  148. package/src/template/testomatio.hbs +1081 -0
  149. package/src/uploader.js +376 -0
  150. package/src/utils/pipe_utils.js +119 -0
  151. package/src/utils/utils.js +416 -0
  152. package/src/xmlReader.js +614 -0
@@ -1,498 +1,453 @@
1
- const debug = require('debug')('@testomatio/reporter:pipe:testomatio');
2
- const chalk = require('chalk');
3
- // Retry interceptor function
4
- const axiosRetry = require('axios-retry');
5
- // Default axios instance
6
- const axios = require('axios');
7
- const JsonCycle = require('json-cycle');
8
-
9
- const { APP_PREFIX, STATUS, AXIOS_TIMEOUT, REPORTER_REQUEST_RETRIES } = require('../constants');
10
- const { isValidUrl, foundedTestLog } = require('../utils/utils');
11
- const { parseFilterParams, generateFilterRequestParams, setS3Credentials } = require('../utils/pipe_utils');
12
- const config = require('../config');
13
-
14
- if (process.env.TESTOMATIO_RUN) {
15
- process.env.runId = process.env.TESTOMATIO_RUN;
16
- }
17
-
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 picocolors_1 = __importDefault(require("picocolors"));
8
+ const gaxios_1 = require("gaxios");
9
+ const json_cycle_1 = __importDefault(require("json-cycle"));
10
+ const constants_js_1 = require("../constants.js");
11
+ const utils_js_1 = require("../utils/utils.js");
12
+ const pipe_utils_js_1 = require("../utils/pipe_utils.js");
13
+ const config_js_1 = require("../config.js");
14
+ const debug = (0, debug_1.default)('@testomatio/reporter:pipe:testomatio');
15
+ if (process.env.TESTOMATIO_RUN)
16
+ process.env.runId = process.env.TESTOMATIO_RUN;
18
17
  /**
19
- * @typedef {import('../../types').Pipe} Pipe
20
- * @typedef {import('../../types').TestData} TestData
18
+ * @typedef {import('../../types/types.js').Pipe} Pipe
19
+ * @typedef {import('../../types/types.js').TestData} TestData
21
20
  * @class TestomatioPipe
22
21
  * @implements {Pipe}
23
22
  */
24
23
  class TestomatioPipe {
25
- constructor(params, store) {
26
- this.batch = {
27
- isEnabled: params.isBatchEnabled ?? !process.env.TESTOMATIO_DISABLE_BATCH_UPLOAD ?? true,
28
- intervalFunction: null, // will be created in createRun by setInterval function
29
- intervalTime: 5000, // how often tests are sent
30
- tests: [], // array of tests in batch
31
- batchIndex: 0, // represents the current batch index (starts from 1 and increments by 1 for each batch)
32
- };
33
- this.retriesTimestamps = [];
34
- this.reportingCanceledDueToReqFailures = false;
35
- this.notReportedTestsCount = 0;
36
-
37
- this.isEnabled = false;
38
- this.url = params.testomatioUrl || process.env.TESTOMATIO_URL || 'https://app.testomat.io';
39
- this.apiKey = params.apiKey || config.TESTOMATIO;
40
-
41
- if (!this.apiKey) {
42
- return;
43
- }
44
- debug('Testomatio Pipe: Enabled');
45
-
46
- const proxyUrl = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
47
- const proxy = proxyUrl ? new URL(proxyUrl) : null;
48
-
49
- this.parallel = params.parallel;
50
- this.store = store || {};
51
- this.title = params.title || process.env.TESTOMATIO_TITLE;
52
- this.sharedRun = !!process.env.TESTOMATIO_SHARED_RUN;
53
- this.sharedRunTimeout = !!process.env.TESTOMATIO_SHARED_RUN_TIMEOUT;
54
- this.groupTitle = params.groupTitle || process.env.TESTOMATIO_RUNGROUP_TITLE;
55
- this.env = process.env.TESTOMATIO_ENV;
56
- this.label = process.env.TESTOMATIO_LABEL;
57
- // Create a new instance of axios with a custom config
58
- this.axios = axios.create({
59
- baseURL: `${this.url.trim()}`,
60
- timeout: AXIOS_TIMEOUT,
61
- proxy: proxy ? {
62
- host: proxy.hostname,
63
- port: proxy.port,
64
- protocol: proxy.protocol,
65
- } : false,
66
- });
67
-
68
- // Pass the axios instance to the retry function
69
- axiosRetry(this.axios, {
70
- // do not use retries for unit tests
71
- retries: REPORTER_REQUEST_RETRIES.retriesPerRequest, // Number of retries
72
- shouldResetTimeout: true,
73
- retryCondition: error => {
74
- if (!error.response) return false;
75
- switch (error.response?.status) {
76
- case 400: // Bad request (probably wrong API key)
77
- case 404: // Test not matched
78
- case 429: // Rate limit exceeded
79
- case 500: // Internal server error
80
- return false;
81
- default:
82
- break;
24
+ constructor(params, store) {
25
+ this.batch = {
26
+ isEnabled: params?.isBatchEnabled ?? !process.env.TESTOMATIO_DISABLE_BATCH_UPLOAD ?? true,
27
+ intervalFunction: null, // will be created in createRun by setInterval function
28
+ intervalTime: 5000, // how often tests are sent
29
+ tests: [], // array of tests in batch
30
+ batchIndex: 0, // represents the current batch index (starts from 1 and increments by 1 for each batch)
31
+ numberOfTimesCalledWithoutTests: 0, // how many times batch was called without tests
32
+ };
33
+ this.retriesTimestamps = [];
34
+ this.reportingCanceledDueToReqFailures = false;
35
+ this.notReportedTestsCount = 0;
36
+ this.isEnabled = false;
37
+ this.url = params.testomatioUrl || process.env.TESTOMATIO_URL || 'https://app.testomat.io';
38
+ this.apiKey = params.apiKey || config_js_1.config.TESTOMATIO;
39
+ debug('Testomatio Pipe: ', this.apiKey ? 'API KEY' : '*no api key*');
40
+ if (!this.apiKey) {
41
+ return;
42
+ }
43
+ debug('Testomatio Pipe: Enabled');
44
+ const proxyUrl = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
45
+ const proxy = proxyUrl ? new URL(proxyUrl) : null;
46
+ this.parallel = params.parallel;
47
+ this.store = store || {};
48
+ this.title = params.title || process.env.TESTOMATIO_TITLE;
49
+ this.sharedRun = !!process.env.TESTOMATIO_SHARED_RUN;
50
+ this.sharedRunTimeout = !!process.env.TESTOMATIO_SHARED_RUN_TIMEOUT;
51
+ this.groupTitle = params.groupTitle || process.env.TESTOMATIO_RUNGROUP_TITLE;
52
+ this.env = process.env.TESTOMATIO_ENV;
53
+ this.label = process.env.TESTOMATIO_LABEL;
54
+ // Create a new instance of gaxios with a custom config
55
+ this.client = new gaxios_1.Gaxios({
56
+ baseURL: `${this.url.trim()}`,
57
+ timeout: constants_js_1.AXIOS_TIMEOUT,
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
+ httpMethodsToRetry: ['GET', 'PUT', 'HEAD', 'OPTIONS', 'DELETE', 'POST'],
64
+ shouldRetry: (error) => {
65
+ if (!error.response)
66
+ return false;
67
+ switch (error.response?.status) {
68
+ case 400: // Bad request (probably wrong API key)
69
+ case 404: // Test not matched
70
+ case 429: // Rate limit exceeded
71
+ case 500: // Internal server error
72
+ return false;
73
+ default:
74
+ break;
75
+ }
76
+ return error.response?.status >= 401; // Retry on 401+ and 5xx
77
+ }
78
+ }
79
+ });
80
+ this.isEnabled = true;
81
+ // do not finish this run (for parallel testing)
82
+ this.proceed = process.env.TESTOMATIO_PROCEED;
83
+ this.jiraId = process.env.TESTOMATIO_JIRA_ID;
84
+ this.runId = params.runId || process.env.TESTOMATIO_RUN;
85
+ this.createNewTests = params.createNewTests ?? !!process.env.TESTOMATIO_CREATE;
86
+ this.hasUnmatchedTests = false;
87
+ this.requestFailures = 0;
88
+ if (!(0, utils_js_1.isValidUrl)(this.url.trim())) {
89
+ this.isEnabled = false;
90
+ console.error(constants_js_1.APP_PREFIX, picocolors_1.default.red(`Error creating report on Testomat.io, report url '${this.url}' is invalid`));
83
91
  }
84
- return error.response?.status >= 401; // Retry on 401+ and 5xx
85
- },
86
- retryDelay: () => REPORTER_REQUEST_RETRIES.retryTimeout, // sum = 15sec
87
- onRetry: async (retryCount, error) => {
88
- this.retriesTimestamps.push(Date.now());
89
-
90
- debug(`${error.message || `Request failed ${error.status}`}. Retry #${retryCount} ...`);
91
- },
92
- });
93
-
94
- this.isEnabled = true;
95
- // do not finish this run (for parallel testing)
96
- this.proceed = process.env.TESTOMATIO_PROCEED;
97
- this.jiraId = process.env.TESTOMATIO_JIRA_ID;
98
- this.runId = params.runId || process.env.runId;
99
- this.createNewTests = params.createNewTests ?? !!process.env.TESTOMATIO_CREATE;
100
- this.hasUnmatchedTests = false;
101
- this.requestFailures = 0;
102
-
103
- if (!isValidUrl(this.url.trim())) {
104
- this.isEnabled = false;
105
- console.error(APP_PREFIX, chalk.red(`Error creating report on Testomat.io, report url '${this.url}' is invalid`));
106
- }
107
- }
108
-
109
- /**
110
- * Asynchronously prepares and retrieves the Testomat.io test grepList based on the provided options.
111
- * @param {Object} opts - The options for preparing the test grepList.
112
- * @returns {Promise<string[]>} - An array containing the retrieved
113
- * test grepList, or an empty array if no tests are found or the request is disabled.
114
- * @throws {Error} - Throws an error if there was a problem while making the request.
115
- */
116
- async prepareRun(opts) {
117
- if (!this.isEnabled) return [];
118
-
119
- const { type, id } = parseFilterParams(opts);
120
-
121
- try {
122
- const q = generateFilterRequestParams({
123
- type,
124
- id,
125
- apiKey: this.apiKey.trim(),
126
- });
127
-
128
- if (!q) {
129
- return;
130
- }
131
-
132
- const resp = await this.axios.get('/api/test_grep', q);
133
- const { data } = resp;
134
-
135
- if (Array.isArray(data?.tests) && data?.tests?.length > 0) {
136
- foundedTestLog(APP_PREFIX, data.tests);
137
- return data.tests;
138
- }
139
-
140
- console.log(APP_PREFIX, `⛔ No tests found for your --filter --> ${type}=${id}`);
141
- } catch (err) {
142
- console.error(APP_PREFIX, `🚩 Error getting Testomat.io test grepList: ${err}`);
143
- }
144
- }
145
-
146
- /**
147
- * Creates a new run on Testomat.io
148
- * @param {{isBatchEnabled?: boolean}} params
149
- * @returns Promise<void>
150
- */
151
- async createRun(params = {}) {
152
- this.batch.isEnabled = params.isBatchEnabled ?? this.batch.isEnabled;
153
- if (!this.isEnabled) return;
154
- if (this.batch.isEnabled) this.batch.intervalFunction = setInterval(this.#batchUpload, this.batch.intervalTime);
155
-
156
- let buildUrl = process.env.BUILD_URL || process.env.CI_JOB_URL || process.env.CIRCLE_BUILD_URL;
157
-
158
- // GitHub Actions Url
159
- if (!buildUrl && process.env.GITHUB_RUN_ID) {
160
- // eslint-disable-next-line max-len
161
- buildUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
162
- }
163
-
164
- // Azure DevOps Url
165
- if (!buildUrl && process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI) {
166
- const collectionUri = process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI;
167
- const project = process.env.SYSTEM_TEAMPROJECT;
168
- const buildId = process.env.BUILD_BUILDID;
169
- buildUrl = `${collectionUri}/${project}/_build/results?buildId=${buildId}`;
170
- }
171
-
172
- if (buildUrl && !buildUrl.startsWith('http')) buildUrl = undefined;
173
-
174
- const accessEvent = process.env.TESTOMATIO_PUBLISH ? 'publish' : null;
175
-
176
- const runParams = Object.fromEntries(
177
- Object.entries({
178
- ci_build_url: buildUrl,
179
- parallel: this.parallel,
180
- api_key: this.apiKey.trim(),
181
- group_title: this.groupTitle,
182
- access_event: accessEvent,
183
- jira_id: this.jiraId,
184
- env: this.env,
185
- title: this.title,
186
- label: this.label,
187
- shared_run: this.sharedRun,
188
- shared_run_timeout: this.sharedRunTimeout,
189
- }).filter(([, value]) => !!value),
190
- );
191
- debug('Run params', JSON.stringify(runParams, null, 2));
192
-
193
- if (this.runId) {
194
- this.store.runId = this.runId;
195
- debug(`Run with id ${this.runId} already created, updating...`);
196
- const resp = await this.axios.put(`/api/reporter/${this.runId}`, runParams);
197
- if (resp.data.artifacts) setS3Credentials(resp.data.artifacts);
198
- return;
199
92
  }
200
-
201
- debug('Creating run...');
202
- try {
203
- const resp = await this.axios.post(`/api/reporter`, runParams, {
204
- maxContentLength: Infinity,
205
- maxBodyLength: Infinity,
206
- });
207
-
208
- this.runId = resp.data.uid;
209
- this.runUrl = `${this.url}/${resp.data.url.split('/').splice(3).join('/')}`;
210
- this.runPublicUrl = resp.data.public_url;
211
-
212
- if (resp.data.artifacts) setS3Credentials(resp.data.artifacts);
213
-
214
- this.store.runUrl = this.runUrl;
215
- this.store.runPublicUrl = this.runPublicUrl;
216
- this.store.runId = this.runId;
217
- console.log(APP_PREFIX, '📊 Report created. Report ID:', this.runId);
218
- process.env.runId = this.runId;
219
- debug('Run created', this.runId);
220
- } catch (err) {
221
- const errorText = err.response?.data?.message || err.message;
222
- console.log(errorText || err);
223
- if (!this.apiKey) console.error('Testomat.io API key is not set');
224
- if (!this.apiKey?.startsWith('tstmt')) console.error('Testomat.io API key is invalid');
225
- console.error(
226
- APP_PREFIX,
227
- 'Error creating Testomat.io report (see details above), please check if your API key is valid. Skipping report'
228
- );
229
- printCreateIssue(err);
93
+ /**
94
+ * Asynchronously prepares and retrieves the Testomat.io test grepList based on the provided options.
95
+ * @param {Object} opts - The options for preparing the test grepList.
96
+ * @returns {Promise<string[]>} - An array containing the retrieved
97
+ * test grepList, or an empty array if no tests are found or the request is disabled.
98
+ * @throws {Error} - Throws an error if there was a problem while making the request.
99
+ */
100
+ async prepareRun(opts) {
101
+ if (!this.isEnabled)
102
+ return [];
103
+ const { type, id } = (0, pipe_utils_js_1.parseFilterParams)(opts);
104
+ try {
105
+ const q = (0, pipe_utils_js_1.generateFilterRequestParams)({
106
+ type,
107
+ id,
108
+ apiKey: this.apiKey.trim(),
109
+ });
110
+ if (!q) {
111
+ return;
112
+ }
113
+ const resp = await this.client.request({
114
+ method: 'GET',
115
+ url: '/api/test_grep',
116
+ params: q
117
+ });
118
+ if (Array.isArray(resp.data?.tests) && resp.data?.tests?.length > 0) {
119
+ (0, utils_js_1.foundedTestLog)(constants_js_1.APP_PREFIX, resp.data.tests);
120
+ return resp.data.tests;
121
+ }
122
+ console.log(constants_js_1.APP_PREFIX, `⛔ No tests found for your --filter --> ${type}=${id}`);
123
+ }
124
+ catch (err) {
125
+ console.error(constants_js_1.APP_PREFIX, `🚩 Error getting Testomat.io test grepList: ${err}`);
126
+ }
230
127
  }
231
- debug('"createRun" function finished');
232
- }
233
-
234
- /**
235
- * Decides whether to skip test reporting in case of too many request failures
236
- * @returns {boolean}
237
- */
238
- #cancelTestReportingInCaseOfTooManyReqFailures() {
239
- if (!process.env.TESTOMATIO_MAX_REQUEST_FAILURES) return;
240
-
241
- const cancelReporting = this.requestFailures >= parseInt(process.env.TESTOMATIO_MAX_REQUEST_FAILURES, 10);
242
- if (cancelReporting) {
243
- this.reportingCanceledDueToReqFailures = true;
244
- const errorMessage =
245
- `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES} requests were failed, reporting to Testomat aborted.`;
246
- console.warn(`${APP_PREFIX} ${chalk.yellow(errorMessage)}`);
128
+ /**
129
+ * Creates a new run on Testomat.io
130
+ * @param {{isBatchEnabled?: boolean}} params
131
+ * @returns Promise<void>
132
+ */
133
+ async createRun(params = {}) {
134
+ this.batch.isEnabled = params.isBatchEnabled ?? this.batch.isEnabled;
135
+ if (!this.isEnabled)
136
+ return;
137
+ if (this.batch.isEnabled && this.isEnabled)
138
+ this.batch.intervalFunction = setInterval(this.#batchUpload, this.batch.intervalTime);
139
+ let buildUrl = process.env.BUILD_URL || process.env.CI_JOB_URL || process.env.CIRCLE_BUILD_URL;
140
+ // GitHub Actions Url
141
+ if (!buildUrl && process.env.GITHUB_RUN_ID) {
142
+ // eslint-disable-next-line max-len
143
+ buildUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
144
+ }
145
+ // Azure DevOps Url
146
+ if (!buildUrl && process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI) {
147
+ const collectionUri = process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI;
148
+ const project = process.env.SYSTEM_TEAMPROJECT;
149
+ const buildId = process.env.BUILD_BUILDID;
150
+ buildUrl = `${collectionUri}/${project}/_build/results?buildId=${buildId}`;
151
+ }
152
+ if (buildUrl && !buildUrl.startsWith('http'))
153
+ buildUrl = undefined;
154
+ const accessEvent = process.env.TESTOMATIO_PUBLISH ? 'publish' : null;
155
+ const runParams = Object.fromEntries(Object.entries({
156
+ ci_build_url: buildUrl,
157
+ parallel: this.parallel,
158
+ api_key: this.apiKey.trim(),
159
+ group_title: this.groupTitle,
160
+ access_event: accessEvent,
161
+ jira_id: this.jiraId,
162
+ env: this.env,
163
+ title: this.title,
164
+ label: this.label,
165
+ shared_run: this.sharedRun,
166
+ shared_run_timeout: this.sharedRunTimeout,
167
+ }).filter(([, value]) => !!value));
168
+ debug(' >>>>>> Run params', JSON.stringify(runParams, null, 2));
169
+ if (this.runId) {
170
+ this.store.runId = this.runId;
171
+ debug(`Run with id ${this.runId} already created, updating...`);
172
+ const resp = await this.client.request({
173
+ method: 'PUT',
174
+ url: `/api/reporter/${this.runId}`,
175
+ data: runParams
176
+ });
177
+ if (resp.data.artifacts)
178
+ (0, pipe_utils_js_1.setS3Credentials)(resp.data.artifacts);
179
+ return;
180
+ }
181
+ debug('Creating run...');
182
+ try {
183
+ const resp = await this.client.request({
184
+ method: 'POST',
185
+ url: '/api/reporter',
186
+ data: runParams,
187
+ maxContentLength: Infinity,
188
+ responseType: 'json'
189
+ });
190
+ this.runId = resp.data.uid;
191
+ this.runUrl = `${this.url}/${resp.data.url.split('/').splice(3).join('/')}`;
192
+ this.runPublicUrl = resp.data.public_url;
193
+ if (resp.data.artifacts)
194
+ (0, pipe_utils_js_1.setS3Credentials)(resp.data.artifacts);
195
+ this.store.runUrl = this.runUrl;
196
+ this.store.runPublicUrl = this.runPublicUrl;
197
+ this.store.runId = this.runId;
198
+ console.log(constants_js_1.APP_PREFIX, '📊 Report created. Report ID:', this.runId);
199
+ process.env.runId = this.runId;
200
+ debug('Run created', this.runId);
201
+ }
202
+ catch (err) {
203
+ const errorText = err.response?.data?.message || err.message;
204
+ debug('Error creating run', err);
205
+ console.log(errorText || err);
206
+ if (!this.apiKey)
207
+ console.error('Testomat.io API key is not set');
208
+ if (!this.apiKey?.startsWith('tstmt'))
209
+ console.error('Testomat.io API key is invalid');
210
+ 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');
211
+ printCreateIssue(err);
212
+ }
213
+ debug('"createRun" function finished');
247
214
  }
248
- return cancelReporting;
249
- }
250
-
251
- #uploadSingleTest = async data => {
252
- if (!this.isEnabled) return;
253
- if (!this.runId) return;
254
- if (this.#cancelTestReportingInCaseOfTooManyReqFailures()) return;
255
-
256
- data.api_key = this.apiKey;
257
- data.create = this.createNewTests;
258
-
259
- if (!process.env.TESTOMATIO_STACK_PASSED && data.status === STATUS.PASSED) {
260
- data.stack = null;
215
+ /**
216
+ * Decides whether to skip test reporting in case of too many request failures
217
+ * @returns {boolean}
218
+ */
219
+ #cancelTestReportingInCaseOfTooManyReqFailures() {
220
+ if (!process.env.TESTOMATIO_MAX_REQUEST_FAILURES)
221
+ return;
222
+ const cancelReporting = this.requestFailures >= parseInt(process.env.TESTOMATIO_MAX_REQUEST_FAILURES, 10);
223
+ if (cancelReporting) {
224
+ this.reportingCanceledDueToReqFailures = true;
225
+ let errorMessage = `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES}`;
226
+ errorMessage += ' requests were failed, reporting to Testomat aborted.';
227
+ console.warn(`${constants_js_1.APP_PREFIX} ${picocolors_1.default.yellow(errorMessage)}`);
228
+ }
229
+ return cancelReporting;
261
230
  }
262
-
263
- const json = JsonCycle.stringify(data);
264
-
265
- debug('Adding test', json);
266
-
267
- return this.axios
268
- .post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig)
269
- .catch(err => {
270
- this.requestFailures++;
271
- this.notReportedTestsCount++;
272
- if (err.response) {
273
- if (err.response.status >= 400) {
274
- const responseData = err.response.data || { message: '' };
275
- console.log(
276
- APP_PREFIX,
277
- chalk.yellow(`Warning: ${responseData.message} (${err.response.status})`),
278
- chalk.grey(data?.title || ''),
279
- );
280
- if (err.response?.data?.message?.includes('could not be matched')) {
281
- this.hasUnmatchedTests = true;
282
- }
231
+ #uploadSingleTest = async (data) => {
232
+ if (!this.isEnabled)
283
233
  return;
284
- }
285
- console.log(
286
- APP_PREFIX,
287
- chalk.yellow(`Warning: ${data?.title || ''} (${err.response?.status})`),
288
- `Report couldn't be processed: ${err?.response?.data?.message}`,
289
- );
290
- printCreateIssue(err);
291
- } else {
292
- console.log(APP_PREFIX, chalk.blue(data?.title || ''), "Report couldn't be processed", err);
234
+ if (!this.runId)
235
+ return;
236
+ if (this.#cancelTestReportingInCaseOfTooManyReqFailures())
237
+ return;
238
+ data.api_key = this.apiKey;
239
+ data.create = this.createNewTests;
240
+ if (!process.env.TESTOMATIO_STACK_PASSED && data.status === constants_js_1.STATUS.PASSED) {
241
+ data.stack = null;
293
242
  }
294
- });
295
- };
296
-
297
-
298
- /**
299
- * Uploads tests as a batch (multiple tests at once). Intended to be used with a setInterval
300
- */
301
- #batchUpload = async () => {
302
- this.batch.batchIndex++;
303
- if (!this.batch.isEnabled) return;
304
- if (!this.batch.tests.length) return;
305
- if (this.#cancelTestReportingInCaseOfTooManyReqFailures()) return;
306
-
307
- // get tests from batch and clear batch
308
- const testsToSend = this.batch.tests.splice(0);
309
- debug('📨 Batch upload', testsToSend.length, 'tests');
310
-
311
- testsToSend.forEach(debug);
312
-
313
- return this.axios
314
- .post(
315
- `/api/reporter/${this.runId}/testrun`,
316
- { api_key: this.apiKey, tests: testsToSend, batch_index: this.batch.batchIndex },
317
- axiosAddTestrunRequestConfig,
318
- )
319
- .catch(err => {
320
- this.requestFailures++;
321
- this.notReportedTestsCount += testsToSend.length;
322
- if (err.response) {
323
- if (err.response.status >= 400) {
324
- const responseData = err.response.data || { message: '' };
325
- console.log(
326
- APP_PREFIX,
327
- chalk.yellow(`Warning: ${responseData.message} (${err.response.status})`),
328
- // chalk.grey(data?.title || ''),
329
- );
330
- if (err.response?.data?.message?.includes('could not be matched')) {
331
- this.hasUnmatchedTests = true;
243
+ const json = json_cycle_1.default.stringify(data);
244
+ debug('Adding test', json);
245
+ return this.client.request({
246
+ method: 'POST',
247
+ url: `/api/reporter/${this.runId}/testrun`,
248
+ data: json,
249
+ headers: {
250
+ 'Content-Type': 'application/json',
251
+ },
252
+ maxContentLength: Infinity
253
+ }).catch(err => {
254
+ this.requestFailures++;
255
+ this.notReportedTestsCount++;
256
+ if (err.response) {
257
+ if (err.response.status >= 400) {
258
+ const responseData = err.response.data || { message: '' };
259
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.yellow(`Warning: ${responseData.message} (${err.response.status})`), picocolors_1.default.gray(data?.title || ''));
260
+ if (err.response?.data?.message?.includes('could not be matched')) {
261
+ this.hasUnmatchedTests = true;
262
+ }
263
+ return;
264
+ }
265
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.yellow(`Warning: ${data?.title || ''} (${err.response?.status})`), `Report couldn't be processed: ${err?.response?.data?.message}`);
266
+ printCreateIssue(err);
267
+ }
268
+ else {
269
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.blue(data?.title || ''), "Report couldn't be processed", err);
332
270
  }
271
+ });
272
+ };
273
+ /**
274
+ * Uploads tests as a batch (multiple tests at once). Intended to be used with a setInterval
275
+ */
276
+ #batchUpload = async () => {
277
+ if (!this.batch.isEnabled)
278
+ return;
279
+ if (!this.batch.tests.length)
280
+ return;
281
+ if (this.#cancelTestReportingInCaseOfTooManyReqFailures())
333
282
  return;
334
- }
335
- console.log(
336
- APP_PREFIX,
337
- chalk.yellow(`Warning: (${err.response?.status})`),
338
- `Report couldn't be processed: ${err?.response?.data?.message}`,
339
- );
340
- printCreateIssue(err);
341
- } else {
342
- console.log(APP_PREFIX, "Report couldn't be processed", err);
283
+ // prevent infinite loop
284
+ if (this.batch.numberOfTimesCalledWithoutTests > 10) {
285
+ debug('📨 Batch upload: no tests to send for 10 times, stopping batch');
286
+ clearInterval(this.batch.intervalFunction);
287
+ this.batch.isEnabled = false;
343
288
  }
344
- });
345
- };
346
-
347
- /**
348
- * Adds a test to the batch uploader (or reports a single test if batch uploading is disabled)
349
- */
350
- addTest(data) {
351
- this.isEnabled = this.apiKey ?? this.isEnabled;
352
-
353
- if (!this.isEnabled) return;
354
- if (!this.runId) return;
355
-
356
- // add test ID + run ID
357
- if (data.rid) data.rid = `${this.runId}-${data.rid}`;
358
- data.api_key = this.apiKey;
359
- data.create = this.createNewTests;
360
-
361
- let uploading = null;
362
- if (!this.batch.isEnabled) uploading = this.#uploadSingleTest(data);
363
- else this.batch.tests.push(data);
364
-
365
- // if test is added after run already finished
366
- if (!this.batch.intervalFunction) uploading = this.#batchUpload();
367
-
368
- // return promise to be able to wait for it
369
- return uploading;
370
- }
371
-
372
- /**
373
- * @param {import('../../types').RunData} params
374
- * @returns
375
- */
376
- async finishRun(params) {
377
- if (!this.isEnabled) return;
378
-
379
- await this.#batchUpload();
380
- if (this.batch.intervalFunction) {
381
- clearInterval(this.batch.intervalFunction);
382
- // this code is required in case test is added after run is finished
383
- // (e.g. if test has artifacts, add test function will be invoked only after artifacts are uploaded)
384
- // batch stops working after run is finished; thus, disable it to use single test uploading
385
- this.batch.intervalFunction = null;
386
- this.batch.isEnabled = false;
387
- }
388
-
389
- debug('Finishing run...');
390
-
391
- if (this.reportingCanceledDueToReqFailures) {
392
- const errorMessage = chalk.red(
393
- `⚠️ Due to request failures, ${this.notReportedTestsCount} test(s) were not reported to Testomat.io`,
394
- );
395
- console.warn(`${APP_PREFIX} ${errorMessage}`);
396
- }
397
-
398
- const { status, parallel } = params;
399
-
400
- let status_event;
401
-
402
- if (status === STATUS.FINISHED) status_event = 'finish';
403
- if (status === STATUS.PASSED) status_event = 'pass';
404
- if (status === STATUS.FAILED) status_event = 'fail';
405
- if (parallel) status_event += '_parallel';
406
-
407
- try {
408
- if (this.runId && !this.proceed) {
409
- await this.axios.put(`/api/reporter/${this.runId}`, {
410
- api_key: this.apiKey,
411
- status_event,
412
- detach: params.detach,
413
- duration: params.duration,
414
- tests: params.tests,
289
+ if (!this.batch.tests.length) {
290
+ debug('📨 Batch upload: no tests to send');
291
+ this.batch.numberOfTimesCalledWithoutTests++;
292
+ return;
293
+ }
294
+ this.batch.batchIndex++;
295
+ // get tests from batch and clear batch
296
+ const testsToSend = this.batch.tests.splice(0);
297
+ debug('📨 Batch upload', testsToSend.length, 'tests');
298
+ return this.client.request({
299
+ method: 'POST',
300
+ url: `/api/reporter/${this.runId}/testrun`,
301
+ data: {
302
+ api_key: this.apiKey,
303
+ tests: testsToSend,
304
+ batch_index: this.batch.batchIndex
305
+ },
306
+ headers: {
307
+ 'Content-Type': 'application/json',
308
+ },
309
+ maxContentLength: Infinity
310
+ }).catch(err => {
311
+ this.requestFailures++;
312
+ this.notReportedTestsCount += testsToSend.length;
313
+ if (err.response) {
314
+ if (err.response.status >= 400) {
315
+ const responseData = err.response.data || { message: '' };
316
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.yellow(`Warning: ${responseData.message} (${err.response.status})`));
317
+ if (err.response?.data?.message?.includes('could not be matched')) {
318
+ this.hasUnmatchedTests = true;
319
+ }
320
+ return;
321
+ }
322
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.yellow(`Warning: (${err.response?.status})`), `Report couldn't be processed: ${err?.response?.data?.message}`);
323
+ printCreateIssue(err);
324
+ }
325
+ else {
326
+ console.log(constants_js_1.APP_PREFIX, "Report couldn't be processed", err);
327
+ }
415
328
  });
416
- if (this.runUrl) {
417
- console.log(APP_PREFIX, '📊 Report Saved. Report URL:', chalk.magenta(this.runUrl));
329
+ };
330
+ /**
331
+ * Adds a test to the batch uploader (or reports a single test if batch uploading is disabled)
332
+ */
333
+ addTest(data) {
334
+ this.isEnabled = this.apiKey ?? this.isEnabled;
335
+ if (!this.isEnabled)
336
+ return;
337
+ if (!this.runId)
338
+ return;
339
+ // add test ID + run ID
340
+ if (data.rid)
341
+ data.rid = `${this.runId}-${data.rid}`;
342
+ data.api_key = this.apiKey;
343
+ data.create = this.createNewTests;
344
+ let uploading = null;
345
+ if (!this.batch.isEnabled)
346
+ uploading = this.#uploadSingleTest(data);
347
+ else
348
+ this.batch.tests.push(data);
349
+ // if test is added after run which is already finished
350
+ if (!this.batch.intervalFunction)
351
+ uploading = this.#batchUpload();
352
+ // return promise to be able to wait for it
353
+ return uploading;
354
+ }
355
+ /**
356
+ * @param {import('../../types/types.js').RunData} params
357
+ * @returns
358
+ */
359
+ async finishRun(params) {
360
+ if (!this.isEnabled)
361
+ return;
362
+ await this.#batchUpload();
363
+ if (this.batch.intervalFunction) {
364
+ clearInterval(this.batch.intervalFunction);
365
+ // this code is required in case test is added after run is finished
366
+ // (e.g. if test has artifacts, add test function will be invoked only after artifacts are uploaded)
367
+ // batch stops working after run is finished; thus, disable it to use single test uploading
368
+ this.batch.intervalFunction = null;
369
+ this.batch.isEnabled = false;
370
+ }
371
+ debug('Finishing run...');
372
+ if (this.reportingCanceledDueToReqFailures) {
373
+ const errorMessage = picocolors_1.default.red(`⚠️ Due to request failures, ${this.notReportedTestsCount} test(s) were not reported to Testomat.io`);
374
+ console.warn(`${constants_js_1.APP_PREFIX} ${errorMessage}`);
375
+ }
376
+ const { status, parallel } = params;
377
+ let status_event;
378
+ if (status === constants_js_1.STATUS.FINISHED)
379
+ status_event = 'finish';
380
+ if (status === constants_js_1.STATUS.PASSED)
381
+ status_event = 'pass';
382
+ if (status === constants_js_1.STATUS.FAILED)
383
+ status_event = 'fail';
384
+ if (parallel)
385
+ status_event += '_parallel';
386
+ try {
387
+ if (this.runId && !this.proceed) {
388
+ await this.client.request({
389
+ method: 'PUT',
390
+ url: `/api/reporter/${this.runId}`,
391
+ data: {
392
+ api_key: this.apiKey,
393
+ duration: params.duration,
394
+ status_event,
395
+ detach: params.detach,
396
+ tests: params.tests,
397
+ }
398
+ });
399
+ if (this.runUrl) {
400
+ console.log(constants_js_1.APP_PREFIX, '📊 Report Saved. Report URL:', picocolors_1.default.magenta(this.runUrl));
401
+ }
402
+ if (this.runPublicUrl) {
403
+ console.log(constants_js_1.APP_PREFIX, '🌟 Public URL:', picocolors_1.default.magenta(this.runPublicUrl));
404
+ }
405
+ }
406
+ if (this.runUrl && this.proceed) {
407
+ const notFinishedMessage = picocolors_1.default.yellow(picocolors_1.default.bold('Run was not finished because of $TESTOMATIO_PROCEED'));
408
+ console.log(constants_js_1.APP_PREFIX, `📊 ${notFinishedMessage}. Report URL: ${picocolors_1.default.magenta(this.runUrl)}`);
409
+ console.log(constants_js_1.APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx start-test-run --finish`);
410
+ }
411
+ if (this.hasUnmatchedTests) {
412
+ console.log('');
413
+ 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')));
414
+ 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')}`);
415
+ console.log(constants_js_1.APP_PREFIX, `But to keep your tests consistent it is recommended to ${picocolors_1.default.bold('import tests first')}`);
416
+ console.log(constants_js_1.APP_PREFIX, 'If tests were imported but still not matched, assign test IDs to your tests.');
417
+ console.log(constants_js_1.APP_PREFIX, 'You can do that automatically via command line tools:');
418
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.bold('npx check-tests ... --update-ids'), 'See: https://bit.ly/js-update-ids');
419
+ console.log(constants_js_1.APP_PREFIX, 'or for Cucumber:');
420
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.bold('npx check-cucumber ... --update-ids'), 'See: https://bit.ly/bdd-update-ids');
421
+ }
418
422
  }
419
- if (this.runPublicUrl) {
420
- console.log(APP_PREFIX, '🌟 Public URL:', chalk.magenta(this.runPublicUrl));
423
+ catch (err) {
424
+ console.log(constants_js_1.APP_PREFIX, 'Error updating status, skipping...', err);
425
+ printCreateIssue(err);
421
426
  }
422
- }
423
- if (this.runUrl && this.proceed) {
424
- const notFinishedMessage = chalk.yellow.bold('Run was not finished because of $TESTOMATIO_PROCEED');
425
- console.log(APP_PREFIX, `📊 ${notFinishedMessage}. Report URL: ${chalk.magenta(this.runUrl)}`);
426
- console.log(APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx start-test-run --finish`);
427
- }
428
-
429
- if (this.hasUnmatchedTests) {
430
- console.log('');
431
- // eslint-disable-next-line max-len
432
- console.log(APP_PREFIX, chalk.yellow.bold('⚠️ Some reported tests were not found in Testomat.io project'));
433
- // eslint-disable-next-line max-len
434
- console.log(
435
- APP_PREFIX,
436
- `If you use Testomat.io as a reporter only, please re-run tests using ${chalk.bold('TESTOMATIO_CREATE=1')}`,
437
- );
438
- // eslint-disable-next-line max-len
439
- console.log(
440
- APP_PREFIX,
441
- `But to keep your tests consistent it is recommended to ${chalk.bold('import tests first')}`,
442
- );
443
- console.log(APP_PREFIX, 'If tests were imported but still not matched, assign test IDs to your tests.');
444
- console.log(APP_PREFIX, 'You can do that automatically via command line tools:');
445
- console.log(APP_PREFIX, chalk.bold('npx check-tests ... --update-ids'), 'See: https://bit.ly/js-update-ids');
446
- console.log(APP_PREFIX, 'or for Cucumber:');
447
- // eslint-disable-next-line max-len
448
- console.log(
449
- APP_PREFIX,
450
- chalk.bold('npx check-cucumber ... --update-ids'),
451
- 'See: https://bit.ly/bdd-update-ids',
452
- );
453
- }
454
- } catch (err) {
455
- console.log(APP_PREFIX, 'Error updating status, skipping...', err);
456
- printCreateIssue(err);
427
+ debug('Run finished');
428
+ }
429
+ toString() {
430
+ return 'Testomatio Reporter';
457
431
  }
458
- debug('Run finished');
459
- }
460
-
461
- toString() {
462
- return 'Testomatio Reporter';
463
- }
464
432
  }
465
-
466
433
  let registeredErrorHints = false;
467
434
  function printCreateIssue(err) {
468
- if (registeredErrorHints) return;
469
- registeredErrorHints = true;
470
- process.on('exit', () => {
471
- console.log();
472
- console.log(APP_PREFIX, 'There was an error reporting to Testomat.io:');
473
- console.log(
474
- APP_PREFIX,
475
- 'If you think this is a bug please create an issue: https://github.com/testomatio/reporter/issues/new',
476
- ); // eslint-disable-line max-len
477
- console.log(APP_PREFIX, 'Provide this information:');
478
- console.log('Error:', err.message || err.code);
479
- if (!err.config) return;
480
-
481
- const time = new Date().toUTCString();
482
- const { data, url, baseURL, method } = err?.config || {};
483
- console.log('```js');
484
- console.log({ data: data?.replace(/"(tstmt_[^"]+)"/g, 'tstmt_*'), url, baseURL, method, time });
485
- console.log('```');
486
- });
435
+ if (registeredErrorHints)
436
+ return;
437
+ registeredErrorHints = true;
438
+ process.on('exit', () => {
439
+ console.log();
440
+ console.log(constants_js_1.APP_PREFIX, 'There was an error reporting to Testomat.io:');
441
+ 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');
442
+ console.log(constants_js_1.APP_PREFIX, 'Provide this information:');
443
+ console.log('Error:', err.message || err.code);
444
+ if (!err.config)
445
+ return;
446
+ const time = new Date().toUTCString();
447
+ const { body, url, baseURL, method } = err?.config || {};
448
+ console.log('```js');
449
+ console.log({ body: body?.replace(/"(tstmt_[^"]+)"/g, 'tstmt_*'), url, baseURL, method, time });
450
+ console.log('```');
451
+ });
487
452
  }
488
-
489
- const axiosAddTestrunRequestConfig = {
490
- maxContentLength: Infinity,
491
- maxBodyLength: Infinity,
492
- headers: {
493
- // Overwrite Axios's automatically set Content-Type
494
- 'Content-Type': 'application/json',
495
- },
496
- };
497
-
498
453
  module.exports = TestomatioPipe;