testeranto 0.47.33 → 0.47.52
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/.nvmrc +1 -0
- package/Bundle.Dockerfile +45 -0
- package/README.md +86 -11
- package/Report.Dockerfile +43 -0
- package/dist/cjs-shim.js +12 -0
- package/dist/common/Features.js +3 -37
- package/dist/common/Init.js +30 -0
- package/dist/common/Node.js +15 -66
- package/dist/common/PM/index.js +7 -0
- package/dist/common/PM/main.js +641 -0
- package/dist/common/PM/node.js +88 -0
- package/dist/common/PM/web.js +132 -0
- package/dist/common/Project.js +109 -637
- package/dist/common/Puppeteer.js +103 -0
- package/dist/common/Reporter.js +112 -0
- package/dist/common/Scheduler.js +1 -0
- package/dist/common/SubPackages/puppeteer.js +21 -0
- package/dist/common/{subPackages → SubPackages}/react/component/node.js +4 -4
- package/dist/common/{subPackages → SubPackages}/react/component/web.js +4 -4
- package/dist/common/SubPackages/react/jsx/index.js +25 -0
- package/dist/common/SubPackages/react/jsx/node.js +10 -0
- package/dist/common/SubPackages/react/jsx/web.js +10 -0
- package/dist/common/{subPackages/react-dom/jsx → SubPackages/react-dom/component}/node.js +6 -6
- package/dist/common/SubPackages/react-dom/component/web.js +93 -0
- package/dist/common/SubPackages/react-dom/jsx/index.js +2 -0
- package/dist/common/SubPackages/react-dom/jsx/node.js +39 -0
- package/dist/common/SubPackages/react-dom/jsx/web.js +118 -0
- package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +44 -0
- package/dist/common/SubPackages/react-test-renderer/component/index.js +2 -0
- package/dist/common/{subPackages/react-test-renderer/component/index.js → SubPackages/react-test-renderer/component/interface.js} +23 -33
- package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/node.js +3 -5
- package/dist/common/{subPackages/react/jsx → SubPackages/react-test-renderer/component}/web.js +3 -5
- package/dist/common/SubPackages/react-test-renderer/fc/node.js +50 -0
- package/dist/common/SubPackages/react-test-renderer/fc/web.js +50 -0
- package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +7 -3
- package/dist/common/SubPackages/react-test-renderer/jsx/node.js +10 -0
- package/dist/common/SubPackages/react-test-renderer/jsx/web.js +10 -0
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +42 -0
- package/dist/common/{subPackages/react/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +2 -2
- package/dist/common/TaskManBackEnd.js +174 -0
- package/dist/common/Web.js +31 -108
- package/dist/common/esbuildConfigs/features.js +14 -0
- package/dist/common/esbuildConfigs/index.js +21 -0
- package/dist/common/esbuildConfigs/inputFilesPlugin.js +49 -0
- package/dist/common/esbuildConfigs/node.js +39 -0
- package/dist/common/esbuildConfigs/report.js +14 -0
- package/dist/common/esbuildConfigs/tests.js +13 -0
- package/dist/common/esbuildConfigs/web.js +57 -0
- package/dist/common/lib/abstractBase.js +553 -0
- package/dist/common/lib/basebuilder.js +79 -0
- package/dist/common/lib/classBuilder.js +42 -0
- package/dist/common/lib/core.js +75 -0
- package/dist/common/lib/index.js +22 -0
- package/dist/common/lib/types.js +2 -0
- package/dist/common/mongooseSchemas.js +56 -0
- package/dist/common/preload.js +14 -27
- package/dist/common/puppeteerConfiger.js +24 -0
- package/dist/common/report.html.js +31 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/common/utils.js +16 -0
- package/dist/common/web.html.js +22 -0
- package/dist/module/ExampleTab.js +112 -0
- package/dist/module/Features.js +2 -35
- package/dist/module/Init.js +25 -0
- package/dist/module/Node.js +15 -66
- package/dist/module/PM/index.js +3 -0
- package/dist/module/PM/main.js +611 -0
- package/dist/module/PM/node.js +81 -0
- package/dist/module/PM/web.js +125 -0
- package/dist/module/Project.js +110 -615
- package/dist/module/Puppeteer.js +98 -0
- package/dist/module/Reporter.js +107 -0
- package/dist/module/Scheduler.js +1 -0
- package/dist/module/SubPackages/puppeteer.js +16 -0
- package/dist/module/{subPackages → SubPackages}/react/component/node.js +3 -3
- package/dist/module/{subPackages → SubPackages}/react/component/web.js +3 -3
- package/dist/module/SubPackages/react/jsx/index.js +19 -0
- package/dist/module/SubPackages/react/jsx/node.js +5 -0
- package/dist/module/SubPackages/react/jsx/web.js +5 -0
- package/dist/module/{subPackages → SubPackages}/react-dom/component/node.js +7 -7
- package/dist/module/SubPackages/react-dom/component/web.js +88 -0
- package/dist/module/SubPackages/react-dom/jsx/node.js +31 -0
- package/dist/module/SubPackages/react-dom/jsx/web.js +90 -0
- package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +16 -0
- package/dist/module/SubPackages/react-test-renderer/component/index.js +1 -0
- package/dist/module/SubPackages/react-test-renderer/component/interface.js +39 -0
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/node.js +2 -2
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/web.js +2 -2
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/node.js +3 -3
- package/dist/module/SubPackages/react-test-renderer/fc/web.js +22 -0
- package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +7 -3
- package/dist/module/SubPackages/react-test-renderer/jsx/node.js +5 -0
- package/dist/module/SubPackages/react-test-renderer/jsx/web.js +5 -0
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +16 -0
- package/dist/module/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +1 -1
- package/dist/module/TaskManBackEnd.js +169 -0
- package/dist/module/TaskManFrontEnd.js +600 -0
- package/dist/module/Web.js +31 -108
- package/dist/module/esbuildConfigs/features.js +12 -0
- package/dist/module/esbuildConfigs/index.js +19 -0
- package/dist/module/esbuildConfigs/inputFilesPlugin.js +44 -0
- package/dist/module/esbuildConfigs/node.js +34 -0
- package/dist/module/esbuildConfigs/report.js +14 -0
- package/dist/module/esbuildConfigs/tests.js +11 -0
- package/dist/module/esbuildConfigs/web.js +52 -0
- package/dist/module/lib/abstractBase.js +545 -0
- package/dist/module/lib/basebuilder.js +75 -0
- package/dist/module/lib/classBuilder.js +38 -0
- package/dist/module/lib/core.js +72 -0
- package/dist/module/lib/index.js +18 -0
- package/dist/module/lib/types.js +1 -0
- package/dist/module/mongooseSchemas.js +50 -0
- package/dist/module/preload.js +15 -26
- package/dist/module/puppeteerConfiger.js +19 -0
- package/dist/module/report.html.js +29 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/module/utils.js +9 -0
- package/dist/module/web.html.js +20 -0
- package/dist/prebuild/TaskManBackEnd.mjs +174 -0
- package/dist/prebuild/TaskManFrontEnd.css +12301 -0
- package/dist/prebuild/TaskManFrontEnd.js +81264 -0
- package/dist/types/Features.d.ts +1 -34
- package/dist/types/Init.d.ts +2 -0
- package/dist/types/Node.d.ts +5 -11
- package/dist/types/PM/index.d.ts +20 -0
- package/dist/types/PM/main.d.ts +31 -0
- package/dist/types/PM/node.d.ts +27 -0
- package/dist/types/PM/web.d.ts +25 -0
- package/dist/types/Project.d.ts +3 -29
- package/dist/types/Puppeteer.d.ts +2 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/puppeteer.d.ts +6 -0
- package/dist/types/SubPackages/react/component/node.d.ts +7 -0
- package/dist/types/SubPackages/react/component/web.d.ts +7 -0
- package/dist/types/SubPackages/react/jsx/index.d.ts +12 -0
- package/dist/types/SubPackages/react/jsx/node.d.ts +4 -0
- package/dist/types/SubPackages/react/jsx/web.d.ts +4 -0
- package/dist/types/SubPackages/react-dom/component/node.d.ts +12 -0
- package/dist/types/SubPackages/react-dom/component/web.d.ts +11 -0
- package/dist/types/SubPackages/react-dom/jsx/index.d.ts +6 -0
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +6 -0
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +5 -0
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +5 -0
- package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +13 -0
- package/dist/types/SubPackages/react-test-renderer/component/interface.d.ts +9 -0
- package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +8 -0
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +3 -0
- package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +8 -0
- package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +8 -0
- package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx/index.d.ts +5 -4
- package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +8 -0
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +8 -0
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +15 -0
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +4 -0
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +4 -0
- package/dist/types/TaskManBackEnd.d.ts +3 -0
- package/dist/types/Types.d.ts +49 -16
- package/dist/types/Web.d.ts +5 -11
- package/dist/types/esbuildConfigs/features.d.ts +4 -0
- package/dist/types/esbuildConfigs/index.d.ts +4 -0
- package/dist/types/esbuildConfigs/inputFilesPlugin.d.ts +5 -0
- package/dist/types/esbuildConfigs/node.d.ts +4 -0
- package/dist/types/esbuildConfigs/report.d.ts +0 -0
- package/dist/types/esbuildConfigs/tests.d.ts +4 -0
- package/dist/types/esbuildConfigs/web.d.ts +4 -0
- package/dist/types/lib/abstractBase.d.ts +104 -0
- package/dist/types/lib/basebuilder.d.ts +27 -0
- package/dist/types/lib/classBuilder.d.ts +7 -0
- package/dist/types/lib/core.d.ts +8 -0
- package/dist/types/lib/index.d.ts +59 -0
- package/dist/types/lib/types.d.ts +62 -0
- package/dist/types/mongooseSchemas.d.ts +124 -0
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/puppeteerConfiger.d.ts +4 -0
- package/dist/types/report.html.d.ts +2 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/utils.d.ts +2 -0
- package/dist/types/web.html.d.ts +2 -0
- package/index.html +30 -0
- package/package.json +150 -78
- package/src/ExampleTab.tsx +219 -0
- package/src/Features.ts +2 -58
- package/src/Init.ts +51 -0
- package/src/Node.ts +71 -157
- package/src/PM/index.ts +25 -0
- package/src/PM/main.ts +830 -0
- package/src/PM/node.ts +128 -0
- package/src/PM/web.ts +166 -0
- package/src/Project.ts +158 -797
- package/src/Puppeteer.ts +141 -0
- package/src/Reporter.ts +126 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +51 -0
- package/src/SubPackages/react/component/node.ts +43 -0
- package/src/SubPackages/react/component/web.ts +43 -0
- package/src/SubPackages/react/jsx/index.ts +42 -0
- package/src/SubPackages/react/jsx/node.ts +26 -0
- package/src/SubPackages/react/jsx/web.ts +30 -0
- package/src/{subPackages → SubPackages}/react-dom/component/node.ts +24 -44
- package/src/SubPackages/react-dom/component/web.ts +143 -0
- package/src/SubPackages/react-dom/jsx/index.ts +6 -0
- package/src/SubPackages/react-dom/jsx/node.ts +68 -0
- package/src/SubPackages/react-dom/jsx/web.ts +139 -0
- package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +38 -0
- package/src/SubPackages/react-test-renderer/component/index.ts +23 -0
- package/src/SubPackages/react-test-renderer/component/interface.ts +48 -0
- package/src/SubPackages/react-test-renderer/component/node.ts +17 -0
- package/src/SubPackages/react-test-renderer/component/web.ts +17 -0
- package/src/SubPackages/react-test-renderer/fc/node.ts +49 -0
- package/src/SubPackages/react-test-renderer/fc/web.ts +48 -0
- package/src/SubPackages/react-test-renderer/jsx/index.ts +48 -0
- package/src/SubPackages/react-test-renderer/jsx/node.ts +20 -0
- package/src/SubPackages/react-test-renderer/jsx/web.ts +20 -0
- package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +40 -0
- package/src/SubPackages/react-test-renderer/jsx-promised/node.ts +19 -0
- package/src/SubPackages/react-test-renderer/jsx-promised/web.ts +22 -0
- package/src/TaskManBackEnd.ts +228 -0
- package/src/TaskManFrontEnd.tsx +1222 -0
- package/src/Types.ts +222 -17
- package/src/Web.ts +86 -217
- package/src/cjs-shim.js +12 -0
- package/src/esbuildConfigs/features.ts +17 -0
- package/src/esbuildConfigs/index.ts +23 -0
- package/src/esbuildConfigs/inputFilesPlugin.ts +65 -0
- package/src/esbuildConfigs/node.ts +62 -0
- package/src/esbuildConfigs/report.ts +15 -0
- package/src/esbuildConfigs/tests.ts +14 -0
- package/src/esbuildConfigs/web.ts +79 -0
- package/src/lib/abstractBase.ts +910 -0
- package/src/lib/basebuilder.ts +214 -0
- package/src/lib/classBuilder.ts +131 -0
- package/src/lib/core.ts +224 -0
- package/src/lib/index.ts +226 -0
- package/src/lib/types.ts +303 -0
- package/src/mongooseSchemas.ts +105 -0
- package/src/preload.ts +14 -28
- package/src/puppeteerConfiger.ts +26 -0
- package/src/report.html.ts +29 -0
- package/src/utils.ts +15 -0
- package/src/web.html.ts +20 -0
- package/tests/Rectangle.test.ts +189 -0
- package/trash/TaskMan.Dockerfile +23 -0
- package/trash/TaskMan1.Dockerfile +43 -0
- package/trash/devBot.dockerfile +12 -0
- package/trash/docker-compose-dev.yml +9 -0
- package/trash/docker-compose-prod.yml +18 -0
- package/trash/electronBuild.ts +32 -0
- package/tsconfig.json +18 -6
- package/tsconfig.module.json +14 -4
- package/tsconfig.types.json +13 -4
- package/dist/common/NodeWriter.js +0 -56
- package/dist/common/core.js +0 -396
- package/dist/common/electron.js +0 -52
- package/dist/common/subPackages/react/jsx/index.js +0 -26
- package/dist/common/subPackages/react-dom/component/node.js +0 -101
- package/dist/common/subPackages/react-dom/component/web.js +0 -61
- package/dist/common/subPackages/react-dom/jsx/web.js +0 -76
- package/dist/common/subPackages/react-test-renderer/component/node.js +0 -8
- package/dist/common/subPackages/react-test-renderer/component/web.js +0 -8
- package/dist/module/NodeWriter.js +0 -50
- package/dist/module/Report.js +0 -186
- package/dist/module/core.js +0 -387
- package/dist/module/electron.js +0 -47
- package/dist/module/subPackages/react/jsx/index.js +0 -22
- package/dist/module/subPackages/react/jsx/node.js +0 -5
- package/dist/module/subPackages/react/jsx/web.js +0 -5
- package/dist/module/subPackages/react-dom/component/web.js +0 -56
- package/dist/module/subPackages/react-dom/jsx/node.js +0 -93
- package/dist/module/subPackages/react-dom/jsx/web.js +0 -48
- package/dist/module/subPackages/react-test-renderer/component/index.js +0 -52
- package/dist/types/NodeWriter.d.ts +0 -2
- package/dist/types/core.d.ts +0 -220
- package/dist/types/subPackages/react/component/node.d.ts +0 -12
- package/dist/types/subPackages/react/component/web.d.ts +0 -12
- package/dist/types/subPackages/react/jsx/index.d.ts +0 -15
- package/dist/types/subPackages/react/jsx/node.d.ts +0 -4
- package/dist/types/subPackages/react/jsx/web.d.ts +0 -4
- package/dist/types/subPackages/react-dom/component/node.d.ts +0 -14
- package/dist/types/subPackages/react-dom/component/web.d.ts +0 -19
- package/dist/types/subPackages/react-dom/jsx/node.d.ts +0 -14
- package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -15
- package/dist/types/subPackages/react-test-renderer/component/index.d.ts +0 -20
- package/dist/types/subPackages/react-test-renderer/component/node.d.ts +0 -9
- package/dist/types/subPackages/react-test-renderer/component/web.d.ts +0 -9
- package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +0 -4
- package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +0 -4
- package/src/NodeWriter.ts +0 -72
- package/src/Report.tsx +0 -392
- package/src/core.ts +0 -1396
- package/src/electron.ts +0 -59
- package/src/subPackages/react/component/node.ts +0 -75
- package/src/subPackages/react/component/web.ts +0 -80
- package/src/subPackages/react/jsx/index.ts +0 -64
- package/src/subPackages/react/jsx/node.ts +0 -29
- package/src/subPackages/react/jsx/web.ts +0 -29
- package/src/subPackages/react-dom/component/web.ts +0 -129
- package/src/subPackages/react-dom/jsx/node.ts +0 -150
- package/src/subPackages/react-dom/jsx/web.ts +0 -117
- package/src/subPackages/react-test-renderer/component/index.ts +0 -101
- package/src/subPackages/react-test-renderer/component/node.ts +0 -30
- package/src/subPackages/react-test-renderer/component/web.ts +0 -30
- package/src/subPackages/react-test-renderer/fc/node.tsx +0 -77
- package/src/subPackages/react-test-renderer/jsx/index.ts +0 -51
- package/src/subPackages/react-test-renderer/jsx/node.ts +0 -31
- package/src/subPackages/react-test-renderer/jsx/web.ts +0 -31
- /package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/web.js +0 -0
- /package/dist/{types/electron.d.ts → module/SubPackages/react-dom/jsx/index.js} +0 -0
- /package/dist/module/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/web.js +0 -0
package/src/PM/node.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import puppeteer from "puppeteer-core";
|
|
4
|
+
import { PassThrough } from "stream";
|
|
5
|
+
|
|
6
|
+
import { ITLog, ITTestResourceConfiguration } from "../lib";
|
|
7
|
+
|
|
8
|
+
import { PM } from "./index.js";
|
|
9
|
+
import { Page } from "puppeteer-core/lib/esm/puppeteer";
|
|
10
|
+
|
|
11
|
+
type IFPaths = string[];
|
|
12
|
+
const fPaths: IFPaths = [];
|
|
13
|
+
|
|
14
|
+
type PuppetMasterServer = Record<string, Promise<any>>;
|
|
15
|
+
|
|
16
|
+
export class PM_Node extends PM {
|
|
17
|
+
server: PuppetMasterServer;
|
|
18
|
+
testResourceConfiguration: ITTestResourceConfiguration;
|
|
19
|
+
|
|
20
|
+
constructor(t: ITTestResourceConfiguration) {
|
|
21
|
+
super();
|
|
22
|
+
this.server = {};
|
|
23
|
+
this.testResourceConfiguration = t;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
customScreenShot(opts: object, page: Page) {
|
|
27
|
+
return globalThis["customScreenShot"](opts, page);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
existsSync(destFolder: string): boolean {
|
|
31
|
+
return globalThis["existsSync"](
|
|
32
|
+
this.testResourceConfiguration.fs + "/" + destFolder
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
mkdirSync() {
|
|
37
|
+
return globalThis["mkdirSync"](this.testResourceConfiguration.fs + "/");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
write(writeObject: { uid: number }, contents: string) {
|
|
41
|
+
return globalThis["write"](writeObject.uid, contents);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
writeFileSync(filepath: string, contents: string) {
|
|
45
|
+
console.log("pm_node-writeFileSync", this.testResourceConfiguration);
|
|
46
|
+
return globalThis["writeFileSync"](
|
|
47
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
48
|
+
contents,
|
|
49
|
+
this.testResourceConfiguration.name
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
createWriteStream(filepath: string): any {
|
|
54
|
+
return globalThis["createWriteStream"](
|
|
55
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
56
|
+
this.testResourceConfiguration.name
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
end(writeObject: { uid: number }) {
|
|
61
|
+
return globalThis["end"](writeObject.uid);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
customclose() {
|
|
65
|
+
globalThis["customclose"](
|
|
66
|
+
this.testResourceConfiguration.fs,
|
|
67
|
+
this.testResourceConfiguration.name
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
|
|
72
|
+
return (fPath, value: string | Buffer | PassThrough) => {
|
|
73
|
+
callback(
|
|
74
|
+
new Promise<void>((res, rej) => {
|
|
75
|
+
tLog("testArtiFactory =>", fPath);
|
|
76
|
+
|
|
77
|
+
const cleanPath = path.resolve(fPath);
|
|
78
|
+
fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
79
|
+
|
|
80
|
+
const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
81
|
+
|
|
82
|
+
fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
83
|
+
if (error) {
|
|
84
|
+
console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fs.writeFileSync(
|
|
88
|
+
path.resolve(
|
|
89
|
+
targetDir.split("/").slice(0, -1).join("/"),
|
|
90
|
+
"manifest"
|
|
91
|
+
),
|
|
92
|
+
fPaths.join(`\n`),
|
|
93
|
+
{
|
|
94
|
+
encoding: "utf-8",
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
if (Buffer.isBuffer(value)) {
|
|
99
|
+
fs.writeFileSync(fPath, value, "binary");
|
|
100
|
+
res();
|
|
101
|
+
} else if (`string` === typeof value) {
|
|
102
|
+
fs.writeFileSync(fPath, value.toString(), {
|
|
103
|
+
encoding: "utf-8",
|
|
104
|
+
});
|
|
105
|
+
res();
|
|
106
|
+
} else {
|
|
107
|
+
/* @ts-ignore:next-line */
|
|
108
|
+
const pipeStream: PassThrough = value;
|
|
109
|
+
const myFile = fs.createWriteStream(fPath);
|
|
110
|
+
pipeStream.pipe(myFile);
|
|
111
|
+
pipeStream.on("close", () => {
|
|
112
|
+
myFile.close();
|
|
113
|
+
res();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
|
|
123
|
+
startPuppeteer(options?: any): Promise<any> {
|
|
124
|
+
return puppeteer.connect(options).then((b) => {
|
|
125
|
+
this.browser = b;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
package/src/PM/web.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { PassThrough } from "stream";
|
|
2
|
+
import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js";
|
|
3
|
+
|
|
4
|
+
import { ITLog, ITTestResourceConfiguration } from "../lib";
|
|
5
|
+
import { PM } from "./index.js";
|
|
6
|
+
|
|
7
|
+
type PuppetMasterServer = Record<string, Promise<any>>;
|
|
8
|
+
|
|
9
|
+
export class PM_Web extends PM {
|
|
10
|
+
server: PuppetMasterServer;
|
|
11
|
+
|
|
12
|
+
constructor(t: ITTestResourceConfiguration) {
|
|
13
|
+
super();
|
|
14
|
+
this.server = {};
|
|
15
|
+
this.testResourceConfiguration = t;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
customScreenShot(opts: object) {
|
|
19
|
+
window["customScreenShot"](opts);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
existsSync(destFolder: string): boolean {
|
|
23
|
+
return window["existsSync"](destFolder);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
mkdirSync() {
|
|
27
|
+
return window["mkdirSync"](this.testResourceConfiguration.fs + "/");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
write(writeObject: { uid: number }, contents: string) {
|
|
31
|
+
return window["write"](writeObject.uid, contents);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
writeFileSync(filepath: string, contents: string) {
|
|
35
|
+
return window["writeFileSync"](
|
|
36
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
37
|
+
contents,
|
|
38
|
+
this.testResourceConfiguration.name
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
createWriteStream(filepath: string): any {
|
|
43
|
+
return window["createWriteStream"](
|
|
44
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
45
|
+
this.testResourceConfiguration.name
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
end(writeObject: { uid: number }) {
|
|
50
|
+
return window["end"](writeObject.uid);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
customclose() {
|
|
54
|
+
window["customclose"](
|
|
55
|
+
this.testResourceConfiguration.fs,
|
|
56
|
+
this.testResourceConfiguration.name
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
|
|
61
|
+
return (fPath, value: string | Buffer | PassThrough) => {
|
|
62
|
+
callback(
|
|
63
|
+
new Promise<void>((res, rej) => {
|
|
64
|
+
tLog("testArtiFactory =>", fPath);
|
|
65
|
+
|
|
66
|
+
// const cleanPath = path.resolve(fPath);
|
|
67
|
+
// fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
68
|
+
|
|
69
|
+
// const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
70
|
+
|
|
71
|
+
// fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
72
|
+
// if (error) {
|
|
73
|
+
// console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
// fs.writeFileSync(
|
|
77
|
+
// path.resolve(
|
|
78
|
+
// targetDir.split("/").slice(0, -1).join("/"),
|
|
79
|
+
// "manifest"
|
|
80
|
+
// ),
|
|
81
|
+
// fPaths.join(`\n`),
|
|
82
|
+
// {
|
|
83
|
+
// encoding: "utf-8",
|
|
84
|
+
// }
|
|
85
|
+
// );
|
|
86
|
+
|
|
87
|
+
// if (Buffer.isBuffer(value)) {
|
|
88
|
+
// fs.writeFileSync(fPath, value, "binary");
|
|
89
|
+
// res();
|
|
90
|
+
// } else if (`string` === typeof value) {
|
|
91
|
+
// fs.writeFileSync(fPath, value.toString(), {
|
|
92
|
+
// encoding: "utf-8",
|
|
93
|
+
// });
|
|
94
|
+
// res();
|
|
95
|
+
// } else {
|
|
96
|
+
// /* @ts-ignore:next-line */
|
|
97
|
+
// const pipeStream: PassThrough = value;
|
|
98
|
+
// const myFile = fs.createWriteStream(fPath);
|
|
99
|
+
// pipeStream.pipe(myFile);
|
|
100
|
+
// pipeStream.on("close", () => {
|
|
101
|
+
// myFile.close();
|
|
102
|
+
// res();
|
|
103
|
+
// });
|
|
104
|
+
// }
|
|
105
|
+
// });
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
startPuppeteer(options, destFolder: string): Promise<any> {
|
|
112
|
+
const name = this.testResourceConfiguration.name;
|
|
113
|
+
|
|
114
|
+
return fetch(`http://localhost:3234/json/version`)
|
|
115
|
+
.then((v) => {
|
|
116
|
+
return v.json();
|
|
117
|
+
})
|
|
118
|
+
.then((json) => {
|
|
119
|
+
return puppeteer
|
|
120
|
+
.connect({
|
|
121
|
+
browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
122
|
+
})
|
|
123
|
+
.then((b) => {
|
|
124
|
+
this.browser = b;
|
|
125
|
+
const handler2 = {
|
|
126
|
+
get(target, prop, receiver) {
|
|
127
|
+
if (prop === "screenshot") {
|
|
128
|
+
return async (x) => {
|
|
129
|
+
return await window["custom-screenshot"](
|
|
130
|
+
{
|
|
131
|
+
...x,
|
|
132
|
+
// path: destFolder + "/" + x.path,
|
|
133
|
+
path: x.path,
|
|
134
|
+
},
|
|
135
|
+
name
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
} else if (prop === "mainFrame") {
|
|
139
|
+
return () => target[prop](...arguments);
|
|
140
|
+
} else {
|
|
141
|
+
return Reflect.get(...arguments);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
const handler1 = {
|
|
146
|
+
get(target, prop, receiver) {
|
|
147
|
+
if (prop === "pages") {
|
|
148
|
+
return async () => {
|
|
149
|
+
return target.pages().then((pages) => {
|
|
150
|
+
return pages.map((p) => {
|
|
151
|
+
return new Proxy(p, handler2);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return Reflect.get(...arguments);
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const proxy3 = new Proxy(this.browser, handler1);
|
|
162
|
+
this.browser = proxy3;
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|