@browsermation/test 0.0.63-beta.11 → 0.0.63-beta.13
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/reporter/reporter.d.ts +2 -1
- package/dist/reporter.js +20 -9
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestError, Test
|
|
|
2
2
|
export default class BrowsermationReporter implements Reporter {
|
|
3
3
|
browsermationURL: string;
|
|
4
4
|
apiToken: string;
|
|
5
|
+
suiteRunId: string | null;
|
|
5
6
|
log(message: string): void;
|
|
6
7
|
constructor(options?: {
|
|
7
8
|
reportingURL?: string;
|
|
@@ -12,7 +13,7 @@ export default class BrowsermationReporter implements Reporter {
|
|
|
12
13
|
getLatestCommitId(): Promise<string>;
|
|
13
14
|
getLatestCommitMessage(): Promise<string>;
|
|
14
15
|
gitRemoteOriginUrl(): Promise<string>;
|
|
15
|
-
sendData(data: Record<string, any>): Promise<
|
|
16
|
+
sendData(data: Record<string, any>): Promise<any>;
|
|
16
17
|
/**
|
|
17
18
|
* onBegin() is called once with a root suite that contains all other suites and tests. Learn more about suites hierarchy.
|
|
18
19
|
*
|
package/dist/reporter.js
CHANGED
|
@@ -35,6 +35,7 @@ var stripAnsi = (str) => str.replace(regex, "");
|
|
|
35
35
|
var BrowsermationReporter = class {
|
|
36
36
|
browsermationURL = "";
|
|
37
37
|
apiToken = "";
|
|
38
|
+
suiteRunId = null;
|
|
38
39
|
log(message) {
|
|
39
40
|
if (process.env.BM_REPORTER_LOGS) {
|
|
40
41
|
console.log(message);
|
|
@@ -137,6 +138,7 @@ var BrowsermationReporter = class {
|
|
|
137
138
|
`Failed to send data to Browsermation. Status: ${response.status} - ${response.statusText}`
|
|
138
139
|
);
|
|
139
140
|
}
|
|
141
|
+
return await response.json();
|
|
140
142
|
} catch (error) {
|
|
141
143
|
console.error("Error sending data to Browsermation:", error);
|
|
142
144
|
}
|
|
@@ -160,22 +162,25 @@ var BrowsermationReporter = class {
|
|
|
160
162
|
git_commit_message: await this.getLatestCommitMessage(),
|
|
161
163
|
git_remote_origin_url: await this.gitRemoteOriginUrl(),
|
|
162
164
|
totalTests: suite.allTests().length,
|
|
163
|
-
cpus: (0, import_node_os.cpus)().length,
|
|
164
165
|
playwright_version: _config.version,
|
|
165
166
|
node_version: process.version
|
|
166
167
|
};
|
|
167
168
|
this.log(`${JSON.stringify(data)}
|
|
168
169
|
`);
|
|
169
|
-
await this.sendData(data);
|
|
170
|
+
const response = await this.sendData(data);
|
|
171
|
+
if (response && response.data.suite_run_id) {
|
|
172
|
+
this.suiteRunId = response.data.suite_run_id;
|
|
173
|
+
this.log(`Received suite_run_id: ${this.suiteRunId}`);
|
|
174
|
+
}
|
|
170
175
|
}
|
|
171
176
|
async onEnd(result) {
|
|
172
177
|
const data = {
|
|
173
178
|
type: "end",
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
suite_run_id: this.suiteRunId,
|
|
180
|
+
start_time: result.startTime,
|
|
181
|
+
duration_in_ms: result.duration,
|
|
176
182
|
status: result.status,
|
|
177
|
-
timestamp: Date.now()
|
|
178
|
-
hostname: (0, import_node_os.hostname)()
|
|
183
|
+
timestamp: Date.now()
|
|
179
184
|
};
|
|
180
185
|
this.log(`${JSON.stringify(data)}
|
|
181
186
|
`);
|
|
@@ -190,7 +195,9 @@ var BrowsermationReporter = class {
|
|
|
190
195
|
timestamp: Date.now(),
|
|
191
196
|
free_memory: (0, import_node_os.freemem)(),
|
|
192
197
|
total_memory: (0, import_node_os.totalmem)(),
|
|
193
|
-
|
|
198
|
+
cpus: (0, import_node_os.cpus)().length,
|
|
199
|
+
project: test.parent.project.name,
|
|
200
|
+
cpu_architecture: process.arch
|
|
194
201
|
};
|
|
195
202
|
this.log(`${JSON.stringify(data)}
|
|
196
203
|
`);
|
|
@@ -199,15 +206,17 @@ var BrowsermationReporter = class {
|
|
|
199
206
|
async onTestEnd(test, result) {
|
|
200
207
|
const data = {
|
|
201
208
|
id: test.id,
|
|
209
|
+
suite_run_id: this.suiteRunId,
|
|
202
210
|
type: "test-end",
|
|
203
211
|
title: test.title,
|
|
204
|
-
|
|
212
|
+
title_path: test.titlePath,
|
|
205
213
|
status: result.status,
|
|
206
214
|
duration: result.duration,
|
|
207
215
|
errors: stripAnsi(result.error?.message || ""),
|
|
208
216
|
timestamp: Date.now(),
|
|
209
217
|
free_memory: (0, import_node_os.freemem)(),
|
|
210
|
-
total_memory: (0, import_node_os.totalmem)()
|
|
218
|
+
total_memory: (0, import_node_os.totalmem)(),
|
|
219
|
+
cpu_architecture: process.arch
|
|
211
220
|
};
|
|
212
221
|
this.log(`${JSON.stringify(data)}
|
|
213
222
|
`);
|
|
@@ -216,6 +225,7 @@ var BrowsermationReporter = class {
|
|
|
216
225
|
async onError(error) {
|
|
217
226
|
const data = {
|
|
218
227
|
type: "error",
|
|
228
|
+
suite_run_id: this.suiteRunId,
|
|
219
229
|
message: error.message,
|
|
220
230
|
stack: error.stack,
|
|
221
231
|
timestamp: Date.now()
|
|
@@ -227,6 +237,7 @@ var BrowsermationReporter = class {
|
|
|
227
237
|
async onExit() {
|
|
228
238
|
const data = {
|
|
229
239
|
type: "exit",
|
|
240
|
+
suite_run_id: this.suiteRunId,
|
|
230
241
|
timestamp: Date.now()
|
|
231
242
|
};
|
|
232
243
|
this.log(`${JSON.stringify(data)}
|