@browsermation/test 0.0.4 → 0.0.5

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
@@ -42872,11 +42872,15 @@ var {
42872
42872
  // package.json
42873
42873
  var package_default = {
42874
42874
  name: "@browsermation/test",
42875
- version: "0.0.4",
42875
+ version: "0.0.5",
42876
42876
  description: "The testing platform for Playwright by Browsermation.",
42877
42877
  main: "dist/index.js",
42878
+ types: "dist/index.d.ts",
42878
42879
  exports: {
42879
- ".": "./dist/index.js"
42880
+ ".": {
42881
+ import: "./dist/index.js",
42882
+ types: "./dist/index.d.ts"
42883
+ }
42880
42884
  },
42881
42885
  bin: {
42882
42886
  browsermation: "dist/bin/cli.js"
@@ -42884,11 +42888,11 @@ var package_default = {
42884
42888
  files: [
42885
42889
  "dist"
42886
42890
  ],
42887
- publisher: "@browsermation",
42888
42891
  scripts: {
42889
- "build:cli": "esbuild src/bin/cli.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/bin/cli.js ",
42890
- "build:index": "esbuild src/index.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/index.js ",
42891
- build: "npm run build:cli && npm run build:index",
42892
+ "build:cli": "esbuild src/bin/cli.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/bin/cli.js",
42893
+ "build:index": "esbuild src/index.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/index.js",
42894
+ "build:types": "tsc --emitDeclarationOnly --outDir dist",
42895
+ build: "npm run build:cli && npm run build:index && npm run build:types",
42892
42896
  start: "node dist/bin/cli.js",
42893
42897
  "build:start": "npm run build && npm start",
42894
42898
  publish: "npm run build && npm publish --access public"
@@ -48126,13 +48130,13 @@ async function zipFolderToBuffer(folder, testFiles) {
48126
48130
 
48127
48131
  // src/core.ts
48128
48132
  var import_promises = require("node:fs/promises");
48129
- async function uploadZip(zipBuffer, shardNumber, totalShards, playwrightConfig2, options = {}, eventStream) {
48133
+ async function uploadZip(zipBuffer, shardNumber, totalShards, playwrightConfig, options = {}, eventStream) {
48130
48134
  if (!process.env.API_URL) {
48131
48135
  console.error(source_default.red("Error: API_URL environment variable is not set."));
48132
48136
  process.exit();
48133
48137
  }
48134
48138
  const formData = new FormData();
48135
- formData.append("playwright_config", JSON.stringify(playwrightConfig2));
48139
+ formData.append("playwright_config", JSON.stringify(playwrightConfig));
48136
48140
  formData.append("zip_file", new Blob([zipBuffer]), "project.zip");
48137
48141
  formData.append("shard", `${shardNumber || "1"}/${totalShards || "1"}`);
48138
48142
  if (options?.proxy) {
@@ -48194,13 +48198,13 @@ async function zip(folder, testFiles) {
48194
48198
  console.log(`Zipped project folder to ${tmpZipPath}`);
48195
48199
  return zipBuffer;
48196
48200
  }
48197
- async function upload(zipBuffer, shardNumber, totalShards, playwrightConfig2, options = {}, eventStream) {
48201
+ async function upload(zipBuffer, shardNumber, totalShards, playwrightConfig, options = {}, eventStream) {
48198
48202
  try {
48199
48203
  await uploadZip(
48200
48204
  zipBuffer,
48201
48205
  shardNumber,
48202
48206
  totalShards,
48203
- playwrightConfig2,
48207
+ playwrightConfig,
48204
48208
  options,
48205
48209
  eventStream
48206
48210
  );
@@ -48305,32 +48309,13 @@ async function downloadFile(fileUrl, outputLocationPath) {
48305
48309
  });
48306
48310
  });
48307
48311
  } catch (err) {
48308
- console.error(`Error downloading the file: ${err.message}`);
48312
+ console.error(
48313
+ `Error downloading the file: ${err instanceof Error ? err.message : String(err)}`
48314
+ );
48309
48315
  throw err;
48310
48316
  }
48311
48317
  }
48312
48318
 
48313
- // src/playwright.ts
48314
- function getUniqueFilesFromJson(data, key = "file") {
48315
- const results = /* @__PURE__ */ new Set();
48316
- function recurse(value) {
48317
- if (Array.isArray(value)) {
48318
- for (const item of value) {
48319
- recurse(item);
48320
- }
48321
- } else if (value && typeof value === "object") {
48322
- for (const k in value) {
48323
- if (k === key) {
48324
- results.add(value[k]);
48325
- }
48326
- recurse(value[k]);
48327
- }
48328
- }
48329
- }
48330
- recurse(data);
48331
- return Array.from(results);
48332
- }
48333
-
48334
48319
  // src/bin/cli.ts
48335
48320
  var program2 = new Command().name("browsermation").version(package_default.version).description(package_default.description);
48336
48321
  program2.command("test").argument("<folder>", "The path to the folder to zip and upload").argument("<totalShards>", "Total number of shards").option("-t, --tunnel <port>").option("-p, --proxy").option("--project <project>", "Run a specific project").option(
@@ -48352,27 +48337,6 @@ program2.command("test").argument("<folder>", "The path to the folder to zip and
48352
48337
  formOptions.proxy = true;
48353
48338
  }
48354
48339
  await new Promise((resolve) => setTimeout(resolve, 3e7));
48355
- delete playwrightConfig.webServer;
48356
- delete playwrightConfig.globalSetup;
48357
- delete playwrightConfig.globalTeardown;
48358
- delete playwrightConfig.grep;
48359
- delete playwrightConfig.grepInvert;
48360
- delete playwrightConfig.configFile;
48361
- delete playwrightConfig.rootDir;
48362
- delete playwrightConfig.version;
48363
- playwrightConfig.projects = playwrightConfig.projects?.map((project) => {
48364
- const fullconfig = playwrightConfigTypescript?.projects?.find(
48365
- (p) => p.name === project.name
48366
- );
48367
- if (fullconfig) {
48368
- project.use = fullconfig.use;
48369
- project.outputDir = fullconfig.outputDir;
48370
- project.testDir = fullconfig.testDir;
48371
- }
48372
- return project;
48373
- });
48374
- playwrightConfig.use = playwrightConfigTypescript.use;
48375
- let testFiles = getUniqueFilesFromJson(suites);
48376
48340
  let blobReports = [];
48377
48341
  let sharedsDone = 0;
48378
48342
  const uploadSpinner = ora(
@@ -48397,7 +48361,7 @@ program2.command("test").argument("<folder>", "The path to the folder to zip and
48397
48361
  });
48398
48362
  }
48399
48363
  });
48400
- const zipBuffer = await zip(folder, testFiles);
48364
+ const zipBuffer = await zip(folder, []);
48401
48365
  if (totalShards) {
48402
48366
  const shardPromises = [];
48403
48367
  for (let i = 0; i < totalShards; i++) {
@@ -48406,7 +48370,7 @@ program2.command("test").argument("<folder>", "The path to the folder to zip and
48406
48370
  zipBuffer,
48407
48371
  i + 1,
48408
48372
  totalShards,
48409
- playwrightConfig,
48373
+ {},
48410
48374
  { proxy: options.proxy, project: options.project },
48411
48375
  eventStream
48412
48376
  )
@@ -48420,14 +48384,12 @@ program2.command("test").argument("<folder>", "The path to the folder to zip and
48420
48384
  );
48421
48385
  const downloadedReports = await Promise.all(downloadPromises);
48422
48386
  } else {
48423
- await upload(zipBuffer, 1, 1, {}, playwrightConfig, eventStream);
48387
+ await upload(zipBuffer, 1, 1, {}, {}, eventStream);
48424
48388
  }
48425
- webserverProcess?.kill();
48426
48389
  tunnelProcess?.kill();
48427
48390
  uploadSpinner.succeed(source_default.green("Upload complete."));
48428
48391
  console.log(source_default.green.bold("\n\u2705 Success!"));
48429
48392
  } catch (error) {
48430
- webserverProcess?.kill();
48431
48393
  tunnelProcess?.kill();
48432
48394
  console.error(source_default.red.bold("\u274C An error occurred during the process."));
48433
48395
  console.log(error);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import 'dotenv/config';
@@ -0,0 +1,9 @@
1
+ import { Readable } from 'node:stream';
2
+ import 'dotenv/config';
3
+ /**
4
+ * The main function that orchestrates zipping and uploading.
5
+ * @param folderPath The path to the folder to process.
6
+ * @param testFiles The list of test files to include in the upload.
7
+ */
8
+ export declare function zip(folder: string, testFiles: string[]): Promise<Buffer>;
9
+ export declare function upload(zipBuffer: Buffer, shardNumber: number, totalShards: number, playwrightConfig: object, options: object | undefined, eventStream: Readable): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { PlaywrightTestConfig } from 'playwright/test';
2
+ export declare function defineConfig(config: PlaywrightTestConfig): Promise<PlaywrightTestConfig>;
@@ -0,0 +1 @@
1
+ export declare function compileFileUsingEsbuild(folder: string, filepath: string): Promise<unknown>;
@@ -0,0 +1 @@
1
+ export declare function downloadFile(fileUrl: string, outputLocationPath: string): Promise<unknown>;
@@ -0,0 +1,2 @@
1
+ export { defineConfig } from './defineConfig';
2
+ export { test } from './test';
@@ -0,0 +1,3 @@
1
+ export declare function getConfigViaTypescript(folder: string): Promise<unknown>;
2
+ export declare function getConfig(projectPath: string): Promise<unknown>;
3
+ export declare function getUniqueFilesFromJson(data: any, key?: string): any[];
@@ -0,0 +1 @@
1
+ export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
@@ -0,0 +1,5 @@
1
+ import { spawn } from 'node:child_process';
2
+ export declare function startTunnel(tunnelProcess: ReturnType<typeof spawn> | null, options: any): Promise<{
3
+ tunnelProcess: import("child_process").ChildProcess;
4
+ tunnelUrl: string;
5
+ }>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Zips a folder to a Buffer. it keeps the folder structure intact.
3
+ * @param folder the folder where the testFiles are located
4
+ * @param testFiles Array of file paths to include in the zip.
5
+ */
6
+ export declare function zipFolderToBuffer(folder: string, testFiles: string[]): Promise<Buffer>;
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@browsermation/test",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "The testing platform for Playwright by Browsermation.",
5
5
  "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
6
7
  "exports": {
7
- ".": "./dist/index.js"
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ }
8
12
  },
9
13
  "bin": {
10
14
  "browsermation": "dist/bin/cli.js"
@@ -12,11 +16,11 @@
12
16
  "files": [
13
17
  "dist"
14
18
  ],
15
- "publisher": "@browsermation",
16
19
  "scripts": {
17
- "build:cli": "esbuild src/bin/cli.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/bin/cli.js ",
18
- "build:index": "esbuild src/index.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/index.js ",
19
- "build": "npm run build:cli && npm run build:index",
20
+ "build:cli": "esbuild src/bin/cli.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/bin/cli.js",
21
+ "build:index": "esbuild src/index.ts --bundle --platform=node --external:playwright --target=node22 --outfile=dist/index.js",
22
+ "build:types": "tsc --emitDeclarationOnly --outDir dist",
23
+ "build": "npm run build:cli && npm run build:index && npm run build:types",
20
24
  "start": "node dist/bin/cli.js",
21
25
  "build:start": "npm run build && npm start",
22
26
  "publish": "npm run build && npm publish --access public"