testeranto 0.81.3 → 0.84.0

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.
Files changed (71) hide show
  1. package/dist/common/src/Node.js +4 -2
  2. package/dist/common/src/PM/main.js +188 -61
  3. package/dist/common/src/PM/node.js +32 -7
  4. package/dist/common/src/PM/web.js +28 -54
  5. package/dist/common/src/Project.js +0 -3
  6. package/dist/common/src/Puppeteer.js +9 -51
  7. package/dist/common/src/SubPackages/react-dom/jsx/web.js +11 -11
  8. package/dist/common/src/Web.js +7 -1
  9. package/dist/common/src/esbuildConfigs/featuresPlugin.js +39 -0
  10. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +62 -64
  11. package/dist/common/src/esbuildConfigs/node.js +10 -3
  12. package/dist/common/src/esbuildConfigs/web.js +6 -2
  13. package/dist/common/src/lib/abstractBase.js +348 -337
  14. package/dist/common/src/lib/basebuilder.js +9 -4
  15. package/dist/common/src/lib/core.js +1 -1
  16. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  17. package/dist/module/src/Node.js +3 -3
  18. package/dist/module/src/PM/main.js +188 -61
  19. package/dist/module/src/PM/node.js +32 -7
  20. package/dist/module/src/PM/web.js +28 -51
  21. package/dist/module/src/Project.js +0 -3
  22. package/dist/module/src/Puppeteer.js +9 -51
  23. package/dist/module/src/SubPackages/react-dom/jsx/web.js +10 -10
  24. package/dist/module/src/Web.js +6 -2
  25. package/dist/module/src/esbuildConfigs/featuresPlugin.js +34 -0
  26. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +62 -64
  27. package/dist/module/src/esbuildConfigs/node.js +10 -3
  28. package/dist/module/src/esbuildConfigs/web.js +6 -2
  29. package/dist/module/src/lib/abstractBase.js +348 -337
  30. package/dist/module/src/lib/basebuilder.js +9 -4
  31. package/dist/module/src/lib/core.js +1 -1
  32. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  33. package/dist/prebuild/Puppeteer.mjs +82033 -0
  34. package/dist/types/src/Node.d.ts +5 -1
  35. package/dist/types/src/PM/index.d.ts +10 -4
  36. package/dist/types/src/PM/main.d.ts +21 -9
  37. package/dist/types/src/PM/node.d.ts +11 -3
  38. package/dist/types/src/PM/web.d.ts +11 -2
  39. package/dist/types/src/SubPackages/react-dom/jsx/index.d.ts +1 -0
  40. package/dist/types/src/SubPackages/react-test-renderer/jsx/index.d.ts +1 -0
  41. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -0
  42. package/dist/types/src/Types.d.ts +2 -2
  43. package/dist/types/src/Web.d.ts +5 -1
  44. package/dist/types/src/esbuildConfigs/featuresPlugin.d.ts +5 -0
  45. package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +4 -2
  46. package/dist/types/src/lib/abstractBase.d.ts +5 -4
  47. package/dist/types/src/lib/core.d.ts +1 -1
  48. package/dist/types/src/lib/index.d.ts +1 -0
  49. package/dist/types/src/lib/types.d.ts +7 -5
  50. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  51. package/package.json +18 -45
  52. package/pupBuild.js +18 -0
  53. package/src/Node.ts +3 -5
  54. package/src/PM/index.ts +12 -3
  55. package/src/PM/main.ts +306 -140
  56. package/src/PM/node.ts +40 -7
  57. package/src/PM/web.ts +108 -58
  58. package/src/Project.ts +0 -8
  59. package/src/Puppeteer.ts +11 -57
  60. package/src/SubPackages/react-dom/jsx/web.ts +15 -10
  61. package/src/Types.ts +5 -2
  62. package/src/Web.ts +6 -2
  63. package/src/esbuildConfigs/featuresPlugin.ts +43 -0
  64. package/src/esbuildConfigs/inputFilesPlugin.ts +97 -90
  65. package/src/esbuildConfigs/node.ts +18 -3
  66. package/src/esbuildConfigs/web.ts +14 -2
  67. package/src/lib/abstractBase.ts +388 -366
  68. package/src/lib/basebuilder.ts +9 -9
  69. package/src/lib/core.ts +4 -2
  70. package/src/lib/index.ts +1 -0
  71. package/src/lib/types.ts +14 -6
package/src/PM/main.ts CHANGED
@@ -1,22 +1,26 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import puppeteer, { Page, ScreenshotOptions } from "puppeteer-core";
3
+ import puppeteer, { Browser, ScreenshotOptions } from "puppeteer-core";
4
4
  import { PassThrough } from "stream";
5
+ import crypto from "crypto";
5
6
 
6
7
  import { IBuiltConfig, ITestTypes } from "../lib/types";
7
8
 
8
9
  import { PM } from "./index.js";
9
10
  import { destinationOfRuntime } from "../utils.js";
10
11
  import { ITLog } from "../lib/index.js";
12
+ import { Page } from "puppeteer-core/lib/esm/puppeteer";
11
13
 
12
14
  type IFPaths = string[];
13
15
 
14
16
  const fPaths: IFPaths = [];
15
17
  const fileStreams3: fs.WriteStream[] = [];
16
- const files: Record<string, Set<string>> = {}; // = new Set<string>();
18
+ const files: Record<string, Set<string>> = {};
17
19
  const screenshots: Record<string, Promise<Uint8Array>[]> = {};
18
20
 
19
21
  export class PM_Main extends PM {
22
+ browser: Browser;
23
+
20
24
  shutdownMode = false;
21
25
  configs: IBuiltConfig;
22
26
  ports: Record<number, boolean>;
@@ -125,19 +129,128 @@ export class PM_Main extends PM {
125
129
  };
126
130
  }
127
131
 
128
- shutDown() {
129
- console.log("shutting down...");
130
- this.shutdownMode = true;
131
- this.checkForShutdown();
132
+ $(selector: string): boolean {
133
+ throw new Error("Method not implemented.");
134
+ }
135
+ screencast(opts: object) {
136
+ throw new Error("Method not implemented.");
132
137
  }
133
-
134
138
  customScreenShot(opts: object) {
135
139
  throw new Error("Method not implemented.");
136
140
  }
137
141
 
142
+ end(accessObject: { uid: number }): boolean {
143
+ throw new Error("Method not implemented.");
144
+ }
145
+
146
+ existsSync(destFolder: string): boolean {
147
+ return fs.existsSync(destFolder);
148
+ }
149
+
150
+ async mkdirSync(fp: string) {
151
+ if (!fs.existsSync(fp)) {
152
+ return fs.mkdirSync(fp, {
153
+ recursive: true,
154
+ });
155
+ }
156
+ return false;
157
+ }
158
+
159
+ writeFileSync(fp: string, contents: string) {
160
+ fs.writeFileSync(fp, contents);
161
+ }
162
+
163
+ createWriteStream(filepath: string): fs.WriteStream {
164
+ return fs.createWriteStream(filepath);
165
+ }
166
+
167
+ testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
168
+ return (fPath, value: string | Buffer | PassThrough) => {
169
+ callback(
170
+ new Promise<void>((res, rej) => {
171
+ tLog("testArtiFactory =>", fPath);
172
+
173
+ const cleanPath = path.resolve(fPath);
174
+ fPaths.push(cleanPath.replace(process.cwd(), ``));
175
+
176
+ const targetDir = cleanPath.split("/").slice(0, -1).join("/");
177
+
178
+ fs.mkdir(targetDir, { recursive: true }, async (error) => {
179
+ if (error) {
180
+ console.error(`❗️testArtiFactory failed`, targetDir, error);
181
+ }
182
+
183
+ fs.writeFileSync(
184
+ path.resolve(
185
+ targetDir.split("/").slice(0, -1).join("/"),
186
+ "manifest"
187
+ ),
188
+ fPaths.join(`\n`),
189
+ {
190
+ encoding: "utf-8",
191
+ }
192
+ );
193
+
194
+ if (Buffer.isBuffer(value)) {
195
+ fs.writeFileSync(fPath, value, "binary");
196
+ res();
197
+ } else if (`string` === typeof value) {
198
+ fs.writeFileSync(fPath, value.toString(), {
199
+ encoding: "utf-8",
200
+ });
201
+ res();
202
+ } else {
203
+ /* @ts-ignore:next-line */
204
+ const pipeStream: PassThrough = value;
205
+ const myFile = fs.createWriteStream(fPath);
206
+ pipeStream.pipe(myFile);
207
+ pipeStream.on("close", () => {
208
+ myFile.close();
209
+ res();
210
+ });
211
+ }
212
+ });
213
+ })
214
+ );
215
+ };
216
+ }
217
+
218
+ write(accessObject: { uid: number }, contents: string): boolean {
219
+ throw new Error("Method not implemented.");
220
+ }
221
+ page(): string | undefined {
222
+ throw new Error("Method not implemented.");
223
+ }
224
+ click(selector: string): string | undefined {
225
+ throw new Error("Method not implemented.");
226
+ }
227
+ focusOn(selector: string) {
228
+ throw new Error("Method not implemented.");
229
+ }
230
+ typeInto(value: string) {
231
+ throw new Error("Method not implemented.");
232
+ }
233
+ getValue(value: string) {
234
+ throw new Error("Method not implemented.");
235
+ }
236
+ getAttribute(selector: string, attribute: string) {
237
+ throw new Error("Method not implemented.");
238
+ }
239
+ isDisabled(selector: string): boolean {
240
+ throw new Error("Method not implemented.");
241
+ }
242
+ ////////////////////////////////////////////////////////////////////////////////
243
+
138
244
  async startPuppeteer(options: any, destfolder: string): Promise<any> {
139
245
  this.browser = (await puppeteer.launch(options)) as any;
140
- return this.browser;
246
+ }
247
+
248
+ ////////////////////////////////////////////////////////////////////////////////
249
+
250
+ shutDown() {
251
+ console.log("shutting down...");
252
+ this.shutdownMode = true;
253
+ this.checkForShutdown();
141
254
  }
142
255
 
143
256
  checkForShutdown = () => {
@@ -153,14 +266,11 @@ export class PM_Main extends PM {
153
266
  };
154
267
 
155
268
  register = (src: string) => {
156
- // console.log("register", src);
157
269
  this.registry[src] = false;
158
270
  };
159
271
 
160
272
  deregister = (src: string) => {
161
- // console.log("deregister", src, this.shutdownMode);
162
273
  this.registry[src] = true;
163
-
164
274
  if (this.shutdownMode) {
165
275
  this.checkForShutdown();
166
276
  }
@@ -250,6 +360,9 @@ export class PM_Main extends PM {
250
360
  return module.default.then((defaultModule) => {
251
361
  defaultModule
252
362
  .receiveTestResourceConfig(argz)
363
+ .then(async (features: string[]) => {
364
+ this.receiveFeatures(features, destFolder);
365
+ })
253
366
  .catch((e) => {
254
367
  console.log("catch", e);
255
368
  })
@@ -282,11 +395,11 @@ export class PM_Main extends PM {
282
395
  browserWSEndpoint: this.browser.wsEndpoint(),
283
396
  });
284
397
 
285
- const evaluation = `
286
- console.log("importing ${dest}.mjs");
287
- import('${dest}.mjs').then(async (x) => {
288
- console.log("imported", x.default);
289
- })`;
398
+ // const evaluation = `
399
+ // console.log("importing ${dest}.mjs");
400
+ // import('${dest}.mjs').then(async (x) => {
401
+ // console.log("imported", x.default);
402
+ // })`;
290
403
 
291
404
  const fileStreams2: fs.WriteStream[] = [];
292
405
  const doneFileStream2: Promise<any>[] = [];
@@ -295,11 +408,11 @@ export class PM_Main extends PM {
295
408
  this.browser
296
409
  .newPage()
297
410
  .then((page) => {
298
- page.on("console", (msg) => {
299
- console.log("web > ", msg.args(), msg.text());
300
- // for (let i = 0; i < msg._args.length; ++i)
301
- // console.log(`${i}: ${msg._args[i]}`);
302
- });
411
+ // page.on("console", (msg) => {
412
+ // console.log("web > ", msg.args(), msg.text());
413
+ // // for (let i = 0; i < msg._args.length; ++i)
414
+ // // console.log(`${i}: ${msg._args[i]}`);
415
+ // });
303
416
 
304
417
  page.exposeFunction(
305
418
  "custom-screenshot",
@@ -411,44 +524,13 @@ export class PM_Main extends PM {
411
524
  delete screenshots[testName];
412
525
  // page.close();
413
526
  });
414
-
415
- // globalThis["writeFileSync"](
416
- // p + "/manifest.json",
417
- // // files.entries()
418
- // JSON.stringify(Array.from(files[testName]))
419
- // );
420
-
421
- // console.log("closing doneFileStream2", doneFileStream2);
422
- // console.log("closing doneFileStream2", doneFileStream2);
423
- // Promise.all([...doneFileStream2, ...screenshots2]).then(() => {
424
- // page.close();
425
- // });
426
-
427
- // Promise.all(screenshots).then(() => {
428
- // page.close();
429
- // });
430
- // setTimeout(() => {
431
- // console.log("Delayed for 1 second.");
432
- // page.close();
433
- // }, 5000);
434
-
435
- // return page.close();
436
527
  });
437
528
 
438
529
  return page;
439
530
  })
440
531
  .then(async (page) => {
441
- page.on("console", (log) =>
442
- console.debug(`Log from client: [${log.text()}] `)
443
- );
444
532
  await page.goto(`file://${`${dest}.html`}`, {});
445
533
  res(page);
446
-
447
- // page.evaluate(evaluation).finally(() => {
448
- // console.log("evaluation failed.", dest);
449
- // });
450
-
451
- // return page;
452
534
  });
453
535
  });
454
536
  };
@@ -465,14 +547,6 @@ export class PM_Main extends PM {
465
547
 
466
548
  let argz = "";
467
549
 
468
- // const testConfig = this.configs.tests.find((t) => {
469
- // return t[0] === src;
470
- // });
471
-
472
- // if (!testConfig) {
473
- // console.error("missing test config");
474
- // process.exit(-1);
475
- // }
476
550
  const testConfigResource = testConfig[2];
477
551
 
478
552
  let portsToUse: string[] = [];
@@ -574,9 +648,9 @@ export class PM_Main extends PM {
574
648
  const evaluation = `
575
649
  console.log("importing ${dest}.mjs");
576
650
  import('${dest}.mjs').then(async (x) => {
577
- console.log("imported", x.default);
651
+ console.log("imported", (await x.default));
578
652
  try {
579
- await (await x.default).receiveTestResourceConfig(${webArgz})
653
+ return await (await x.default).receiveTestResourceConfig(${webArgz})
580
654
  } catch (e) {
581
655
  console.log("fail", e)
582
656
  }
@@ -588,16 +662,42 @@ export class PM_Main extends PM {
588
662
  this.browser
589
663
  .newPage()
590
664
  .then((page) => {
591
- page.on("console", (msg) => {
592
- console.log("web > ", msg.args(), msg.text());
593
- // for (let i = 0; i < msg._args.length; ++i)
594
- // console.log(`${i}: ${msg._args[i]}`);
595
- });
665
+ // page.on("console", (msg) => {
666
+ // // console.log("web > ", msg.args(), msg.text());
667
+ // });
668
+
669
+ page.exposeFunction(
670
+ "screencast",
671
+ async (ssOpts: ScreenshotOptions, testName: string) => {
672
+ const p = ssOpts.path as string;
673
+ const dir = path.dirname(p);
674
+ fs.mkdirSync(dir, {
675
+ recursive: true,
676
+ });
677
+ if (!files[testName]) {
678
+ files[testName] = new Set();
679
+ }
680
+ files[testName].add(ssOpts.path as string);
681
+
682
+ const sPromise = page.screenshot({
683
+ ...ssOpts,
684
+ path: p,
685
+ });
686
+
687
+ if (!screenshots[testName]) {
688
+ screenshots[testName] = [];
689
+ }
690
+ screenshots[testName].push(sPromise);
691
+ // sPromise.then(())
692
+ await sPromise;
693
+ return sPromise;
694
+ // page.evaluate(`window["screenshot done"]`);
695
+ }
696
+ );
596
697
 
597
698
  page.exposeFunction(
598
699
  "customScreenShot",
599
700
  async (ssOpts: ScreenshotOptions, testName: string) => {
600
- // console.log("main.ts browser custom-screenshot", testName);
601
701
  const p = ssOpts.path as string;
602
702
  const dir = path.dirname(p);
603
703
  fs.mkdirSync(dir, {
@@ -733,16 +833,67 @@ export class PM_Main extends PM {
733
833
  // return page.close();
734
834
  });
735
835
 
836
+ page.exposeFunction("page", () => {
837
+ return page.mainFrame()._id;
838
+ });
839
+
840
+ page.exposeFunction("click", (sel) => {
841
+ return page.click(sel);
842
+ });
843
+
844
+ page.exposeFunction("focusOn", (sel) => {
845
+ return page.focus(sel);
846
+ });
847
+
848
+ page.exposeFunction(
849
+ "typeInto",
850
+ async (value) => await page.keyboard.type(value)
851
+ );
852
+
853
+ page.exposeFunction("getValue", (selector) =>
854
+ page.$eval(selector, (input) => input.getAttribute("value"))
855
+ );
856
+
857
+ page.exposeFunction(
858
+ "getAttribute",
859
+ async (selector: string, attribute: string) => {
860
+ const attributeValue = await page.$eval(selector, (input) => {
861
+ return input.getAttribute(attribute);
862
+ });
863
+ return attributeValue;
864
+ }
865
+ );
866
+
867
+ page.exposeFunction("isDisabled", async (selector: string) => {
868
+ const attributeValue = await page.$eval(
869
+ selector,
870
+ (input: HTMLButtonElement) => {
871
+ return input.disabled;
872
+ }
873
+ );
874
+ return attributeValue;
875
+ });
876
+
877
+ page.exposeFunction("$", async (selector: string) => {
878
+ const x = page.$(selector);
879
+ const y = await x;
880
+
881
+ return y;
882
+ });
883
+
736
884
  return page;
737
885
  })
738
886
  .then(async (page) => {
739
- page.on("console", (log) =>
740
- console.debug(`Log from client: [${log.text()}] `)
741
- );
887
+ // page.on("console", (log) =>
888
+ // console.debug(`Log from client: [${log.text()}] `)
889
+ // );
742
890
  await page.goto(`file://${`${dest}.html`}`, {});
743
891
 
744
- page
892
+ await page
745
893
  .evaluate(evaluation)
894
+ .then(async (features: string[]) => {
895
+ this.receiveFeatures(features, destFolder);
896
+ })
746
897
  .catch((e) => {
747
898
  console.log("evaluation failed.", dest);
748
899
  console.log(e);
@@ -751,90 +902,105 @@ export class PM_Main extends PM {
751
902
  console.log("evaluation complete.", dest);
752
903
  // page.close();
753
904
  this.deregister(t);
754
- // whyIsNodeRunning();
755
905
  });
756
906
 
757
907
  return page;
758
908
  });
759
909
  };
760
910
 
761
- end(accessObject: { uid: number }): boolean {
762
- throw new Error("Method not implemented.");
763
- }
764
-
765
- existsSync(destFolder: string): boolean {
766
- return fs.existsSync(destFolder);
767
- }
768
-
769
- async mkdirSync(fp: string) {
770
- if (!fs.existsSync(fp)) {
771
- return fs.mkdirSync(fp, {
772
- recursive: true,
773
- });
774
- }
775
- return false;
776
- }
777
-
778
- writeFileSync(fp: string, contents: string) {
779
- fs.writeFileSync(fp, contents);
780
- }
911
+ receiveFeatures = (features: string[], destFolder: string) => {
912
+ console.log("this.receiveFeatures", features);
913
+ features
914
+ .reduce(async (mm, featureStringKey) => {
915
+ const accum = await mm;
781
916
 
782
- createWriteStream(filepath: string): fs.WriteStream {
783
- return fs.createWriteStream(filepath);
784
- }
917
+ const isUrl = isValidUrl(featureStringKey);
785
918
 
786
- testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
787
- return (fPath, value: string | Buffer | PassThrough) => {
788
- callback(
789
- new Promise<void>((res, rej) => {
790
- tLog("testArtiFactory =>", fPath);
919
+ if (isUrl) {
920
+ const u = new URL(featureStringKey);
791
921
 
792
- const cleanPath = path.resolve(fPath);
793
- fPaths.push(cleanPath.replace(process.cwd(), ``));
922
+ if (u.protocol === "file:") {
923
+ const newPath = `${process.cwd()}/docs/features/internal/${path.relative(
924
+ process.cwd(),
925
+ u.pathname
926
+ )}`;
794
927
 
795
- const targetDir = cleanPath.split("/").slice(0, -1).join("/");
928
+ await fs.promises.mkdir(path.dirname(newPath), { recursive: true });
796
929
 
797
- fs.mkdir(targetDir, { recursive: true }, async (error) => {
798
- if (error) {
799
- console.error(`❗️testArtiFactory failed`, targetDir, error);
930
+ try {
931
+ await fs.unlinkSync(newPath);
932
+ // console.log(`Removed existing link at ${newPath}`);
933
+ } catch (error) {
934
+ if (error.code !== "ENOENT") {
935
+ // throw error;
936
+ }
800
937
  }
801
938
 
802
- fs.writeFileSync(
803
- path.resolve(
804
- targetDir.split("/").slice(0, -1).join("/"),
805
- "manifest"
806
- ),
807
- fPaths.join(`\n`),
808
- {
809
- encoding: "utf-8",
939
+ fs.symlink(u.pathname, newPath, (err) => {
940
+ if (err) {
941
+ // console.error("Error creating symlink:", err);
942
+ } else {
943
+ // console.log("Symlink created successfully");
810
944
  }
811
- );
945
+ });
946
+ accum.push(newPath);
947
+ } else if (u.protocol === "http:" || u.protocol === "https:") {
948
+ const newPath = `${process.cwd()}/docs/features/external${
949
+ u.hostname
950
+ }${u.pathname}`;
951
+ const body = await this.configs.featureIngestor(featureStringKey);
952
+ writeFileAndCreateDir(newPath, body);
953
+ accum.push(newPath);
954
+ }
955
+ } else {
956
+ const newPath = `${process.cwd()}/docs/features/plain/${await sha256(
957
+ featureStringKey
958
+ )}`;
959
+ writeFileAndCreateDir(newPath, featureStringKey);
960
+ accum.push(newPath);
961
+ }
812
962
 
813
- if (Buffer.isBuffer(value)) {
814
- fs.writeFileSync(fPath, value, "binary");
815
- res();
816
- } else if (`string` === typeof value) {
817
- fs.writeFileSync(fPath, value.toString(), {
818
- encoding: "utf-8",
819
- });
820
- res();
821
- } else {
822
- /* @ts-ignore:next-line */
823
- const pipeStream: PassThrough = value;
824
- const myFile = fs.createWriteStream(fPath);
825
- pipeStream.pipe(myFile);
826
- pipeStream.on("close", () => {
827
- myFile.close();
828
- res();
829
- });
830
- }
831
- });
832
- })
833
- );
834
- };
963
+ return accum;
964
+ }, Promise.resolve([] as string[]))
965
+ .then((features: string[]) => {
966
+ fs.writeFileSync(
967
+ `${destFolder}/featurePrompt.txt`,
968
+ features
969
+ .map((f) => {
970
+ return `/read ${f}`;
971
+ })
972
+ .join("\n")
973
+ );
974
+ });
975
+ };
976
+ }
977
+
978
+ async function writeFileAndCreateDir(filePath, data) {
979
+ const dirPath = path.dirname(filePath);
980
+
981
+ try {
982
+ await fs.promises.mkdir(dirPath, { recursive: true });
983
+ await fs.promises.writeFile(filePath, data);
984
+ } catch (error) {
985
+ console.error(`Error writing file: ${error}`);
835
986
  }
987
+ }
836
988
 
837
- write(accessObject: { uid: number }, contents: string): boolean {
838
- throw new Error("Method not implemented.");
989
+ async function sha256(rawData) {
990
+ const data =
991
+ typeof rawData === "object" ? JSON.stringify(rawData) : String(rawData);
992
+
993
+ const msgBuffer = new TextEncoder().encode(data);
994
+ const hashBuffer = await crypto.subtle.digest("SHA-256", msgBuffer);
995
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
996
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
997
+ }
998
+
999
+ function isValidUrl(string) {
1000
+ try {
1001
+ new URL(string);
1002
+ return true;
1003
+ } catch (err) {
1004
+ return false;
839
1005
  }
840
1006
  }
package/src/PM/node.ts CHANGED
@@ -23,8 +23,42 @@ export class PM_Node extends PM {
23
23
  this.testResourceConfiguration = t;
24
24
  }
25
25
 
26
- customScreenShot(opts: object, page: Page) {
27
- return globalThis["customScreenShot"](opts, page);
26
+ $(selector: string): boolean {
27
+ throw new Error("Method not implemented.");
28
+ }
29
+ screencast(opts: object) {
30
+ throw new Error("Method not implemented.");
31
+ }
32
+
33
+ isDisabled(selector: string): boolean {
34
+ throw new Error("Method not implemented.");
35
+ }
36
+
37
+ getAttribute(selector: string, attribute: string) {
38
+ throw new Error("Method not implemented.");
39
+ }
40
+ getValue(selector: string) {
41
+ throw new Error("Method not implemented.");
42
+ }
43
+
44
+ focusOn(selector: string) {
45
+ throw new Error("Method not implemented.");
46
+ }
47
+
48
+ typeInto(value: string) {
49
+ throw new Error("Method not implemented.");
50
+ }
51
+
52
+ page() {
53
+ return globalThis["page"]();
54
+ }
55
+
56
+ click(selector: string): string | undefined {
57
+ return globalThis["click"](selector);
58
+ }
59
+
60
+ customScreenShot(opts: object) {
61
+ return globalThis["customScreenShot"](opts);
28
62
  }
29
63
 
30
64
  existsSync(destFolder: string): boolean {
@@ -42,7 +76,6 @@ export class PM_Node extends PM {
42
76
  }
43
77
 
44
78
  writeFileSync(filepath: string, contents: string) {
45
- // console.log("pm_node-writeFileSync", this.testResourceConfiguration);
46
79
  return globalThis["writeFileSync"](
47
80
  this.testResourceConfiguration.fs + "/" + filepath,
48
81
  contents,
@@ -120,9 +153,9 @@ export class PM_Node extends PM {
120
153
  }
121
154
 
122
155
  // launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
123
- startPuppeteer(options?: any): Promise<any> {
124
- return puppeteer.connect(options).then((b) => {
125
- this.browser = b;
126
- });
156
+ startPuppeteer(options?: any): any {
157
+ // return puppeteer.connect(options).then((b) => {
158
+ // this.browser = b;
159
+ // });
127
160
  }
128
161
  }