@browsermation/test 0.0.23 → 0.0.25

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/core.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Readable } from 'node:stream';
2
- import 'dotenv/config';
3
2
  /**
4
3
  * The main function that orchestrates zipping and uploading.
5
4
  * @param folderPath The path to the folder to process.
@@ -1,2 +1,2 @@
1
1
  import { PlaywrightTestConfig } from 'playwright/test';
2
- export declare function defineConfig(config: PlaywrightTestConfig): Promise<PlaywrightTestConfig>;
2
+ export declare function defineConfig<T extends PlaywrightTestConfig>(config: T): Promise<T & PlaywrightTestConfig>;
package/dist/index.js CHANGED
@@ -37,21 +37,7 @@ module.exports = __toCommonJS(index_exports);
37
37
 
38
38
  // src/defineConfig.ts
39
39
  var import_node_https = __toESM(require("node:https"));
40
-
41
- // ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
42
- var isProduction = process.env.NODE_ENV === "production";
43
- var prefix = "Invariant failed";
44
- function invariant(condition, message) {
45
- if (condition) {
46
- return;
47
- }
48
- if (isProduction) {
49
- throw new Error(prefix);
50
- }
51
- var provided = typeof message === "function" ? message() : message;
52
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
53
- throw new Error(value);
54
- }
40
+ var import_node_http = __toESM(require("node:http"));
55
41
 
56
42
  // node_modules/chalk/source/vendor/ansi-styles/index.js
57
43
  var ANSI_BACKGROUND_OFFSET = 10;
@@ -551,6 +537,14 @@ var source_default = chalk;
551
537
  // src/tunnel.ts
552
538
  var import_node_child_process = require("node:child_process");
553
539
  function startTunnel(tunnelProcess2, options) {
540
+ if (!process.env.TUNNEL_TOKEN) {
541
+ console.error(
542
+ source_default.red.bold(
543
+ "\u274C Error: TUNNEL_TOKEN environment variable is not set. Please set it to your tunnel token."
544
+ )
545
+ );
546
+ process.exit(1);
547
+ }
554
548
  const tunnelDomain = `${options.subdomain || crypto.randomUUID()}.browsermationtunnel.com`;
555
549
  tunnelProcess2 = (0, import_node_child_process.spawn)("ssh", [
556
550
  "-o",
@@ -595,12 +589,18 @@ function startTunnel(tunnelProcess2, options) {
595
589
 
596
590
  // src/defineConfig.ts
597
591
  async function fetchEndpoint() {
598
- invariant(
599
- process.env.SERVER_URL,
600
- "SERVER_URL environment variable is not set"
601
- );
592
+ if (!process.env.SERVER_URL) {
593
+ console.error(
594
+ source_default.red.bold("\u274C Error: SERVER_URL environment variable is not set")
595
+ );
596
+ process.exit(1);
597
+ }
598
+ let protocol = import_node_https.default;
599
+ if (process.env.SERVER_URL.startsWith("http:")) {
600
+ protocol = import_node_http.default;
601
+ }
602
602
  return new Promise((resolve, reject) => {
603
- import_node_https.default.get(process.env.SERVER_URL || "", (res) => {
603
+ protocol.get(process.env.SERVER_URL || "", (res) => {
604
604
  res.on("data", async (chunk) => {
605
605
  try {
606
606
  const parsedData = JSON.parse(chunk.toString());
@@ -638,7 +638,7 @@ async function defineConfig(config) {
638
638
  };
639
639
  }
640
640
 
641
- // ../../node_modules/@playwright/test/index.mjs
641
+ // node_modules/@playwright/test/index.mjs
642
642
  var test_exports = {};
643
643
  __export(test_exports, {
644
644
  default: () => import_test.default
@@ -648,6 +648,23 @@ var import_test = __toESM(require("playwright/test"), 1);
648
648
 
649
649
  // src/test.ts
650
650
  var import_node_https2 = __toESM(require("node:https"));
651
+
652
+ // node_modules/tiny-invariant/dist/esm/tiny-invariant.js
653
+ var isProduction = process.env.NODE_ENV === "production";
654
+ var prefix = "Invariant failed";
655
+ function invariant(condition, message) {
656
+ if (condition) {
657
+ return;
658
+ }
659
+ if (isProduction) {
660
+ throw new Error(prefix);
661
+ }
662
+ var provided = typeof message === "function" ? message() : message;
663
+ var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
664
+ throw new Error(value);
665
+ }
666
+
667
+ // src/test.ts
651
668
  async function fetchEndpoint2() {
652
669
  invariant(
653
670
  process.env.SERVER_URL,
@@ -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,15 +32,14 @@ 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",
@@ -52,22 +51,8 @@ var BrowsermationReporter = class {
52
51
  body: JSON.stringify(data)
53
52
  }
54
53
  );
55
- if (process.env.REPORTER_DEBUG) {
56
- console.log(
57
- "Send data to Browsermation:",
58
- JSON.stringify(
59
- {
60
- data,
61
- response: await response.json(),
62
- statusCode: response.status
63
- },
64
- null,
65
- 2
66
- )
67
- );
68
- }
69
54
  } catch (error) {
70
- console.log("Error sending data to Browsermation:", error);
55
+ console.error("Error sending data to Browsermation:", error);
71
56
  }
72
57
  }
73
58
  async onBegin(_config, suite) {
@@ -77,7 +62,7 @@ var BrowsermationReporter = class {
77
62
  file: suite.location?.file,
78
63
  timestamp: Date.now()
79
64
  };
80
- console.log(`${JSON.stringify(data)}
65
+ this.log(`${JSON.stringify(data)}
81
66
  `);
82
67
  await this.sendData(data);
83
68
  }
@@ -89,7 +74,7 @@ var BrowsermationReporter = class {
89
74
  status: result.status,
90
75
  timestamp: Date.now()
91
76
  };
92
- console.log(`${JSON.stringify(data)}
77
+ this.log(`${JSON.stringify(data)}
93
78
  `);
94
79
  await this.sendData(data);
95
80
  }
@@ -101,7 +86,7 @@ var BrowsermationReporter = class {
101
86
  file: test.location.file,
102
87
  timestamp: Date.now()
103
88
  };
104
- console.log(`${JSON.stringify(data)}
89
+ this.log(`${JSON.stringify(data)}
105
90
  `);
106
91
  await this.sendData(data);
107
92
  }
@@ -116,7 +101,7 @@ var BrowsermationReporter = class {
116
101
  errors: stripAnsi(result.error?.message || ""),
117
102
  timestamp: Date.now()
118
103
  };
119
- console.log(`${JSON.stringify(data)}
104
+ this.log(`${JSON.stringify(data)}
120
105
  `);
121
106
  await this.sendData(data);
122
107
  }
@@ -136,7 +121,7 @@ var BrowsermationReporter = class {
136
121
  type: "exit",
137
122
  timestamp: Date.now()
138
123
  };
139
- console.log(`${JSON.stringify(data)}
124
+ this.log(`${JSON.stringify(data)}
140
125
  `);
141
126
  await this.sendData(data);
142
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browsermation/test",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
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",
@@ -50,6 +50,7 @@
50
50
  "typescript": "^5.9.2"
51
51
  },
52
52
  "dependencies": {
53
+ "@playwright/test": "^1.55.0",
53
54
  "archiver": "^7.0.1",
54
55
  "axios": "^1.10.0",
55
56
  "chalk": "^5.4.1",