testeranto 0.90.0 → 0.100.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/bundle.js +4 -7
- package/dist/common/src/Node.js +5 -3
- package/dist/common/src/PM/main.js +254 -126
- package/dist/common/src/PM/node.js +20 -5
- package/dist/common/src/PM/web.js +19 -4
- package/dist/common/src/SubPackages/puppeteer.js +1 -1
- package/dist/common/src/SubPackages/react/jsx/index.js +14 -6
- package/dist/common/src/SubPackages/react/jsx/node.js +2 -2
- package/dist/common/src/SubPackages/react-dom/component/web.js +13 -39
- package/dist/common/src/SubPackages/react-test-renderer/component/interface.js +2 -10
- package/dist/common/src/Web.js +25 -21
- package/dist/common/src/cli.js +439 -0
- package/dist/common/src/cli2.js +144 -0
- package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +18 -8
- package/dist/common/src/esbuildConfigs/node.js +1 -4
- package/dist/common/src/esbuildConfigs/web.js +1 -1
- package/dist/common/src/lib/abstractBase.js +31 -263
- package/dist/common/src/lib/basebuilder.js +1 -11
- package/dist/common/src/lib/classBuilder.js +1 -1
- package/dist/common/src/lib/core.js +8 -28
- package/dist/common/src/lib/types.js +1 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/Node.js +5 -3
- package/dist/module/src/PM/main.js +254 -126
- package/dist/module/src/PM/node.js +20 -5
- package/dist/module/src/PM/web.js +19 -4
- package/dist/module/src/SubPackages/puppeteer.js +1 -1
- package/dist/module/src/SubPackages/react/jsx/index.js +14 -6
- package/dist/module/src/SubPackages/react/jsx/node.js +2 -2
- package/dist/module/src/SubPackages/react-dom/component/web.js +13 -39
- package/dist/module/src/SubPackages/react-test-renderer/component/interface.js +2 -10
- package/dist/module/src/Web.js +25 -21
- package/dist/module/src/cli.js +411 -0
- package/dist/module/src/cli2.js +116 -0
- package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +18 -8
- package/dist/module/src/esbuildConfigs/node.js +1 -4
- package/dist/module/src/esbuildConfigs/web.js +1 -1
- package/dist/module/src/lib/abstractBase.js +31 -263
- package/dist/module/src/lib/basebuilder.js +1 -11
- package/dist/module/src/lib/classBuilder.js +1 -1
- package/dist/module/src/lib/core.js +8 -28
- package/dist/module/src/lib/types.js +1 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/cli.mjs +1491 -0
- package/dist/prebuild/{run-tests.mjs → cli2.mjs} +223 -212
- package/dist/types/src/Node.d.ts +6 -3
- package/dist/types/src/PM/index.d.ts +10 -2
- package/dist/types/src/PM/main.d.ts +14 -7
- package/dist/types/src/PM/node.d.ts +9 -2
- package/dist/types/src/PM/web.d.ts +9 -3
- package/dist/types/src/SubPackages/puppeteer.d.ts +1 -1
- package/dist/types/src/SubPackages/react/component/node.d.ts +1 -1
- package/dist/types/src/SubPackages/react/component/web.d.ts +1 -1
- package/dist/types/src/SubPackages/react/jsx/node.d.ts +3 -3
- package/dist/types/src/SubPackages/react/jsx/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-dom/component/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/src/SubPackages/react-dom/jsx/node.d.ts +1 -1
- package/dist/types/src/SubPackages/react-dom/jsx/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +1 -1
- package/dist/types/src/SubPackages/react-test-renderer/component/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/component/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/fc/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/fc/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx/node.d.ts +3 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx/web.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/node.d.ts +2 -2
- package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/web.d.ts +2 -2
- package/dist/types/src/Types.d.ts +60 -21
- package/dist/types/src/Web.d.ts +3 -3
- package/dist/types/src/lib/abstractBase.d.ts +6 -2
- package/dist/types/src/lib/core.d.ts +3 -3
- package/dist/types/src/lib/index.d.ts +1 -1
- package/dist/types/src/lib/types.d.ts +6 -30
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +23 -20
- package/src/Node.ts +6 -3
- package/src/PM/index.ts +12 -8
- package/src/PM/main.ts +331 -165
- package/src/PM/node.ts +42 -7
- package/src/PM/web.ts +33 -5
- package/src/SubPackages/puppeteer.ts +1 -1
- package/src/SubPackages/react/jsx/index.ts +15 -7
- package/src/SubPackages/react/jsx/node.ts +18 -6
- package/src/SubPackages/react-dom/component/web.ts +28 -51
- package/src/SubPackages/react-test-renderer/component/interface.ts +4 -11
- package/src/SubPackages/react-test-renderer/jsx/node.ts +16 -1
- package/src/Types.ts +362 -114
- package/src/Web.ts +45 -23
- package/src/cli.ts +535 -0
- package/src/cli2.ts +157 -0
- package/src/esbuildConfigs/inputFilesPlugin.ts +27 -9
- package/src/esbuildConfigs/node.ts +4 -7
- package/src/esbuildConfigs/web.ts +4 -3
- package/src/lib/abstractBase.ts +84 -291
- package/src/lib/basebuilder.ts +1 -12
- package/src/lib/classBuilder.ts +2 -1
- package/src/lib/core.ts +17 -29
- package/src/lib/types.ts +5 -177
- package/dist/common/src/Aider.js +0 -143
- package/dist/common/src/Project.js +0 -225
- package/dist/common/src/Puppeteer.js +0 -113
- package/dist/common/src/build-tests.js +0 -39
- package/dist/common/src/esbuildConfigs/features.js +0 -14
- package/dist/common/src/esbuildConfigs/report.js +0 -14
- package/dist/common/src/esbuildConfigs/tests.js +0 -13
- package/dist/common/src/run-tests.js +0 -39
- package/dist/module/src/Aider.js +0 -136
- package/dist/module/src/Project.js +0 -218
- package/dist/module/src/Puppeteer.js +0 -108
- package/dist/module/src/build-tests.js +0 -11
- package/dist/module/src/esbuildConfigs/features.js +0 -12
- package/dist/module/src/esbuildConfigs/report.js +0 -14
- package/dist/module/src/esbuildConfigs/tests.js +0 -11
- package/dist/module/src/run-tests.js +0 -11
- package/dist/prebuild/build-tests.mjs +0 -552
- package/dist/types/src/Aider.d.ts +0 -1
- package/dist/types/src/Project.d.ts +0 -12
- package/dist/types/src/Puppeteer.d.ts +0 -2
- package/dist/types/src/esbuildConfigs/features.d.ts +0 -4
- package/dist/types/src/esbuildConfigs/report.d.ts +0 -0
- package/dist/types/src/esbuildConfigs/tests.d.ts +0 -4
- package/src/Aider.ts +0 -168
- package/src/Project.ts +0 -291
- package/src/Puppeteer.ts +0 -145
- package/src/build-tests.ts +0 -12
- package/src/esbuildConfigs/features.ts +0 -17
- package/src/esbuildConfigs/report.ts +0 -15
- package/src/esbuildConfigs/tests.ts +0 -14
- package/src/run-tests.ts +0 -12
- /package/dist/types/src/{build-tests.d.ts → cli.d.ts} +0 -0
- /package/dist/types/src/{run-tests.d.ts → cli2.d.ts} +0 -0
package/bundle.js
CHANGED
|
@@ -18,13 +18,11 @@ await esbuild.build({
|
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
await esbuild.build({
|
|
21
|
-
entryPoints: ['src/
|
|
21
|
+
entryPoints: ['src/cli.ts'],
|
|
22
22
|
bundle: true,
|
|
23
23
|
format: "esm",
|
|
24
24
|
platform: "node",
|
|
25
|
-
|
|
26
|
-
outfile: 'dist/prebuild/build-tests.mjs',
|
|
27
|
-
// external: ['crypto', 'os'],
|
|
25
|
+
outfile: 'dist/prebuild/cli.mjs',
|
|
28
26
|
packages: "external",
|
|
29
27
|
supported: {
|
|
30
28
|
"dynamic-import": true,
|
|
@@ -36,12 +34,11 @@ await esbuild.build({
|
|
|
36
34
|
})
|
|
37
35
|
|
|
38
36
|
await esbuild.build({
|
|
39
|
-
entryPoints: ['src/
|
|
37
|
+
entryPoints: ['src/cli2.ts'],
|
|
40
38
|
bundle: true,
|
|
41
39
|
format: "esm",
|
|
42
40
|
platform: "node",
|
|
43
|
-
|
|
44
|
-
outfile: 'dist/prebuild/run-tests.mjs',
|
|
41
|
+
outfile: 'dist/prebuild/cli2.mjs',
|
|
45
42
|
packages: "external",
|
|
46
43
|
supported: {
|
|
47
44
|
"dynamic-import": true,
|
package/dist/common/src/Node.js
CHANGED
|
@@ -9,14 +9,16 @@ const index_js_1 = require("./lib/index.js");
|
|
|
9
9
|
const node_js_1 = require("./PM/node.js");
|
|
10
10
|
class NodeTesteranto extends core_js_1.default {
|
|
11
11
|
constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
|
|
12
|
-
super(input, testSpecification, testImplementation, testResourceRequirement, testInterface)
|
|
12
|
+
super(input, testSpecification, testImplementation, testResourceRequirement, testInterface, () => {
|
|
13
|
+
// no-op
|
|
14
|
+
});
|
|
13
15
|
}
|
|
14
16
|
async receiveTestResourceConfig(partialTestResource) {
|
|
15
17
|
const t = JSON.parse(partialTestResource);
|
|
16
18
|
const pm = new node_js_1.PM_Node(t);
|
|
17
19
|
const { failed, artifacts, logPromise, features } = await this.testJobs[0].receiveTestResourceConfig(pm);
|
|
18
|
-
pm.customclose();
|
|
19
|
-
return features;
|
|
20
|
+
// pm.customclose();
|
|
21
|
+
return { features, failed };
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
exports.NodeTesteranto = NodeTesteranto;
|
|
@@ -32,11 +32,22 @@ const path_1 = __importDefault(require("path"));
|
|
|
32
32
|
const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
|
|
33
33
|
const crypto_1 = __importDefault(require("crypto"));
|
|
34
34
|
const index_js_1 = require("./index.js");
|
|
35
|
-
const utils_js_1 = require("../utils.js");
|
|
36
35
|
const fileStreams3 = [];
|
|
37
36
|
const fPaths = [];
|
|
38
37
|
const files = {};
|
|
38
|
+
const recorders = {};
|
|
39
39
|
const screenshots = {};
|
|
40
|
+
const red = "\x1b[31m";
|
|
41
|
+
const green = "\x1b[32m";
|
|
42
|
+
const reset = "\x1b[0m"; // Resets to default color
|
|
43
|
+
const statusMessagePretty = (failures, test) => {
|
|
44
|
+
if (failures === 0) {
|
|
45
|
+
console.log(green + `${test} completed successfully` + reset);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.log(red + `${test} failed ${failures} times` + reset);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
40
51
|
class PM_Main extends index_js_1.PM {
|
|
41
52
|
constructor(configs) {
|
|
42
53
|
super();
|
|
@@ -62,7 +73,7 @@ class PM_Main extends index_js_1.PM {
|
|
|
62
73
|
}
|
|
63
74
|
};
|
|
64
75
|
this.launchNode = async (src, dest) => {
|
|
65
|
-
console.log("
|
|
76
|
+
console.log("! node", src);
|
|
66
77
|
this.register(src);
|
|
67
78
|
const destFolder = dest.replace(".mjs", "");
|
|
68
79
|
let argz = "";
|
|
@@ -109,26 +120,42 @@ class PM_Main extends index_js_1.PM {
|
|
|
109
120
|
console.error("negative port makes no sense", src);
|
|
110
121
|
process.exit(-1);
|
|
111
122
|
}
|
|
112
|
-
const builtfile = dest
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
const builtfile = dest;
|
|
124
|
+
const webSideCares = [];
|
|
125
|
+
// await Promise.all(
|
|
126
|
+
// testConfig[3].map(async (sidecar) => {
|
|
127
|
+
// if (sidecar[1] === "web") {
|
|
128
|
+
// const s = await this.launchWebSideCar(
|
|
129
|
+
// sidecar[0],
|
|
130
|
+
// destinationOfRuntime(sidecar[0], "web", this.configs),
|
|
131
|
+
// sidecar
|
|
132
|
+
// );
|
|
133
|
+
// webSideCares.push(s);
|
|
134
|
+
// return s;
|
|
135
|
+
// }
|
|
136
|
+
// if (sidecar[1] === "node") {
|
|
137
|
+
// return this.launchNodeSideCar(
|
|
138
|
+
// sidecar[0],
|
|
139
|
+
// destinationOfRuntime(sidecar[0], "node", this.configs),
|
|
140
|
+
// sidecar
|
|
141
|
+
// );
|
|
142
|
+
// }
|
|
143
|
+
// })
|
|
144
|
+
// );
|
|
121
145
|
this.server[builtfile] = await Promise.resolve().then(() => __importStar(require(`${builtfile}?cacheBust=${Date.now()}`))).then((module) => {
|
|
122
146
|
return module.default.then((defaultModule) => {
|
|
123
147
|
defaultModule
|
|
124
148
|
.receiveTestResourceConfig(argz)
|
|
125
|
-
.then(async (features) => {
|
|
126
|
-
this.receiveFeatures(features, destFolder);
|
|
149
|
+
.then(async ({ features, failed }) => {
|
|
150
|
+
this.receiveFeatures(features, destFolder, src);
|
|
151
|
+
// console.log(`${src} completed with ${failed} errors`);
|
|
152
|
+
statusMessagePretty(failed, src);
|
|
127
153
|
})
|
|
128
154
|
.catch((e) => {
|
|
129
|
-
console.log(
|
|
155
|
+
console.log(`${src} errored with`, e);
|
|
130
156
|
})
|
|
131
157
|
.finally(() => {
|
|
158
|
+
webSideCares.forEach((webSideCar) => webSideCar.close());
|
|
132
159
|
this.deregister(src);
|
|
133
160
|
});
|
|
134
161
|
});
|
|
@@ -144,18 +171,12 @@ class PM_Main extends index_js_1.PM {
|
|
|
144
171
|
const d = dest + ".mjs";
|
|
145
172
|
console.log("launchWebSideCar", src, dest, d);
|
|
146
173
|
const destFolder = dest.replace(".mjs", "");
|
|
147
|
-
const webArgz = JSON.stringify({
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
153
|
-
// files[src] = new Set();
|
|
154
|
-
// const evaluation = `
|
|
155
|
-
// console.log("importing ${dest}.mjs");
|
|
156
|
-
// import('${dest}.mjs').then(async (x) => {
|
|
157
|
-
// console.log("imported", x.default);
|
|
158
|
-
// })`;
|
|
174
|
+
// const webArgz = JSON.stringify({
|
|
175
|
+
// name: dest,
|
|
176
|
+
// ports: [].toString(),
|
|
177
|
+
// fs: destFolder,
|
|
178
|
+
// browserWSEndpoint: this.browser.wsEndpoint(),
|
|
179
|
+
// });
|
|
159
180
|
const fileStreams2 = [];
|
|
160
181
|
const doneFileStream2 = [];
|
|
161
182
|
return new Promise((res, rej) => {
|
|
@@ -234,14 +255,17 @@ class PM_Main extends index_js_1.PM {
|
|
|
234
255
|
page.exposeFunction("end", async (uid) => {
|
|
235
256
|
return fileStreams2[uid].end();
|
|
236
257
|
});
|
|
237
|
-
page.exposeFunction("customclose", (p, testName) => {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
258
|
+
// page.exposeFunction("customclose", (p: string, testName: string) => {
|
|
259
|
+
// fs.writeFileSync(
|
|
260
|
+
// p + "/manifest.json",
|
|
261
|
+
// JSON.stringify(Array.from(files[testName]))
|
|
262
|
+
// );
|
|
263
|
+
// delete files[testName];
|
|
264
|
+
// Promise.all(screenshots[testName] || []).then(() => {
|
|
265
|
+
// delete screenshots[testName];
|
|
266
|
+
// // page.close();
|
|
267
|
+
// });
|
|
268
|
+
// });
|
|
245
269
|
return page;
|
|
246
270
|
})
|
|
247
271
|
.then(async (page) => {
|
|
@@ -321,14 +345,18 @@ class PM_Main extends index_js_1.PM {
|
|
|
321
345
|
}
|
|
322
346
|
}
|
|
323
347
|
};
|
|
324
|
-
this.launchWeb = (t, dest
|
|
325
|
-
console.log("
|
|
348
|
+
this.launchWeb = (t, dest) => {
|
|
349
|
+
console.log("! web", t);
|
|
326
350
|
this.register(t);
|
|
327
|
-
sidecars.map((sidecar) => {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
351
|
+
// sidecars.map((sidecar) => {
|
|
352
|
+
// if (sidecar[1] === "node") {
|
|
353
|
+
// return this.launchNodeSideCar(
|
|
354
|
+
// sidecar[0],
|
|
355
|
+
// destinationOfRuntime(sidecar[0], "node", this.configs),
|
|
356
|
+
// sidecar
|
|
357
|
+
// );
|
|
358
|
+
// }
|
|
359
|
+
// });
|
|
332
360
|
const destFolder = dest.replace(".mjs", "");
|
|
333
361
|
const webArgz = JSON.stringify({
|
|
334
362
|
name: dest,
|
|
@@ -336,9 +364,10 @@ class PM_Main extends index_js_1.PM {
|
|
|
336
364
|
fs: destFolder,
|
|
337
365
|
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
338
366
|
});
|
|
367
|
+
const d = `${dest}?cacheBust=${Date.now()}`;
|
|
339
368
|
const evaluation = `
|
|
340
|
-
console.log("importing ${
|
|
341
|
-
import('${
|
|
369
|
+
console.log("importing ${d}");
|
|
370
|
+
import('${d}').then(async (x) => {
|
|
342
371
|
console.log("imported", (await x.default));
|
|
343
372
|
try {
|
|
344
373
|
return await (await x.default).receiveTestResourceConfig(${webArgz})
|
|
@@ -348,8 +377,8 @@ class PM_Main extends index_js_1.PM {
|
|
|
348
377
|
})`;
|
|
349
378
|
const fileStreams2 = [];
|
|
350
379
|
const doneFileStream2 = [];
|
|
351
|
-
const stdoutStream = fs_1.default.createWriteStream(`${
|
|
352
|
-
const stderrStream = fs_1.default.createWriteStream(`${
|
|
380
|
+
const stdoutStream = fs_1.default.createWriteStream(`${destFolder}/stdout.log`);
|
|
381
|
+
const stderrStream = fs_1.default.createWriteStream(`${destFolder}/stderr.log`);
|
|
353
382
|
this.browser
|
|
354
383
|
.newPage()
|
|
355
384
|
.then((page) => {
|
|
@@ -397,20 +426,21 @@ class PM_Main extends index_js_1.PM {
|
|
|
397
426
|
// page.evaluate(`window["screenshot done"]`);
|
|
398
427
|
});
|
|
399
428
|
page.exposeFunction("writeFileSync", (fp, contents, testName) => {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
429
|
+
return globalThis["writeFileSync"](fp, contents, testName);
|
|
430
|
+
// const dir = path.dirname(fp);
|
|
431
|
+
// fs.mkdirSync(dir, {
|
|
432
|
+
// recursive: true,
|
|
433
|
+
// });
|
|
434
|
+
// const p = new Promise<string>(async (res, rej) => {
|
|
435
|
+
// fs.writeFileSync(fp, contents);
|
|
436
|
+
// res(fp);
|
|
437
|
+
// });
|
|
438
|
+
// doneFileStream2.push(p);
|
|
439
|
+
// if (!files[testName]) {
|
|
440
|
+
// files[testName] = new Set();
|
|
441
|
+
// }
|
|
442
|
+
// files[testName].add(fp);
|
|
443
|
+
// return p;
|
|
414
444
|
});
|
|
415
445
|
page.exposeFunction("existsSync", (fp, contents) => {
|
|
416
446
|
return fs_1.default.existsSync(fp);
|
|
@@ -445,36 +475,37 @@ class PM_Main extends index_js_1.PM {
|
|
|
445
475
|
page.exposeFunction("end", async (uid) => {
|
|
446
476
|
return fileStreams2[uid].end();
|
|
447
477
|
});
|
|
448
|
-
page.exposeFunction("customclose", (p, testName) => {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
+
// page.exposeFunction("customclose", (p: string, testName: string) => {
|
|
479
|
+
// // console.log("closing", p);
|
|
480
|
+
// console.log("\t GOODBYE customclose");
|
|
481
|
+
// fs.writeFileSync(
|
|
482
|
+
// p + "/manifest.json",
|
|
483
|
+
// JSON.stringify(Array.from(files[testName]))
|
|
484
|
+
// );
|
|
485
|
+
// delete files[testName];
|
|
486
|
+
// // console.log("screenshots[testName]", screenshots[testName]);
|
|
487
|
+
// Promise.all(screenshots[testName] || []).then(() => {
|
|
488
|
+
// delete screenshots[testName];
|
|
489
|
+
// });
|
|
490
|
+
// // globalThis["writeFileSync"](
|
|
491
|
+
// // p + "/manifest.json",
|
|
492
|
+
// // // files.entries()
|
|
493
|
+
// // JSON.stringify(Array.from(files[testName]))
|
|
494
|
+
// // );
|
|
495
|
+
// // console.log("closing doneFileStream2", doneFileStream2);
|
|
496
|
+
// // console.log("closing doneFileStream2", doneFileStream2);
|
|
497
|
+
// // Promise.all([...doneFileStream2, ...screenshots2]).then(() => {
|
|
498
|
+
// // page.close();
|
|
499
|
+
// // });
|
|
500
|
+
// // Promise.all(screenshots).then(() => {
|
|
501
|
+
// // page.close();
|
|
502
|
+
// // });
|
|
503
|
+
// // setTimeout(() => {
|
|
504
|
+
// // console.log("Delayed for 1 second.");
|
|
505
|
+
// // page.close();
|
|
506
|
+
// // }, 5000);
|
|
507
|
+
// // return page.close();
|
|
508
|
+
// });
|
|
478
509
|
page.exposeFunction("page", () => {
|
|
479
510
|
return page.mainFrame()._id;
|
|
480
511
|
});
|
|
@@ -507,12 +538,19 @@ class PM_Main extends index_js_1.PM {
|
|
|
507
538
|
})
|
|
508
539
|
.then(async (page) => {
|
|
509
540
|
const close = () => {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
541
|
+
if (!files[t]) {
|
|
542
|
+
files[t] = new Set();
|
|
543
|
+
}
|
|
544
|
+
// files[t].add(filepath);
|
|
545
|
+
fs_1.default.writeFileSync(destFolder + "/manifest.json", JSON.stringify(Array.from(files[t])));
|
|
546
|
+
delete files[t];
|
|
547
|
+
Promise.all(screenshots[t] || []).then(() => {
|
|
548
|
+
delete screenshots[t];
|
|
549
|
+
page.close();
|
|
550
|
+
this.deregister(t);
|
|
551
|
+
stderrStream.close();
|
|
552
|
+
stdoutStream.close();
|
|
553
|
+
});
|
|
516
554
|
};
|
|
517
555
|
page.on("pageerror", (err) => {
|
|
518
556
|
console.debug(`Error from ${t}: [${err.name}] `);
|
|
@@ -539,29 +577,25 @@ class PM_Main extends index_js_1.PM {
|
|
|
539
577
|
stdoutStream.write(JSON.stringify(log.location()));
|
|
540
578
|
stdoutStream.write(JSON.stringify(log.stackTrace()));
|
|
541
579
|
});
|
|
542
|
-
await page.goto(`file://${`${
|
|
580
|
+
await page.goto(`file://${`${destFolder}.html`}`, {});
|
|
543
581
|
await page
|
|
544
582
|
.evaluate(evaluation)
|
|
545
|
-
.then(async (features) => {
|
|
546
|
-
this.receiveFeatures(features, destFolder);
|
|
583
|
+
.then(async ({ failed, features }) => {
|
|
584
|
+
this.receiveFeatures(features, destFolder, t);
|
|
585
|
+
// console.log(`${t} completed with ${failed} errors`);
|
|
586
|
+
statusMessagePretty(failed, t);
|
|
547
587
|
})
|
|
548
588
|
.catch((e) => {
|
|
549
|
-
console.log(
|
|
550
|
-
console.log(e);
|
|
589
|
+
console.log(`${t} errored with`, e);
|
|
551
590
|
})
|
|
552
591
|
.finally(() => {
|
|
553
592
|
close();
|
|
554
|
-
// console.log("evaluation complete.", dest);
|
|
555
|
-
// page.close();
|
|
556
|
-
// this.deregister(t);
|
|
557
|
-
// stderrStream.close();
|
|
558
|
-
// stdoutStream.close();
|
|
559
593
|
});
|
|
560
594
|
return page;
|
|
561
595
|
});
|
|
562
596
|
};
|
|
563
|
-
this.receiveFeatures = (features, destFolder) => {
|
|
564
|
-
|
|
597
|
+
this.receiveFeatures = (features, destFolder, srcTest) => {
|
|
598
|
+
const featureDestination = path_1.default.resolve(process.cwd(), "docs", "features", "strings", srcTest.split(".").slice(0, -1).join(".") + ".features.txt");
|
|
565
599
|
features
|
|
566
600
|
.reduce(async (mm, featureStringKey) => {
|
|
567
601
|
const accum = await mm;
|
|
@@ -588,24 +622,33 @@ class PM_Main extends index_js_1.PM {
|
|
|
588
622
|
// console.log("Symlink created successfully");
|
|
589
623
|
}
|
|
590
624
|
});
|
|
591
|
-
accum.push(newPath);
|
|
625
|
+
accum.files.push(newPath);
|
|
592
626
|
}
|
|
593
627
|
else if (u.protocol === "http:" || u.protocol === "https:") {
|
|
594
628
|
const newPath = `${process.cwd()}/docs/features/external${u.hostname}${u.pathname}`;
|
|
595
629
|
const body = await this.configs.featureIngestor(featureStringKey);
|
|
596
630
|
writeFileAndCreateDir(newPath, body);
|
|
597
|
-
accum.push(newPath);
|
|
631
|
+
accum.files.push(newPath);
|
|
598
632
|
}
|
|
599
633
|
}
|
|
600
634
|
else {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
635
|
+
await fs_1.default.promises.mkdir(path_1.default.dirname(featureDestination), {
|
|
636
|
+
recursive: true,
|
|
637
|
+
});
|
|
638
|
+
// const newPath = `${process.cwd()}/docs/features/plain/${await sha256(
|
|
639
|
+
// featureStringKey
|
|
640
|
+
// )}`;
|
|
641
|
+
// writeFileAndCreateDir(
|
|
642
|
+
// `${featureDestination}/${await sha256(featureStringKey)}`,
|
|
643
|
+
// featureStringKey
|
|
644
|
+
// );
|
|
645
|
+
accum.strings.push(featureStringKey);
|
|
604
646
|
}
|
|
605
647
|
return accum;
|
|
606
|
-
}, Promise.resolve([]))
|
|
607
|
-
.then((
|
|
608
|
-
|
|
648
|
+
}, Promise.resolve({ files: [], strings: [] }))
|
|
649
|
+
.then(({ files, strings }) => {
|
|
650
|
+
// writeFileAndCreateDir(`${featureDestination}`, JSON.stringify(strings));
|
|
651
|
+
fs_1.default.writeFileSync(`${destFolder}/featurePrompt.txt`, files
|
|
609
652
|
.map((f) => {
|
|
610
653
|
return `/read ${f}`;
|
|
611
654
|
})
|
|
@@ -619,6 +662,33 @@ class PM_Main extends index_js_1.PM {
|
|
|
619
662
|
this.configs.ports.forEach((element) => {
|
|
620
663
|
this.ports[element] = "true"; // set ports as open
|
|
621
664
|
});
|
|
665
|
+
globalThis["waitForSelector"] = async (pageKey, sel) => {
|
|
666
|
+
console.log("waitForSelector", pageKey, sel);
|
|
667
|
+
const page = (await this.browser.pages()).find((p) => p.mainFrame()._id === pageKey);
|
|
668
|
+
await (page === null || page === void 0 ? void 0 : page.waitForSelector(sel));
|
|
669
|
+
};
|
|
670
|
+
globalThis["screencastStop"] = async (path) => {
|
|
671
|
+
return recorders[path].stop();
|
|
672
|
+
};
|
|
673
|
+
globalThis["closePage"] = async (pageKey) => {
|
|
674
|
+
const page = (await this.browser.pages()).find((p) => p.mainFrame()._id === pageKey);
|
|
675
|
+
return page.close();
|
|
676
|
+
};
|
|
677
|
+
// globalThis["closePage"] = (p) => {
|
|
678
|
+
// console.log("closePage", p);
|
|
679
|
+
// return p.close();
|
|
680
|
+
// };
|
|
681
|
+
globalThis["goto"] = async (pageKey, url) => {
|
|
682
|
+
const page = (await this.browser.pages()).find((p) => p.mainFrame()._id === pageKey);
|
|
683
|
+
await (page === null || page === void 0 ? void 0 : page.goto(url));
|
|
684
|
+
return;
|
|
685
|
+
};
|
|
686
|
+
globalThis["newPage"] = () => {
|
|
687
|
+
return this.browser.newPage();
|
|
688
|
+
};
|
|
689
|
+
globalThis["pages"] = () => {
|
|
690
|
+
return this.browser.pages();
|
|
691
|
+
};
|
|
622
692
|
globalThis["mkdirSync"] = (fp) => {
|
|
623
693
|
if (!fs_1.default.existsSync(fp)) {
|
|
624
694
|
return fs_1.default.mkdirSync(fp, {
|
|
@@ -628,12 +698,14 @@ class PM_Main extends index_js_1.PM {
|
|
|
628
698
|
return false;
|
|
629
699
|
};
|
|
630
700
|
globalThis["writeFileSync"] = (filepath, contents, testName) => {
|
|
631
|
-
// console.log("
|
|
701
|
+
// console.log(testName, "writeFileSync", filepath, testName);
|
|
632
702
|
// Create directories if they don't exist
|
|
633
|
-
const dir = path_1.default.dirname(filepath
|
|
703
|
+
const dir = path_1.default.dirname(filepath);
|
|
704
|
+
// console.log(testName, "mkdirSync", dir);
|
|
634
705
|
fs_1.default.mkdirSync(dir, {
|
|
635
706
|
recursive: true,
|
|
636
707
|
});
|
|
708
|
+
// console.log(testName, "mkdirSync2");
|
|
637
709
|
if (!files[testName]) {
|
|
638
710
|
files[testName] = new Set();
|
|
639
711
|
}
|
|
@@ -656,7 +728,31 @@ class PM_Main extends index_js_1.PM {
|
|
|
656
728
|
globalThis["end"] = (uid) => {
|
|
657
729
|
fileStreams3[uid].end();
|
|
658
730
|
};
|
|
659
|
-
|
|
731
|
+
// async (ssOpts: ScreenshotOptions, testName: string) => {
|
|
732
|
+
// const p = ssOpts.path as string;
|
|
733
|
+
// const dir = path.dirname(p);
|
|
734
|
+
// fs.mkdirSync(dir, {
|
|
735
|
+
// recursive: true,
|
|
736
|
+
// });
|
|
737
|
+
// if (!files[testName]) {
|
|
738
|
+
// files[testName] = new Set();
|
|
739
|
+
// }
|
|
740
|
+
// files[testName].add(ssOpts.path as string);
|
|
741
|
+
// const sPromise = page.screenshot({
|
|
742
|
+
// ...ssOpts,
|
|
743
|
+
// path: p,
|
|
744
|
+
// });
|
|
745
|
+
// if (!screenshots[testName]) {
|
|
746
|
+
// screenshots[testName] = [];
|
|
747
|
+
// }
|
|
748
|
+
// screenshots[testName].push(sPromise);
|
|
749
|
+
// // sPromise.then(())
|
|
750
|
+
// await sPromise;
|
|
751
|
+
// return sPromise;
|
|
752
|
+
// // page.evaluate(`window["screenshot done"]`);
|
|
753
|
+
// };
|
|
754
|
+
globalThis["customScreenShot"] = async (opts, pageKey, testName) => {
|
|
755
|
+
const page = (await this.browser.pages()).find((p) => p.mainFrame()._id === pageKey);
|
|
660
756
|
const p = opts.path;
|
|
661
757
|
const dir = path_1.default.dirname(p);
|
|
662
758
|
fs_1.default.mkdirSync(dir, {
|
|
@@ -674,13 +770,42 @@ class PM_Main extends index_js_1.PM {
|
|
|
674
770
|
await sPromise;
|
|
675
771
|
return sPromise;
|
|
676
772
|
};
|
|
677
|
-
globalThis["
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
fs_1.default.
|
|
682
|
-
|
|
773
|
+
globalThis["screencast"] = async (opts, pageKey) => {
|
|
774
|
+
const page = (await this.browser.pages()).find((p) => p.mainFrame()._id === pageKey);
|
|
775
|
+
const p = opts.path;
|
|
776
|
+
const dir = path_1.default.dirname(p);
|
|
777
|
+
fs_1.default.mkdirSync(dir, {
|
|
778
|
+
recursive: true,
|
|
779
|
+
});
|
|
780
|
+
const recorder = await (page === null || page === void 0 ? void 0 : page.screencast(Object.assign(Object.assign({}, opts), { path: p })));
|
|
781
|
+
recorders[opts.path] = recorder;
|
|
782
|
+
return opts.path;
|
|
683
783
|
};
|
|
784
|
+
// globalThis["customclose"] = (p: string, testName: string) => {
|
|
785
|
+
// if (!files[testName]) {
|
|
786
|
+
// files[testName] = new Set();
|
|
787
|
+
// }
|
|
788
|
+
// fs.writeFileSync(
|
|
789
|
+
// p + "/manifest.json",
|
|
790
|
+
// JSON.stringify(Array.from(files[testName]))
|
|
791
|
+
// );
|
|
792
|
+
// delete files[testName];
|
|
793
|
+
// };
|
|
794
|
+
}
|
|
795
|
+
customclose() {
|
|
796
|
+
throw new Error("Method not implemented.");
|
|
797
|
+
}
|
|
798
|
+
waitForSelector(p, s) {
|
|
799
|
+
throw new Error("Method not implemented.");
|
|
800
|
+
}
|
|
801
|
+
closePage(p) {
|
|
802
|
+
throw new Error("Method not implemented.");
|
|
803
|
+
}
|
|
804
|
+
newPage() {
|
|
805
|
+
throw new Error("Method not implemented.");
|
|
806
|
+
}
|
|
807
|
+
goto(p, url) {
|
|
808
|
+
throw new Error("Method not implemented.");
|
|
684
809
|
}
|
|
685
810
|
$(selector) {
|
|
686
811
|
throw new Error("Method not implemented.");
|
|
@@ -688,7 +813,7 @@ class PM_Main extends index_js_1.PM {
|
|
|
688
813
|
screencast(opts) {
|
|
689
814
|
throw new Error("Method not implemented.");
|
|
690
815
|
}
|
|
691
|
-
customScreenShot(opts) {
|
|
816
|
+
customScreenShot(opts, cdpPage) {
|
|
692
817
|
throw new Error("Method not implemented.");
|
|
693
818
|
}
|
|
694
819
|
end(accessObject) {
|
|
@@ -773,6 +898,9 @@ class PM_Main extends index_js_1.PM {
|
|
|
773
898
|
isDisabled(selector) {
|
|
774
899
|
throw new Error("Method not implemented.");
|
|
775
900
|
}
|
|
901
|
+
screencastStop(s) {
|
|
902
|
+
throw new Error("Method not implemented.");
|
|
903
|
+
}
|
|
776
904
|
////////////////////////////////////////////////////////////////////////////////
|
|
777
905
|
async startPuppeteer(options, destfolder) {
|
|
778
906
|
this.browser = (await puppeteer_core_1.default.launch(options));
|
|
@@ -789,7 +917,7 @@ async function writeFileAndCreateDir(filePath, data) {
|
|
|
789
917
|
const dirPath = path_1.default.dirname(filePath);
|
|
790
918
|
try {
|
|
791
919
|
await fs_1.default.promises.mkdir(dirPath, { recursive: true });
|
|
792
|
-
await fs_1.default.
|
|
920
|
+
await fs_1.default.appendFileSync(filePath, data);
|
|
793
921
|
}
|
|
794
922
|
catch (error) {
|
|
795
923
|
console.error(`Error writing file: ${error}`);
|
|
@@ -14,10 +14,19 @@ class PM_Node extends index_js_1.PM {
|
|
|
14
14
|
this.server = {};
|
|
15
15
|
this.testResourceConfiguration = t;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
waitForSelector(p, s) {
|
|
18
|
+
return globalThis["waitForSelector"](p, s);
|
|
19
|
+
}
|
|
20
|
+
closePage(p) {
|
|
21
|
+
return globalThis["closePage"](p);
|
|
22
|
+
}
|
|
23
|
+
goto(cdpPage, url) {
|
|
24
|
+
return globalThis["goto"](cdpPage.mainFrame()._id, url);
|
|
19
25
|
}
|
|
20
|
-
|
|
26
|
+
newPage() {
|
|
27
|
+
return globalThis["newPage"]();
|
|
28
|
+
}
|
|
29
|
+
$(selector) {
|
|
21
30
|
throw new Error("Method not implemented.");
|
|
22
31
|
}
|
|
23
32
|
isDisabled(selector) {
|
|
@@ -41,8 +50,14 @@ class PM_Node extends index_js_1.PM {
|
|
|
41
50
|
click(selector) {
|
|
42
51
|
return globalThis["click"](selector);
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
return globalThis["
|
|
53
|
+
screencast(opts, page) {
|
|
54
|
+
return globalThis["screencast"](Object.assign(Object.assign({}, opts), { path: this.testResourceConfiguration.fs + "/" + opts.path }), page.mainFrame()._id, this.testResourceConfiguration.name);
|
|
55
|
+
}
|
|
56
|
+
screencastStop(p) {
|
|
57
|
+
return globalThis["screencastStop"](p);
|
|
58
|
+
}
|
|
59
|
+
customScreenShot(opts, cdpPage) {
|
|
60
|
+
return globalThis["customScreenShot"](Object.assign(Object.assign({}, opts), { path: this.testResourceConfiguration.fs + "/" + opts.path }), cdpPage.mainFrame()._id, this.testResourceConfiguration.name);
|
|
46
61
|
}
|
|
47
62
|
existsSync(destFolder) {
|
|
48
63
|
return globalThis["existsSync"](this.testResourceConfiguration.fs + "/" + destFolder);
|