testeranto 0.94.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/PM/main.js +160 -42
- package/dist/common/src/PM/node.js +20 -5
- package/dist/common/src/PM/web.js +19 -4
- package/dist/common/src/SubPackages/react/jsx/node.js +1 -6
- package/dist/common/src/cli.js +439 -0
- package/dist/common/src/cli2.js +144 -0
- package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +18 -6
- 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 +14 -91
- package/dist/common/src/lib/types.js +1 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/PM/main.js +160 -42
- package/dist/module/src/PM/node.js +20 -5
- package/dist/module/src/PM/web.js +19 -4
- package/dist/module/src/SubPackages/react/jsx/node.js +1 -6
- package/dist/module/src/cli.js +411 -0
- package/dist/module/src/cli2.js +116 -0
- package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +18 -6
- 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 +14 -91
- 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} +203 -156
- package/dist/types/src/Node.d.ts +2 -2
- package/dist/types/src/PM/index.d.ts +10 -2
- package/dist/types/src/PM/main.d.ts +13 -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/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 +2 -2
- package/dist/types/src/lib/index.d.ts +1 -1
- package/dist/types/src/lib/types.d.ts +2 -30
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +11 -8
- package/src/PM/index.ts +12 -8
- package/src/PM/main.ts +218 -62
- package/src/PM/node.ts +42 -7
- package/src/PM/web.ts +33 -5
- package/src/SubPackages/react/jsx/node.ts +16 -5
- package/src/SubPackages/react-test-renderer/jsx/node.ts +16 -1
- package/src/Types.ts +362 -114
- package/src/cli.ts +535 -0
- package/src/cli2.ts +157 -0
- package/src/esbuildConfigs/inputFilesPlugin.ts +27 -6
- package/src/esbuildConfigs/node.ts +4 -7
- package/src/esbuildConfigs/web.ts +4 -3
- package/src/lib/abstractBase.ts +58 -115
- package/src/lib/types.ts +3 -177
- package/dist/common/src/Aider.js +0 -143
- package/dist/common/src/Project.js +0 -227
- package/dist/common/src/Puppeteer.js +0 -111
- 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 -220
- package/dist/module/src/Puppeteer.js +0 -106
- 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 -553
- 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 -292
- package/src/Puppeteer.ts +0 -143
- 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
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
// src/
|
|
4
|
-
import
|
|
5
|
-
import fs2 from "fs";
|
|
6
|
-
import watch from "recursive-watch";
|
|
3
|
+
// src/cli2.ts
|
|
4
|
+
import { watch } from "fs";
|
|
7
5
|
|
|
8
6
|
// src/PM/main.ts
|
|
9
7
|
import fs from "fs";
|
|
10
|
-
import
|
|
8
|
+
import path from "path";
|
|
11
9
|
import puppeteer from "puppeteer-core";
|
|
12
10
|
import crypto from "crypto";
|
|
13
11
|
|
|
@@ -15,17 +13,22 @@ import crypto from "crypto";
|
|
|
15
13
|
var PM = class {
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
// src/utils.ts
|
|
19
|
-
import path from "path";
|
|
20
|
-
var destinationOfRuntime = (f, r, configs) => {
|
|
21
|
-
return path.normalize(`${configs.buildDir}/${r}/${f}`).split(".").slice(0, -1).join(".");
|
|
22
|
-
};
|
|
23
|
-
|
|
24
16
|
// src/PM/main.ts
|
|
25
17
|
var fileStreams3 = [];
|
|
26
18
|
var fPaths = [];
|
|
27
19
|
var files = {};
|
|
20
|
+
var recorders = {};
|
|
28
21
|
var screenshots = {};
|
|
22
|
+
var red = "\x1B[31m";
|
|
23
|
+
var green = "\x1B[32m";
|
|
24
|
+
var reset = "\x1B[0m";
|
|
25
|
+
var statusMessagePretty = (failures, test) => {
|
|
26
|
+
if (failures === 0) {
|
|
27
|
+
console.log(green + `${test} completed successfully` + reset);
|
|
28
|
+
} else {
|
|
29
|
+
console.log(red + `${test} failed ${failures} times` + reset);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
29
32
|
var PM_Main = class extends PM {
|
|
30
33
|
constructor(configs) {
|
|
31
34
|
super();
|
|
@@ -50,7 +53,7 @@ var PM_Main = class extends PM {
|
|
|
50
53
|
}
|
|
51
54
|
};
|
|
52
55
|
this.launchNode = async (src, dest) => {
|
|
53
|
-
console.log("
|
|
56
|
+
console.log("! node", src);
|
|
54
57
|
this.register(src);
|
|
55
58
|
const destFolder = dest.replace(".mjs", "");
|
|
56
59
|
let argz = "";
|
|
@@ -96,33 +99,13 @@ var PM_Main = class extends PM {
|
|
|
96
99
|
console.error("negative port makes no sense", src);
|
|
97
100
|
process.exit(-1);
|
|
98
101
|
}
|
|
99
|
-
const builtfile = dest
|
|
102
|
+
const builtfile = dest;
|
|
100
103
|
const webSideCares = [];
|
|
101
|
-
await Promise.all(
|
|
102
|
-
testConfig[3].map(async (sidecar) => {
|
|
103
|
-
if (sidecar[1] === "web") {
|
|
104
|
-
const s = await this.launchWebSideCar(
|
|
105
|
-
sidecar[0],
|
|
106
|
-
destinationOfRuntime(sidecar[0], "web", this.configs),
|
|
107
|
-
sidecar
|
|
108
|
-
);
|
|
109
|
-
webSideCares.push(s);
|
|
110
|
-
return s;
|
|
111
|
-
}
|
|
112
|
-
if (sidecar[1] === "node") {
|
|
113
|
-
return this.launchNodeSideCar(
|
|
114
|
-
sidecar[0],
|
|
115
|
-
destinationOfRuntime(sidecar[0], "node", this.configs),
|
|
116
|
-
sidecar
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
);
|
|
121
104
|
this.server[builtfile] = await import(`${builtfile}?cacheBust=${Date.now()}`).then((module) => {
|
|
122
105
|
return module.default.then((defaultModule) => {
|
|
123
106
|
defaultModule.receiveTestResourceConfig(argz).then(async ({ features, failed }) => {
|
|
124
|
-
this.receiveFeatures(features, destFolder);
|
|
125
|
-
|
|
107
|
+
this.receiveFeatures(features, destFolder, src);
|
|
108
|
+
statusMessagePretty(failed, src);
|
|
126
109
|
}).catch((e) => {
|
|
127
110
|
console.log(`${src} errored with`, e);
|
|
128
111
|
}).finally(() => {
|
|
@@ -149,7 +132,7 @@ var PM_Main = class extends PM {
|
|
|
149
132
|
"custom-screenshot",
|
|
150
133
|
async (ssOpts, testName) => {
|
|
151
134
|
const p = ssOpts.path;
|
|
152
|
-
const dir =
|
|
135
|
+
const dir = path.dirname(p);
|
|
153
136
|
fs.mkdirSync(dir, {
|
|
154
137
|
recursive: true
|
|
155
138
|
});
|
|
@@ -169,7 +152,7 @@ var PM_Main = class extends PM {
|
|
|
169
152
|
page.exposeFunction(
|
|
170
153
|
"writeFileSync",
|
|
171
154
|
(fp, contents, testName) => {
|
|
172
|
-
const dir =
|
|
155
|
+
const dir = path.dirname(fp);
|
|
173
156
|
fs.mkdirSync(dir, {
|
|
174
157
|
recursive: true
|
|
175
158
|
});
|
|
@@ -284,18 +267,9 @@ var PM_Main = class extends PM {
|
|
|
284
267
|
}
|
|
285
268
|
}
|
|
286
269
|
};
|
|
287
|
-
this.launchWeb = (t, dest
|
|
288
|
-
console.log("
|
|
270
|
+
this.launchWeb = (t, dest) => {
|
|
271
|
+
console.log("! web", t);
|
|
289
272
|
this.register(t);
|
|
290
|
-
sidecars.map((sidecar) => {
|
|
291
|
-
if (sidecar[1] === "node") {
|
|
292
|
-
return this.launchNodeSideCar(
|
|
293
|
-
sidecar[0],
|
|
294
|
-
destinationOfRuntime(sidecar[0], "node", this.configs),
|
|
295
|
-
sidecar
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
273
|
const destFolder = dest.replace(".mjs", "");
|
|
300
274
|
const webArgz = JSON.stringify({
|
|
301
275
|
name: dest,
|
|
@@ -303,9 +277,10 @@ var PM_Main = class extends PM {
|
|
|
303
277
|
fs: destFolder,
|
|
304
278
|
browserWSEndpoint: this.browser.wsEndpoint()
|
|
305
279
|
});
|
|
280
|
+
const d = `${dest}?cacheBust=${Date.now()}`;
|
|
306
281
|
const evaluation = `
|
|
307
|
-
console.log("importing ${
|
|
308
|
-
import('${
|
|
282
|
+
console.log("importing ${d}");
|
|
283
|
+
import('${d}').then(async (x) => {
|
|
309
284
|
console.log("imported", (await x.default));
|
|
310
285
|
try {
|
|
311
286
|
return await (await x.default).receiveTestResourceConfig(${webArgz})
|
|
@@ -315,14 +290,14 @@ var PM_Main = class extends PM {
|
|
|
315
290
|
})`;
|
|
316
291
|
const fileStreams2 = [];
|
|
317
292
|
const doneFileStream2 = [];
|
|
318
|
-
const stdoutStream = fs.createWriteStream(`${
|
|
319
|
-
const stderrStream = fs.createWriteStream(`${
|
|
293
|
+
const stdoutStream = fs.createWriteStream(`${destFolder}/stdout.log`);
|
|
294
|
+
const stderrStream = fs.createWriteStream(`${destFolder}/stderr.log`);
|
|
320
295
|
this.browser.newPage().then((page) => {
|
|
321
296
|
page.exposeFunction(
|
|
322
297
|
"screencast",
|
|
323
298
|
async (ssOpts, testName) => {
|
|
324
299
|
const p = ssOpts.path;
|
|
325
|
-
const dir =
|
|
300
|
+
const dir = path.dirname(p);
|
|
326
301
|
fs.mkdirSync(dir, {
|
|
327
302
|
recursive: true
|
|
328
303
|
});
|
|
@@ -346,7 +321,7 @@ var PM_Main = class extends PM {
|
|
|
346
321
|
"customScreenShot",
|
|
347
322
|
async (ssOpts, testName) => {
|
|
348
323
|
const p = ssOpts.path;
|
|
349
|
-
const dir =
|
|
324
|
+
const dir = path.dirname(p);
|
|
350
325
|
fs.mkdirSync(dir, {
|
|
351
326
|
recursive: true
|
|
352
327
|
});
|
|
@@ -458,7 +433,7 @@ var PM_Main = class extends PM {
|
|
|
458
433
|
files[t] = /* @__PURE__ */ new Set();
|
|
459
434
|
}
|
|
460
435
|
fs.writeFileSync(
|
|
461
|
-
|
|
436
|
+
destFolder + "/manifest.json",
|
|
462
437
|
JSON.stringify(Array.from(files[t]))
|
|
463
438
|
);
|
|
464
439
|
delete files[t];
|
|
@@ -489,10 +464,10 @@ var PM_Main = class extends PM {
|
|
|
489
464
|
stdoutStream.write(JSON.stringify(log.location()));
|
|
490
465
|
stdoutStream.write(JSON.stringify(log.stackTrace()));
|
|
491
466
|
});
|
|
492
|
-
await page.goto(`file://${`${
|
|
467
|
+
await page.goto(`file://${`${destFolder}.html`}`, {});
|
|
493
468
|
await page.evaluate(evaluation).then(async ({ failed, features }) => {
|
|
494
|
-
this.receiveFeatures(features, destFolder);
|
|
495
|
-
|
|
469
|
+
this.receiveFeatures(features, destFolder, t);
|
|
470
|
+
statusMessagePretty(failed, t);
|
|
496
471
|
}).catch((e) => {
|
|
497
472
|
console.log(`${t} errored with`, e);
|
|
498
473
|
}).finally(() => {
|
|
@@ -501,18 +476,25 @@ var PM_Main = class extends PM {
|
|
|
501
476
|
return page;
|
|
502
477
|
});
|
|
503
478
|
};
|
|
504
|
-
this.receiveFeatures = (features, destFolder) => {
|
|
479
|
+
this.receiveFeatures = (features, destFolder, srcTest) => {
|
|
480
|
+
const featureDestination = path.resolve(
|
|
481
|
+
process.cwd(),
|
|
482
|
+
"docs",
|
|
483
|
+
"features",
|
|
484
|
+
"strings",
|
|
485
|
+
srcTest.split(".").slice(0, -1).join(".") + ".features.txt"
|
|
486
|
+
);
|
|
505
487
|
features.reduce(async (mm, featureStringKey) => {
|
|
506
488
|
const accum = await mm;
|
|
507
489
|
const isUrl = isValidUrl(featureStringKey);
|
|
508
490
|
if (isUrl) {
|
|
509
491
|
const u = new URL(featureStringKey);
|
|
510
492
|
if (u.protocol === "file:") {
|
|
511
|
-
const newPath = `${process.cwd()}/docs/features/internal/${
|
|
493
|
+
const newPath = `${process.cwd()}/docs/features/internal/${path.relative(
|
|
512
494
|
process.cwd(),
|
|
513
495
|
u.pathname
|
|
514
496
|
)}`;
|
|
515
|
-
await fs.promises.mkdir(
|
|
497
|
+
await fs.promises.mkdir(path.dirname(newPath), { recursive: true });
|
|
516
498
|
try {
|
|
517
499
|
await fs.unlinkSync(newPath);
|
|
518
500
|
} catch (error) {
|
|
@@ -524,25 +506,24 @@ var PM_Main = class extends PM {
|
|
|
524
506
|
} else {
|
|
525
507
|
}
|
|
526
508
|
});
|
|
527
|
-
accum.push(newPath);
|
|
509
|
+
accum.files.push(newPath);
|
|
528
510
|
} else if (u.protocol === "http:" || u.protocol === "https:") {
|
|
529
511
|
const newPath = `${process.cwd()}/docs/features/external${u.hostname}${u.pathname}`;
|
|
530
512
|
const body = await this.configs.featureIngestor(featureStringKey);
|
|
531
513
|
writeFileAndCreateDir(newPath, body);
|
|
532
|
-
accum.push(newPath);
|
|
514
|
+
accum.files.push(newPath);
|
|
533
515
|
}
|
|
534
516
|
} else {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
)
|
|
538
|
-
|
|
539
|
-
accum.push(newPath);
|
|
517
|
+
await fs.promises.mkdir(path.dirname(featureDestination), {
|
|
518
|
+
recursive: true
|
|
519
|
+
});
|
|
520
|
+
accum.strings.push(featureStringKey);
|
|
540
521
|
}
|
|
541
522
|
return accum;
|
|
542
|
-
}, Promise.resolve([])).then((
|
|
523
|
+
}, Promise.resolve({ files: [], strings: [] })).then(({ files: files2, strings }) => {
|
|
543
524
|
fs.writeFileSync(
|
|
544
525
|
`${destFolder}/featurePrompt.txt`,
|
|
545
|
-
|
|
526
|
+
files2.map((f) => {
|
|
546
527
|
return `/read ${f}`;
|
|
547
528
|
}).join("\n")
|
|
548
529
|
);
|
|
@@ -555,6 +536,35 @@ var PM_Main = class extends PM {
|
|
|
555
536
|
this.configs.ports.forEach((element) => {
|
|
556
537
|
this.ports[element] = "true";
|
|
557
538
|
});
|
|
539
|
+
globalThis["waitForSelector"] = async (pageKey, sel) => {
|
|
540
|
+
console.log("waitForSelector", pageKey, sel);
|
|
541
|
+
const page = (await this.browser.pages()).find(
|
|
542
|
+
(p) => p.mainFrame()._id === pageKey
|
|
543
|
+
);
|
|
544
|
+
await page?.waitForSelector(sel);
|
|
545
|
+
};
|
|
546
|
+
globalThis["screencastStop"] = async (path3) => {
|
|
547
|
+
return recorders[path3].stop();
|
|
548
|
+
};
|
|
549
|
+
globalThis["closePage"] = async (pageKey) => {
|
|
550
|
+
const page = (await this.browser.pages()).find(
|
|
551
|
+
(p) => p.mainFrame()._id === pageKey
|
|
552
|
+
);
|
|
553
|
+
return page.close();
|
|
554
|
+
};
|
|
555
|
+
globalThis["goto"] = async (pageKey, url) => {
|
|
556
|
+
const page = (await this.browser.pages()).find(
|
|
557
|
+
(p) => p.mainFrame()._id === pageKey
|
|
558
|
+
);
|
|
559
|
+
await page?.goto(url);
|
|
560
|
+
return;
|
|
561
|
+
};
|
|
562
|
+
globalThis["newPage"] = () => {
|
|
563
|
+
return this.browser.newPage();
|
|
564
|
+
};
|
|
565
|
+
globalThis["pages"] = () => {
|
|
566
|
+
return this.browser.pages();
|
|
567
|
+
};
|
|
558
568
|
globalThis["mkdirSync"] = (fp) => {
|
|
559
569
|
if (!fs.existsSync(fp)) {
|
|
560
570
|
return fs.mkdirSync(fp, {
|
|
@@ -564,7 +574,7 @@ var PM_Main = class extends PM {
|
|
|
564
574
|
return false;
|
|
565
575
|
};
|
|
566
576
|
globalThis["writeFileSync"] = (filepath, contents, testName) => {
|
|
567
|
-
const dir =
|
|
577
|
+
const dir = path.dirname(filepath);
|
|
568
578
|
fs.mkdirSync(dir, {
|
|
569
579
|
recursive: true
|
|
570
580
|
});
|
|
@@ -592,9 +602,12 @@ var PM_Main = class extends PM {
|
|
|
592
602
|
globalThis["end"] = (uid) => {
|
|
593
603
|
fileStreams3[uid].end();
|
|
594
604
|
};
|
|
595
|
-
globalThis["customScreenShot"] = async (opts,
|
|
605
|
+
globalThis["customScreenShot"] = async (opts, pageKey, testName) => {
|
|
606
|
+
const page = (await this.browser.pages()).find(
|
|
607
|
+
(p2) => p2.mainFrame()._id === pageKey
|
|
608
|
+
);
|
|
596
609
|
const p = opts.path;
|
|
597
|
-
const dir =
|
|
610
|
+
const dir = path.dirname(p);
|
|
598
611
|
fs.mkdirSync(dir, {
|
|
599
612
|
recursive: true
|
|
600
613
|
});
|
|
@@ -613,6 +626,37 @@ var PM_Main = class extends PM {
|
|
|
613
626
|
await sPromise;
|
|
614
627
|
return sPromise;
|
|
615
628
|
};
|
|
629
|
+
globalThis["screencast"] = async (opts, pageKey) => {
|
|
630
|
+
const page = (await this.browser.pages()).find(
|
|
631
|
+
(p2) => p2.mainFrame()._id === pageKey
|
|
632
|
+
);
|
|
633
|
+
const p = opts.path;
|
|
634
|
+
const dir = path.dirname(p);
|
|
635
|
+
fs.mkdirSync(dir, {
|
|
636
|
+
recursive: true
|
|
637
|
+
});
|
|
638
|
+
const recorder = await page?.screencast({
|
|
639
|
+
...opts,
|
|
640
|
+
path: p
|
|
641
|
+
});
|
|
642
|
+
recorders[opts.path] = recorder;
|
|
643
|
+
return opts.path;
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
customclose() {
|
|
647
|
+
throw new Error("Method not implemented.");
|
|
648
|
+
}
|
|
649
|
+
waitForSelector(p, s) {
|
|
650
|
+
throw new Error("Method not implemented.");
|
|
651
|
+
}
|
|
652
|
+
closePage(p) {
|
|
653
|
+
throw new Error("Method not implemented.");
|
|
654
|
+
}
|
|
655
|
+
newPage() {
|
|
656
|
+
throw new Error("Method not implemented.");
|
|
657
|
+
}
|
|
658
|
+
goto(p, url) {
|
|
659
|
+
throw new Error("Method not implemented.");
|
|
616
660
|
}
|
|
617
661
|
$(selector) {
|
|
618
662
|
throw new Error("Method not implemented.");
|
|
@@ -620,7 +664,7 @@ var PM_Main = class extends PM {
|
|
|
620
664
|
screencast(opts) {
|
|
621
665
|
throw new Error("Method not implemented.");
|
|
622
666
|
}
|
|
623
|
-
customScreenShot(opts) {
|
|
667
|
+
customScreenShot(opts, cdpPage) {
|
|
624
668
|
throw new Error("Method not implemented.");
|
|
625
669
|
}
|
|
626
670
|
end(accessObject) {
|
|
@@ -648,7 +692,7 @@ var PM_Main = class extends PM {
|
|
|
648
692
|
callback(
|
|
649
693
|
new Promise((res, rej) => {
|
|
650
694
|
tLog("testArtiFactory =>", fPath);
|
|
651
|
-
const cleanPath =
|
|
695
|
+
const cleanPath = path.resolve(fPath);
|
|
652
696
|
fPaths.push(cleanPath.replace(process.cwd(), ``));
|
|
653
697
|
const targetDir = cleanPath.split("/").slice(0, -1).join("/");
|
|
654
698
|
fs.mkdir(targetDir, { recursive: true }, async (error) => {
|
|
@@ -656,7 +700,7 @@ var PM_Main = class extends PM {
|
|
|
656
700
|
console.error(`\u2757\uFE0FtestArtiFactory failed`, targetDir, error);
|
|
657
701
|
}
|
|
658
702
|
fs.writeFileSync(
|
|
659
|
-
|
|
703
|
+
path.resolve(
|
|
660
704
|
targetDir.split("/").slice(0, -1).join("/"),
|
|
661
705
|
"manifest"
|
|
662
706
|
),
|
|
@@ -712,6 +756,9 @@ var PM_Main = class extends PM {
|
|
|
712
756
|
isDisabled(selector) {
|
|
713
757
|
throw new Error("Method not implemented.");
|
|
714
758
|
}
|
|
759
|
+
screencastStop(s) {
|
|
760
|
+
throw new Error("Method not implemented.");
|
|
761
|
+
}
|
|
715
762
|
////////////////////////////////////////////////////////////////////////////////
|
|
716
763
|
async startPuppeteer(options, destfolder) {
|
|
717
764
|
this.browser = await puppeteer.launch(options);
|
|
@@ -724,21 +771,14 @@ var PM_Main = class extends PM {
|
|
|
724
771
|
}
|
|
725
772
|
};
|
|
726
773
|
async function writeFileAndCreateDir(filePath, data) {
|
|
727
|
-
const dirPath =
|
|
774
|
+
const dirPath = path.dirname(filePath);
|
|
728
775
|
try {
|
|
729
776
|
await fs.promises.mkdir(dirPath, { recursive: true });
|
|
730
|
-
await fs.
|
|
777
|
+
await fs.appendFileSync(filePath, data);
|
|
731
778
|
} catch (error) {
|
|
732
779
|
console.error(`Error writing file: ${error}`);
|
|
733
780
|
}
|
|
734
781
|
}
|
|
735
|
-
async function sha256(rawData) {
|
|
736
|
-
const data = typeof rawData === "object" ? JSON.stringify(rawData) : String(rawData);
|
|
737
|
-
const msgBuffer = new TextEncoder().encode(data);
|
|
738
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", msgBuffer);
|
|
739
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
740
|
-
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
741
|
-
}
|
|
742
782
|
function isValidUrl(string) {
|
|
743
783
|
try {
|
|
744
784
|
new URL(string);
|
|
@@ -748,29 +788,57 @@ function isValidUrl(string) {
|
|
|
748
788
|
}
|
|
749
789
|
}
|
|
750
790
|
|
|
751
|
-
// src/
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
var
|
|
791
|
+
// src/cli2.ts
|
|
792
|
+
import path2 from "path";
|
|
793
|
+
import crypto2 from "node:crypto";
|
|
794
|
+
import fs2 from "fs";
|
|
795
|
+
var fileHashes = {};
|
|
796
|
+
async function fileHash(filePath, algorithm = "md5") {
|
|
797
|
+
return new Promise((resolve, reject) => {
|
|
798
|
+
const hash = crypto2.createHash(algorithm);
|
|
799
|
+
const fileStream = fs2.createReadStream(filePath);
|
|
800
|
+
fileStream.on("data", (data) => {
|
|
801
|
+
hash.update(data);
|
|
802
|
+
});
|
|
803
|
+
fileStream.on("end", () => {
|
|
804
|
+
const fileHash2 = hash.digest("hex");
|
|
805
|
+
resolve(fileHash2);
|
|
806
|
+
});
|
|
807
|
+
fileStream.on("error", (error) => {
|
|
808
|
+
reject(`Error reading file: ${error.message}`);
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
var getRunnables = (tests, payload = {
|
|
813
|
+
nodeEntryPoints: {},
|
|
814
|
+
webEntryPoints: {}
|
|
815
|
+
}) => {
|
|
816
|
+
return tests.reduce((pt, cv, cndx, cry) => {
|
|
817
|
+
if (cv[1] === "node") {
|
|
818
|
+
pt.nodeEntryPoints[cv[0]] = path2.resolve(
|
|
819
|
+
`./docs/node/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
|
|
820
|
+
);
|
|
821
|
+
} else if (cv[1] === "web") {
|
|
822
|
+
pt.webEntryPoints[cv[0]] = path2.resolve(
|
|
823
|
+
`./docs/web/${cv[0].split(".").slice(0, -1).concat("mjs").join(".")}`
|
|
824
|
+
);
|
|
825
|
+
}
|
|
826
|
+
if (cv[3].length) {
|
|
827
|
+
getRunnables(cv[3], payload);
|
|
828
|
+
}
|
|
829
|
+
return pt;
|
|
830
|
+
}, payload);
|
|
831
|
+
};
|
|
832
|
+
import(process.cwd() + "/" + process.argv[2]).then(async (module) => {
|
|
833
|
+
const rawConfig = module.default;
|
|
756
834
|
const config = {
|
|
757
|
-
...
|
|
758
|
-
buildDir: process.cwd() + "/" +
|
|
835
|
+
...rawConfig,
|
|
836
|
+
buildDir: process.cwd() + "/" + rawConfig.outdir
|
|
759
837
|
};
|
|
760
|
-
|
|
761
|
-
`${config.outdir}/testeranto.json`,
|
|
762
|
-
JSON.stringify(
|
|
763
|
-
{
|
|
764
|
-
...config,
|
|
765
|
-
buildDir: process.cwd() + "/" + config.outdir
|
|
766
|
-
},
|
|
767
|
-
null,
|
|
768
|
-
2
|
|
769
|
-
)
|
|
770
|
-
);
|
|
771
|
-
const pm = new PM_Main(config);
|
|
838
|
+
let pm = new PM_Main(config);
|
|
772
839
|
await pm.startPuppeteer(
|
|
773
840
|
{
|
|
841
|
+
slowMo: 1,
|
|
774
842
|
// timeout: 1,
|
|
775
843
|
waitForInitialPage: false,
|
|
776
844
|
executablePath: (
|
|
@@ -814,58 +882,37 @@ var Puppeteer_default = async (partialConfig) => {
|
|
|
814
882
|
},
|
|
815
883
|
"."
|
|
816
884
|
);
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
if (runtime === "node") {
|
|
830
|
-
pm.launchNode(test, destinationOfRuntime(test, "node", config));
|
|
831
|
-
} else if (runtime === "web") {
|
|
832
|
-
pm.launchWeb(test, destinationOfRuntime(test, "web", config), sidecars);
|
|
833
|
-
} else {
|
|
834
|
-
console.error("runtime makes no sense", runtime);
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
if (config.devMode) {
|
|
838
|
-
console.log("ready and watching for changes...", config.buildDir);
|
|
839
|
-
watch(config.buildDir, (eventType, changedFile) => {
|
|
840
|
-
if (changedFile) {
|
|
841
|
-
config.tests.forEach(([test, runtime, tr, sidecars]) => {
|
|
842
|
-
if (eventType === "change" || eventType === "rename") {
|
|
843
|
-
if (changedFile === test.replace("./", "node/").split(".").slice(0, -1).concat("mjs").join(".")) {
|
|
844
|
-
pm.launchNode(test, destinationOfRuntime(test, "node", config));
|
|
845
|
-
}
|
|
846
|
-
if (changedFile === test.replace("./", "web/").split(".").slice(0, -1).concat("mjs").join(".")) {
|
|
847
|
-
pm.launchWeb(
|
|
848
|
-
test,
|
|
849
|
-
destinationOfRuntime(test, "web", config),
|
|
850
|
-
sidecars
|
|
851
|
-
);
|
|
852
|
-
}
|
|
885
|
+
const { nodeEntryPoints, webEntryPoints } = getRunnables(config.tests);
|
|
886
|
+
Object.entries(nodeEntryPoints).forEach(
|
|
887
|
+
([k, outputFile]) => {
|
|
888
|
+
console.log("watching and running", outputFile);
|
|
889
|
+
pm.launchNode(k, outputFile);
|
|
890
|
+
try {
|
|
891
|
+
watch(outputFile, async (e, filename) => {
|
|
892
|
+
const hash = await fileHash(outputFile);
|
|
893
|
+
if (fileHashes[k] !== hash) {
|
|
894
|
+
fileHashes[k] = hash;
|
|
895
|
+
console.log(`< ${e} ${filename} ${hash}`);
|
|
896
|
+
pm.launchNode(k, outputFile);
|
|
853
897
|
}
|
|
854
898
|
});
|
|
899
|
+
} catch (e) {
|
|
900
|
+
console.error(e);
|
|
855
901
|
}
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
902
|
+
}
|
|
903
|
+
);
|
|
904
|
+
Object.entries(webEntryPoints).forEach(
|
|
905
|
+
([k, outputFile]) => {
|
|
906
|
+
console.log("watching and running", outputFile);
|
|
907
|
+
pm.launchWeb(k, outputFile);
|
|
908
|
+
watch(outputFile, async (e, filename) => {
|
|
909
|
+
const hash = await fileHash(outputFile);
|
|
910
|
+
console.log(`< ${e} ${filename} ${hash}`);
|
|
911
|
+
if (fileHashes[k] !== hash) {
|
|
912
|
+
fileHashes[k] = hash;
|
|
913
|
+
pm.launchWeb(k, outputFile);
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
);
|
|
918
|
+
});
|
package/dist/types/src/Node.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Testeranto from "./lib/core.js";
|
|
2
2
|
import { ITTestResourceRequest } from "./lib/index.js";
|
|
3
3
|
import type { IBaseTest, ITestImplementation, ITestSpecification } from "./Types.js";
|
|
4
|
-
import { ITestInterface
|
|
4
|
+
import { ITestInterface } from "./lib/types.js";
|
|
5
5
|
export declare class NodeTesteranto<TestShape extends IBaseTest<unknown, unknown, unknown, unknown, unknown, unknown, unknown, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>> extends Testeranto<TestShape> {
|
|
6
6
|
constructor(input: TestShape["iinput"], testSpecification: ITestSpecification<TestShape>, testImplementation: ITestImplementation<TestShape>, testResourceRequirement: ITTestResourceRequest, testInterface: Partial<ITestInterface<TestShape>>);
|
|
7
7
|
receiveTestResourceConfig(partialTestResource: string): Promise<{
|
|
@@ -9,5 +9,5 @@ export declare class NodeTesteranto<TestShape extends IBaseTest<unknown, unknown
|
|
|
9
9
|
failed: number;
|
|
10
10
|
}>;
|
|
11
11
|
}
|
|
12
|
-
declare const _default: <ITestShape extends IBaseTest<unknown, unknown, unknown, unknown, unknown, unknown, unknown, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>>(input: ITestShape["iinput"], testSpecification: ITestSpecification<ITestShape>, testImplementation:
|
|
12
|
+
declare const _default: <ITestShape extends IBaseTest<unknown, unknown, unknown, unknown, unknown, unknown, unknown, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>>(input: ITestShape["iinput"], testSpecification: ITestSpecification<ITestShape>, testImplementation: any, testInterface: INodeTestInterface<ITestShape>, testResourceRequirement?: ITTestResourceRequest) => Promise<Testeranto<ITestShape>>;
|
|
13
13
|
export default _default;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CdpPage } from "puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser";
|
|
2
|
+
import { ScreenRecorderOptions } from "puppeteer-core/lib/esm/puppeteer";
|
|
1
3
|
import { ITLog, ITTestResourceConfiguration } from "../lib";
|
|
2
4
|
export declare abstract class PM {
|
|
3
5
|
server: any;
|
|
@@ -13,8 +15,9 @@ export declare abstract class PM {
|
|
|
13
15
|
abstract end(accessObject: {
|
|
14
16
|
uid: number;
|
|
15
17
|
}): boolean;
|
|
16
|
-
abstract customScreenShot(opts: object): any;
|
|
17
|
-
abstract screencast(opts:
|
|
18
|
+
abstract customScreenShot(opts: object, page?: string): any;
|
|
19
|
+
abstract screencast(opts: ScreenRecorderOptions, p?: any): any;
|
|
20
|
+
abstract screencastStop(s: string): any;
|
|
18
21
|
abstract page(): string | undefined;
|
|
19
22
|
abstract click(selector: string): any;
|
|
20
23
|
abstract focusOn(selector: string): any;
|
|
@@ -23,4 +26,9 @@ export declare abstract class PM {
|
|
|
23
26
|
abstract getAttribute(selector: string, attribute: string): any;
|
|
24
27
|
abstract isDisabled(selector: string): boolean;
|
|
25
28
|
abstract $(selector: string): any;
|
|
29
|
+
abstract newPage(): CdpPage;
|
|
30
|
+
abstract goto(p: any, url: string): any;
|
|
31
|
+
abstract closePage(p: any): any;
|
|
32
|
+
abstract waitForSelector(p: any, sel: string): any;
|
|
33
|
+
abstract customclose(): any;
|
|
26
34
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
+
import { CdpPage, Page } from "puppeteer-core/lib/esm/puppeteer";
|
|
4
5
|
import fs from "fs";
|
|
5
|
-
import { Browser } from "puppeteer-core";
|
|
6
|
+
import { Browser, LaunchOptions } from "puppeteer-core";
|
|
6
7
|
import { PassThrough } from "stream";
|
|
7
8
|
import { IBuiltConfig, ITestTypes } from "../lib/types";
|
|
8
|
-
import { PM } from "./index.js";
|
|
9
9
|
import { ITLog } from "../lib/index.js";
|
|
10
|
-
import {
|
|
10
|
+
import { PM } from "./index.js";
|
|
11
11
|
export declare class PM_Main extends PM {
|
|
12
12
|
browser: Browser;
|
|
13
13
|
shutdownMode: boolean;
|
|
@@ -16,9 +16,14 @@ export declare class PM_Main extends PM {
|
|
|
16
16
|
queue: any[];
|
|
17
17
|
registry: Record<string, boolean>;
|
|
18
18
|
constructor(configs: IBuiltConfig);
|
|
19
|
+
customclose(): void;
|
|
20
|
+
waitForSelector(p: string, s: string): any;
|
|
21
|
+
closePage(p: any): any;
|
|
22
|
+
newPage(): CdpPage;
|
|
23
|
+
goto(p: any, url: string): any;
|
|
19
24
|
$(selector: string): boolean;
|
|
20
25
|
screencast(opts: object): void;
|
|
21
|
-
customScreenShot(opts: object): void;
|
|
26
|
+
customScreenShot(opts: object, cdpPage?: CdpPage): void;
|
|
22
27
|
end(accessObject: {
|
|
23
28
|
uid: number;
|
|
24
29
|
}): boolean;
|
|
@@ -37,7 +42,8 @@ export declare class PM_Main extends PM {
|
|
|
37
42
|
getValue(value: string): void;
|
|
38
43
|
getAttribute(selector: string, attribute: string): void;
|
|
39
44
|
isDisabled(selector: string): boolean;
|
|
40
|
-
|
|
45
|
+
screencastStop(s: string): void;
|
|
46
|
+
startPuppeteer(options: LaunchOptions, destfolder: string): Promise<any>;
|
|
41
47
|
shutDown(): void;
|
|
42
48
|
checkForShutdown: () => void;
|
|
43
49
|
register: (src: string) => void;
|
|
@@ -45,6 +51,6 @@ export declare class PM_Main extends PM {
|
|
|
45
51
|
launchNode: (src: string, dest: string) => Promise<void>;
|
|
46
52
|
launchWebSideCar: (src: string, dest: string, testConfig: ITestTypes) => Promise<Page>;
|
|
47
53
|
launchNodeSideCar: (src: string, dest: string, testConfig: ITestTypes) => Promise<void>;
|
|
48
|
-
launchWeb: (t: string, dest: string
|
|
49
|
-
receiveFeatures: (features: string[], destFolder: string) => void;
|
|
54
|
+
launchWeb: (t: string, dest: string) => void;
|
|
55
|
+
receiveFeatures: (features: string[], destFolder: string, srcTest: string) => void;
|
|
50
56
|
}
|