@browsermation/test 0.0.40 → 0.0.42

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/bin/cli.js CHANGED
@@ -42258,7 +42258,7 @@ var {
42258
42258
  // package.json
42259
42259
  var package_default = {
42260
42260
  name: "@browsermation/test",
42261
- version: "0.0.40",
42261
+ version: "0.0.42",
42262
42262
  description: "The testing platform for Playwright by Browsermation.",
42263
42263
  main: "./dist/index.js",
42264
42264
  types: "./dist/index.d.ts",
@@ -46653,10 +46653,10 @@ async function upload(zipBuffer, shardNumber, totalShards, playwrightConfig, opt
46653
46653
  // src/tunnel.ts
46654
46654
  var import_node_child_process = require("node:child_process");
46655
46655
  function startTunnel(tunnelProcess, options) {
46656
- if (!process.env.TUNNEL_TOKEN) {
46656
+ if (!process.env.BM_TUNNEL_TOKEN) {
46657
46657
  console.error(
46658
46658
  source_default.red.bold(
46659
- "\u274C Error: TUNNEL_TOKEN environment variable is not set. Please set it to your tunnel token."
46659
+ "\u274C Error: BM_TUNNEL_TOKEN environment variable is not set. Please set it to your tunnel token."
46660
46660
  )
46661
46661
  );
46662
46662
  process.exit(1);
@@ -46678,7 +46678,7 @@ function startTunnel(tunnelProcess, options) {
46678
46678
  "--custom_domain",
46679
46679
  tunnelDomain,
46680
46680
  "--token",
46681
- process.env.TUNNEL_TOKEN || ""
46681
+ process.env.BM_TUNNEL_TOKEN || ""
46682
46682
  ]);
46683
46683
  process.on("SIGINT", function() {
46684
46684
  console.log("\nGracefully shutting down from SIGINT (Ctrl+C)");
package/dist/index.js CHANGED
@@ -537,10 +537,10 @@ var source_default = chalk;
537
537
  // src/tunnel.ts
538
538
  var import_node_child_process = require("node:child_process");
539
539
  function startTunnel(tunnelProcess2, options) {
540
- if (!process.env.TUNNEL_TOKEN) {
540
+ if (!process.env.BM_TUNNEL_TOKEN) {
541
541
  console.error(
542
542
  source_default.red.bold(
543
- "\u274C Error: TUNNEL_TOKEN environment variable is not set. Please set it to your tunnel token."
543
+ "\u274C Error: BM_TUNNEL_TOKEN environment variable is not set. Please set it to your tunnel token."
544
544
  )
545
545
  );
546
546
  process.exit(1);
@@ -562,7 +562,7 @@ function startTunnel(tunnelProcess2, options) {
562
562
  "--custom_domain",
563
563
  tunnelDomain,
564
564
  "--token",
565
- process.env.TUNNEL_TOKEN || ""
565
+ process.env.BM_TUNNEL_TOKEN || ""
566
566
  ]);
567
567
  process.on("SIGINT", function() {
568
568
  console.log("\nGracefully shutting down from SIGINT (Ctrl+C)");
@@ -617,36 +617,12 @@ async function fetchEndpoint() {
617
617
  }
618
618
  };
619
619
  protocol.get(process.env.BM_SERVER_URL || "", options, (res) => {
620
- if (res.statusCode && (res.statusCode < 200 || res.statusCode >= 400)) {
621
- console.error(
622
- source_default.red.bold(
623
- `\u274C Error: HTTP status code ${res.statusCode} received`
624
- )
625
- );
626
- return reject(new Error(`HTTP status code ${res.statusCode} received`));
627
- }
628
- res.on("error", (err) => {
629
- console.log("err", err);
630
- console.error(
631
- source_default.red.bold("\u274C Error: Failed to fetch WebSocket endpoint.")
632
- );
633
- reject(err);
634
- });
635
- res.on("data", async (chunk) => {
636
- if (process.env.BM_DEBUG) {
637
- console.log("Received chunk:", chunk.toString());
638
- }
639
- try {
640
- const parsedData = JSON.parse(chunk.toString().trim());
641
- if (parsedData.type === "ws-endpoint") {
642
- resolve(parsedData.wsEndpoint);
643
- res.destroy();
644
- }
645
- } catch (error) {
646
- console.log("Error parsing JSON:", error);
647
- console.log(chunk.toString());
620
+ if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400) {
621
+ const redirectUrl = res.headers.location;
622
+ if (redirectUrl) {
623
+ resolve(redirectUrl);
648
624
  }
649
- });
625
+ }
650
626
  });
651
627
  });
652
628
  }
@@ -661,15 +637,17 @@ async function defineConfig(config) {
661
637
  `\u2705 WebSocket endpoint fetched successfully: ${endpointUrl}`
662
638
  )
663
639
  );
640
+ let tunnelUrl = void 0;
664
641
  if (config.webServer && (Array.isArray(config.webServer) ? config.webServer.some((server) => server.port) : config.webServer.port)) {
665
- await startTunnel(tunnelProcess, {
642
+ ({ tunnelUrl } = await startTunnel(tunnelProcess, {
666
643
  tunnel: Array.isArray(config.webServer) ? config.webServer.find((server) => server.port)?.port : config.webServer.port
667
- });
644
+ }));
668
645
  }
669
646
  return {
670
647
  ...config,
671
648
  use: {
672
649
  ...config.use,
650
+ baseURL: tunnelUrl,
673
651
  connectOptions: {
674
652
  wsEndpoint: endpointUrl
675
653
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browsermation/test",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "description": "The testing platform for Playwright by Browsermation.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",