testeranto 0.70.0 → 0.74.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 +7 -34
- package/dist/common/PM/index.js +71 -0
- package/dist/common/PM/main.js +370 -0
- package/dist/common/PM/node.js +84 -0
- package/dist/common/PM/web.js +129 -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/jsx/index.js +14 -2
- 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 -44
- 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 +7 -34
- package/dist/module/PM/index.js +67 -0
- package/dist/module/PM/main.js +340 -0
- package/dist/module/PM/node.js +77 -0
- package/dist/module/PM/web.js +122 -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/index.js +11 -2
- 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 -44
- 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 +26 -0
- package/dist/types/PM/node.d.ts +25 -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/jsx/index.d.ts +2 -5
- 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 +8 -47
- package/src/PM/index.ts +102 -0
- package/src/PM/main.ts +452 -0
- package/src/PM/node.ts +122 -0
- package/src/PM/web.ts +162 -0
- package/src/Project.ts +21 -2
- package/src/Puppeteer.ts +131 -0
- package/src/Report.tsx +160 -46
- package/src/Reporter.ts +134 -0
- package/src/Scheduler.ts +0 -0
- package/src/SubPackages/puppeteer.ts +3 -3
- package/src/SubPackages/react/jsx/index.ts +13 -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 -69
- 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/dist/module/Project.js
CHANGED
|
@@ -70,6 +70,24 @@ export class ITProject {
|
|
|
70
70
|
.then((x) => fs.writeFileSync(htmlFilePath, webHtmlFrame(jsfilePath, htmlFilePath)));
|
|
71
71
|
})));
|
|
72
72
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
73
|
+
// nodeEntryPoints.forEach((nep) => {
|
|
74
|
+
// const f = `${process.cwd()}/${nep}`;
|
|
75
|
+
// console.log("nep", f);
|
|
76
|
+
// import(f).then((module) => {
|
|
77
|
+
// return module.default.then((defaultModule) => {
|
|
78
|
+
// console.log("defaultModule", defaultModule);
|
|
79
|
+
// // defaultModule
|
|
80
|
+
// // .receiveTestResourceConfig(argz)
|
|
81
|
+
// // .then((x) => {
|
|
82
|
+
// // console.log("then", x);
|
|
83
|
+
// // return x;
|
|
84
|
+
// // })
|
|
85
|
+
// // .catch((e) => {
|
|
86
|
+
// // console.log("catch", e);
|
|
87
|
+
// // });
|
|
88
|
+
// });
|
|
89
|
+
// });
|
|
90
|
+
// });
|
|
73
91
|
glob(`./${config.outdir}/chunk-*.mjs`, { ignore: "node_modules/**" }).then((chunks) => {
|
|
74
92
|
chunks.forEach((chunk) => {
|
|
75
93
|
fs.unlinkSync(chunk);
|
|
@@ -149,8 +167,8 @@ const getRunnables = (tests, payload = [new Set(), new Set()]) => {
|
|
|
149
167
|
else if (cv[1] === "web") {
|
|
150
168
|
pt[1].add(cv[0]);
|
|
151
169
|
}
|
|
152
|
-
if (cv[
|
|
153
|
-
getRunnables(cv[
|
|
170
|
+
if (cv[3].length) {
|
|
171
|
+
getRunnables(cv[3], payload);
|
|
154
172
|
}
|
|
155
173
|
return pt;
|
|
156
174
|
}, payload);
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import readline from "readline";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { jsonc } from "jsonc";
|
|
5
|
+
import { PM_Main } from "./PM/main.js";
|
|
6
|
+
var mode = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
7
|
+
const node2web = {};
|
|
8
|
+
const web2node = {};
|
|
9
|
+
const childProcesses = {};
|
|
10
|
+
readline.emitKeypressEvents(process.stdin);
|
|
11
|
+
if (process.stdin.isTTY)
|
|
12
|
+
process.stdin.setRawMode(true);
|
|
13
|
+
console.log("\n Puppeteer is running. Press 'q' to quit\n");
|
|
14
|
+
process.stdin.on("keypress", (str, key) => {
|
|
15
|
+
if (key.name === "q") {
|
|
16
|
+
process.exit();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const main = async () => {
|
|
20
|
+
const configs = jsonc.parse((await fs.readFileSync("./docs/testeranto.json")).toString());
|
|
21
|
+
const pm = new PM_Main(configs);
|
|
22
|
+
await pm.startPuppeteer({
|
|
23
|
+
waitForInitialPage: false,
|
|
24
|
+
executablePath: "/opt/homebrew/bin/chromium",
|
|
25
|
+
headless: true,
|
|
26
|
+
dumpio: true,
|
|
27
|
+
args: [
|
|
28
|
+
"--allow-file-access-from-files",
|
|
29
|
+
"--allow-running-insecure-content",
|
|
30
|
+
"--auto-open-devtools-for-tabs",
|
|
31
|
+
"--disable-dev-shm-usage",
|
|
32
|
+
"--disable-extensions",
|
|
33
|
+
"--disable-gpu",
|
|
34
|
+
"--disable-setuid-sandbox",
|
|
35
|
+
"--disable-site-isolation-trials",
|
|
36
|
+
"--disable-web-security",
|
|
37
|
+
"--disable-web-security",
|
|
38
|
+
"--no-first-run",
|
|
39
|
+
"--no-sandbox",
|
|
40
|
+
"--no-startup-window",
|
|
41
|
+
// "--no-zygote",
|
|
42
|
+
"--reduce-security-for-testing",
|
|
43
|
+
"--remote-allow-origins=*",
|
|
44
|
+
"--unsafely-treat-insecure-origin-as-secure=*",
|
|
45
|
+
// "--disable-features=IsolateOrigins",
|
|
46
|
+
// "--remote-allow-origins=ws://localhost:3234",
|
|
47
|
+
// "--single-process",
|
|
48
|
+
// "--unsafely-treat-insecure-origin-as-secure",
|
|
49
|
+
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
50
|
+
`--remote-debugging-port=3234`,
|
|
51
|
+
// "--disk-cache-dir=/dev/null",
|
|
52
|
+
// "--disk-cache-size=1",
|
|
53
|
+
// "--start-maximized",
|
|
54
|
+
],
|
|
55
|
+
}, ".");
|
|
56
|
+
const destinationOfRuntime = (f, r) => {
|
|
57
|
+
return path
|
|
58
|
+
.normalize(`${configs.buildDir}/${r}/${f}`)
|
|
59
|
+
.split(".")
|
|
60
|
+
.slice(0, -1)
|
|
61
|
+
.join(".");
|
|
62
|
+
};
|
|
63
|
+
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
64
|
+
if (runtime === "node") {
|
|
65
|
+
pm.launchNode(test, destinationOfRuntime(test, "node"));
|
|
66
|
+
}
|
|
67
|
+
else if (runtime === "web") {
|
|
68
|
+
pm.launchWeb(test, destinationOfRuntime(test, "web"));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.error("runtime makes no sense", runtime);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
console.log("ready and watching for changes...", configs.buildDir);
|
|
75
|
+
fs.watch(configs.buildDir, {
|
|
76
|
+
recursive: true,
|
|
77
|
+
}, (eventType, changedFile) => {
|
|
78
|
+
if (changedFile) {
|
|
79
|
+
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
80
|
+
if (eventType === "change" || eventType === "rename") {
|
|
81
|
+
if (changedFile ===
|
|
82
|
+
test
|
|
83
|
+
.replace("./", "node/")
|
|
84
|
+
.split(".")
|
|
85
|
+
.slice(0, -1)
|
|
86
|
+
.concat("mjs")
|
|
87
|
+
.join(".")) {
|
|
88
|
+
pm.launchNode(test, destinationOfRuntime(test, "node"));
|
|
89
|
+
}
|
|
90
|
+
if (changedFile ===
|
|
91
|
+
test
|
|
92
|
+
.replace("./", "web/")
|
|
93
|
+
.split(".")
|
|
94
|
+
.slice(0, -1)
|
|
95
|
+
.concat("mjs")
|
|
96
|
+
.join(".")) {
|
|
97
|
+
pm.launchWeb(test, destinationOfRuntime(test, "web"));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
main();
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import readline from "readline";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { jsonc } from "jsonc";
|
|
4
|
+
import puppeteer from "puppeteer-core";
|
|
5
|
+
// import { PM_Main } from "./PM/main.js";
|
|
6
|
+
// var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
7
|
+
// const node2web: Record<string, string[]> = {};
|
|
8
|
+
// const web2node: Record<string, string[]> = {};
|
|
9
|
+
// const childProcesses: Record<string, "loaded" | "running" | "done"> = {};
|
|
10
|
+
readline.emitKeypressEvents(process.stdin);
|
|
11
|
+
if (process.stdin.isTTY)
|
|
12
|
+
process.stdin.setRawMode(true);
|
|
13
|
+
console.log("\n Puppeteer is running. Press 'q' to quit\n");
|
|
14
|
+
process.stdin.on("keypress", (str, key) => {
|
|
15
|
+
if (key.name === "q") {
|
|
16
|
+
process.exit();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const main = async () => {
|
|
20
|
+
const configs = jsonc.parse((await fs.readFileSync("./docs/testeranto.json")).toString());
|
|
21
|
+
// const pm = new PM_Main(configs);
|
|
22
|
+
// await puppeteer.launch(options);
|
|
23
|
+
const browser = await puppeteer.launch({
|
|
24
|
+
waitForInitialPage: false,
|
|
25
|
+
executablePath: "/opt/homebrew/bin/chromium",
|
|
26
|
+
headless: false,
|
|
27
|
+
args: [
|
|
28
|
+
"--allow-file-access-from-files",
|
|
29
|
+
"--allow-running-insecure-content",
|
|
30
|
+
// "--auto-open-devtools-for-tabs",
|
|
31
|
+
"--disable-dev-shm-usage",
|
|
32
|
+
"--disable-extensions",
|
|
33
|
+
"--disable-gpu",
|
|
34
|
+
"--disable-setuid-sandbox",
|
|
35
|
+
"--disable-site-isolation-trials",
|
|
36
|
+
"--disable-web-security",
|
|
37
|
+
"--disable-web-security",
|
|
38
|
+
"--no-first-run",
|
|
39
|
+
"--no-sandbox",
|
|
40
|
+
"--no-startup-window",
|
|
41
|
+
"--no-zygote",
|
|
42
|
+
"--reduce-security-for-testing",
|
|
43
|
+
"--remote-allow-origins=*",
|
|
44
|
+
// "--remote-allow-origins=ws://localhost:3234",
|
|
45
|
+
"--unsafely-treat-insecure-origin-as-secure=*",
|
|
46
|
+
// "--disable-features=IsolateOrigins",
|
|
47
|
+
// "--single-process",
|
|
48
|
+
// "--unsafely-treat-insecure-origin-as-secure",
|
|
49
|
+
// "--unsafely-treat-insecure-origin-as-secure=ws://192.168.0.101:3234",
|
|
50
|
+
// `--remote-debugging-port=3234`,
|
|
51
|
+
],
|
|
52
|
+
}
|
|
53
|
+
// "."
|
|
54
|
+
);
|
|
55
|
+
console.log("Creating new page...");
|
|
56
|
+
const page = await browser.newPage();
|
|
57
|
+
await page.setViewport({ width: 0, height: 0 });
|
|
58
|
+
console.log("Requesting url...");
|
|
59
|
+
await page.goto(`file://${process.cwd()}/docs/report.html`);
|
|
60
|
+
// const destinationOfRuntime = (f: string, r: IRunTime) => {
|
|
61
|
+
// return path
|
|
62
|
+
// .normalize(`${configs.buildDir}/${r}/${f}`)
|
|
63
|
+
// .split(".")
|
|
64
|
+
// .slice(0, -1)
|
|
65
|
+
// .join(".");
|
|
66
|
+
// };
|
|
67
|
+
// configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
68
|
+
// if (runtime === "node") {
|
|
69
|
+
// pm.launchNode(test, destinationOfRuntime(test, "node"));
|
|
70
|
+
// } else if (runtime === "web") {
|
|
71
|
+
// pm.launchWeb(test, destinationOfRuntime(test, "web"));
|
|
72
|
+
// } else {
|
|
73
|
+
// console.error("runtime makes no sense", runtime);
|
|
74
|
+
// }
|
|
75
|
+
// });
|
|
76
|
+
// console.log("ready and watching for changes...", configs.buildDir);
|
|
77
|
+
// fs.watch(
|
|
78
|
+
// configs.buildDir,
|
|
79
|
+
// {
|
|
80
|
+
// recursive: true,
|
|
81
|
+
// },
|
|
82
|
+
// (eventType, changedFile) => {
|
|
83
|
+
// if (changedFile) {
|
|
84
|
+
// configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
85
|
+
// if (eventType === "change" || eventType === "rename") {
|
|
86
|
+
// if (
|
|
87
|
+
// changedFile ===
|
|
88
|
+
// test
|
|
89
|
+
// .replace("./", "node/")
|
|
90
|
+
// .split(".")
|
|
91
|
+
// .slice(0, -1)
|
|
92
|
+
// .concat("mjs")
|
|
93
|
+
// .join(".")
|
|
94
|
+
// ) {
|
|
95
|
+
// pm.launchNode(test, destinationOfRuntime(test, "node"));
|
|
96
|
+
// }
|
|
97
|
+
// if (
|
|
98
|
+
// changedFile ===
|
|
99
|
+
// test
|
|
100
|
+
// .replace("./", "web/")
|
|
101
|
+
// .split(".")
|
|
102
|
+
// .slice(0, -1)
|
|
103
|
+
// .concat("mjs")
|
|
104
|
+
// .join(".")
|
|
105
|
+
// ) {
|
|
106
|
+
// pm.launchWeb(test, destinationOfRuntime(test, "web"));
|
|
107
|
+
// }
|
|
108
|
+
// }
|
|
109
|
+
// });
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
// );
|
|
113
|
+
};
|
|
114
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -2,7 +2,9 @@ import React from "react";
|
|
|
2
2
|
import Testeranto from "../Node.js";
|
|
3
3
|
export default (testInput, testSpecifications, testImplementations, testInterface) => {
|
|
4
4
|
return Testeranto(testInput, testSpecifications, testImplementations, Object.assign({ beforeAll(x) {
|
|
5
|
-
process.parentPort.postMessage(
|
|
5
|
+
// process.parentPort.postMessage(
|
|
6
|
+
// `/docs/web/src/ClassicalComponent/test.html`
|
|
7
|
+
// );
|
|
6
8
|
return x;
|
|
7
9
|
}, beforeEach: async () => {
|
|
8
10
|
return new Promise((resolve, rej) => {
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
export const testInterface = {
|
|
2
|
-
|
|
3
|
+
// beforeAll: async (proto, testResource, artificer, pm): Promise<IStore> => {
|
|
4
|
+
// return React.createElement(proto);
|
|
5
|
+
// // return new Promise((resolve, rej) => {
|
|
6
|
+
// // resolve(x());
|
|
7
|
+
// // });
|
|
8
|
+
// },
|
|
9
|
+
beforeEach: async (subject, initializer, artificer) => {
|
|
3
10
|
return new Promise((resolve, rej) => {
|
|
4
|
-
|
|
11
|
+
const x = React.createElement(subject);
|
|
12
|
+
console.log("react-element", x);
|
|
13
|
+
resolve(x);
|
|
5
14
|
});
|
|
6
15
|
},
|
|
7
16
|
andWhen: function (s, whenCB) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Testeranto from "../../../Node.js";
|
|
2
|
-
import { testInterface as baseInterface } from "./index.js";
|
|
2
|
+
import { testInterface as baseInterface, } from "./index.js";
|
|
3
3
|
export default (testImplementations, testSpecifications, testInput, testInterface) => {
|
|
4
4
|
return Testeranto(testInput, testSpecifications, testImplementations, Object.assign(Object.assign({}, baseInterface), testInterface));
|
|
5
5
|
};
|
|
@@ -2,54 +2,107 @@ import { createElement } from "react";
|
|
|
2
2
|
import ReactDom from "react-dom/client";
|
|
3
3
|
import Testeranto from "../../../Web.js";
|
|
4
4
|
export default (testInput, testSpecifications, testImplementations) => {
|
|
5
|
+
class TesterantoComponent extends testInput {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.done = props.done;
|
|
9
|
+
}
|
|
10
|
+
componentDidMount() {
|
|
11
|
+
super.componentDidMount && super.componentDidMount();
|
|
12
|
+
return this.done(this);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const t = Testeranto(testInput, testSpecifications, testImplementations, {
|
|
16
|
+
beforeAll: async (initialProps, artificer) => {
|
|
17
|
+
console.log("mark5", initialProps);
|
|
18
|
+
return await new Promise((resolve, rej) => {
|
|
19
|
+
const htmlElement = document.getElementById("root");
|
|
20
|
+
if (htmlElement) {
|
|
21
|
+
const domRoot = ReactDom.createRoot(htmlElement);
|
|
22
|
+
// Ignore these type errors
|
|
23
|
+
domRoot.render(createElement(TesterantoComponent, Object.assign(Object.assign({}, initialProps), { done: (reactElement) => {
|
|
24
|
+
resolve({
|
|
25
|
+
htmlElement,
|
|
26
|
+
reactElement,
|
|
27
|
+
domRoot,
|
|
28
|
+
});
|
|
29
|
+
} }), []));
|
|
30
|
+
// resolve({ htmlElement });
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
// beforeEach: async (
|
|
35
|
+
// s,
|
|
36
|
+
// initializer,
|
|
37
|
+
// testResource,
|
|
38
|
+
// artificer,
|
|
39
|
+
// initialValues
|
|
40
|
+
// ): Promise<IStore> => {
|
|
41
|
+
// return new Promise((resolve, rej) => {
|
|
42
|
+
// console.log("beforeEach" + TesterantoComponent);
|
|
43
|
+
// // const domRoot = ReactDom.createRoot(htmlElement);
|
|
44
|
+
// // // Ignore these type errors
|
|
45
|
+
// // domRoot.render(
|
|
46
|
+
// // createElement(
|
|
47
|
+
// // TesterantoComponent,
|
|
48
|
+
// // {
|
|
49
|
+
// // ...initializer,
|
|
50
|
+
// // done: (reactElement) => {
|
|
51
|
+
// // resolve({
|
|
52
|
+
// // htmlElement,
|
|
53
|
+
// // reactElement,
|
|
54
|
+
// // domRoot,
|
|
55
|
+
// // });
|
|
56
|
+
// // },
|
|
57
|
+
// // },
|
|
58
|
+
// // []
|
|
59
|
+
// // )
|
|
60
|
+
// // );
|
|
61
|
+
// });
|
|
62
|
+
// },
|
|
63
|
+
andWhen: function (s, whenCB) {
|
|
64
|
+
return whenCB(s);
|
|
65
|
+
},
|
|
66
|
+
butThen: async function (s, thenCB) {
|
|
67
|
+
return thenCB(s);
|
|
68
|
+
},
|
|
69
|
+
afterEach: async function (store, ndx, artificer, utils) {
|
|
70
|
+
console.log("afterEach", store);
|
|
71
|
+
utils.writeFileSync("aftereachlog", store.toString());
|
|
72
|
+
const page = (await utils.browser.pages()).filter((x) => {
|
|
73
|
+
const parsedUrl = new URL(x.url());
|
|
74
|
+
parsedUrl.search = "";
|
|
75
|
+
const strippedUrl = parsedUrl.toString();
|
|
76
|
+
return (strippedUrl ===
|
|
77
|
+
"file:///Users/adam/Code/kokomoBay/docs/web/src/ClassicalComponent/react-dom/client.web.test.html");
|
|
78
|
+
// return true;
|
|
79
|
+
})[0];
|
|
80
|
+
const x = await page.screenshot({
|
|
81
|
+
path: "afterEachLog.jpg",
|
|
82
|
+
});
|
|
83
|
+
console.log("x", x);
|
|
84
|
+
// debugger;
|
|
85
|
+
// const div_root = document.getElementById("root");
|
|
86
|
+
// store.domRoot && store.domRoot.unmount(); //React 18
|
|
87
|
+
// store.remove();
|
|
88
|
+
// store.htmlElement.remove();
|
|
89
|
+
// store.htmlElement = document.createElement("root");
|
|
90
|
+
return store;
|
|
91
|
+
},
|
|
92
|
+
afterAll: async (store, artificer, utils) => {
|
|
93
|
+
// setTimeout(() => {
|
|
94
|
+
// console.log("This will run after 1 second");
|
|
95
|
+
// }, 1000); // 1000 milliseconds = 1 second
|
|
96
|
+
// store.htmlElement.remove();
|
|
97
|
+
// store.htmlElement = document.createElement("root");
|
|
98
|
+
return store;
|
|
99
|
+
},
|
|
100
|
+
});
|
|
5
101
|
document.addEventListener("DOMContentLoaded", function () {
|
|
6
102
|
const elem = document.getElementById("root");
|
|
7
103
|
if (elem) {
|
|
8
|
-
|
|
9
|
-
constructor(props) {
|
|
10
|
-
super(props);
|
|
11
|
-
this.done = props.done;
|
|
12
|
-
}
|
|
13
|
-
componentDidMount() {
|
|
14
|
-
super.componentDidMount && super.componentDidMount();
|
|
15
|
-
return this.done(this);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return Testeranto(testInput, testSpecifications, testImplementations, {
|
|
19
|
-
beforeAll: async (initialProps, artificer) => {
|
|
20
|
-
console.log("mark5", initialProps);
|
|
21
|
-
return await new Promise((resolve, rej) => {
|
|
22
|
-
const elem = document.getElementById("root");
|
|
23
|
-
if (elem) {
|
|
24
|
-
resolve({ htmlElement: elem });
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
beforeEach: async ({ htmlElement }, initializer, testResource, artificer, initialValues) => {
|
|
29
|
-
return new Promise((resolve, rej) => {
|
|
30
|
-
// console.log("beforeEach" + JSON.stringify(initializer) + JSON.stringify(initialValues));
|
|
31
|
-
// Ignore these type errors
|
|
32
|
-
ReactDom.createRoot(htmlElement).render(createElement(TesterantoComponent, Object.assign(Object.assign({}, initializer), { done: (reactElement) => {
|
|
33
|
-
resolve({
|
|
34
|
-
htmlElement,
|
|
35
|
-
reactElement,
|
|
36
|
-
});
|
|
37
|
-
} }), []));
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
andWhen: function (s, whenCB) {
|
|
41
|
-
return whenCB(s);
|
|
42
|
-
},
|
|
43
|
-
butThen: async function (s) {
|
|
44
|
-
return s;
|
|
45
|
-
},
|
|
46
|
-
afterEach: async function (store, ndx, artificer) {
|
|
47
|
-
return {};
|
|
48
|
-
},
|
|
49
|
-
afterAll: (store, artificer) => {
|
|
50
|
-
return;
|
|
51
|
-
},
|
|
52
|
-
});
|
|
104
|
+
return t;
|
|
53
105
|
}
|
|
54
106
|
});
|
|
107
|
+
return t;
|
|
55
108
|
};
|
package/dist/module/Web.js
CHANGED
|
@@ -1,52 +1,32 @@
|
|
|
1
|
+
import { PM_Web } from "./PM/web";
|
|
1
2
|
import Testeranto from "./lib/core.js";
|
|
2
3
|
import { defaultTestResourceRequirement, } from "./lib/index.js";
|
|
3
|
-
// const remote = require("@electron/remote");
|
|
4
|
-
// import remote from "@electron/remote";
|
|
5
|
-
// const electron = require("electron");
|
|
6
|
-
// const remote =
|
|
7
|
-
// process.type === "browser" ? electron : require("@electron/remote");
|
|
8
4
|
class WebTesteranto extends Testeranto {
|
|
9
5
|
constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
|
|
10
|
-
super(input, testSpecification, testImplementation, testResourceRequirement,
|
|
11
|
-
const testResourceArg = decodeURIComponent(new URLSearchParams(location.search).get("requesting") || "");
|
|
12
|
-
try {
|
|
13
|
-
const partialTestResource = JSON.parse(testResourceArg);
|
|
14
|
-
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
console.error(e);
|
|
18
|
-
// process.exit(-1);
|
|
19
|
-
}
|
|
20
|
-
const requesting = new URLSearchParams(location.search).get("requesting");
|
|
21
|
-
if (requesting) {
|
|
22
|
-
const testResourceArg = decodeURIComponent(requesting);
|
|
23
|
-
try {
|
|
24
|
-
const partialTestResource = JSON.parse(testResourceArg);
|
|
25
|
-
console.log("initial test resource", partialTestResource);
|
|
26
|
-
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
console.error(e);
|
|
30
|
-
// process.exit(-1);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
6
|
+
super(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
|
|
33
7
|
}
|
|
34
|
-
async receiveTestResourceConfig(
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
8
|
+
async receiveTestResourceConfig(partialTestResource) {
|
|
9
|
+
const t = partialTestResource; //JSON.parse(partialTestResource);
|
|
10
|
+
const pm = new PM_Web(t);
|
|
11
|
+
const { failed, artifacts, logPromise } = await this.testJobs[0].receiveTestResourceConfig(pm);
|
|
12
|
+
pm.customclose();
|
|
13
|
+
// Promise.all([...artifacts, logPromise]).then(async () => {
|
|
14
|
+
// console.log("hello world");
|
|
15
|
+
// pm.customclose();
|
|
16
|
+
// // we can't close the window becuase we might be taking a screenshot
|
|
17
|
+
// // window.close();
|
|
18
|
+
// // console.log(
|
|
19
|
+
// // "(window as any).browser",
|
|
20
|
+
// // JSON.stringify(await (window as any).browser)
|
|
21
|
+
// // );
|
|
22
|
+
// // var currentWindow = (await (window as any).browser).getCurrentWindow();
|
|
23
|
+
// // window.close();
|
|
24
|
+
// // var customWindow = window.open("", "_blank", "");
|
|
25
|
+
// // customWindow.close();
|
|
26
|
+
// // this.puppetMaster.browser.page
|
|
27
|
+
// // window["customclose"]();
|
|
28
|
+
// // console.log("goodbye", window["customclose"]());
|
|
29
|
+
// });
|
|
50
30
|
}
|
|
51
31
|
}
|
|
52
32
|
export default async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = defaultTestResourceRequirement) => {
|
|
@@ -14,7 +14,6 @@ export default (config, entryPoints) => {
|
|
|
14
14
|
"features.test.ts",
|
|
15
15
|
// "url",
|
|
16
16
|
"react",
|
|
17
|
-
"electron",
|
|
18
17
|
"path",
|
|
19
18
|
"fs",
|
|
20
19
|
"stream",
|
|
@@ -29,6 +28,9 @@ export default (config, entryPoints) => {
|
|
|
29
28
|
"zlib",
|
|
30
29
|
"crypto",
|
|
31
30
|
"https",
|
|
31
|
+
"util",
|
|
32
|
+
"process",
|
|
33
|
+
"dns",
|
|
32
34
|
], platform: "browser", entryPoints: [...entryPoints], plugins: [
|
|
33
35
|
...(config.webPlugins || []),
|
|
34
36
|
{
|