@testomatio/reporter 2.8.5-beta.2-yarn → 2.8.5

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.
@@ -3,6 +3,8 @@ declare class PlaywrightReporter {
3
3
  constructor(config?: {});
4
4
  client: TestomatioClient;
5
5
  uploads: any[];
6
+ reportTestPromises: any[];
7
+ runPromise: Promise<void>;
6
8
  onBegin(config: any, suite: any): void;
7
9
  suite: any;
8
10
  config: any;
@@ -21,11 +21,12 @@ const playwright_js_1 = require("./utils/playwright.js");
21
21
  Object.defineProperty(exports, "fetchLinksFromLogs", { enumerable: true, get: function () { return playwright_js_1.fetchLinksFromLogs; } });
22
22
  const step_formatter_js_1 = require("./utils/step-formatter.js");
23
23
  const log_js_1 = require("../utils/log.js");
24
- const reportTestPromises = [];
25
24
  class PlaywrightReporter {
26
25
  constructor(config = {}) {
27
26
  this.client = new client_js_1.default({ apiKey: config?.apiKey });
28
27
  this.uploads = [];
28
+ this.reportTestPromises = [];
29
+ this.runPromise = Promise.resolve();
29
30
  }
30
31
  onBegin(config, suite) {
31
32
  // clean data storage
@@ -34,7 +35,9 @@ class PlaywrightReporter {
34
35
  return;
35
36
  this.suite = suite;
36
37
  this.config = config;
37
- this.client.createRun();
38
+ this.uploads = [];
39
+ this.reportTestPromises = [];
40
+ this.runPromise = this.client.createRun();
38
41
  }
39
42
  onTestBegin(testInfo) {
40
43
  const fullTestTitle = getTestContextName(testInfo);
@@ -44,6 +47,7 @@ class PlaywrightReporter {
44
47
  // test.parent.project().__projectId
45
48
  if (!this.client)
46
49
  return;
50
+ await this.runPromise;
47
51
  const { title } = test;
48
52
  const { error, duration } = result;
49
53
  const pwAttachments = (result.attachments || []).filter(a => a.body || a.path);
@@ -126,7 +130,12 @@ class PlaywrightReporter {
126
130
  ...meta,
127
131
  ...project.metadata, // metadata has any type (in playwright), but we will stringify it in client.js
128
132
  ...test.annotations?.reduce((acc, annotation) => {
129
- acc[annotation.type] = annotation.description;
133
+ if (acc[annotation.type]) {
134
+ acc[annotation.type] = `${acc[annotation.type]}, ${annotation.description}`;
135
+ }
136
+ else {
137
+ acc[annotation.type] = annotation.description;
138
+ }
130
139
  return acc;
131
140
  }, {}),
132
141
  },
@@ -140,7 +149,7 @@ class PlaywrightReporter {
140
149
  });
141
150
  // remove empty uploads
142
151
  this.uploads = this.uploads.filter(anUpload => anUpload.files.length);
143
- reportTestPromises.push(reportTestPromise);
152
+ this.reportTestPromises.push(reportTestPromise);
144
153
  }
145
154
  #getArtifactPath(artifact) {
146
155
  if (artifact.path) {
@@ -164,7 +173,8 @@ class PlaywrightReporter {
164
173
  async onEnd(result) {
165
174
  if (!this.client)
166
175
  return;
167
- await Promise.all(reportTestPromises);
176
+ await this.runPromise;
177
+ await Promise.all(this.reportTestPromises);
168
178
  if (this.uploads.length) {
169
179
  if (this.client.uploader.isEnabled)
170
180
  log_js_1.log.info(`🎞️ Uploading ${this.uploads.length} files...`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "2.8.5-beta.2-yarn",
3
+ "version": "2.8.5",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -14,13 +14,13 @@ import { fetchLinksFromLogs } from './utils/playwright.js';
14
14
  import { formatStep, addStatusToStep, addArtifactsToStep } from './utils/step-formatter.js';
15
15
  import { log } from '../utils/log.js';
16
16
 
17
- const reportTestPromises = [];
18
-
19
17
  class PlaywrightReporter {
20
18
  constructor(config = {}) {
21
19
  this.client = new TestomatioClient({ apiKey: config?.apiKey });
22
20
 
23
21
  this.uploads = [];
22
+ this.reportTestPromises = [];
23
+ this.runPromise = Promise.resolve();
24
24
  }
25
25
 
26
26
  onBegin(config, suite) {
@@ -29,7 +29,9 @@ class PlaywrightReporter {
29
29
  if (!this.client) return;
30
30
  this.suite = suite;
31
31
  this.config = config;
32
- this.client.createRun();
32
+ this.uploads = [];
33
+ this.reportTestPromises = [];
34
+ this.runPromise = this.client.createRun();
33
35
  }
34
36
 
35
37
  onTestBegin(testInfo) {
@@ -41,6 +43,7 @@ class PlaywrightReporter {
41
43
  // test.parent.project().__projectId
42
44
 
43
45
  if (!this.client) return;
46
+ await this.runPromise;
44
47
 
45
48
  const { title } = test;
46
49
  const { error, duration } = result;
@@ -133,7 +136,11 @@ class PlaywrightReporter {
133
136
  ...meta,
134
137
  ...project.metadata, // metadata has any type (in playwright), but we will stringify it in client.js
135
138
  ...test.annotations?.reduce((acc, annotation) => {
136
- acc[annotation.type] = annotation.description;
139
+ if (acc[annotation.type]) {
140
+ acc[annotation.type] = `${acc[annotation.type]}, ${annotation.description}`;
141
+ } else {
142
+ acc[annotation.type] = annotation.description;
143
+ }
137
144
  return acc;
138
145
  }, {}),
139
146
  },
@@ -149,7 +156,7 @@ class PlaywrightReporter {
149
156
  // remove empty uploads
150
157
  this.uploads = this.uploads.filter(anUpload => anUpload.files.length);
151
158
 
152
- reportTestPromises.push(reportTestPromise);
159
+ this.reportTestPromises.push(reportTestPromise);
153
160
  }
154
161
 
155
162
  #getArtifactPath(artifact) {
@@ -173,7 +180,8 @@ class PlaywrightReporter {
173
180
  async onEnd(result) {
174
181
  if (!this.client) return;
175
182
 
176
- await Promise.all(reportTestPromises);
183
+ await this.runPromise;
184
+ await Promise.all(this.reportTestPromises);
177
185
 
178
186
  if (this.uploads.length) {
179
187
  if (this.client.uploader.isEnabled) log.info(`🎞️ Uploading ${this.uploads.length} files...`);