@testomatio/reporter 1.6.6-beta-detach-xml-2 → 1.6.6-beta-2-pw-metadata

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.
@@ -55,11 +55,28 @@ class PlaywrightReporter {
55
55
  logs = `\n\n${chalk.bold('Logs:')}\n${chalk.red(result.stderr.join(''))}\n${result.stdout.join('')}`;
56
56
  }
57
57
  const manuallyAttachedArtifacts = services.artifacts.get(fullTestTitle);
58
- const keyValues = services.keyValues.get(fullTestTitle);
58
+ const testMeta = services.keyValues.get(fullTestTitle);
59
59
  const rid = test.id || test.testId || uuidv4();
60
60
 
61
+ /**
62
+ * @type {{
63
+ * browser?: string,
64
+ * dependencies: string[],
65
+ * isMobile?: boolean
66
+ * metadata: Record<string, any>,
67
+ * name: string,
68
+ * }}
69
+ */
70
+ const project = {
71
+ browser: test.parent.project().use.defaultBrowserType,
72
+ dependencies: test.parent.project().dependencies,
73
+ isMobile: test.parent.project().use.isMobile,
74
+ metadata: test.parent.project().metadata,
75
+ name: test.parent.project().name,
76
+ };
77
+
61
78
  const reportTestPromise = this.client.addTestRun(checkStatus(result.status), {
62
- rid,
79
+ rid: `${rid}-${project.name}`,
63
80
  error,
64
81
  test_id: getTestomatIdFromTestTitle(`${title} ${test.tags?.join(' ')}`),
65
82
  suite_title,
@@ -68,12 +85,19 @@ class PlaywrightReporter {
68
85
  time: duration,
69
86
  logs,
70
87
  manuallyAttachedArtifacts,
71
- meta: keyValues,
88
+ meta: {
89
+ browser: project.browser,
90
+ isMobile: project.isMobile,
91
+ project: project.name,
92
+ projectDependencies: project.dependencies?.length ? project.dependencies : null,
93
+ ...testMeta,
94
+ ...project.metadata, // metadata has any type (in playwright), but we will stringify it in client.js
95
+ },
72
96
  file: test.location?.file,
73
97
  });
74
98
 
75
99
  this.uploads.push({
76
- rid,
100
+ rid: `${rid}-${project.name}`,
77
101
  title: test.title,
78
102
  files: result.attachments.filter(a => a.body || a.path),
79
103
  file: test.location?.file,
package/lib/client.js CHANGED
@@ -165,6 +165,27 @@ class Client {
165
165
  } = testData;
166
166
  let { message = '' } = testData;
167
167
 
168
+ // stringify meta values and limit keys and values length to 255
169
+ if (meta) {
170
+ for (const key in meta) {
171
+ if (typeof meta[key] === 'object') {
172
+ meta[key] = JSON.stringify(meta[key]);
173
+ }
174
+ // cut values
175
+ if (meta[key].length > 255) {
176
+ meta[key] = meta[key].substring(0, 255);
177
+ debug(APP_PREFIX, `Meta info value "${meta[key]}" is too long, trimmed to 255 characters`);
178
+ }
179
+ // cut keys
180
+ if (key.length > 255) {
181
+ const newKey = key.substring(0, 255);
182
+ meta[newKey] = meta[key];
183
+ delete meta[key];
184
+ debug(APP_PREFIX, `Meta info key "${key}" is too long, trimmed to 255 characters`);
185
+ }
186
+ }
187
+ }
188
+
168
189
  let errorFormatted = '';
169
190
  if (error) {
170
191
  errorFormatted += this.formatError(error) || '';
@@ -258,7 +279,7 @@ class Client {
258
279
  APP_PREFIX,
259
280
  `🗄️ ${this.uploader.successfulUploads.length} artifacts ${
260
281
  process.env.TESTOMATIO_PRIVATE_ARTIFACTS ? 'privately' : chalk.bold('publicly')
261
- } 🟢 uploaded to S3 bucket`,
282
+ } 🟢uploaded to S3 bucket`,
262
283
  );
263
284
  }
264
285
 
@@ -274,7 +295,7 @@ class Client {
274
295
 
275
296
  uploadedArtifacts.forEach(upload => {
276
297
  debug(
277
- `🟢 Uploaded artifact`,
298
+ `🟢Uploaded artifact`,
278
299
  `${upload.relativePath},`,
279
300
  'size:',
280
301
  `${upload.sizePretty},`,
@@ -215,7 +215,7 @@ class TestomatioPipe {
215
215
  this.store.runPublicUrl = this.runPublicUrl;
216
216
  this.store.runId = this.runId;
217
217
  console.log(APP_PREFIX, '📊 Report created. Report ID:', this.runId);
218
- process.env.runId = this.runId;
218
+ process.env.runId = this.runId;
219
219
  debug('Run created', this.runId);
220
220
  } catch (err) {
221
221
  const errorText = err.response?.data?.message || err.message;
@@ -241,7 +241,7 @@ class TestomatioPipe {
241
241
  const cancelReporting = this.requestFailures >= parseInt(process.env.TESTOMATIO_MAX_REQUEST_FAILURES, 10);
242
242
  if (cancelReporting) {
243
243
  this.reportingCanceledDueToReqFailures = true;
244
- const errorMessage =
244
+ const errorMessage =
245
245
  `⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES} requests were failed, reporting to Testomat aborted.`;
246
246
  console.warn(`${APP_PREFIX} ${chalk.yellow(errorMessage)}`);
247
247
  }
@@ -396,7 +396,6 @@ class TestomatioPipe {
396
396
  await this.axios.put(`/api/reporter/${this.runId}`, {
397
397
  api_key: this.apiKey,
398
398
  status_event,
399
- detach: params.detach,
400
399
  duration: params.duration,
401
400
  tests: params.tests,
402
401
  });
package/lib/xmlReader.js CHANGED
@@ -21,8 +21,7 @@ const config = require('./config');
21
21
  const ridRunId = randomUUID();
22
22
 
23
23
  const TESTOMATIO_URL = process.env.TESTOMATIO_URL || 'https://app.testomat.io';
24
- const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN,
25
- TESTOMATIO_MARK_DETACHED } = process.env;
24
+ const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN } = process.env;
26
25
 
27
26
  const options = {
28
27
  ignoreDeclaration: true,
@@ -42,7 +41,6 @@ class XmlReader {
42
41
  title: TESTOMATIO_TITLE,
43
42
  env: TESTOMATIO_ENV,
44
43
  group_title: TESTOMATIO_RUNGROUP_TITLE,
45
- detach: !!TESTOMATIO_MARK_DETACHED,
46
44
  // batch uploading is implemented for xml already
47
45
  isBatchEnabled: false,
48
46
  };
@@ -426,7 +424,6 @@ class XmlReader {
426
424
 
427
425
  const dataString = {
428
426
  ...this.stats,
429
- detach: this.requestParams.detach,
430
427
  api_key: this.requestParams.apiKey,
431
428
  status: 'finished',
432
429
  tests: this.tests,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "1.6.6-beta-detach-xml-2",
3
+ "version": "1.6.6-beta-2-pw-metadata",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",