@browsermation/test 0.0.63-beta.18 → 0.0.63-beta.19

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.
@@ -1,4 +1,4 @@
1
- import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestError, TestResult } from '@playwright/test/reporter';
1
+ import type { FullConfig, FullProject, FullResult, Reporter, Suite, TestCase, TestError, TestResult } from '@playwright/test/reporter';
2
2
  export default class BrowsermationReporter implements Reporter {
3
3
  browsermationURL: string;
4
4
  apiToken: string;
@@ -14,7 +14,7 @@ export default class BrowsermationReporter implements Reporter {
14
14
  getLatestCommitMessage(): Promise<string>;
15
15
  gitRemoteOriginUrl(): Promise<string>;
16
16
  sendData(data: Record<string, any>): Promise<any>;
17
- getProjectSuite(parent: Suite): Suite;
17
+ getProjectSuite(parent: Suite): FullProject | undefined;
18
18
  /**
19
19
  * onBegin() is called once with a root suite that contains all other suites and tests. Learn more about suites hierarchy.
20
20
  *
package/dist/reporter.js CHANGED
@@ -37,7 +37,7 @@ var BrowsermationReporter = class {
37
37
  apiToken = "";
38
38
  suiteRunId = null;
39
39
  log(message) {
40
- if (process.env.BM_REPORTER_LOGS) {
40
+ if (process.env.BM_REPORTER_DEBUG_LOGS) {
41
41
  console.log(message);
42
42
  }
43
43
  }
@@ -55,6 +55,12 @@ var BrowsermationReporter = class {
55
55
  }
56
56
  }
57
57
  async getCurrentBranch() {
58
+ if (process.env.BM_REPORTER_DISABLE_GIT_INFO) {
59
+ this.log(
60
+ "BM_REPORTER_DISABLE_GIT_INFO is set to true. Skipping git info."
61
+ );
62
+ return;
63
+ }
58
64
  return new Promise((resolve) => {
59
65
  const { exec } = require("child_process");
60
66
  exec("git rev-parse --abbrev-ref HEAD", (error, stdout) => {
@@ -67,6 +73,12 @@ var BrowsermationReporter = class {
67
73
  });
68
74
  }
69
75
  async getCurrentRepo() {
76
+ if (process.env.BM_REPORTER_DISABLE_GIT_INFO) {
77
+ this.log(
78
+ "BM_REPORTER_DISABLE_GIT_INFO is set to true. Skipping git info."
79
+ );
80
+ return;
81
+ }
70
82
  return new Promise((resolve) => {
71
83
  const { exec } = require("child_process");
72
84
  exec(
@@ -82,6 +94,12 @@ var BrowsermationReporter = class {
82
94
  });
83
95
  }
84
96
  async getLatestCommitId() {
97
+ if (process.env.BM_REPORTER_DISABLE_GIT_INFO) {
98
+ this.log(
99
+ "BM_REPORTER_DISABLE_GIT_INFO is set to true. Skipping git info."
100
+ );
101
+ return;
102
+ }
85
103
  return new Promise((resolve) => {
86
104
  const { exec } = require("child_process");
87
105
  exec("git rev-parse HEAD", (error, stdout) => {
@@ -94,6 +112,12 @@ var BrowsermationReporter = class {
94
112
  });
95
113
  }
96
114
  async getLatestCommitMessage() {
115
+ if (process.env.BM_REPORTER_DISABLE_GIT_INFO) {
116
+ this.log(
117
+ "BM_REPORTER_DISABLE_GIT_INFO is set to true. Skipping git info."
118
+ );
119
+ return;
120
+ }
97
121
  return new Promise((resolve) => {
98
122
  const { exec } = require("child_process");
99
123
  exec("git log -1 --pretty=%B", (error, stdout) => {
@@ -106,6 +130,12 @@ var BrowsermationReporter = class {
106
130
  });
107
131
  }
108
132
  async gitRemoteOriginUrl() {
133
+ if (process.env.BM_REPORTER_DISABLE_GIT_INFO) {
134
+ this.log(
135
+ "BM_REPORTER_DISABLE_GIT_INFO is set to true. Skipping git info."
136
+ );
137
+ return;
138
+ }
109
139
  return new Promise((resolve) => {
110
140
  const { exec } = require("child_process");
111
141
  exec("git remote get-url origin", (error, stdout) => {
@@ -123,6 +153,12 @@ var BrowsermationReporter = class {
123
153
  return;
124
154
  }
125
155
  this.log(`Sending data to Browsermation: ${JSON.stringify(data)}`);
156
+ if (process.env.BM_REPORTER_LOG_ONLY) {
157
+ this.log(
158
+ "BM_REPORTER_LOG_ONLY is set to true. Skipping sending data to Browsermation."
159
+ );
160
+ return;
161
+ }
126
162
  try {
127
163
  const response = await fetch(this.browsermationURL, {
128
164
  method: "POST",
@@ -145,10 +181,13 @@ var BrowsermationReporter = class {
145
181
  }
146
182
  getProjectSuite(parent) {
147
183
  let currentSuite = parent;
148
- while (currentSuite.parent && currentSuite.type !== "project") {
184
+ while (currentSuite.parent) {
185
+ if (currentSuite.project()) {
186
+ break;
187
+ }
149
188
  currentSuite = currentSuite.parent;
150
189
  }
151
- return currentSuite;
190
+ return currentSuite.project();
152
191
  }
153
192
  /**
154
193
  * onBegin() is called once with a root suite that contains all other suites and tests. Learn more about suites hierarchy.
@@ -203,13 +242,12 @@ var BrowsermationReporter = class {
203
242
  free_memory: (0, import_node_os.freemem)(),
204
243
  total_memory: (0, import_node_os.totalmem)(),
205
244
  cpus: (0, import_node_os.cpus)().length,
206
- project: test.parent.project.name,
207
245
  cpu_architecture: process.arch,
208
246
  retries: test.retries,
209
- project_title: this.getProjectSuite(test.parent)?.project?.name
247
+ project_name: this.getProjectSuite(test.parent)?.name,
248
+ project_default_browser_type: this.getProjectSuite(test.parent)?.use.defaultBrowserType,
249
+ suite_title: test.parent.title
210
250
  };
211
- this.log(`${JSON.stringify(data)}
212
- `);
213
251
  await this.sendData(data);
214
252
  }
215
253
  async onTestEnd(test, result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browsermation/test",
3
- "version": "0.0.63-beta.18",
3
+ "version": "0.0.63-beta.19",
4
4
  "description": "The testing platform for Playwright by Browsermation.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -53,5 +53,6 @@
53
53
  "chalk": "^5.4.1",
54
54
  "ora": "^8.2.0",
55
55
  "ts-node": "^10.9.2"
56
- }
56
+ },
57
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
57
58
  }