@testomatio/reporter 2.3.7-beta.-stack-artifacts → 2.3.7-beta.10-stack-artifacts

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -192,9 +192,11 @@ class Client {
192
192
  message = error?.message;
193
193
  }
194
194
  let fullLogs = this.formatLogs({ error: errorFormatted, steps, logs: testData.logs });
195
- if (stackArtifactsEnabled) {
195
+ if (stackArtifactsEnabled && status && (steps || testData.logs || error)) {
196
196
  const timestamp = +new Date;
197
- uploadedFiles.push(this.uploader.uploadFileAsBuffer(Buffer.from(stripColors(fullLogs), 'utf8'), [this.runId, rid, `logs_${timestamp}.log`]));
197
+ if (fullLogs && fullLogs.trim().length > 0) {
198
+ uploadedFiles.push(this.uploader.uploadFileAsBuffer(Buffer.from(stripColors(fullLogs), 'utf8'), [this.runId, rid, `logs_${timestamp}.txt`]));
199
+ }
198
200
  fullLogs = '';
199
201
  }
200
202
  if (!this.pipes || !this.pipes.length)
@@ -294,7 +296,7 @@ class Client {
294
296
  const uploadedArtifacts = this.uploader.successfulUploads.map(file => ({
295
297
  relativePath: file.path.replace(process.cwd(), ''),
296
298
  link: file.link,
297
- sizePretty: (0, filesize_1.filesize)(file.size, { round: 0 }).toString(),
299
+ sizePretty: file.size == null ? 'unknown' : (0, filesize_1.filesize)(file.size, { round: 0 }).toString(),
298
300
  }));
299
301
  uploadedArtifacts.forEach(upload => {
300
302
  debug(`🟢Uploaded artifact`, `${upload.relativePath},`, 'size:', `${upload.sizePretty},`, 'link:', `${upload.link}`);
@@ -304,7 +306,7 @@ class Client {
304
306
  console.log(constants_js_1.APP_PREFIX, `🗄️ ${this.uploader.failedUploads.length} artifacts 🔴${picocolors_1.default.bold('failed')} to upload`);
305
307
  const failedUploads = this.uploader.failedUploads.map(file => ({
306
308
  relativePath: file.path.replace(process.cwd(), ''),
307
- sizePretty: (0, filesize_1.filesize)(file.size, { round: 0 }).toString(),
309
+ sizePretty: file.size == null ? 'unknown' : (0, filesize_1.filesize)(file.size, { round: 0 }).toString(),
308
310
  }));
309
311
  const pathPadding = Math.max(...failedUploads.map(upload => upload.relativePath.length)) + 1;
310
312
  failedUploads.forEach(upload => {
@@ -471,10 +471,14 @@ function transformEnvVarToBoolean(value) {
471
471
  return Boolean(value);
472
472
  }
473
473
  function truncate(s, size = 255) {
474
- if (s.toString().trim().length < size) {
475
- return s.toString();
474
+ if (s === undefined || s === null) {
475
+ return '';
476
+ }
477
+ const str = s.toString();
478
+ if (str.trim().length < size) {
479
+ return str;
476
480
  }
477
- return `${s.toString().substring(0, size)}...`;
481
+ return `${str.substring(0, size)}...`;
478
482
  }
479
483
 
480
484
  module.exports.getPackageVersion = getPackageVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "2.3.7-beta.-stack-artifacts",
3
+ "version": "2.3.7-beta.10-stack-artifacts",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "engines": {
6
6
  "node": ">=18"
package/src/client.js CHANGED
@@ -210,14 +210,16 @@ class Client {
210
210
 
211
211
  let fullLogs = this.formatLogs({ error: errorFormatted, steps, logs: testData.logs });
212
212
 
213
- if (stackArtifactsEnabled) {
213
+ if (stackArtifactsEnabled && status && (steps || testData.logs || error)) {
214
214
  const timestamp = +new Date;
215
- uploadedFiles.push(
216
- this.uploader.uploadFileAsBuffer(
217
- Buffer.from(stripColors(fullLogs), 'utf8'),
218
- [this.runId, rid, `logs_${timestamp}.log`]
219
- )
220
- );
215
+ if (fullLogs && fullLogs.trim().length > 0) {
216
+ uploadedFiles.push(
217
+ this.uploader.uploadFileAsBuffer(
218
+ Buffer.from(stripColors(fullLogs), 'utf8'),
219
+ [this.runId, rid, `logs_${timestamp}.txt`]
220
+ )
221
+ );
222
+ }
221
223
  fullLogs = '';
222
224
  }
223
225
 
@@ -336,7 +338,7 @@ class Client {
336
338
  const uploadedArtifacts = this.uploader.successfulUploads.map(file => ({
337
339
  relativePath: file.path.replace(process.cwd(), ''),
338
340
  link: file.link,
339
- sizePretty: prettyBytes(file.size, { round: 0 }).toString(),
341
+ sizePretty: file.size == null ? 'unknown' : prettyBytes(file.size, { round: 0 }).toString(),
340
342
  }));
341
343
 
342
344
  uploadedArtifacts.forEach(upload => {
@@ -358,7 +360,7 @@ class Client {
358
360
  );
359
361
  const failedUploads = this.uploader.failedUploads.map(file => ({
360
362
  relativePath: file.path.replace(process.cwd(), ''),
361
- sizePretty: prettyBytes(file.size, { round: 0 }).toString(),
363
+ sizePretty: file.size == null ? 'unknown' : prettyBytes(file.size, { round: 0 }).toString(),
362
364
  }));
363
365
 
364
366
  const pathPadding = Math.max(...failedUploads.map(upload => upload.relativePath.length)) + 1;
@@ -429,10 +429,14 @@ function transformEnvVarToBoolean(value) {
429
429
  }
430
430
 
431
431
  function truncate(s, size = 255) {
432
- if (s.toString().trim().length < size) {
433
- return s.toString();
432
+ if (s === undefined || s === null) {
433
+ return '';
434
434
  }
435
- return `${s.toString().substring(0, size)}...`;
435
+ const str = s.toString();
436
+ if (str.trim().length < size) {
437
+ return str;
438
+ }
439
+ return `${str.substring(0, size)}...`;
436
440
  }
437
441
 
438
442
  export {