@browsermation/test 0.0.22 → 0.0.24

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.
package/dist/bin/cli.js CHANGED
@@ -42871,7 +42871,7 @@ var {
42871
42871
  // package.json
42872
42872
  var package_default = {
42873
42873
  name: "@browsermation/test",
42874
- version: "0.0.22",
42874
+ version: "0.0.24",
42875
42875
  description: "The testing platform for Playwright by Browsermation.",
42876
42876
  main: "./dist/index.js",
42877
42877
  types: "./dist/index.d.ts",
@@ -42904,7 +42904,7 @@ var package_default = {
42904
42904
  build: "rm -rf dist && npm run build:cli && npm run build:index && npm run build:reporter && npm run build:types",
42905
42905
  start: "node dist/bin/cli.js",
42906
42906
  "build:start": "npm run build && npm start",
42907
- publish: "npm run build && npm publish --access public"
42907
+ publishPackage: "npm run build && npm publish --access public"
42908
42908
  },
42909
42909
  keywords: [
42910
42910
  "cli",
@@ -1,5 +1,6 @@
1
1
  import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestError, TestResult } from '@playwright/test/reporter';
2
2
  export default class BrowsermationReporter implements Reporter {
3
+ log(message: string): void;
3
4
  sendData(data: Record<string, any>): Promise<void>;
4
5
  onBegin(_config: FullConfig, suite: Suite): Promise<void>;
5
6
  onEnd(result: FullResult): Promise<void>;
package/dist/reporter.js CHANGED
@@ -32,41 +32,27 @@ var regex = (({ onlyFirst = false } = {}) => {
32
32
  })();
33
33
  var stripAnsi = (str) => str.replace(regex, "");
34
34
  var BrowsermationReporter = class {
35
- async sendData(data) {
36
- if (process.env.REPORTER_DEBUG) {
37
- console.log(
38
- "Sending data to Browsermation:",
39
- JSON.stringify(data, null, 2)
40
- );
35
+ log(message) {
36
+ if (process.env.REPORTER_LOGS) {
37
+ console.log(message);
41
38
  }
39
+ }
40
+ async sendData(data) {
42
41
  try {
43
- const response = await fetch(
42
+ await fetch(
44
43
  process.env.REPORTING_URL || "https://browsermation.com/api/v1/playwright/reporting",
45
44
  {
46
45
  method: "POST",
47
46
  headers: {
47
+ Accept: "application/json",
48
48
  "Content-Type": "application/json",
49
49
  Authorization: `Bearer ${process.env.API_TOKEN}`
50
50
  },
51
51
  body: JSON.stringify(data)
52
52
  }
53
53
  );
54
- if (process.env.REPORTER_DEBUG) {
55
- console.log(
56
- "Send data to Browsermation:",
57
- JSON.stringify(
58
- {
59
- data,
60
- response: await response.json(),
61
- statusCode: response.status
62
- },
63
- null,
64
- 2
65
- )
66
- );
67
- }
68
54
  } catch (error) {
69
- console.log("Error sending data to Browsermation:", error);
55
+ console.error("Error sending data to Browsermation:", error);
70
56
  }
71
57
  }
72
58
  async onBegin(_config, suite) {
@@ -76,7 +62,7 @@ var BrowsermationReporter = class {
76
62
  file: suite.location?.file,
77
63
  timestamp: Date.now()
78
64
  };
79
- console.log(`${JSON.stringify(data)}
65
+ this.log(`${JSON.stringify(data)}
80
66
  `);
81
67
  await this.sendData(data);
82
68
  }
@@ -88,7 +74,7 @@ var BrowsermationReporter = class {
88
74
  status: result.status,
89
75
  timestamp: Date.now()
90
76
  };
91
- console.log(`${JSON.stringify(data)}
77
+ this.log(`${JSON.stringify(data)}
92
78
  `);
93
79
  await this.sendData(data);
94
80
  }
@@ -100,7 +86,7 @@ var BrowsermationReporter = class {
100
86
  file: test.location.file,
101
87
  timestamp: Date.now()
102
88
  };
103
- console.log(`${JSON.stringify(data)}
89
+ this.log(`${JSON.stringify(data)}
104
90
  `);
105
91
  await this.sendData(data);
106
92
  }
@@ -115,7 +101,7 @@ var BrowsermationReporter = class {
115
101
  errors: stripAnsi(result.error?.message || ""),
116
102
  timestamp: Date.now()
117
103
  };
118
- console.log(`${JSON.stringify(data)}
104
+ this.log(`${JSON.stringify(data)}
119
105
  `);
120
106
  await this.sendData(data);
121
107
  }
@@ -135,7 +121,7 @@ var BrowsermationReporter = class {
135
121
  type: "exit",
136
122
  timestamp: Date.now()
137
123
  };
138
- console.log(`${JSON.stringify(data)}
124
+ this.log(`${JSON.stringify(data)}
139
125
  `);
140
126
  await this.sendData(data);
141
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browsermation/test",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "The testing platform for Playwright by Browsermation.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "build": "rm -rf dist && npm run build:cli && npm run build:index && npm run build:reporter && npm run build:types",
34
34
  "start": "node dist/bin/cli.js",
35
35
  "build:start": "npm run build && npm start",
36
- "publish": "npm run build && npm publish --access public"
36
+ "publishPackage": "npm run build && npm publish --access public"
37
37
  },
38
38
  "keywords": [
39
39
  "cli",