@testomatio/reporter 1.4.3 → 1.4.5-beta.1-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,7 +129,7 @@ function CodeceptReporter(config) {
129
129
  await Promise.all(reportTestPromises);
130
130
 
131
131
  if (upload.isArtifactsEnabled()) {
132
- uploadAttachments(client, videos, '🎞️ Uploading', 'video');
132
+ uploadAttachments(client, videos, '🎞️ Uploading', 'video');
133
133
  uploadAttachments(client, traces, '📁 Uploading', 'trace');
134
134
  }
135
135
 
@@ -142,7 +142,6 @@ function CodeceptReporter(config) {
142
142
  if (id && failedTests.includes(id)) {
143
143
  failedTests = failedTests.filter(failed => id !== failed);
144
144
  }
145
- const testId = getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`);
146
145
  const testObj = getTestAndMessage(title);
147
146
 
148
147
  const logs = getTestLogs(test);
@@ -152,11 +151,12 @@ function CodeceptReporter(config) {
152
151
 
153
152
  client.addTestRun(STATUS.PASSED, {
154
153
  ...stripExampleFromTitle(title),
154
+ rid: id,
155
155
  suite_title: test.parent && test.parent.title,
156
156
  message: testObj.message,
157
157
  time: getDuration(test),
158
158
  steps: global.testomatioDataStore.steps.join('\n') || null,
159
- test_id: testId,
159
+ test_id: getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`),
160
160
  logs,
161
161
  manuallyAttachedArtifacts,
162
162
  meta: keyValues,
@@ -179,6 +179,7 @@ function CodeceptReporter(config) {
179
179
  const testId = getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`);
180
180
 
181
181
  client.addTestRun(STATUS.FAILED, {
182
+ rid: id,
182
183
  ...stripExampleFromTitle(title),
183
184
  suite_title: suite.title,
184
185
  test_id: testId,
@@ -194,7 +195,6 @@ function CodeceptReporter(config) {
194
195
  if (test.err) error = test.err;
195
196
  const { id, tags, title, artifacts } = test;
196
197
  failedTests.push(id || title);
197
- let testId = getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`);
198
198
  const testObj = getTestAndMessage(title);
199
199
 
200
200
  const files = [];
@@ -206,10 +206,10 @@ function CodeceptReporter(config) {
206
206
  const keyValues = services.keyValues.get(test.fullTitle());
207
207
  services.setContext(null);
208
208
 
209
- const reportTestPromise = client
210
- .addTestRun(STATUS.FAILED, {
209
+ client.addTestRun(STATUS.FAILED, {
211
210
  ...stripExampleFromTitle(title),
212
- test_id: testId,
211
+ rid: id,
212
+ test_id: getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`),
213
213
  suite_title: test.parent && test.parent.title,
214
214
  error,
215
215
  message: testObj.message,
@@ -219,19 +219,14 @@ function CodeceptReporter(config) {
219
219
  logs,
220
220
  manuallyAttachedArtifacts,
221
221
  meta: keyValues,
222
- })
223
- .then(pipes => {
224
- testId = pipes.filter(p => p.pipe.includes('Testomatio'))[0]?.result?.data?.test_id;
222
+ });
225
223
 
226
- debug('artifacts', artifacts);
224
+ debug('artifacts', artifacts);
227
225
 
228
- for (const aid in artifacts) {
229
- if (aid.startsWith('video')) videos.push({ testId, title, path: artifacts[aid], type: 'video/webm' });
230
- if (aid.startsWith('trace')) traces.push({ testId, title, path: artifacts[aid], type: 'application/zip' });
231
- }
232
- });
233
-
234
- reportTestPromises.push(reportTestPromise);
226
+ for (const aid in artifacts) {
227
+ if (aid.startsWith('video')) videos.push({ rid: id, title, path: artifacts[aid], type: 'video/webm' });
228
+ if (aid.startsWith('trace')) traces.push({ rid: id, title, path: artifacts[aid], type: 'application/zip' });
229
+ }
235
230
 
236
231
  // output.stop();
237
232
  });
@@ -240,11 +235,11 @@ function CodeceptReporter(config) {
240
235
  const { id, tags, title } = test;
241
236
  if (failedTests.includes(id || title)) return;
242
237
 
243
- const testId = getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`);
244
238
  const testObj = getTestAndMessage(title);
245
239
  client.addTestRun(STATUS.SKIPPED, {
240
+ rid: id,
246
241
  ...stripExampleFromTitle(title),
247
- test_id: testId,
242
+ test_id: getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`),
248
243
  suite_title: test.parent && test.parent.title,
249
244
  message: testObj.message,
250
245
  time: getDuration(test),
@@ -313,11 +308,11 @@ async function uploadAttachments(client, attachments, messagePrefix, attachmentT
313
308
  console.log(APP_PREFIX, `Attachments: ${messagePrefix} ${attachments.length} ${attachmentType}/-s ...`);
314
309
 
315
310
  const promises = attachments.map(async attachment => {
316
- const { testId, title, path, type } = attachment;
311
+ const { rid, title, path, type } = attachment;
317
312
  const file = { path, type, title };
318
313
  return client.addTestRun(undefined, {
319
314
  ...stripExampleFromTitle(title),
320
- test_id: testId,
315
+ rid,
321
316
  files: [file],
322
317
  });
323
318
  });
@@ -39,8 +39,6 @@ class PlaywrightReporter {
39
39
 
40
40
  const { title } = test;
41
41
 
42
- let testId = getTestomatIdFromTestTitle(`${title} ${test.tags?.join(' ')}`);
43
-
44
42
  const { error, duration } = result;
45
43
 
46
44
  const suite_title = test.parent ? test.parent?.title : path.basename(test?.location?.file);
@@ -58,10 +56,10 @@ class PlaywrightReporter {
58
56
  const manuallyAttachedArtifacts = services.artifacts.get(fullTestTitle);
59
57
  const keyValues = services.keyValues.get(fullTestTitle);
60
58
 
61
- const reportTestPromise = this.client
62
- .addTestRun(checkStatus(result.status), {
59
+ const reportTestPromise = this.client.addTestRun(checkStatus(result.status), {
60
+ rid: test.testId,
63
61
  error,
64
- test_id: testId,
62
+ test_id: getTestomatIdFromTestTitle(`${title} ${test.tags?.join(' ')}`),
65
63
  suite_title,
66
64
  title,
67
65
  steps: steps.join('\n'),
@@ -70,21 +68,16 @@ class PlaywrightReporter {
70
68
  manuallyAttachedArtifacts,
71
69
  meta: keyValues,
72
70
  file: test.location?.file,
73
- })
74
- .then(pipes => {
75
- testId = pipes?.filter(p => p.pipe.includes('Testomatio'))[0]?.result?.data?.test_id;
76
-
77
- this.uploads.push({
78
- testId,
79
- title,
80
- suite_title,
81
- files: result.attachments.filter(a => a.body || a.path),
82
- file: test.location?.file,
83
- });
84
- // remove empty uploads
85
- this.uploads = this.uploads.filter(upload => upload.files.length);
86
71
  });
87
72
 
73
+ this.uploads.push({
74
+ rid: test.testId,
75
+ files: result.attachments.filter(a => a.body || a.path),
76
+ file: test.location?.file,
77
+ });
78
+ // remove empty uploads
79
+ this.uploads = this.uploads.filter(upload => upload.files.length);
80
+
88
81
  reportTestPromises.push(reportTestPromise);
89
82
  }
90
83
 
@@ -110,7 +103,7 @@ class PlaywrightReporter {
110
103
  await Promise.all(reportTestPromises);
111
104
 
112
105
  if (this.uploads.length && isArtifactsEnabled()) {
113
- console.log(APP_PREFIX, `🎞️ Uploading ${this.uploads.length} files...`);
106
+ console.log(APP_PREFIX, `🎞️ Uploading ${this.uploads.length} files...`);
114
107
 
115
108
  const promises = [];
116
109
 
package/lib/client.js CHANGED
@@ -6,7 +6,7 @@ const fs = require('fs');
6
6
  const chalk = require('chalk');
7
7
  const { randomUUID } = require('crypto');
8
8
  const upload = require('./fileUploader');
9
- const { APP_PREFIX } = require('./constants');
9
+ const { APP_PREFIX, STATUS } = require('./constants');
10
10
  const pipesFactory = require('./pipe');
11
11
  const { glob } = require('glob');
12
12
  const path = require('path');
@@ -122,6 +122,11 @@ class Client {
122
122
 
123
123
  if (isTestShouldBeExculedFromReport(testData)) return [];
124
124
 
125
+ if (status === STATUS.SKIPPED && process.env.TESTOMATIO_EXCLUDE_SKIPPED) {
126
+ debug('Skipping test from report', testData?.title)
127
+ return []; // do not log skipped tests
128
+ }
129
+
125
130
  if (!testData)
126
131
  testData = {
127
132
  title: 'Unknown test',
@@ -129,6 +134,7 @@ class Client {
129
134
  };
130
135
 
131
136
  const {
137
+ rid,
132
138
  error = null,
133
139
  time = '',
134
140
  example = null,
@@ -179,6 +185,7 @@ class Client {
179
185
  this.totalUploaded += artifacts.length;
180
186
 
181
187
  const data = {
188
+ rid,
182
189
  files,
183
190
  steps,
184
191
  status,
@@ -339,6 +339,9 @@ class TestomatioPipe {
339
339
  addTest(data) {
340
340
  if (!this.isEnabled) return;
341
341
  if (!this.runId) return;
342
+
343
+ // add test ID + run ID
344
+ data.rid = `${this.runId}-${data.rid}`;
342
345
  data.api_key = this.apiKey;
343
346
  data.create = this.createNewTests;
344
347
 
@@ -354,11 +357,11 @@ class TestomatioPipe {
354
357
  * @returns
355
358
  */
356
359
  async finishRun(params) {
357
- this.#batchUpload();
360
+ if (!this.isEnabled) return;
361
+
362
+ await this.#batchUpload();
358
363
  if (this.batch.intervalFunction) clearInterval(this.batch.intervalFunction);
359
364
 
360
- debug('Finishing run...');
361
- if (!this.isEnabled) return;
362
365
  debug('Finishing run...');
363
366
 
364
367
  if (this.reportingCanceledDueToReqFailures) {
package/lib/xmlReader.js CHANGED
@@ -460,6 +460,7 @@ function reduceTestCases(prev, item) {
460
460
  // SpecFlow config
461
461
  let { title, tags } = fetchProperties(item.type === 'ParameterizedMethod' ? item : testCaseItem);
462
462
  let example = null;
463
+ const suiteTitle = reduceOptions.preferClassname ? testCaseItem.classname : item.name || testCaseItem.classname;
463
464
 
464
465
  title ||= testCaseItem.name || testCaseItem.methodname || testCaseItem.classname;
465
466
  tags ||= [];
@@ -493,7 +494,7 @@ function reduceTestCases(prev, item) {
493
494
  run_time: parseFloat(testCaseItem.time || testCaseItem.duration) * 1000,
494
495
  status,
495
496
  title,
496
- suite_title: reduceOptions.preferClassname ? testCaseItem.classname : item.name || testCaseItem.classname,
497
+ suite_title: suiteTitle,
497
498
  });
498
499
  });
499
500
  return prev;
@@ -527,4 +528,4 @@ function fetchProperties(item) {
527
528
  .filter(p => p.name === 'Category')
528
529
  .forEach(p => tags.push(p.value));
529
530
  return { title, tags };
530
- }
531
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "1.4.3",
3
+ "version": "1.4.5-beta.1-report-id",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",