@browsermation/test 0.0.60 → 0.0.62
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/README.md +0 -6
- package/dist/reporter/reporter.d.ts +12 -0
- package/dist/reporter.js +42 -16
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -12,12 +12,6 @@ npm install @browsermation/test
|
|
|
12
12
|
|
|
13
13
|
See also [Browsermation](https://www.npmjs.com/package/@browsermation/test) for the test package.
|
|
14
14
|
|
|
15
|
-
You can use via the CLI
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npx @browsermation/test test
|
|
19
|
-
```
|
|
20
|
-
|
|
21
15
|
Or use it as Playwright reporter
|
|
22
16
|
|
|
23
17
|
```bash
|
|
@@ -1,7 +1,19 @@
|
|
|
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
|
log(message: string): void;
|
|
4
|
+
constructor(options?: {
|
|
5
|
+
customOption?: string;
|
|
6
|
+
});
|
|
7
|
+
getCurrentBranch(): Promise<string>;
|
|
4
8
|
sendData(data: Record<string, any>): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* onBegin() is called once with a root suite that contains all other suites and tests. Learn more about suites hierarchy.
|
|
11
|
+
*
|
|
12
|
+
* @param {FullConfig} _config
|
|
13
|
+
* @param {Suite} suite
|
|
14
|
+
* @return {*} {Promise<void>}
|
|
15
|
+
* @memberof BrowsermationReporter
|
|
16
|
+
*/
|
|
5
17
|
onBegin(_config: FullConfig, suite: Suite): Promise<void>;
|
|
6
18
|
onEnd(result: FullResult): Promise<void>;
|
|
7
19
|
onTestBegin(test: TestCase): Promise<void>;
|
package/dist/reporter.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(reporter_exports, {
|
|
|
22
22
|
default: () => BrowsermationReporter
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(reporter_exports);
|
|
25
|
+
var import_node_os = require("node:os");
|
|
25
26
|
var regex = (({ onlyFirst = false } = {}) => {
|
|
26
27
|
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
27
28
|
const pattern = [
|
|
@@ -37,30 +38,54 @@ var BrowsermationReporter = class {
|
|
|
37
38
|
console.log(message);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
41
|
+
constructor(options = {}) {
|
|
42
|
+
this.log(
|
|
43
|
+
`my-awesome-reporter setup with customOption set to ${options.customOption}`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
async getCurrentBranch() {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
const { exec } = require("child_process");
|
|
49
|
+
exec("git rev-parse --abbrev-ref HEAD", (error, stdout) => {
|
|
50
|
+
if (error) {
|
|
51
|
+
resolve("unknown");
|
|
52
|
+
} else {
|
|
53
|
+
resolve(stdout.trim());
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
40
58
|
async sendData(data) {
|
|
59
|
+
const url = process.env.BM_REPORTING_URL || "https://browsermation.com/api/v1/playwright/reporting";
|
|
41
60
|
try {
|
|
42
|
-
await fetch(
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
body: JSON.stringify(data)
|
|
52
|
-
}
|
|
53
|
-
);
|
|
61
|
+
await fetch(url, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: {
|
|
64
|
+
Accept: "application/json",
|
|
65
|
+
"Content-Type": "application/json",
|
|
66
|
+
Authorization: `Bearer ${process.env.BM_API_TOKEN}`
|
|
67
|
+
},
|
|
68
|
+
body: JSON.stringify(data)
|
|
69
|
+
});
|
|
54
70
|
} catch (error) {
|
|
55
71
|
console.error("Error sending data to Browsermation:", error);
|
|
56
72
|
}
|
|
57
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* onBegin() is called once with a root suite that contains all other suites and tests. Learn more about suites hierarchy.
|
|
76
|
+
*
|
|
77
|
+
* @param {FullConfig} _config
|
|
78
|
+
* @param {Suite} suite
|
|
79
|
+
* @return {*} {Promise<void>}
|
|
80
|
+
* @memberof BrowsermationReporter
|
|
81
|
+
*/
|
|
58
82
|
async onBegin(_config, suite) {
|
|
59
83
|
const data = {
|
|
60
84
|
type: "begin",
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
timestamp: Date.now(),
|
|
86
|
+
hostname: (0, import_node_os.hostname)(),
|
|
87
|
+
branch: await this.getCurrentBranch(),
|
|
88
|
+
totalTests: suite.allTests().length
|
|
64
89
|
};
|
|
65
90
|
this.log(`${JSON.stringify(data)}
|
|
66
91
|
`);
|
|
@@ -72,7 +97,8 @@ var BrowsermationReporter = class {
|
|
|
72
97
|
startTime: result.startTime,
|
|
73
98
|
duration: result.duration,
|
|
74
99
|
status: result.status,
|
|
75
|
-
timestamp: Date.now()
|
|
100
|
+
timestamp: Date.now(),
|
|
101
|
+
hostname: (0, import_node_os.hostname)()
|
|
76
102
|
};
|
|
77
103
|
this.log(`${JSON.stringify(data)}
|
|
78
104
|
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browsermation/test",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"description": "The testing platform for Playwright by Browsermation.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"build": "rm -rf dist && npm run build:index && npm run build:reporter && npm run build:types",
|
|
33
33
|
"start": "node dist/bin/cli.js",
|
|
34
34
|
"build:start": "npm run build && npm start",
|
|
35
|
-
"publishPackage": "npm run build && npm publish --access public"
|
|
35
|
+
"publishPackage": "npm run build && npm publish --access public",
|
|
36
|
+
"publishBetaPackage": "npm run build && npm publish --access public --tag beta"
|
|
36
37
|
},
|
|
37
38
|
"keywords": [
|
|
38
39
|
"cli",
|