testeranto 0.70.0 → 0.73.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 (94) hide show
  1. package/README.md +9 -18
  2. package/dist/common/Node.js +14 -34
  3. package/dist/common/PM/index.js +71 -0
  4. package/dist/common/PM/main.js +361 -0
  5. package/dist/common/PM/node.js +176 -0
  6. package/dist/common/PM/web.js +174 -0
  7. package/dist/common/Project.js +20 -2
  8. package/dist/common/Puppeteer.js +109 -0
  9. package/dist/common/Reporter.js +119 -0
  10. package/dist/common/Scheduler.js +1 -0
  11. package/dist/common/SubPackages/puppeteer.js +3 -1
  12. package/dist/common/SubPackages/react-dom/component/web.js +98 -45
  13. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
  14. package/dist/common/Web.js +24 -43
  15. package/dist/common/esbuildConfigs/web.js +3 -1
  16. package/dist/common/lib/abstractBase.js +189 -41
  17. package/dist/common/lib/basebuilder.js +56 -29
  18. package/dist/common/lib/classBuilder.js +6 -2
  19. package/dist/common/lib/core.js +41 -45
  20. package/dist/common/lib/index.js +2 -1
  21. package/dist/common/preload.js +14 -18
  22. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  23. package/dist/module/Node.js +14 -34
  24. package/dist/module/PM/index.js +67 -0
  25. package/dist/module/PM/main.js +331 -0
  26. package/dist/module/PM/node.js +168 -0
  27. package/dist/module/PM/web.js +167 -0
  28. package/dist/module/Project.js +20 -2
  29. package/dist/module/Puppeteer.js +104 -0
  30. package/dist/module/Reporter.js +114 -0
  31. package/dist/module/Scheduler.js +1 -0
  32. package/dist/module/SubPackages/puppeteer.js +3 -1
  33. package/dist/module/SubPackages/react/jsx/node.js +1 -1
  34. package/dist/module/SubPackages/react-dom/component/web.js +98 -45
  35. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
  36. package/dist/module/Web.js +24 -43
  37. package/dist/module/esbuildConfigs/web.js +3 -1
  38. package/dist/module/lib/abstractBase.js +189 -41
  39. package/dist/module/lib/basebuilder.js +56 -29
  40. package/dist/module/lib/classBuilder.js +6 -2
  41. package/dist/module/lib/core.js +41 -45
  42. package/dist/module/lib/index.js +2 -1
  43. package/dist/module/preload.js +15 -14
  44. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  45. package/dist/prebuild/Report.css +1616 -584
  46. package/dist/prebuild/Report.js +2635 -2506
  47. package/dist/types/PM/index.d.ts +19 -0
  48. package/dist/types/PM/main.d.ts +28 -0
  49. package/dist/types/PM/node.d.ts +26 -0
  50. package/dist/types/PM/web.d.ts +24 -0
  51. package/dist/types/Reporter.d.ts +1 -0
  52. package/dist/types/Scheduler.d.ts +0 -0
  53. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  54. package/dist/types/lib/abstractBase.d.ts +13 -12
  55. package/dist/types/lib/basebuilder.d.ts +4 -2
  56. package/dist/types/lib/classBuilder.d.ts +2 -2
  57. package/dist/types/lib/core.d.ts +4 -4
  58. package/dist/types/lib/index.d.ts +6 -5
  59. package/dist/types/lib/types.d.ts +16 -24
  60. package/dist/types/preload.d.ts +0 -1
  61. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  62. package/package.json +3 -5
  63. package/src/Node.ts +18 -43
  64. package/src/PM/index.ts +102 -0
  65. package/src/PM/main.ts +420 -0
  66. package/src/PM/node.ts +515 -0
  67. package/src/PM/web.ts +497 -0
  68. package/src/Project.ts +21 -2
  69. package/src/Puppeteer.ts +131 -0
  70. package/src/Report.tsx +158 -44
  71. package/src/Reporter.ts +134 -0
  72. package/src/Scheduler.ts +0 -0
  73. package/src/SubPackages/puppeteer.ts +3 -3
  74. package/src/SubPackages/react/jsx/node.ts +5 -8
  75. package/src/SubPackages/react-dom/component/web.ts +126 -67
  76. package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
  77. package/src/Web.ts +25 -67
  78. package/src/esbuildConfigs/web.ts +4 -2
  79. package/src/lib/abstractBase.ts +260 -65
  80. package/src/lib/basebuilder.ts +121 -100
  81. package/src/lib/classBuilder.ts +5 -4
  82. package/src/lib/core.ts +58 -59
  83. package/src/lib/index.ts +10 -9
  84. package/src/lib/types.ts +18 -27
  85. package/src/preload.ts +14 -14
  86. package/dist/common/NodeWriter.js +0 -54
  87. package/dist/common/electron.js +0 -266
  88. package/dist/module/NodeWriter.js +0 -48
  89. package/dist/module/electron.js +0 -261
  90. package/dist/types/NodeWriter.d.ts +0 -2
  91. package/src/NodeWriter.ts +0 -72
  92. package/src/electron.ts +0 -317
  93. package/yarn-error.log +0 -3144
  94. /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
package/src/PM/node.ts ADDED
@@ -0,0 +1,515 @@
1
+ // import puppeteer from "puppeteer";
2
+ import fs from "fs";
3
+ import path from "path";
4
+ // import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core";
5
+ import puppeteer from "puppeteer-core";
6
+
7
+ // import { Browser } from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser";
8
+ import { Browser } from "puppeteer-core";
9
+ import { PassThrough } from "stream";
10
+ import { ITLog, ITTestResourceConfiguration } from "../lib";
11
+ import { PM } from "./index.js";
12
+ import { PuppeteerLaunchOptions } from "puppeteer-core/lib/esm/puppeteer";
13
+
14
+ type IFPaths = string[];
15
+ const fPaths: IFPaths = [];
16
+
17
+ type PuppetMasterServer = Record<string, Promise<any>>;
18
+
19
+ export function addPageBinding(
20
+ type: string,
21
+ name: string,
22
+ prefix: string
23
+ ): void {
24
+ // Depending on the frame loading state either Runtime.evaluate or
25
+ // Page.addScriptToEvaluateOnNewDocument might succeed. Let's check that we
26
+ // don't re-wrap Puppeteer's binding.
27
+ if (globalThis[name]) {
28
+ return;
29
+ }
30
+
31
+ // We replace the CDP binding with a Puppeteer binding.
32
+ Object.assign(globalThis, {
33
+ [name](...args: unknown[]): Promise<unknown> {
34
+ // This is the Puppeteer binding.
35
+ const callPuppeteer = globalThis[name];
36
+ callPuppeteer.args ??= new Map();
37
+ callPuppeteer.callbacks ??= new Map();
38
+
39
+ const seq = (callPuppeteer.lastSeq ?? 0) + 1;
40
+ callPuppeteer.lastSeq = seq;
41
+ callPuppeteer.args.set(seq, args);
42
+
43
+ // Needs to be the same as CDP_BINDING_PREFIX.
44
+ globalThis[prefix + name](
45
+ JSON.stringify({
46
+ type,
47
+ name,
48
+ seq,
49
+ args,
50
+ isTrivial: !args.some((value) => {
51
+ return value instanceof Node;
52
+ }),
53
+ })
54
+ );
55
+
56
+ return new Promise((resolve, reject) => {
57
+ callPuppeteer.callbacks.set(seq, {
58
+ resolve(value: unknown) {
59
+ callPuppeteer.args.delete(seq);
60
+ resolve(value);
61
+ },
62
+ reject(value?: unknown) {
63
+ callPuppeteer.args.delete(seq);
64
+ reject(value);
65
+ },
66
+ });
67
+ });
68
+ },
69
+ });
70
+ }
71
+
72
+ const files = new Set<string>();
73
+
74
+ export class PM_Node extends PM {
75
+ server: PuppetMasterServer;
76
+ testResourceConfiguration: ITTestResourceConfiguration;
77
+
78
+ constructor(t: ITTestResourceConfiguration) {
79
+ super();
80
+ this.server = {};
81
+ this.testResourceConfiguration = t;
82
+ }
83
+
84
+ existsSync(destFolder: string): boolean {
85
+ return globalThis["existsSync"](
86
+ this.testResourceConfiguration.fs + "/" + destFolder
87
+ );
88
+ }
89
+
90
+ mkdirSync() {
91
+ return globalThis["mkdirSync"](this.testResourceConfiguration.fs + "/");
92
+ }
93
+
94
+ write(writeObject: { uid: number }, contents: string) {
95
+ return globalThis["write"](writeObject.uid, contents);
96
+ }
97
+
98
+ writeFileSync(filepath: string, contents: string) {
99
+ files.add(filepath);
100
+ return globalThis["writeFileSync"](
101
+ this.testResourceConfiguration.fs + "/" + filepath,
102
+ contents
103
+ );
104
+ }
105
+
106
+ createWriteStream(filepath: string): any {
107
+ files.add(filepath);
108
+ return globalThis["createWriteStream"](
109
+ this.testResourceConfiguration.fs + "/" + filepath
110
+ );
111
+ }
112
+
113
+ end(writeObject: { uid: number }) {
114
+ return globalThis["end"](writeObject.uid);
115
+ }
116
+
117
+ customclose() {
118
+ console.log("node-customclose");
119
+ // globalThis["writeFileSync"](
120
+ // this.testResourceConfiguration.fs + "/manifest.json",
121
+ // // files.entries()
122
+ // JSON.stringify(Array.from(files))
123
+ // ).then(() => {
124
+ // globalThis["customclose"]();
125
+ // });
126
+ }
127
+ // write(accessObject: { uid: number; }, contents: string): boolean {
128
+ // throw new Error("Method not implemented.");
129
+ // }
130
+ // existsSync(destFolder: string): boolean {
131
+ // return fs.existsSync(destFolder);
132
+ // }
133
+
134
+ // async mkdirSync(destFolder: string) {
135
+ // if (!fs.existsSync(destFolder)) {
136
+ // return fs.mkdirSync(destFolder, { recursive: true });
137
+ // }
138
+ // return false;
139
+ // }
140
+
141
+ // writeFileSync(fp: string, contents: string) {
142
+ // fs.writeFileSync(fp, contents);
143
+ // }
144
+
145
+ // createWriteStream(filepath: string): fs.WriteStream {
146
+ // return fs.createWriteStream(filepath);
147
+ // }
148
+
149
+ testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
150
+ return (fPath, value: string | Buffer | PassThrough) => {
151
+ callback(
152
+ new Promise<void>((res, rej) => {
153
+ tLog("testArtiFactory =>", fPath);
154
+
155
+ const cleanPath = path.resolve(fPath);
156
+ fPaths.push(cleanPath.replace(process.cwd(), ``));
157
+
158
+ const targetDir = cleanPath.split("/").slice(0, -1).join("/");
159
+
160
+ fs.mkdir(targetDir, { recursive: true }, async (error) => {
161
+ if (error) {
162
+ console.error(`❗️testArtiFactory failed`, targetDir, error);
163
+ }
164
+
165
+ fs.writeFileSync(
166
+ path.resolve(
167
+ targetDir.split("/").slice(0, -1).join("/"),
168
+ "manifest"
169
+ ),
170
+ fPaths.join(`\n`),
171
+ {
172
+ encoding: "utf-8",
173
+ }
174
+ );
175
+
176
+ if (Buffer.isBuffer(value)) {
177
+ fs.writeFileSync(fPath, value, "binary");
178
+ res();
179
+ } else if (`string` === typeof value) {
180
+ fs.writeFileSync(fPath, value.toString(), {
181
+ encoding: "utf-8",
182
+ });
183
+ res();
184
+ } else {
185
+ /* @ts-ignore:next-line */
186
+ const pipeStream: PassThrough = value;
187
+ const myFile = fs.createWriteStream(fPath);
188
+ pipeStream.pipe(myFile);
189
+ pipeStream.on("close", () => {
190
+ myFile.close();
191
+ res();
192
+ });
193
+ }
194
+ });
195
+ })
196
+ );
197
+ };
198
+ }
199
+
200
+ // launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
201
+ startPuppeteer(options?: any): Promise<any> {
202
+ console.log("start1");
203
+ return puppeteer.connect(options).then((b) => {
204
+ this.browser = b;
205
+ });
206
+ // return new Promise<Browser>((res, rej) => {
207
+ // // this.browser = await puppeteer.connect(options);
208
+ // // console.log("start2", this.browser);
209
+ // // console.log("mark5", this.browser);
210
+ // // res(this.browser);
211
+ // });
212
+ }
213
+
214
+ // launchNode = (src: string, dest: string) => {
215
+ // console.log("launchNode", src);
216
+ // // childProcesses[src] = "running";
217
+ // const destFolder = dest.replace(".mjs", "");
218
+
219
+ // const argz = JSON.stringify({
220
+ // scheduled: true,
221
+ // name: src,
222
+ // ports: [3333],
223
+ // // fs: path.resolve(configs.buildDir, "web", destFolder + "/"),
224
+ // // fs: destFolder,
225
+ // fs: ".",
226
+ // });
227
+
228
+ // const builtfile = dest + ".mjs";
229
+ // console.log("importing and running ", builtfile);
230
+ // // import(builtfile).then(async (v) => {
231
+ // // console.log("v", (await v.default).receiveTestResourceConfig(argz));
232
+ // // });
233
+
234
+ // // console.log("launchNode", src, dest, " -> ", destFolder, argz);
235
+
236
+ // // const child = utilityProcess.fork(dest + ".mjs", [argz], {
237
+ // // cwd: destFolder,
238
+ // // stdio: "pipe",
239
+ // // });
240
+ // // const nodeGuid = uuidv4();
241
+ // // nodeChildren[nodeGuid] = child;
242
+
243
+ // // if (!fs.existsSync(destFolder)) {
244
+ // // fs.mkdirSync(destFolder, { recursive: true });
245
+ // // }
246
+
247
+ // // fs.rmSync(`${destFolder}/stdout.log`, { force: true });
248
+ // // fs.rmSync(`${destFolder}/stderr.log`, { force: true });
249
+ // // const stdout = fs.createWriteStream(`${destFolder}/stdout.log`);
250
+ // // const stderr = fs.createWriteStream(`${destFolder}/stderr.log`);
251
+
252
+ // // child
253
+ // // .on("message", (data) => {
254
+ // // console.log("from child", JSON.stringify(data));
255
+ // // if (data.launchWeb) {
256
+ // // const guid = uuidv4();
257
+ // // const webChild = launchWebSecondary(process.cwd() + data.launchWeb);
258
+ // // // child.postMessage({ webLaunched: guid });
259
+
260
+ // // webChild.webContents.on("did-finish-load", () => {
261
+ // // // webChild.webContents.send("message", "hello world");
262
+ // // child.postMessage({ webLaunched: guid });
263
+ // // webChildren[guid] = webChild;
264
+ // // node2web[nodeGuid] = [...(node2web[nodeGuid] || []), guid];
265
+ // // });
266
+ // // }
267
+ // // if (data.teardown) {
268
+ // // webChildren[data.teardown].close();
269
+ // // delete webChildren[data.teardown];
270
+ // // node2web[nodeGuid] = node2web[nodeGuid].filter(
271
+ // // (x) => x !== data.teardown
272
+ // // );
273
+ // // }
274
+ // // })
275
+ // // .on("exit", (data) => {
276
+ // // stdout.close();
277
+ // // stderr.close();
278
+ // // console.log(`ending node ${src}`);
279
+ // // onDone(src);
280
+ // // });
281
+
282
+ // // child.stdout?.pipe(stdout);
283
+ // // child.stderr?.pipe(stderr);
284
+ // };
285
+
286
+ // const launchWebSecondary = (htmlFile: string): BrowserWindow => {
287
+ // console.log("launchWebSecondary", htmlFile);
288
+ // const subWin = new BrowserWindow({
289
+ // show: false,
290
+
291
+ // webPreferences: {
292
+ // nodeIntegration: true,
293
+ // nodeIntegrationInWorker: true,
294
+ // contextIsolation: false,
295
+ // preload: path.join(app.getAppPath(), "preload.js"),
296
+ // offscreen: false,
297
+ // devTools: true,
298
+ // },
299
+ // });
300
+ // remoteMain.enable(subWin.webContents);
301
+ // subWin.webContents.openDevTools();
302
+ // subWin.loadFile(htmlFile);
303
+ // return subWin;
304
+
305
+ // // const uuid = uuidv4();
306
+ // // windows[uuid] = subWin;
307
+ // // return uuid;
308
+ // };
309
+
310
+ // const launchWeb = (t: string, dest: string) => {
311
+ // console.log("launchWeb", t);
312
+ // childProcesses[t] = "running";
313
+ // const destFolder = dest.replace(".mjs", "");
314
+
315
+ // const subWin = new BrowserWindow({
316
+ // show: true,
317
+ // webPreferences: {
318
+ // nodeIntegration: true,
319
+ // nodeIntegrationInWorker: true,
320
+ // contextIsolation: false,
321
+ // preload: path.join(app.getAppPath(), "preload.js"),
322
+ // offscreen: false,
323
+ // devTools: true,
324
+ // },
325
+ // });
326
+
327
+ // webChildren[uuidv4()] = subWin;
328
+
329
+ // remoteMain.enable(subWin.webContents);
330
+
331
+ // const webArgz = JSON.stringify({
332
+ // name: dest,
333
+ // ports: [].toString(),
334
+ // fs: destFolder,
335
+ // });
336
+
337
+ // // console.log("webArgz", webArgz);
338
+ // subWin.loadFile(`${dest}.html`, {
339
+ // query: {
340
+ // requesting: encodeURIComponent(webArgz),
341
+ // },
342
+ // });
343
+
344
+ // if (!fs.existsSync(destFolder)) {
345
+ // fs.mkdirSync(destFolder, { recursive: true });
346
+ // }
347
+ // const stdout = fs.createWriteStream(`${destFolder}/stdout.log`);
348
+
349
+ // subWin.webContents.on(
350
+ // "console-message",
351
+ // (event, level, message, line, sourceId) => {
352
+ // stdout.write(
353
+ // JSON.stringify(
354
+ // {
355
+ // event,
356
+ // level,
357
+ // message: JSON.stringify(message),
358
+ // line,
359
+ // sourceId,
360
+ // },
361
+ // null,
362
+ // 2
363
+ // )
364
+ // );
365
+ // stdout.write("\n");
366
+ // }
367
+ // );
368
+ // subWin.on("closed", () => {
369
+ // stdout.close();
370
+ // console.log(`ending web ${t}`);
371
+ // // childProcesses[t] = "done";
372
+ // onDone(t);
373
+ // });
374
+ // ipcMain.on("message", (message, data) => {
375
+ // console.log("ipcMain message: " + JSON.stringify(data));
376
+ // // process.exit();
377
+ // });
378
+ // };
379
+
380
+ // return await import("${dest}.mjs");
381
+
382
+ // launchWeb = (t: string, dest: string) => {
383
+ // console.log("launchWeb", t);
384
+ // // // childProcesses[t] = "running";
385
+ // // const destFolder = dest.replace(".mjs", "");
386
+
387
+ // // const webArgz = JSON.stringify({
388
+ // // name: dest,
389
+ // // ports: [].toString(),
390
+ // // fs: destFolder,
391
+ // // });
392
+
393
+ // // const evaluation = `import('file:///Users/adam/Code/kokomoBay/docs/web/src/LoginPage/react/web.test.mjs').then(async (x) => {
394
+ // // return (await x.default).receiveTestResourceConfig(${webArgz})
395
+ // // })`;
396
+
397
+ // // // console.log("evaluation", evaluation);
398
+
399
+ // // const y = browser
400
+ // // .newPage()
401
+ // // .then(async (page) => {
402
+ // // // const codeString = "1 + 1";
403
+ // // await page.goto(
404
+ // // // "file:///Users/adam/Code/kokomoBay/docs/web/src/LoginPage/react/web.test.html"
405
+ // // `file://${`${dest}.html`}`
406
+ // // );
407
+ // // // page.url
408
+ // // // page.setContent(`
409
+
410
+ // // // <!DOCTYPE html>
411
+ // // // <html lang="en">
412
+
413
+ // // // <head>
414
+
415
+ // // // </head>
416
+
417
+ // // // <body>
418
+ // // // <h1>/Users/adam/Code/kokomoBay/docs/web/src/LoginPage/react/web.test.html</h1>
419
+ // // // <div id="root">
420
+
421
+ // // // </div>
422
+ // // // </body>
423
+
424
+ // // // <footer></footer>
425
+
426
+ // // // </html>
427
+ // // // `);
428
+ // // // return await page.evaluate((code) => eval(code), evaluation);
429
+
430
+ // // return await page.evaluate(evaluation);
431
+ // // // return await page.evaluate(async () => {
432
+ // // // return await import(dest);
433
+ // // // });
434
+ // // })
435
+ // // .then((x) => {
436
+ // // console.log("mark1", x);
437
+ // // });
438
+ // // .then((x) => {
439
+ // // console.log("mark0", x);
440
+ // // })
441
+ // // .catch((z) => {
442
+ // // console.log("mark2", z);
443
+ // // });
444
+
445
+ // // const subWin = new BrowserWindow({
446
+ // // show: true,
447
+ // // webPreferences: {
448
+ // // nodeIntegration: true,
449
+ // // nodeIntegrationInWorker: true,
450
+ // // contextIsolation: false,
451
+ // // preload: path.join(app.getAppPath(), "preload.js"),
452
+ // // offscreen: false,
453
+ // // devTools: true,
454
+ // // },
455
+ // // });
456
+
457
+ // // webChildren[uuidv4()] = subWin;
458
+
459
+ // // remoteMain.enable(subWin.webContents);
460
+
461
+ // // // console.log("webArgz", webArgz);
462
+ // // subWin.loadFile(`${dest}.html`, {
463
+ // // query: {
464
+ // // requesting: encodeURIComponent(webArgz),
465
+ // // },
466
+ // // });
467
+
468
+ // // if (!fs.existsSync(destFolder)) {
469
+ // // fs.mkdirSync(destFolder, { recursive: true });
470
+ // // }
471
+ // // const stdout = fs.createWriteStream(`${destFolder}/stdout.log`);
472
+
473
+ // // subWin.webContents.on(
474
+ // // "console-message",
475
+ // // (event, level, message, line, sourceId) => {
476
+ // // stdout.write(
477
+ // // JSON.stringify(
478
+ // // {
479
+ // // event,
480
+ // // level,
481
+ // // message: JSON.stringify(message),
482
+ // // line,
483
+ // // sourceId,
484
+ // // },
485
+ // // null,
486
+ // // 2
487
+ // // )
488
+ // // );
489
+ // // stdout.write("\n");
490
+ // // }
491
+ // // );
492
+ // // subWin.on("closed", () => {
493
+ // // stdout.close();
494
+ // // console.log(`ending web ${t}`);
495
+ // // // childProcesses[t] = "done";
496
+ // // onDone(t);
497
+ // // });
498
+ // // ipcMain.on("message", (message, data) => {
499
+ // // console.log("ipcMain message: " + JSON.stringify(data));
500
+ // // // process.exit();
501
+ // // });
502
+ // };
503
+ }
504
+
505
+ // class PuppetMasterServer extends AbstractPuppetMaster {
506
+ // // constructor(...z: []) {
507
+ // // super(...z);
508
+ // // }
509
+ // // // pages(): Promise<Page[]>;
510
+ // // pages(): Promise<Page[]> {
511
+ // // return new Promise<Page[]>((res, rej) => {
512
+ // // res(super.pages());
513
+ // // });
514
+ // // }
515
+ // }