@browsermation/test 0.0.64 → 0.0.66

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.
Files changed (2) hide show
  1. package/dist/reporter.js +26 -20
  2. package/package.json +1 -1
package/dist/reporter.js CHANGED
@@ -53,7 +53,7 @@ var BrowsermationReporter = class {
53
53
  this.log(
54
54
  "Using API Token: " + (this.apiToken ? this.apiToken.slice(0, 4) + "****" : "not set")
55
55
  );
56
- if (!this.apiToken) {
56
+ if (!this.apiToken && !process.env.BM_REPORTER_ONLY_LOG_EVENTS) {
57
57
  console.warn(
58
58
  "Warning: No API token set for Browsermation Reporter. Set BM_API_TOKEN environment variable or pass apiToken in reporter options."
59
59
  );
@@ -153,27 +153,33 @@ var BrowsermationReporter = class {
153
153
  });
154
154
  }
155
155
  async sendData(data) {
156
- if (!this.apiToken) {
157
- this.log("API token not set. Skipping sending data to Browsermation.");
158
- return;
159
- }
160
- this.log(`Sending data to Browsermation: ${JSON.stringify(data)}`);
161
156
  if (process.env.BM_REPORTER_ONLY_LOG_EVENTS) {
162
157
  this.log(
163
158
  "BM_REPORTER_ONLY_LOG_EVENTS is set to true. Skipping sending data to Browsermation."
164
159
  );
165
160
  return;
166
161
  }
162
+ if (process.env.BM_BROWSER_RUN_ID) {
163
+ data.browser_run_id = process.env.BM_BROWSER_RUN_ID;
164
+ }
165
+ if (!this.apiToken) {
166
+ this.log("API token not set. Skipping sending data to Browsermation.");
167
+ return;
168
+ }
169
+ this.log(`Sending data to Browsermation: ${JSON.stringify(data)}`);
167
170
  try {
168
- const response = await fetch(this.browsermationURL, {
169
- method: "POST",
170
- headers: {
171
- Accept: "application/json",
172
- "Content-Type": "application/json",
173
- Authorization: `Bearer ${this.apiToken}`
174
- },
175
- body: JSON.stringify(data)
176
- });
171
+ const response = await fetch(
172
+ `${this.browsermationURL}?type=${data.type}`,
173
+ {
174
+ method: "POST",
175
+ headers: {
176
+ Accept: "application/json",
177
+ "Content-Type": "application/json",
178
+ Authorization: `Bearer ${this.apiToken}`
179
+ },
180
+ body: JSON.stringify(data)
181
+ }
182
+ );
177
183
  if (!response.ok) {
178
184
  this.log(
179
185
  `Failed to send data to Browsermation. Status: ${response.status} - ${response.statusText}`
@@ -215,7 +221,7 @@ var BrowsermationReporter = class {
215
221
  playwright_version: _config.version,
216
222
  node_version: process.version
217
223
  };
218
- this.log(`${JSON.stringify(data)}
224
+ this.logEvent(`${JSON.stringify(data)}
219
225
  `);
220
226
  const response = await this.sendData(data);
221
227
  if (response?.data?.suite_run_id) {
@@ -232,7 +238,7 @@ var BrowsermationReporter = class {
232
238
  status: result.status,
233
239
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
234
240
  };
235
- this.log(`${JSON.stringify(data)}
241
+ this.logEvent(`${JSON.stringify(data)}
236
242
  `);
237
243
  await this.sendData(data);
238
244
  }
@@ -278,7 +284,7 @@ var BrowsermationReporter = class {
278
284
  stderr: result.stderr.map((s) => stripAnsi(s.toString())).join("\n"),
279
285
  stdout: result.stdout.map((s) => stripAnsi(s.toString())).join("\n")
280
286
  };
281
- this.log(`${JSON.stringify(data)}
287
+ this.logEvent(`${JSON.stringify(data)}
282
288
  `);
283
289
  await this.sendData(data);
284
290
  }
@@ -290,7 +296,7 @@ var BrowsermationReporter = class {
290
296
  stack: error.stack,
291
297
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
292
298
  };
293
- console.error(`${JSON.stringify(data)}
299
+ this.logEvent(`${JSON.stringify(data)}
294
300
  `);
295
301
  await this.sendData(data);
296
302
  }
@@ -300,7 +306,7 @@ var BrowsermationReporter = class {
300
306
  suite_run_id: this.suiteRunId,
301
307
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
302
308
  };
303
- this.log(`${JSON.stringify(data)}
309
+ this.logEvent(`${JSON.stringify(data)}
304
310
  `);
305
311
  await this.sendData(data);
306
312
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browsermation/test",
3
- "version": "0.0.64",
3
+ "version": "0.0.66",
4
4
  "description": "The testing platform for Playwright by Browsermation.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",