@testomatio/reporter 1.4.5-beta.1-report-id → 1.4.5-beta.3-report-id

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.
@@ -129,8 +129,8 @@ function CodeceptReporter(config) {
129
129
  await Promise.all(reportTestPromises);
130
130
 
131
131
  if (upload.isArtifactsEnabled()) {
132
- uploadAttachments(client, videos, '🎞️ Uploading', 'video');
133
- uploadAttachments(client, traces, '📁 Uploading', 'trace');
132
+ await uploadAttachments(client, videos, '🎞️ Uploading', 'video');
133
+ await uploadAttachments(client, traces, '📁 Uploading', 'trace');
134
134
  }
135
135
 
136
136
  const status = failedTests.length === 0 ? STATUS.PASSED : STATUS.FAILED;
@@ -304,21 +304,22 @@ function CodeceptReporter(config) {
304
304
  }
305
305
 
306
306
  async function uploadAttachments(client, attachments, messagePrefix, attachmentType) {
307
- if (attachments.length > 0) {
308
- console.log(APP_PREFIX, `Attachments: ${messagePrefix} ${attachments.length} ${attachmentType}/-s ...`);
307
+ if (!attachments?.length) return;
309
308
 
310
- const promises = attachments.map(async attachment => {
311
- const { rid, title, path, type } = attachment;
312
- const file = { path, type, title };
313
- return client.addTestRun(undefined, {
314
- ...stripExampleFromTitle(title),
315
- rid,
316
- files: [file],
317
- });
309
+ console.log(APP_PREFIX, `Attachments: ${messagePrefix} ${attachments.length} ${attachmentType} ...`);
310
+
311
+ const promises = attachments.map(async attachment => {
312
+ const { rid, title, path, type } = attachment;
313
+ const file = { path, type, title };
314
+ return client.addTestRun(undefined, {
315
+ ...stripExampleFromTitle(title),
316
+ rid,
317
+ files: [file],
318
318
  });
319
+ });
320
+
321
+ await Promise.all(promises);
319
322
 
320
- await Promise.all(promises);
321
- }
322
323
  }
323
324
 
324
325
  function getTestAndMessage(title) {
@@ -2,6 +2,7 @@ const chalk = require('chalk');
2
2
  const crypto = require('crypto');
3
3
  const os = require('os');
4
4
  const path = require('path');
5
+ const { v4: uuidv4 } = require('uuid');
5
6
  const fs = require('fs');
6
7
  const { APP_PREFIX, STATUS: Status, TESTOMAT_TMP_STORAGE_DIR } = require('../constants');
7
8
  const TestomatioClient = require('../client');
@@ -56,8 +57,10 @@ class PlaywrightReporter {
56
57
  const manuallyAttachedArtifacts = services.artifacts.get(fullTestTitle);
57
58
  const keyValues = services.keyValues.get(fullTestTitle);
58
59
 
60
+ const rid = test.id || test.testId || uuidv4();
61
+
59
62
  const reportTestPromise = this.client.addTestRun(checkStatus(result.status), {
60
- rid: test.testId,
63
+ rid,
61
64
  error,
62
65
  test_id: getTestomatIdFromTestTitle(`${title} ${test.tags?.join(' ')}`),
63
66
  suite_title,
@@ -71,7 +74,8 @@ class PlaywrightReporter {
71
74
  });
72
75
 
73
76
  this.uploads.push({
74
- rid: test.testId,
77
+ rid,
78
+ title: test.title,
75
79
  files: result.attachments.filter(a => a.body || a.path),
76
80
  file: test.location?.file,
77
81
  });
@@ -103,12 +107,12 @@ class PlaywrightReporter {
103
107
  await Promise.all(reportTestPromises);
104
108
 
105
109
  if (this.uploads.length && isArtifactsEnabled()) {
106
- console.log(APP_PREFIX, `🎞️ Uploading ${this.uploads.length} files...`);
110
+ console.log(APP_PREFIX, `🎞️ Uploading ${this.uploads.length} files...`);
107
111
 
108
112
  const promises = [];
109
113
 
110
114
  for (const upload of this.uploads) {
111
- const { title, testId, suite_title } = upload;
115
+ const { rid, file, title } = upload;
112
116
 
113
117
  const files = upload.files.map(attachment => ({
114
118
  path: this.#getArtifactPath(attachment),
@@ -118,11 +122,10 @@ class PlaywrightReporter {
118
122
 
119
123
  promises.push(
120
124
  this.client.addTestRun(undefined, {
121
- test_id: testId,
125
+ rid,
122
126
  title,
123
- suite_title,
124
127
  files,
125
- file: upload.file,
128
+ file,
126
129
  }),
127
130
  );
128
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "1.4.5-beta.1-report-id",
3
+ "version": "1.4.5-beta.3-report-id",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",