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.
- package/README.md +9 -18
- package/dist/common/Node.js +14 -34
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +361 -0
- package/dist/common/PM/node.js +176 -0
- package/dist/common/PM/web.js +174 -0
- package/dist/common/Project.js +20 -2
- package/dist/common/Puppeteer.js +109 -0
- package/dist/common/Reporter.js +119 -0
- package/dist/common/Scheduler.js +1 -0
- package/dist/common/SubPackages/puppeteer.js +3 -1
- package/dist/common/SubPackages/react-dom/component/web.js +98 -45
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/common/Web.js +24 -43
- package/dist/common/esbuildConfigs/web.js +3 -1
- package/dist/common/lib/abstractBase.js +189 -41
- package/dist/common/lib/basebuilder.js +56 -29
- package/dist/common/lib/classBuilder.js +6 -2
- package/dist/common/lib/core.js +41 -45
- package/dist/common/lib/index.js +2 -1
- package/dist/common/preload.js +14 -18
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +14 -34
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +331 -0
- package/dist/module/PM/node.js +168 -0
- package/dist/module/PM/web.js +167 -0
- package/dist/module/Project.js +20 -2
- package/dist/module/Puppeteer.js +104 -0
- package/dist/module/Reporter.js +114 -0
- package/dist/module/Scheduler.js +1 -0
- package/dist/module/SubPackages/puppeteer.js +3 -1
- package/dist/module/SubPackages/react/jsx/node.js +1 -1
- package/dist/module/SubPackages/react-dom/component/web.js +98 -45
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
- package/dist/module/Web.js +24 -43
- package/dist/module/esbuildConfigs/web.js +3 -1
- package/dist/module/lib/abstractBase.js +189 -41
- package/dist/module/lib/basebuilder.js +56 -29
- package/dist/module/lib/classBuilder.js +6 -2
- package/dist/module/lib/core.js +41 -45
- package/dist/module/lib/index.js +2 -1
- package/dist/module/preload.js +15 -14
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Report.css +1616 -584
- package/dist/prebuild/Report.js +2635 -2506
- package/dist/types/PM/index.d.ts +19 -0
- package/dist/types/PM/main.d.ts +28 -0
- package/dist/types/PM/node.d.ts +26 -0
- package/dist/types/PM/web.d.ts +24 -0
- package/dist/types/Reporter.d.ts +1 -0
- package/dist/types/Scheduler.d.ts +0 -0
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +13 -12
- package/dist/types/lib/basebuilder.d.ts +4 -2
- package/dist/types/lib/classBuilder.d.ts +2 -2
- package/dist/types/lib/core.d.ts +4 -4
- package/dist/types/lib/index.d.ts +6 -5
- package/dist/types/lib/types.d.ts +16 -24
- package/dist/types/preload.d.ts +0 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -5
- package/src/Node.ts +18 -43
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +420 -0
- package/src/PM/node.ts +515 -0
- package/src/PM/web.ts +497 -0
- package/src/Project.ts +21 -2
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +158 -44
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +3 -3
- package/src/SubPackages/react/jsx/node.ts +5 -8
- package/src/SubPackages/react-dom/component/web.ts +126 -67
- package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
- package/src/Web.ts +25 -67
- package/src/esbuildConfigs/web.ts +4 -2
- package/src/lib/abstractBase.ts +260 -65
- package/src/lib/basebuilder.ts +121 -100
- package/src/lib/classBuilder.ts +5 -4
- package/src/lib/core.ts +58 -59
- package/src/lib/index.ts +10 -9
- package/src/lib/types.ts +18 -27
- package/src/preload.ts +14 -14
- package/dist/common/NodeWriter.js +0 -54
- package/dist/common/electron.js +0 -266
- package/dist/module/NodeWriter.js +0 -48
- package/dist/module/electron.js +0 -261
- package/dist/types/NodeWriter.d.ts +0 -2
- package/src/NodeWriter.ts +0 -72
- package/src/electron.ts +0 -317
- package/yarn-error.log +0 -3144
- /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
package/src/PM/web.ts
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import { PassThrough } from "stream";
|
|
2
|
+
import { ITLog, ITTestResourceConfiguration } from "../lib";
|
|
3
|
+
import { PM } from "./index.js";
|
|
4
|
+
import puppeteer from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js";
|
|
5
|
+
|
|
6
|
+
// type IFPaths = string[];
|
|
7
|
+
// const fPaths: IFPaths = [];
|
|
8
|
+
|
|
9
|
+
type PuppetMasterServer = Record<string, Promise<any>>;
|
|
10
|
+
|
|
11
|
+
function waitForFunctionCall() {
|
|
12
|
+
return new Promise<void>((resolve) => {
|
|
13
|
+
window["myFunction"] = () => {
|
|
14
|
+
// Do something when myFunction is called
|
|
15
|
+
console.log("myFunction was called!");
|
|
16
|
+
resolve(); // Resolve the promise
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const files = new Set<string>();
|
|
22
|
+
|
|
23
|
+
export class PM_Web extends PM {
|
|
24
|
+
server: PuppetMasterServer;
|
|
25
|
+
// testResourceConfiguration: ITTestResourceConfiguration;
|
|
26
|
+
|
|
27
|
+
constructor(t: ITTestResourceConfiguration) {
|
|
28
|
+
super();
|
|
29
|
+
this.server = {};
|
|
30
|
+
this.testResourceConfiguration = t;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
existsSync(destFolder: string): boolean {
|
|
34
|
+
return window["existsSync"](destFolder);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
mkdirSync() {
|
|
38
|
+
return window["mkdirSync"](this.testResourceConfiguration.fs + "/");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
write(writeObject: { uid: number }, contents: string) {
|
|
42
|
+
return window["write"](writeObject.uid, contents);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
writeFileSync(filepath: string, contents: string) {
|
|
46
|
+
console.log("WEB writeFileSync", filepath);
|
|
47
|
+
files.add(filepath);
|
|
48
|
+
return window["writeFileSync"](
|
|
49
|
+
this.testResourceConfiguration.fs + "/" + filepath,
|
|
50
|
+
contents
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
createWriteStream(filepath: string): any {
|
|
55
|
+
files.add(filepath);
|
|
56
|
+
return window["createWriteStream"](
|
|
57
|
+
this.testResourceConfiguration.fs + "/" + filepath
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
end(writeObject: { uid: number }) {
|
|
62
|
+
return window["end"](writeObject.uid);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
customclose() {
|
|
66
|
+
window["writeFileSync"](
|
|
67
|
+
this.testResourceConfiguration.fs + "/manifest.json",
|
|
68
|
+
// files.entries()
|
|
69
|
+
JSON.stringify(Array.from(files))
|
|
70
|
+
).then(() => {
|
|
71
|
+
window["customclose"]();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
testArtiFactoryfileWriter(tLog: ITLog, callback: (Promise) => void) {
|
|
76
|
+
return (fPath, value: string | Buffer | PassThrough) => {
|
|
77
|
+
callback(
|
|
78
|
+
new Promise<void>((res, rej) => {
|
|
79
|
+
tLog("testArtiFactory =>", fPath);
|
|
80
|
+
|
|
81
|
+
// const cleanPath = path.resolve(fPath);
|
|
82
|
+
// fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
83
|
+
|
|
84
|
+
// const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
85
|
+
|
|
86
|
+
// fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
87
|
+
// if (error) {
|
|
88
|
+
// console.error(`❗️testArtiFactory failed`, targetDir, error);
|
|
89
|
+
// }
|
|
90
|
+
|
|
91
|
+
// fs.writeFileSync(
|
|
92
|
+
// path.resolve(
|
|
93
|
+
// targetDir.split("/").slice(0, -1).join("/"),
|
|
94
|
+
// "manifest"
|
|
95
|
+
// ),
|
|
96
|
+
// fPaths.join(`\n`),
|
|
97
|
+
// {
|
|
98
|
+
// encoding: "utf-8",
|
|
99
|
+
// }
|
|
100
|
+
// );
|
|
101
|
+
|
|
102
|
+
// if (Buffer.isBuffer(value)) {
|
|
103
|
+
// fs.writeFileSync(fPath, value, "binary");
|
|
104
|
+
// res();
|
|
105
|
+
// } else if (`string` === typeof value) {
|
|
106
|
+
// fs.writeFileSync(fPath, value.toString(), {
|
|
107
|
+
// encoding: "utf-8",
|
|
108
|
+
// });
|
|
109
|
+
// res();
|
|
110
|
+
// } else {
|
|
111
|
+
// /* @ts-ignore:next-line */
|
|
112
|
+
// const pipeStream: PassThrough = value;
|
|
113
|
+
// const myFile = fs.createWriteStream(fPath);
|
|
114
|
+
// pipeStream.pipe(myFile);
|
|
115
|
+
// pipeStream.on("close", () => {
|
|
116
|
+
// myFile.close();
|
|
117
|
+
// res();
|
|
118
|
+
// });
|
|
119
|
+
// }
|
|
120
|
+
// });
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
startPuppeteer(options, destFolder: string): Promise<any> {
|
|
127
|
+
return fetch(`http://localhost:3234/json/version`)
|
|
128
|
+
.then((v) => {
|
|
129
|
+
return v.json();
|
|
130
|
+
})
|
|
131
|
+
.then((json) => {
|
|
132
|
+
console.log("found endpoint", json.webSocketDebuggerUrl);
|
|
133
|
+
return puppeteer
|
|
134
|
+
.connect({
|
|
135
|
+
browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
136
|
+
})
|
|
137
|
+
.then((b) => {
|
|
138
|
+
this.browser = b;
|
|
139
|
+
const handler2 = {
|
|
140
|
+
get(target, prop, receiver) {
|
|
141
|
+
if (prop === "screenshot") {
|
|
142
|
+
return async (x) => {
|
|
143
|
+
// debugger;
|
|
144
|
+
files.add(x.path);
|
|
145
|
+
console.log("aloha", files);
|
|
146
|
+
return await window["custom-screenshot"]({
|
|
147
|
+
...x,
|
|
148
|
+
path: destFolder + "/" + x.path,
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
} else if (prop === "mainFrame") {
|
|
152
|
+
return () => target[prop](...arguments);
|
|
153
|
+
} else {
|
|
154
|
+
return Reflect.get(...arguments);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
const handler1 = {
|
|
159
|
+
get(target, prop, receiver) {
|
|
160
|
+
if (prop === "pages") {
|
|
161
|
+
return async () => {
|
|
162
|
+
return target.pages().then((pages) => {
|
|
163
|
+
return pages.map((p) => {
|
|
164
|
+
return new Proxy(p, handler2);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return Reflect.get(...arguments);
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const proxy3 = new Proxy(this.browser, handler1);
|
|
175
|
+
this.browser = proxy3;
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
// console.log("connecting to ws://localhost:3234/devtools/browser/RANDOM");
|
|
179
|
+
|
|
180
|
+
// return puppeteer
|
|
181
|
+
// .connect({
|
|
182
|
+
// ...options,
|
|
183
|
+
// })
|
|
184
|
+
// .finally(() => {
|
|
185
|
+
// console.log("idk");
|
|
186
|
+
// });
|
|
187
|
+
// return new Promise<Browser>(async (res, rej) => {
|
|
188
|
+
// console.log("connecting with options", options);
|
|
189
|
+
// this.browser = await puppeteer.connect({
|
|
190
|
+
// ...options,
|
|
191
|
+
// });
|
|
192
|
+
// res(this.browser);
|
|
193
|
+
// });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// launchNode = (src: string, dest: string) => {
|
|
197
|
+
// console.log("launchNode", src);
|
|
198
|
+
// // childProcesses[src] = "running";
|
|
199
|
+
// const destFolder = dest.replace(".mjs", "");
|
|
200
|
+
|
|
201
|
+
// const argz = JSON.stringify({
|
|
202
|
+
// scheduled: true,
|
|
203
|
+
// name: src,
|
|
204
|
+
// ports: [3333],
|
|
205
|
+
// // fs: path.resolve(configs.buildDir, "web", destFolder + "/"),
|
|
206
|
+
// // fs: destFolder,
|
|
207
|
+
// fs: ".",
|
|
208
|
+
// });
|
|
209
|
+
|
|
210
|
+
// const builtfile = dest + ".mjs";
|
|
211
|
+
// console.log("importing and running ", builtfile);
|
|
212
|
+
// // import(builtfile).then(async (v) => {
|
|
213
|
+
// // console.log("v", (await v.default).receiveTestResourceConfig(argz));
|
|
214
|
+
// // });
|
|
215
|
+
|
|
216
|
+
// // console.log("launchNode", src, dest, " -> ", destFolder, argz);
|
|
217
|
+
|
|
218
|
+
// // const child = utilityProcess.fork(dest + ".mjs", [argz], {
|
|
219
|
+
// // cwd: destFolder,
|
|
220
|
+
// // stdio: "pipe",
|
|
221
|
+
// // });
|
|
222
|
+
// // const nodeGuid = uuidv4();
|
|
223
|
+
// // nodeChildren[nodeGuid] = child;
|
|
224
|
+
|
|
225
|
+
// // if (!fs.existsSync(destFolder)) {
|
|
226
|
+
// // fs.mkdirSync(destFolder, { recursive: true });
|
|
227
|
+
// // }
|
|
228
|
+
|
|
229
|
+
// // fs.rmSync(`${destFolder}/stdout.log`, { force: true });
|
|
230
|
+
// // fs.rmSync(`${destFolder}/stderr.log`, { force: true });
|
|
231
|
+
// // const stdout = fs.createWriteStream(`${destFolder}/stdout.log`);
|
|
232
|
+
// // const stderr = fs.createWriteStream(`${destFolder}/stderr.log`);
|
|
233
|
+
|
|
234
|
+
// // child
|
|
235
|
+
// // .on("message", (data) => {
|
|
236
|
+
// // console.log("from child", JSON.stringify(data));
|
|
237
|
+
// // if (data.launchWeb) {
|
|
238
|
+
// // const guid = uuidv4();
|
|
239
|
+
// // const webChild = launchWebSecondary(process.cwd() + data.launchWeb);
|
|
240
|
+
// // // child.postMessage({ webLaunched: guid });
|
|
241
|
+
|
|
242
|
+
// // webChild.webContents.on("did-finish-load", () => {
|
|
243
|
+
// // // webChild.webContents.send("message", "hello world");
|
|
244
|
+
// // child.postMessage({ webLaunched: guid });
|
|
245
|
+
// // webChildren[guid] = webChild;
|
|
246
|
+
// // node2web[nodeGuid] = [...(node2web[nodeGuid] || []), guid];
|
|
247
|
+
// // });
|
|
248
|
+
// // }
|
|
249
|
+
// // if (data.teardown) {
|
|
250
|
+
// // webChildren[data.teardown].close();
|
|
251
|
+
// // delete webChildren[data.teardown];
|
|
252
|
+
// // node2web[nodeGuid] = node2web[nodeGuid].filter(
|
|
253
|
+
// // (x) => x !== data.teardown
|
|
254
|
+
// // );
|
|
255
|
+
// // }
|
|
256
|
+
// // })
|
|
257
|
+
// // .on("exit", (data) => {
|
|
258
|
+
// // stdout.close();
|
|
259
|
+
// // stderr.close();
|
|
260
|
+
// // console.log(`ending node ${src}`);
|
|
261
|
+
// // onDone(src);
|
|
262
|
+
// // });
|
|
263
|
+
|
|
264
|
+
// // child.stdout?.pipe(stdout);
|
|
265
|
+
// // child.stderr?.pipe(stderr);
|
|
266
|
+
// };
|
|
267
|
+
|
|
268
|
+
// const launchWebSecondary = (htmlFile: string): BrowserWindow => {
|
|
269
|
+
// console.log("launchWebSecondary", htmlFile);
|
|
270
|
+
// const subWin = new BrowserWindow({
|
|
271
|
+
// show: false,
|
|
272
|
+
|
|
273
|
+
// webPreferences: {
|
|
274
|
+
// nodeIntegration: true,
|
|
275
|
+
// nodeIntegrationInWorker: true,
|
|
276
|
+
// contextIsolation: false,
|
|
277
|
+
// preload: path.join(app.getAppPath(), "preload.js"),
|
|
278
|
+
// offscreen: false,
|
|
279
|
+
// devTools: true,
|
|
280
|
+
// },
|
|
281
|
+
// });
|
|
282
|
+
// remoteMain.enable(subWin.webContents);
|
|
283
|
+
// subWin.webContents.openDevTools();
|
|
284
|
+
// subWin.loadFile(htmlFile);
|
|
285
|
+
// return subWin;
|
|
286
|
+
|
|
287
|
+
// // const uuid = uuidv4();
|
|
288
|
+
// // windows[uuid] = subWin;
|
|
289
|
+
// // return uuid;
|
|
290
|
+
// };
|
|
291
|
+
|
|
292
|
+
// const launchWeb = (t: string, dest: string) => {
|
|
293
|
+
// console.log("launchWeb", t);
|
|
294
|
+
// childProcesses[t] = "running";
|
|
295
|
+
// const destFolder = dest.replace(".mjs", "");
|
|
296
|
+
|
|
297
|
+
// const subWin = new BrowserWindow({
|
|
298
|
+
// show: true,
|
|
299
|
+
// webPreferences: {
|
|
300
|
+
// nodeIntegration: true,
|
|
301
|
+
// nodeIntegrationInWorker: true,
|
|
302
|
+
// contextIsolation: false,
|
|
303
|
+
// preload: path.join(app.getAppPath(), "preload.js"),
|
|
304
|
+
// offscreen: false,
|
|
305
|
+
// devTools: true,
|
|
306
|
+
// },
|
|
307
|
+
// });
|
|
308
|
+
|
|
309
|
+
// webChildren[uuidv4()] = subWin;
|
|
310
|
+
|
|
311
|
+
// remoteMain.enable(subWin.webContents);
|
|
312
|
+
|
|
313
|
+
// const webArgz = JSON.stringify({
|
|
314
|
+
// name: dest,
|
|
315
|
+
// ports: [].toString(),
|
|
316
|
+
// fs: destFolder,
|
|
317
|
+
// });
|
|
318
|
+
|
|
319
|
+
// // console.log("webArgz", webArgz);
|
|
320
|
+
// subWin.loadFile(`${dest}.html`, {
|
|
321
|
+
// query: {
|
|
322
|
+
// requesting: encodeURIComponent(webArgz),
|
|
323
|
+
// },
|
|
324
|
+
// });
|
|
325
|
+
|
|
326
|
+
// if (!fs.existsSync(destFolder)) {
|
|
327
|
+
// fs.mkdirSync(destFolder, { recursive: true });
|
|
328
|
+
// }
|
|
329
|
+
// const stdout = fs.createWriteStream(`${destFolder}/stdout.log`);
|
|
330
|
+
|
|
331
|
+
// subWin.webContents.on(
|
|
332
|
+
// "console-message",
|
|
333
|
+
// (event, level, message, line, sourceId) => {
|
|
334
|
+
// stdout.write(
|
|
335
|
+
// JSON.stringify(
|
|
336
|
+
// {
|
|
337
|
+
// event,
|
|
338
|
+
// level,
|
|
339
|
+
// message: JSON.stringify(message),
|
|
340
|
+
// line,
|
|
341
|
+
// sourceId,
|
|
342
|
+
// },
|
|
343
|
+
// null,
|
|
344
|
+
// 2
|
|
345
|
+
// )
|
|
346
|
+
// );
|
|
347
|
+
// stdout.write("\n");
|
|
348
|
+
// }
|
|
349
|
+
// );
|
|
350
|
+
// subWin.on("closed", () => {
|
|
351
|
+
// stdout.close();
|
|
352
|
+
// console.log(`ending web ${t}`);
|
|
353
|
+
// // childProcesses[t] = "done";
|
|
354
|
+
// onDone(t);
|
|
355
|
+
// });
|
|
356
|
+
// ipcMain.on("message", (message, data) => {
|
|
357
|
+
// console.log("ipcMain message: " + JSON.stringify(data));
|
|
358
|
+
// // process.exit();
|
|
359
|
+
// });
|
|
360
|
+
// };
|
|
361
|
+
|
|
362
|
+
// return await import("${dest}.mjs");
|
|
363
|
+
|
|
364
|
+
// launchWeb = (t: string, dest: string) => {
|
|
365
|
+
// console.log("launchWeb", t, dest);
|
|
366
|
+
// // childProcesses[t] = "running";
|
|
367
|
+
// const destFolder = dest.replace(".mjs", "");
|
|
368
|
+
|
|
369
|
+
// const webArgz = JSON.stringify({
|
|
370
|
+
// name: dest,
|
|
371
|
+
// ports: [].toString(),
|
|
372
|
+
// fs: destFolder,
|
|
373
|
+
// });
|
|
374
|
+
|
|
375
|
+
// const evaluation = `import('${dest}.mjs').then(async (x) => {
|
|
376
|
+
// console.log(x);
|
|
377
|
+
// })`;
|
|
378
|
+
|
|
379
|
+
// // console.log("evaluation", evaluation);
|
|
380
|
+
|
|
381
|
+
// // const y = browser
|
|
382
|
+
// // .newPage()
|
|
383
|
+
// // .then(async (page) => {
|
|
384
|
+
// // // const codeString = "1 + 1";
|
|
385
|
+
// // await page.goto(
|
|
386
|
+
// // // "file:///Users/adam/Code/kokomoBay/docs/web/src/LoginPage/react/web.test.html"
|
|
387
|
+
// // `file://${`${dest}.html`}`
|
|
388
|
+
// // );
|
|
389
|
+
// // // page.url
|
|
390
|
+
// // // page.setContent(`
|
|
391
|
+
|
|
392
|
+
// // // <!DOCTYPE html>
|
|
393
|
+
// // // <html lang="en">
|
|
394
|
+
|
|
395
|
+
// // // <head>
|
|
396
|
+
|
|
397
|
+
// // // </head>
|
|
398
|
+
|
|
399
|
+
// // // <body>
|
|
400
|
+
// // // <h1>/Users/adam/Code/kokomoBay/docs/web/src/LoginPage/react/web.test.html</h1>
|
|
401
|
+
// // // <div id="root">
|
|
402
|
+
|
|
403
|
+
// // // </div>
|
|
404
|
+
// // // </body>
|
|
405
|
+
|
|
406
|
+
// // // <footer></footer>
|
|
407
|
+
|
|
408
|
+
// // // </html>
|
|
409
|
+
// // // `);
|
|
410
|
+
// // // return await page.evaluate((code) => eval(code), evaluation);
|
|
411
|
+
|
|
412
|
+
// // return await page.evaluate(evaluation);
|
|
413
|
+
// // // return await page.evaluate(async () => {
|
|
414
|
+
// // // return await import(dest);
|
|
415
|
+
// // // });
|
|
416
|
+
// // })
|
|
417
|
+
// // .then((x) => {
|
|
418
|
+
// // console.log("mark1", x);
|
|
419
|
+
// // });
|
|
420
|
+
// // .then((x) => {
|
|
421
|
+
// // console.log("mark0", x);
|
|
422
|
+
// // })
|
|
423
|
+
// // .catch((z) => {
|
|
424
|
+
// // console.log("mark2", z);
|
|
425
|
+
// // });
|
|
426
|
+
|
|
427
|
+
// // const subWin = new BrowserWindow({
|
|
428
|
+
// // show: true,
|
|
429
|
+
// // webPreferences: {
|
|
430
|
+
// // nodeIntegration: true,
|
|
431
|
+
// // nodeIntegrationInWorker: true,
|
|
432
|
+
// // contextIsolation: false,
|
|
433
|
+
// // preload: path.join(app.getAppPath(), "preload.js"),
|
|
434
|
+
// // offscreen: false,
|
|
435
|
+
// // devTools: true,
|
|
436
|
+
// // },
|
|
437
|
+
// // });
|
|
438
|
+
|
|
439
|
+
// // webChildren[uuidv4()] = subWin;
|
|
440
|
+
|
|
441
|
+
// // remoteMain.enable(subWin.webContents);
|
|
442
|
+
|
|
443
|
+
// // // console.log("webArgz", webArgz);
|
|
444
|
+
// // subWin.loadFile(`${dest}.html`, {
|
|
445
|
+
// // query: {
|
|
446
|
+
// // requesting: encodeURIComponent(webArgz),
|
|
447
|
+
// // },
|
|
448
|
+
// // });
|
|
449
|
+
|
|
450
|
+
// // if (!fs.existsSync(destFolder)) {
|
|
451
|
+
// // fs.mkdirSync(destFolder, { recursive: true });
|
|
452
|
+
// // }
|
|
453
|
+
// // const stdout = fs.createWriteStream(`${destFolder}/stdout.log`);
|
|
454
|
+
|
|
455
|
+
// // subWin.webContents.on(
|
|
456
|
+
// // "console-message",
|
|
457
|
+
// // (event, level, message, line, sourceId) => {
|
|
458
|
+
// // stdout.write(
|
|
459
|
+
// // JSON.stringify(
|
|
460
|
+
// // {
|
|
461
|
+
// // event,
|
|
462
|
+
// // level,
|
|
463
|
+
// // message: JSON.stringify(message),
|
|
464
|
+
// // line,
|
|
465
|
+
// // sourceId,
|
|
466
|
+
// // },
|
|
467
|
+
// // null,
|
|
468
|
+
// // 2
|
|
469
|
+
// // )
|
|
470
|
+
// // );
|
|
471
|
+
// // stdout.write("\n");
|
|
472
|
+
// // }
|
|
473
|
+
// // );
|
|
474
|
+
// // subWin.on("closed", () => {
|
|
475
|
+
// // stdout.close();
|
|
476
|
+
// // console.log(`ending web ${t}`);
|
|
477
|
+
// // // childProcesses[t] = "done";
|
|
478
|
+
// // onDone(t);
|
|
479
|
+
// // });
|
|
480
|
+
// // ipcMain.on("message", (message, data) => {
|
|
481
|
+
// // console.log("ipcMain message: " + JSON.stringify(data));
|
|
482
|
+
// // // process.exit();
|
|
483
|
+
// // });
|
|
484
|
+
// };
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// class PuppetMasterServer extends AbstractPuppetMaster {
|
|
488
|
+
// // constructor(...z: []) {
|
|
489
|
+
// // super(...z);
|
|
490
|
+
// // }
|
|
491
|
+
// // // pages(): Promise<Page[]>;
|
|
492
|
+
// // pages(): Promise<Page[]> {
|
|
493
|
+
// // return new Promise<Page[]>((res, rej) => {
|
|
494
|
+
// // res(super.pages());
|
|
495
|
+
// // });
|
|
496
|
+
// // }
|
|
497
|
+
// }
|
package/src/Project.ts
CHANGED
|
@@ -109,6 +109,25 @@ export class ITProject {
|
|
|
109
109
|
|
|
110
110
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
111
111
|
|
|
112
|
+
// nodeEntryPoints.forEach((nep) => {
|
|
113
|
+
// const f = `${process.cwd()}/${nep}`;
|
|
114
|
+
// console.log("nep", f);
|
|
115
|
+
// import(f).then((module) => {
|
|
116
|
+
// return module.default.then((defaultModule) => {
|
|
117
|
+
// console.log("defaultModule", defaultModule);
|
|
118
|
+
// // defaultModule
|
|
119
|
+
// // .receiveTestResourceConfig(argz)
|
|
120
|
+
// // .then((x) => {
|
|
121
|
+
// // console.log("then", x);
|
|
122
|
+
// // return x;
|
|
123
|
+
// // })
|
|
124
|
+
// // .catch((e) => {
|
|
125
|
+
// // console.log("catch", e);
|
|
126
|
+
// // });
|
|
127
|
+
// });
|
|
128
|
+
// });
|
|
129
|
+
// });
|
|
130
|
+
|
|
112
131
|
glob(`./${config.outdir}/chunk-*.mjs`, { ignore: "node_modules/**" }).then(
|
|
113
132
|
(chunks) => {
|
|
114
133
|
chunks.forEach((chunk) => {
|
|
@@ -213,8 +232,8 @@ const getRunnables = (
|
|
|
213
232
|
pt[1].add(cv[0]);
|
|
214
233
|
}
|
|
215
234
|
|
|
216
|
-
if (cv[
|
|
217
|
-
getRunnables(cv[
|
|
235
|
+
if (cv[3].length) {
|
|
236
|
+
getRunnables(cv[3], payload);
|
|
218
237
|
}
|
|
219
238
|
|
|
220
239
|
return pt;
|
package/src/Puppeteer.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import readline from "readline";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { jsonc } from "jsonc";
|
|
5
|
+
import { v4 as uuidv4 } from "uuid";
|
|
6
|
+
|
|
7
|
+
import { IBuiltConfig, IRunTime } from "./lib/types";
|
|
8
|
+
|
|
9
|
+
import { PM_Main } from "./PM/main.js";
|
|
10
|
+
|
|
11
|
+
var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
12
|
+
|
|
13
|
+
const node2web: Record<string, string[]> = {};
|
|
14
|
+
const web2node: Record<string, string[]> = {};
|
|
15
|
+
const childProcesses: Record<string, "loaded" | "running" | "done"> = {};
|
|
16
|
+
|
|
17
|
+
readline.emitKeypressEvents(process.stdin);
|
|
18
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
19
|
+
|
|
20
|
+
console.log("\n Puppeteer is running. Press 'q' to quit\n");
|
|
21
|
+
process.stdin.on("keypress", (str, key) => {
|
|
22
|
+
if (key.name === "q") {
|
|
23
|
+
process.exit();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const main = async () => {
|
|
28
|
+
const configs = jsonc.parse(
|
|
29
|
+
(await fs.readFileSync("./docs/testeranto.json")).toString()
|
|
30
|
+
) as IBuiltConfig;
|
|
31
|
+
|
|
32
|
+
const pm = new PM_Main(configs);
|
|
33
|
+
|
|
34
|
+
await pm.startPuppeteer(
|
|
35
|
+
{
|
|
36
|
+
waitForInitialPage: false,
|
|
37
|
+
executablePath: "/opt/homebrew/bin/chromium",
|
|
38
|
+
headless: true,
|
|
39
|
+
dumpio: true,
|
|
40
|
+
args: [
|
|
41
|
+
"--allow-file-access-from-files",
|
|
42
|
+
"--allow-running-insecure-content",
|
|
43
|
+
"--auto-open-devtools-for-tabs",
|
|
44
|
+
"--disable-dev-shm-usage",
|
|
45
|
+
"--disable-extensions",
|
|
46
|
+
"--disable-gpu",
|
|
47
|
+
"--disable-setuid-sandbox",
|
|
48
|
+
"--disable-site-isolation-trials",
|
|
49
|
+
"--disable-web-security",
|
|
50
|
+
"--disable-web-security",
|
|
51
|
+
"--no-first-run",
|
|
52
|
+
"--no-sandbox",
|
|
53
|
+
"--no-startup-window",
|
|
54
|
+
// "--no-zygote",
|
|
55
|
+
"--reduce-security-for-testing",
|
|
56
|
+
"--remote-allow-origins=*",
|
|
57
|
+
"--unsafely-treat-insecure-origin-as-secure=*",
|
|
58
|
+
// "--disable-features=IsolateOrigins",
|
|
59
|
+
// "--remote-allow-origins=ws://localhost:3234",
|
|
60
|
+
// "--single-process",
|
|
61
|
+
// "--unsafely-treat-insecure-origin-as-secure",
|
|
62
|
+
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
63
|
+
`--remote-debugging-port=3234`,
|
|
64
|
+
|
|
65
|
+
// "--disk-cache-dir=/dev/null",
|
|
66
|
+
// "--disk-cache-size=1",
|
|
67
|
+
// "--start-maximized",
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
"."
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const destinationOfRuntime = (f: string, r: IRunTime) => {
|
|
74
|
+
return path
|
|
75
|
+
.normalize(`${configs.buildDir}/${r}/${f}`)
|
|
76
|
+
.split(".")
|
|
77
|
+
.slice(0, -1)
|
|
78
|
+
.join(".");
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
82
|
+
if (runtime === "node") {
|
|
83
|
+
pm.launchNode(test, destinationOfRuntime(test, "node"));
|
|
84
|
+
} else if (runtime === "web") {
|
|
85
|
+
pm.launchWeb(test, destinationOfRuntime(test, "web"));
|
|
86
|
+
} else {
|
|
87
|
+
console.error("runtime makes no sense", runtime);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
console.log("ready and watching for changes...", configs.buildDir);
|
|
92
|
+
fs.watch(
|
|
93
|
+
configs.buildDir,
|
|
94
|
+
{
|
|
95
|
+
recursive: true,
|
|
96
|
+
},
|
|
97
|
+
(eventType, changedFile) => {
|
|
98
|
+
if (changedFile) {
|
|
99
|
+
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
100
|
+
if (eventType === "change" || eventType === "rename") {
|
|
101
|
+
if (
|
|
102
|
+
changedFile ===
|
|
103
|
+
test
|
|
104
|
+
.replace("./", "node/")
|
|
105
|
+
.split(".")
|
|
106
|
+
.slice(0, -1)
|
|
107
|
+
.concat("mjs")
|
|
108
|
+
.join(".")
|
|
109
|
+
) {
|
|
110
|
+
pm.launchNode(test, destinationOfRuntime(test, "node"));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (
|
|
114
|
+
changedFile ===
|
|
115
|
+
test
|
|
116
|
+
.replace("./", "web/")
|
|
117
|
+
.split(".")
|
|
118
|
+
.slice(0, -1)
|
|
119
|
+
.concat("mjs")
|
|
120
|
+
.join(".")
|
|
121
|
+
) {
|
|
122
|
+
pm.launchWeb(test, destinationOfRuntime(test, "web"));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
main();
|