@browsermation/test 0.0.63-beta.3 → 0.0.63-beta.4
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 -0
- package/dist/reporter.js +10 -3
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestError, TestResult } from '@playwright/test/reporter';
|
|
2
2
|
export default class BrowsermationReporter implements Reporter {
|
|
3
3
|
browsermationURL: string;
|
|
4
|
+
apiToken: string;
|
|
4
5
|
log(message: string): void;
|
|
5
6
|
constructor(options?: {
|
|
6
7
|
reportingURL?: string;
|
|
8
|
+
apiToken?: string;
|
|
7
9
|
});
|
|
8
10
|
getCurrentBranch(): Promise<string>;
|
|
9
11
|
getCurrentRepo(): Promise<string>;
|
package/dist/reporter.js
CHANGED
|
@@ -34,6 +34,7 @@ var regex = (({ onlyFirst = false } = {}) => {
|
|
|
34
34
|
var stripAnsi = (str) => str.replace(regex, "");
|
|
35
35
|
var BrowsermationReporter = class {
|
|
36
36
|
browsermationURL = "";
|
|
37
|
+
apiToken = "";
|
|
37
38
|
log(message) {
|
|
38
39
|
if (process.env.BM_REPORTER_LOGS) {
|
|
39
40
|
console.log(message);
|
|
@@ -41,9 +42,10 @@ var BrowsermationReporter = class {
|
|
|
41
42
|
}
|
|
42
43
|
constructor(options = {}) {
|
|
43
44
|
this.browsermationURL = options.reportingURL || process.env.BM_REPORTING_URL || "https://browsermation.com/api/v1/playwright/reporting";
|
|
45
|
+
this.apiToken = options.apiToken || process.env.BM_API_TOKEN || "";
|
|
44
46
|
this.log(`Using Browsermation reporting URL: ${this.browsermationURL}`);
|
|
45
47
|
this.log(
|
|
46
|
-
"Using API Token: " + (
|
|
48
|
+
"Using API Token: " + (this.apiToken ? this.apiToken.slice(0, 4) + "****" : "not set")
|
|
47
49
|
);
|
|
48
50
|
}
|
|
49
51
|
async getCurrentBranch() {
|
|
@@ -76,15 +78,20 @@ var BrowsermationReporter = class {
|
|
|
76
78
|
async sendData(data) {
|
|
77
79
|
this.log(`Sending data to Browsermation: ${JSON.stringify(data)}`);
|
|
78
80
|
try {
|
|
79
|
-
await fetch(this.browsermationURL, {
|
|
81
|
+
const response = await fetch(this.browsermationURL, {
|
|
80
82
|
method: "POST",
|
|
81
83
|
headers: {
|
|
82
84
|
Accept: "application/json",
|
|
83
85
|
"Content-Type": "application/json",
|
|
84
|
-
Authorization: `Bearer ${
|
|
86
|
+
Authorization: `Bearer ${this.apiToken}`
|
|
85
87
|
},
|
|
86
88
|
body: JSON.stringify(data)
|
|
87
89
|
});
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
this.log(
|
|
92
|
+
`Failed to send data to Browsermation. Status: ${response.status} - ${response.statusText}`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
88
95
|
} catch (error) {
|
|
89
96
|
console.error("Error sending data to Browsermation:", error);
|
|
90
97
|
}
|