@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.
Files changed (115) hide show
  1. package/lib/adapter/codecept.d.ts +2 -0
  2. package/lib/adapter/codecept.js +31 -24
  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 +11 -9
  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 -3
  12. package/lib/adapter/playwright.d.ts +14 -0
  13. package/lib/adapter/playwright.js +58 -33
  14. package/lib/adapter/vitest.d.ts +35 -0
  15. package/lib/adapter/vitest.js +6 -6
  16. package/lib/adapter/webdriver.d.ts +24 -0
  17. package/lib/adapter/webdriver.js +34 -6
  18. package/lib/bin/cli.d.ts +2 -0
  19. package/lib/bin/cli.js +228 -0
  20. package/lib/bin/reportXml.d.ts +2 -0
  21. package/lib/bin/reportXml.js +11 -9
  22. package/lib/bin/startTest.d.ts +2 -0
  23. package/lib/bin/startTest.js +9 -5
  24. package/lib/bin/uploadArtifacts.d.ts +2 -0
  25. package/lib/bin/uploadArtifacts.js +81 -0
  26. package/lib/client.d.ts +76 -0
  27. package/lib/client.js +111 -45
  28. package/lib/config.d.ts +1 -0
  29. package/lib/constants.d.ts +25 -0
  30. package/lib/constants.js +5 -1
  31. package/lib/data-storage.d.ts +34 -0
  32. package/lib/data-storage.js +2 -2
  33. package/lib/junit-adapter/adapter.d.ts +9 -0
  34. package/lib/junit-adapter/csharp.d.ts +4 -0
  35. package/lib/junit-adapter/index.d.ts +3 -0
  36. package/lib/junit-adapter/java.d.ts +5 -0
  37. package/lib/junit-adapter/javascript.d.ts +4 -0
  38. package/lib/junit-adapter/python.d.ts +5 -0
  39. package/lib/junit-adapter/ruby.d.ts +4 -0
  40. package/lib/output.d.ts +11 -0
  41. package/lib/package.json +3 -1
  42. package/lib/pipe/bitbucket.d.ts +23 -0
  43. package/lib/pipe/bitbucket.js +2 -2
  44. package/lib/pipe/csv.d.ts +47 -0
  45. package/lib/pipe/csv.js +2 -2
  46. package/lib/pipe/debug.d.ts +29 -0
  47. package/lib/pipe/debug.js +108 -0
  48. package/lib/pipe/github.d.ts +30 -0
  49. package/lib/pipe/github.js +2 -2
  50. package/lib/pipe/gitlab.d.ts +23 -0
  51. package/lib/pipe/gitlab.js +2 -2
  52. package/lib/pipe/html.d.ts +34 -0
  53. package/lib/pipe/html.js +8 -1
  54. package/lib/pipe/index.d.ts +1 -0
  55. package/lib/pipe/index.js +3 -3
  56. package/lib/pipe/testomatio.d.ts +70 -0
  57. package/lib/pipe/testomatio.js +50 -30
  58. package/lib/reporter-functions.d.ts +34 -0
  59. package/lib/reporter-functions.js +17 -7
  60. package/lib/reporter.d.ts +232 -0
  61. package/lib/reporter.js +19 -33
  62. package/lib/services/artifacts.d.ts +33 -0
  63. package/lib/services/index.d.ts +9 -0
  64. package/lib/services/key-values.d.ts +27 -0
  65. package/lib/services/key-values.js +1 -1
  66. package/lib/services/logger.d.ts +64 -0
  67. package/lib/template/testomatio.hbs +651 -1366
  68. package/lib/uploader.d.ts +60 -0
  69. package/lib/uploader.js +312 -0
  70. package/lib/utils/pipe_utils.d.ts +41 -0
  71. package/lib/utils/pipe_utils.js +3 -5
  72. package/lib/utils/utils.d.ts +45 -0
  73. package/lib/utils/utils.js +69 -2
  74. package/lib/xmlReader.d.ts +92 -0
  75. package/lib/xmlReader.js +22 -12
  76. package/package.json +15 -9
  77. package/src/adapter/codecept.js +30 -24
  78. package/src/adapter/cypress-plugin/index.js +5 -3
  79. package/src/adapter/mocha.cjs +1 -1
  80. package/src/adapter/mocha.js +4 -3
  81. package/src/adapter/playwright.js +59 -31
  82. package/src/adapter/vitest.js +6 -6
  83. package/src/adapter/webdriver.js +41 -10
  84. package/src/bin/cli.js +280 -0
  85. package/src/bin/reportXml.js +15 -8
  86. package/src/bin/startTest.js +7 -3
  87. package/src/bin/uploadArtifacts.js +90 -0
  88. package/src/client.js +137 -56
  89. package/src/constants.js +5 -1
  90. package/src/data-storage.js +2 -2
  91. package/src/pipe/bitbucket.js +2 -2
  92. package/src/pipe/csv.js +3 -3
  93. package/src/pipe/debug.js +104 -0
  94. package/src/pipe/github.js +2 -3
  95. package/src/pipe/gitlab.js +6 -6
  96. package/src/pipe/html.js +11 -3
  97. package/src/pipe/index.js +5 -7
  98. package/src/pipe/testomatio.js +72 -67
  99. package/src/reporter-functions.js +18 -7
  100. package/src/reporter.cjs_decprecated +21 -0
  101. package/src/reporter.js +20 -11
  102. package/src/services/key-values.js +1 -1
  103. package/src/services/logger.js +4 -2
  104. package/src/template/testomatio.hbs +651 -1366
  105. package/src/uploader.js +371 -0
  106. package/src/utils/pipe_utils.js +4 -12
  107. package/src/utils/utils.js +48 -6
  108. package/src/xmlReader.js +26 -15
  109. package/lib/adapter/jasmine/jasmine.js +0 -63
  110. package/lib/adapter/mocha/mocha.js +0 -125
  111. package/lib/fileUploader.js +0 -245
  112. package/lib/utils/chalk.js +0 -10
  113. package/src/fileUploader.js +0 -307
  114. package/src/reporter.cjs +0 -22
  115. package/src/utils/chalk.js +0 -13
@@ -0,0 +1,60 @@
1
+ export class S3Uploader {
2
+ isEnabled: any;
3
+ storeEnabled: boolean;
4
+ config: {};
5
+ /**
6
+ * @type {{path: string, size: number}[]}
7
+ */
8
+ skippedUploads: {
9
+ path: string;
10
+ size: number;
11
+ }[];
12
+ failedUploads: any[];
13
+ /**
14
+ * @type {{path: string, size: number, link: string}[]}
15
+ */
16
+ successfulUploads: {
17
+ path: string;
18
+ size: number;
19
+ link: string;
20
+ }[];
21
+ configKeys: string[];
22
+ resetConfig(): void;
23
+ /**
24
+ *
25
+ * @returns {Record<string, string>}
26
+ */
27
+ getConfig(): Record<string, string>;
28
+ getMaskedConfig(): {
29
+ [k: string]: string;
30
+ };
31
+ checkEnabled(): any;
32
+ enableLogStorage(): void;
33
+ disableLogStorage(): void;
34
+ /**
35
+ * Returns an array of uploaded files
36
+ *
37
+ * @returns {{rid: string, file: string, uploaded: boolean}[]}
38
+ */
39
+ readUploadedFiles(runId: any): {
40
+ rid: string;
41
+ file: string;
42
+ uploaded: boolean;
43
+ }[];
44
+ storeUploadedFile(filePath: any, runId: any, rid: any, uploaded?: boolean): void;
45
+ /**
46
+ * @param {*} filePath
47
+ * @param {*} pathInS3 contains runId, rid and filename
48
+ * @returns
49
+ */
50
+ uploadFileByPath(filePath: any, pathInS3: any): Promise<any>;
51
+ /**
52
+ * @param {Buffer} buffer
53
+ * @param {string[]} pathInS3
54
+ * @returns
55
+ */
56
+ uploadFileAsBuffer(buffer: Buffer, pathInS3: string[]): Promise<any>;
57
+ checkArtifactExistsInFileSystem(filePath: any, attempts?: number, intervalMs?: number): Promise<any>;
58
+ getS3LocationLink(out: any): Promise<any>;
59
+ #private;
60
+ }
@@ -0,0 +1,312 @@
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
+ exports.S3Uploader = void 0;
7
+ const debug_1 = __importDefault(require("debug"));
8
+ const client_s3_1 = require("@aws-sdk/client-s3");
9
+ const lib_storage_1 = require("@aws-sdk/lib-storage");
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const os_1 = __importDefault(require("os"));
12
+ const path_1 = __importDefault(require("path"));
13
+ const promise_retry_1 = __importDefault(require("promise-retry"));
14
+ const picocolors_1 = __importDefault(require("picocolors"));
15
+ const constants_js_1 = require("./constants.js");
16
+ const filesize_1 = require("filesize");
17
+ const debug = (0, debug_1.default)('@testomatio/reporter:file-uploader');
18
+ class S3Uploader {
19
+ constructor() {
20
+ this.isEnabled = undefined;
21
+ this.storeEnabled = true;
22
+ this.config = undefined;
23
+ /**
24
+ * @type {{path: string, size: number}[]}
25
+ */
26
+ this.skippedUploads = [];
27
+ this.failedUploads = [];
28
+ /**
29
+ * @type {{path: string, size: number, link: string}[]}
30
+ */
31
+ this.successfulUploads = [];
32
+ this.configKeys = [
33
+ 'S3_ENDPOINT',
34
+ 'S3_REGION',
35
+ 'S3_BUCKET',
36
+ 'S3_ACCESS_KEY_ID',
37
+ 'S3_SECRET_ACCESS_KEY',
38
+ 'S3_SESSION_TOKEN',
39
+ 'S3_FORCE_PATH_STYLE',
40
+ 'TESTOMATIO_DISABLE_ARTIFACTS',
41
+ 'TESTOMATIO_PRIVATE_ARTIFACTS',
42
+ 'TESTOMATIO_ARTIFACT_MAX_SIZE_MB',
43
+ ];
44
+ }
45
+ resetConfig() {
46
+ this.config = undefined;
47
+ this.isEnabled = undefined;
48
+ }
49
+ /**
50
+ *
51
+ * @returns {Record<string, string>}
52
+ */
53
+ getConfig() {
54
+ if (this.config)
55
+ return this.config;
56
+ this.config = this.configKeys.reduce((acc, key) => {
57
+ acc[key] = process.env[key];
58
+ return acc;
59
+ }, {});
60
+ return this.config;
61
+ }
62
+ getMaskedConfig() {
63
+ return Object.fromEntries(Object.entries(this.getConfig()).map(([key, value]) => [
64
+ key,
65
+ key === 'S3_SECRET_ACCESS_KEY' || key === 'S3_ACCESS_KEY_ID' ? '***' : value,
66
+ ]));
67
+ }
68
+ checkEnabled() {
69
+ if (this.isEnabled !== undefined)
70
+ return this.isEnabled;
71
+ const { S3_BUCKET, TESTOMATIO_DISABLE_ARTIFACTS } = this.getConfig();
72
+ if (!S3_BUCKET)
73
+ debug(`Artifacts uploading is disabled because S3_BUCKET is not set`);
74
+ this.isEnabled = !!(S3_BUCKET && !TESTOMATIO_DISABLE_ARTIFACTS);
75
+ if (this.isEnabled)
76
+ debug('S3 uploader is enabled');
77
+ debug(this.getMaskedConfig());
78
+ return this.isEnabled;
79
+ }
80
+ enableLogStorage() {
81
+ this.storeEnabled = true;
82
+ }
83
+ disableLogStorage() {
84
+ this.storeEnabled = false;
85
+ }
86
+ /**
87
+ *
88
+ * @param {*} Body
89
+ * @param {*} Key
90
+ * @param {{path: string, size?: number}} file
91
+ * @returns
92
+ */
93
+ async #uploadToS3(Body, Key, file) {
94
+ const { S3_BUCKET, TESTOMATIO_PRIVATE_ARTIFACTS } = this.getConfig();
95
+ const ACL = TESTOMATIO_PRIVATE_ARTIFACTS ? 'private' : 'public-read';
96
+ if (!S3_BUCKET || !Body) {
97
+ console.log(constants_js_1.APP_PREFIX, picocolors_1.default.bold(picocolors_1.default.red(`Failed uploading '${Key}'. Please check S3 credentials`)), this.getMaskedConfig());
98
+ return;
99
+ }
100
+ debug('Uploading to S3:', Key);
101
+ const s3Config = this.#getS3Config();
102
+ const s3 = new client_s3_1.S3(s3Config);
103
+ const params = {
104
+ Bucket: S3_BUCKET,
105
+ Key,
106
+ Body,
107
+ };
108
+ // disable ACL for I AM roles
109
+ if (!s3Config.credentials.sessionToken) {
110
+ params.ACL = ACL;
111
+ }
112
+ try {
113
+ const upload = new lib_storage_1.Upload({ client: s3, params });
114
+ const link = await this.getS3LocationLink(upload);
115
+ this.successfulUploads.push({ path: file.path, size: file.size, link });
116
+ debug(`📤 Uploaded artifact. File: ${file.path}, size: ${(0, filesize_1.filesize)(file.size)}, link: ${link}`);
117
+ return link;
118
+ }
119
+ catch (e) {
120
+ this.failedUploads.push({ path: file.path, size: file.size });
121
+ debug('S3 uploading error:', e);
122
+ console.log(constants_js_1.APP_PREFIX, 'Upload failed:', e.message, '\nConfig:\n', this.getMaskedConfig());
123
+ }
124
+ }
125
+ /**
126
+ * Returns an array of uploaded files
127
+ *
128
+ * @returns {{rid: string, file: string, uploaded: boolean}[]}
129
+ */
130
+ readUploadedFiles(runId) {
131
+ const tempFilePath = this.#getFilePathWithUploadsList(runId);
132
+ debug('Reading file', tempFilePath);
133
+ if (!fs_1.default.existsSync(tempFilePath)) {
134
+ debug('File not found:', tempFilePath);
135
+ return [];
136
+ }
137
+ const stats = fs_1.default.statSync(tempFilePath);
138
+ debug('Artifacts file stats:', +stats.mtime);
139
+ debug('Current time:', +new Date());
140
+ const diff = +new Date() - +stats.mtime;
141
+ debug('Diff:', diff);
142
+ const diffHours = diff / 1000 / 60 / 60;
143
+ debug('Diff hours:', diffHours);
144
+ if (diffHours > 3) {
145
+ console.log(constants_js_1.APP_PREFIX, "Artifacts file is too old, can't process artifacts. Please re-run the tests.");
146
+ return [];
147
+ }
148
+ const data = fs_1.default.readFileSync(tempFilePath, 'utf8');
149
+ debug('Artifacts file contents:', data);
150
+ const lines = data.split('\n').filter(Boolean);
151
+ return lines.map(line => JSON.parse(line));
152
+ }
153
+ #getFilePathWithUploadsList(runId) {
154
+ const tempFilePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.run.${runId}.json`);
155
+ if (!fs_1.default.existsSync(tempFilePath)) {
156
+ debug('Creating artifacts file:', tempFilePath);
157
+ fs_1.default.writeFileSync(tempFilePath, '');
158
+ }
159
+ return tempFilePath;
160
+ }
161
+ storeUploadedFile(filePath, runId, rid, uploaded = false) {
162
+ if (!this.storeEnabled)
163
+ return;
164
+ if (!filePath || !runId || !rid)
165
+ return;
166
+ const tempFilePath = this.#getFilePathWithUploadsList(runId);
167
+ if (typeof filePath === 'object') {
168
+ filePath = filePath.path;
169
+ }
170
+ if (typeof filePath === 'string' && !path_1.default.isAbsolute(filePath)) {
171
+ filePath = path_1.default.join(process.cwd(), filePath);
172
+ }
173
+ const data = { rid, file: filePath, uploaded };
174
+ const jsonLine = `${JSON.stringify(data)}\n`;
175
+ fs_1.default.appendFileSync(tempFilePath, jsonLine);
176
+ }
177
+ /**
178
+ * @param {*} filePath
179
+ * @param {*} pathInS3 contains runId, rid and filename
180
+ * @returns
181
+ */
182
+ async uploadFileByPath(filePath, pathInS3) {
183
+ // sometimes artifacts uploading started before createRun function completion
184
+ this.isEnabled = this.isEnabled ?? this.checkEnabled();
185
+ const [runId, rid] = pathInS3;
186
+ if (!filePath)
187
+ return;
188
+ let fileSize = null;
189
+ let fileSizeInMb = null;
190
+ try {
191
+ // file may not exist
192
+ fileSize = fs_1.default.statSync(filePath).size;
193
+ fileSizeInMb = Number((fileSize / (1024 * 1024)).toFixed(2));
194
+ }
195
+ catch (e) {
196
+ debug(`File ${filePath} does not exist`);
197
+ }
198
+ if (!this.isEnabled) {
199
+ this.storeUploadedFile(filePath, runId, rid, false);
200
+ this.skippedUploads.push({ path: filePath, size: fileSize });
201
+ return;
202
+ }
203
+ const { S3_BUCKET, TESTOMATIO_ARTIFACT_MAX_SIZE_MB } = this.getConfig();
204
+ debug('Started upload', filePath, 'to', S3_BUCKET);
205
+ const isFileExist = await this.checkArtifactExistsInFileSystem(filePath, 20, 500);
206
+ if (!isFileExist) {
207
+ console.error(picocolors_1.default.yellow(`Artifacts file ${filePath} does not exist. Skipping...`));
208
+ return;
209
+ }
210
+ // skipping artifact only if: 1. storing to file is enabled, 2. max size is set and 3. file size exceeds the limit
211
+ if (this.storeEnabled &&
212
+ TESTOMATIO_ARTIFACT_MAX_SIZE_MB &&
213
+ fileSizeInMb > parseFloat(TESTOMATIO_ARTIFACT_MAX_SIZE_MB)) {
214
+ const skippedArtifact = { path: filePath, size: fileSize };
215
+ this.storeUploadedFile(filePath, runId, rid, false);
216
+ this.skippedUploads.push(skippedArtifact);
217
+ debug(picocolors_1.default.yellow(`Artifacts file ${JSON.stringify(skippedArtifact)} exceeds the maximum allowed size. Skipping.`));
218
+ return;
219
+ }
220
+ debug('File:', filePath, 'exists, size:', (0, filesize_1.filesize)(fileSize));
221
+ const fileStream = fs_1.default.createReadStream(filePath);
222
+ const Key = pathInS3.join('/');
223
+ const link = await this.#uploadToS3(fileStream, Key, { path: filePath, size: fileSize });
224
+ this.storeUploadedFile(filePath, runId, rid, !!link);
225
+ return link;
226
+ }
227
+ /**
228
+ * @param {Buffer} buffer
229
+ * @param {string[]} pathInS3
230
+ * @returns
231
+ */
232
+ async uploadFileAsBuffer(buffer, pathInS3) {
233
+ if (!this.isEnabled)
234
+ return;
235
+ let Key = pathInS3.join('/');
236
+ const ext = this.#getFileExtBase64(buffer);
237
+ if (ext) {
238
+ Key = `${Key}.${ext}`;
239
+ }
240
+ return this.#uploadToS3(buffer, Key, { path: Key });
241
+ }
242
+ async checkArtifactExistsInFileSystem(filePath, attempts = 5, intervalMs = 500) {
243
+ return (0, promise_retry_1.default)(async (retry, number) => {
244
+ try {
245
+ fs_1.default.accessSync(filePath);
246
+ return true;
247
+ }
248
+ catch (err) {
249
+ if (number === attempts) {
250
+ return false;
251
+ }
252
+ debug(`File not found, retrying (attempt ${number}/${attempts})`);
253
+ await new Promise(resolve => {
254
+ setTimeout(resolve, intervalMs);
255
+ });
256
+ retry(err);
257
+ }
258
+ }, {
259
+ retries: attempts,
260
+ minTimeout: intervalMs,
261
+ maxTimeout: intervalMs,
262
+ });
263
+ }
264
+ async getS3LocationLink(out) {
265
+ const response = await out.done();
266
+ let s3Location = response?.Location?.trim();
267
+ if (!s3Location) {
268
+ s3Location = out?.singleUploadResult?.Location;
269
+ debug('Uploaded singleUploadResult.Location', s3Location);
270
+ if (!s3Location) {
271
+ throw new Error("Problems getting the S3 artifact's link. Please check S3 permissions!");
272
+ }
273
+ }
274
+ // Normalize the URL
275
+ if (!s3Location.startsWith('http')) {
276
+ s3Location = `https://${s3Location}`;
277
+ }
278
+ return s3Location;
279
+ }
280
+ #getFileExtBase64(str) {
281
+ const type = str.charAt(0);
282
+ return ({
283
+ '/': 'jpg',
284
+ i: 'png',
285
+ R: 'gif',
286
+ U: 'webp',
287
+ }[type] || '');
288
+ }
289
+ #getS3Config() {
290
+ const { S3_REGION, S3_SESSION_TOKEN, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_FORCE_PATH_STYLE, S3_ENDPOINT } = this.getConfig();
291
+ const cfg = {
292
+ region: S3_REGION,
293
+ credentials: {
294
+ accessKeyId: S3_ACCESS_KEY_ID,
295
+ secretAccessKey: S3_SECRET_ACCESS_KEY,
296
+ },
297
+ };
298
+ if (S3_FORCE_PATH_STYLE) {
299
+ cfg.forcePathStyle = !['false', '0'].includes(String(S3_FORCE_PATH_STYLE || '').toLowerCase());
300
+ }
301
+ if (S3_SESSION_TOKEN) {
302
+ cfg.credentials.sessionToken = S3_SESSION_TOKEN;
303
+ }
304
+ if (S3_ENDPOINT) {
305
+ cfg.endpoint = S3_ENDPOINT;
306
+ }
307
+ return cfg;
308
+ }
309
+ }
310
+ exports.S3Uploader = S3Uploader;
311
+
312
+ module.exports.S3Uploader = S3Uploader;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Update and validate the filter type.
3
+ * @param {string} type - The original filter type.
4
+ * @returns {string|undefined} The updated and validated filter type.
5
+ * Returns undefined if the type is not valid.
6
+ */
7
+ export function updateFilterType(type: string): string | undefined;
8
+ /**
9
+ * Parse filter parameters from a string in the format "type=id".
10
+ * @param {string} opts - The input string containing the filter parameters.
11
+ * @returns {Object} An object containing the parsed filter parameters.
12
+ * The object has properties "type" and "id".
13
+ */
14
+ export function parseFilterParams(opts: string): any;
15
+ /**
16
+ * Generates mode request parameters based on the input params.
17
+ * @param {{type: string, id?: string, apiKey: string}} params - The input parameters for the request.
18
+ * @returns {Object|null} - An object containing the generated request parameters, or null if the type is invalid.
19
+ */
20
+ export function generateFilterRequestParams(params: {
21
+ type: string;
22
+ id?: string;
23
+ apiKey: string;
24
+ }): any | null;
25
+ /**
26
+ * Set S3 credentials from the provided artifacts object.
27
+ * @param {Object} artifacts - The artifacts object containing S3 credentials.
28
+ */
29
+ export function setS3Credentials(artifacts: any): void;
30
+ /**
31
+ * Return an emoji based on the provided status.
32
+ * @param {string} status - The status value ('passed', 'failed', or 'skipped').
33
+ * @returns {string} - An emoji corresponding to the provided status.
34
+ */
35
+ export function statusEmoji(status: string): string;
36
+ /**
37
+ * Generate a full name string based on the provided test object.
38
+ * @param {object} t - The test object.
39
+ * @returns {string} - A formatted full name string for the test object.
40
+ */
41
+ export function fullName(t: object): string;
@@ -6,7 +6,6 @@ exports.generateFilterRequestParams = generateFilterRequestParams;
6
6
  exports.setS3Credentials = setS3Credentials;
7
7
  exports.statusEmoji = statusEmoji;
8
8
  exports.fullName = fullName;
9
- const fileUploader_js_1 = require("../fileUploader.js");
10
9
  const constants_js_1 = require("../constants.js");
11
10
  /**
12
11
  * Set S3 credentials from the provided artifacts object.
@@ -15,7 +14,7 @@ const constants_js_1 = require("../constants.js");
15
14
  function setS3Credentials(artifacts) {
16
15
  if (!Object.keys(artifacts).length)
17
16
  return;
18
- console.log(constants_js_1.APP_PREFIX, 'S3 were credentials obtained from Testomat.io...');
17
+ console.log(constants_js_1.APP_PREFIX, 'S3 credentials obtained from Testomat.io...');
19
18
  if (artifacts.ACCESS_KEY_ID)
20
19
  process.env.S3_ACCESS_KEY_ID = artifacts.ACCESS_KEY_ID;
21
20
  if (artifacts.SECRET_ACCESS_KEY)
@@ -24,13 +23,12 @@ function setS3Credentials(artifacts) {
24
23
  process.env.S3_REGION = artifacts.REGION;
25
24
  if (artifacts.BUCKET)
26
25
  process.env.S3_BUCKET = artifacts.BUCKET;
27
- if (artifacts.ENDPOINT)
28
- process.env.S3_ENDPOINT = artifacts.ENDPOINT;
29
26
  if (artifacts.SESSION_TOKEN)
30
27
  process.env.S3_SESSION_TOKEN = artifacts.SESSION_TOKEN;
31
28
  if (artifacts.presign)
32
29
  process.env.TESTOMATIO_PRIVATE_ARTIFACTS = '1';
33
- fileUploader_js_1.upload.resetConfig();
30
+ // endpoint is not received from the server; and shuld be empty if IAM used (credentails obtained from the testomat)
31
+ process.env.S3_ENDPOINT = artifacts.ENDPOINT || '';
34
32
  }
35
33
  /**
36
34
  * Generates mode request parameters based on the input params.
@@ -0,0 +1,45 @@
1
+ export function ansiRegExp(): RegExp;
2
+ export function isSameTest(test: any, t: any): boolean;
3
+ export function fetchSourceCode(contents: any, opts?: {}): string;
4
+ export function fetchSourceCodeFromStackTrace(stack?: string): string;
5
+ export function fetchIdFromCode(code: any, opts?: {}): any;
6
+ export function fetchIdFromOutput(output: any): any;
7
+ export function fetchFilesFromStackTrace(stack?: string): string[];
8
+ export namespace fileSystem {
9
+ function createDir(dirPath: any): void;
10
+ function clearDir(dirPath: any): void;
11
+ }
12
+ export function foundedTestLog(app: any, tests: any): void;
13
+ export function formatStep(step: any, shift?: number): any;
14
+ export function getCurrentDateTime(): string;
15
+ /**
16
+ * @param {String} testTitle - Test title
17
+ *
18
+ * @returns {String|null} testId
19
+ */
20
+ export function getTestomatIdFromTestTitle(testTitle: string): string | null;
21
+ export function humanize(text: any): any;
22
+ export function isValidUrl(s: any): boolean;
23
+ /**
24
+ * @param {String} suiteTitle - suite title
25
+ *
26
+ * @returns {String|null} suiteId
27
+ */
28
+ export function parseSuite(suiteTitle: string): string | null;
29
+ export function readLatestRunId(): string;
30
+ /**
31
+ * Used to remove color codes
32
+ * @param {*} input
33
+ * @returns
34
+ */
35
+ export function removeColorCodes(input: any): any;
36
+ /**
37
+ * @param {Object} test - Test adapter object
38
+ *
39
+ * @returns {String|null} testInfo as one string
40
+ */
41
+ export function specificTestInfo(test: any): string | null;
42
+ export function storeRunId(runId: any): void;
43
+ export namespace testRunnerHelper {
44
+ function getNameOfCurrentlyRunningTest(): any;
45
+ }
@@ -1,16 +1,43 @@
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
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.testRunnerHelper = exports.foundedTestLog = exports.humanize = exports.parseSuite = exports.getTestomatIdFromTestTitle = exports.ansiRegExp = exports.isValidUrl = exports.specificTestInfo = exports.getCurrentDateTime = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = void 0;
29
+ exports.testRunnerHelper = exports.specificTestInfo = exports.parseSuite = exports.isValidUrl = exports.humanize = exports.getTestomatIdFromTestTitle = exports.getCurrentDateTime = exports.foundedTestLog = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = exports.ansiRegExp = void 0;
30
+ exports.formatStep = formatStep;
31
+ exports.readLatestRunId = readLatestRunId;
7
32
  exports.removeColorCodes = removeColorCodes;
33
+ exports.storeRunId = storeRunId;
8
34
  const url_1 = require("url");
9
- const path_1 = require("path");
35
+ const path_1 = __importStar(require("path"));
10
36
  const picocolors_1 = __importDefault(require("picocolors"));
11
37
  const fs_1 = __importDefault(require("fs"));
12
38
  const is_valid_path_1 = __importDefault(require("is-valid-path"));
13
39
  const debug_1 = __importDefault(require("debug"));
40
+ const os_1 = __importDefault(require("os"));
14
41
  const debug = (0, debug_1.default)('@testomatio/reporter:util');
15
42
  /**
16
43
  * @param {String} testTitle - Test title
@@ -319,9 +346,49 @@ const testRunnerHelper = {
319
346
  },
320
347
  };
321
348
  exports.testRunnerHelper = testRunnerHelper;
349
+ function storeRunId(runId) {
350
+ if (!runId || runId === 'undefined')
351
+ return;
352
+ const filePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.latest.run`);
353
+ fs_1.default.writeFileSync(filePath, runId);
354
+ }
355
+ function readLatestRunId() {
356
+ try {
357
+ const filePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.latest.run`);
358
+ const stats = fs_1.default.statSync(filePath);
359
+ const diff = +new Date() - +stats.mtime;
360
+ const diffHours = diff / 1000 / 60 / 60;
361
+ if (diffHours > 1)
362
+ return;
363
+ return fs_1.default.readFileSync(filePath)?.toString()?.trim();
364
+ }
365
+ catch (e) {
366
+ return null;
367
+ }
368
+ }
369
+ function formatStep(step, shift = 0) {
370
+ const prefix = ' '.repeat(shift);
371
+ const lines = [];
372
+ if (step.error) {
373
+ lines.push(`${prefix}${picocolors_1.default.red(step.title)} ${picocolors_1.default.gray(`${step.duration}ms`)}`);
374
+ }
375
+ else {
376
+ lines.push(`${prefix}${step.title} ${picocolors_1.default.gray(`${step.duration}ms`)}`);
377
+ }
378
+ for (const child of step.steps || []) {
379
+ lines.push(...formatStep(child, shift + 2));
380
+ }
381
+ return lines;
382
+ }
383
+
384
+ module.exports.formatStep = formatStep;
385
+
386
+ module.exports.readLatestRunId = readLatestRunId;
322
387
 
323
388
  module.exports.removeColorCodes = removeColorCodes;
324
389
 
390
+ module.exports.storeRunId = storeRunId;
391
+
325
392
  module.exports.getTestomatIdFromTestTitle = getTestomatIdFromTestTitle;
326
393
 
327
394
  module.exports.parseSuite = parseSuite;
@@ -0,0 +1,92 @@
1
+ export default XmlReader;
2
+ declare class XmlReader {
3
+ constructor(opts?: {});
4
+ requestParams: {
5
+ apiKey: any;
6
+ url: any;
7
+ title: string;
8
+ env: string;
9
+ group_title: string;
10
+ detach: string;
11
+ isBatchEnabled: boolean;
12
+ };
13
+ runId: any;
14
+ adapter: import("./junit-adapter/adapter.js").default;
15
+ opts: {};
16
+ store: {};
17
+ pipesPromise: Promise<any[]>;
18
+ parser: XMLParser;
19
+ tests: any[];
20
+ stats: {};
21
+ uploader: S3Uploader;
22
+ version: any;
23
+ connectAdapter(): import("./junit-adapter/adapter.js").default;
24
+ parse(fileName: any): {
25
+ status: string;
26
+ create_tests: boolean;
27
+ tests_count: number;
28
+ passed_count: number;
29
+ skipped_count: number;
30
+ failed_count: number;
31
+ tests: any;
32
+ } | {
33
+ status: any;
34
+ create_tests: boolean;
35
+ tests_count: number;
36
+ passed_count: number;
37
+ failed_count: number;
38
+ skipped_count: number;
39
+ tests: any[];
40
+ };
41
+ processJUnit(jsonSuite: any): {
42
+ create_tests: boolean;
43
+ duration: number;
44
+ failed_count: number;
45
+ name: any;
46
+ passed_count: number;
47
+ skipped_count: number;
48
+ status: string;
49
+ tests: any[];
50
+ tests_count: number;
51
+ };
52
+ processNUnit(jsonSuite: any): {
53
+ status: any;
54
+ create_tests: boolean;
55
+ tests_count: number;
56
+ passed_count: number;
57
+ failed_count: number;
58
+ skipped_count: number;
59
+ tests: any[];
60
+ };
61
+ processTRX(jsonSuite: any): {
62
+ status: string;
63
+ create_tests: boolean;
64
+ tests_count: number;
65
+ passed_count: number;
66
+ skipped_count: number;
67
+ failed_count: number;
68
+ tests: any;
69
+ };
70
+ processXUnit(assemblies: any): {
71
+ status: string;
72
+ create_tests: boolean;
73
+ name: string;
74
+ tests_count: number;
75
+ passed_count: number;
76
+ failed_count: number;
77
+ skipped_count: number;
78
+ tests: any[];
79
+ };
80
+ calculateStats(): {};
81
+ fetchSourceCode(): void;
82
+ formatTests(): void;
83
+ formatErrors(): void;
84
+ formatStack(t: any): any;
85
+ uploadArtifacts(): Promise<void>;
86
+ createRun(): Promise<any[]>;
87
+ pipes: any;
88
+ uploadData(): Promise<any[]>;
89
+ _finishRun(): Promise<any[]>;
90
+ }
91
+ import { XMLParser } from 'fast-xml-parser';
92
+ import { S3Uploader } from './uploader.js';