testeranto 0.62.0 → 0.70.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 +42 -21
- package/dist/cjs-shim.js +2 -2
- package/dist/common/Node.js +7 -24
- package/dist/common/NodeWriter.js +7 -9
- package/dist/common/Project.js +103 -266
- package/dist/common/SubPackages/puppeteer.js +1 -1
- package/dist/common/SubPackages/react-dom/component/web.js +1 -1
- package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
- package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -2
- package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/common/Types.js +2 -32
- package/dist/common/Web.js +25 -18
- package/dist/common/electron.js +177 -107
- package/dist/common/esbuildConfigs/index.js +5 -5
- package/dist/common/esbuildConfigs/node.js +17 -15
- package/dist/common/esbuildConfigs/report.js +12 -47
- package/dist/common/esbuildConfigs/tests.js +0 -1
- package/dist/common/esbuildConfigs/web.js +14 -11
- package/dist/common/lib/abstractBase.js +13 -6
- package/dist/common/lib/basebuilder.js +11 -11
- package/dist/common/lib/classBuilder.js +2 -3
- package/dist/common/lib/core.js +37 -8
- package/dist/common/lib/index.js +10 -8
- package/dist/common/lib/types.js +2 -0
- package/dist/common/preload.js +15 -25
- package/dist/common/puppeteerConfiger.js +24 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/Node.js +7 -24
- package/dist/module/NodeWriter.js +7 -9
- package/dist/module/Project.js +104 -267
- package/dist/module/SubPackages/puppeteer.js +1 -1
- package/dist/module/SubPackages/react/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-dom/component/node.js +2 -2
- package/dist/module/SubPackages/react-dom/component/web.js +1 -1
- package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
- package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
- package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -2
- package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
- package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
- package/dist/module/Types.js +3 -30
- package/dist/module/Web.js +26 -19
- package/dist/module/electron.js +179 -109
- package/dist/module/esbuildConfigs/index.js +5 -5
- package/dist/module/esbuildConfigs/node.js +17 -15
- package/dist/module/esbuildConfigs/report.js +11 -48
- package/dist/module/esbuildConfigs/tests.js +0 -1
- package/dist/module/esbuildConfigs/web.js +14 -11
- package/dist/module/lib/abstractBase.js +13 -6
- package/dist/module/lib/basebuilder.js +11 -11
- package/dist/module/lib/classBuilder.js +2 -3
- package/dist/module/lib/core.js +39 -10
- package/dist/module/lib/index.js +10 -8
- package/dist/module/lib/types.js +1 -0
- package/dist/module/preload.js +12 -25
- package/dist/module/puppeteerConfiger.js +19 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/types/Node.d.ts +3 -2
- package/dist/types/Project.d.ts +1 -2
- package/dist/types/SubPackages/puppeteer.d.ts +3 -3
- package/dist/types/SubPackages/react/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
- package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
- package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
- package/dist/types/Types.d.ts +19 -100
- package/dist/types/Web.d.ts +3 -2
- package/dist/types/esbuildConfigs/features.d.ts +1 -1
- package/dist/types/esbuildConfigs/index.d.ts +1 -1
- package/dist/types/esbuildConfigs/node.d.ts +1 -1
- package/dist/types/esbuildConfigs/report.d.ts +4 -0
- package/dist/types/esbuildConfigs/tests.d.ts +1 -1
- package/dist/types/esbuildConfigs/web.d.ts +1 -1
- package/dist/types/lib/abstractBase.d.ts +25 -24
- package/dist/types/lib/basebuilder.d.ts +8 -7
- package/dist/types/lib/classBuilder.d.ts +3 -2
- package/dist/types/lib/core.d.ts +3 -2
- package/dist/types/lib/index.d.ts +4 -3
- package/dist/types/lib/types.d.ts +70 -0
- package/dist/types/puppeteerConfiger.d.ts +4 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/Node.ts +24 -54
- package/src/NodeWriter.ts +21 -18
- package/src/Project.ts +165 -620
- package/src/Report.tsx +1 -1
- package/src/SubPackages/puppeteer.ts +19 -14
- package/src/SubPackages/react/component/node.ts +20 -32
- package/src/SubPackages/react/component/web.ts +20 -30
- package/src/SubPackages/react/jsx/index.ts +13 -24
- package/src/SubPackages/react/jsx/web.ts +10 -8
- package/src/SubPackages/react-dom/component/node.ts +17 -23
- package/src/SubPackages/react-dom/component/web.ts +30 -50
- package/src/SubPackages/react-dom/jsx/web.ts +41 -48
- package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
- package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
- package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
- package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
- package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
- package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
- package/src/SubPackages/react-test-renderer/jsx/index.ts +16 -21
- package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
- package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
- package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
- package/src/Types.ts +73 -307
- package/src/Web.ts +54 -53
- package/src/cjs-shim.js +2 -2
- package/src/electron.ts +258 -191
- package/src/esbuildConfigs/features.ts +3 -4
- package/src/esbuildConfigs/index.ts +8 -8
- package/src/esbuildConfigs/node.ts +21 -20
- package/src/esbuildConfigs/report.ts +15 -51
- package/src/esbuildConfigs/tests.ts +3 -9
- package/src/esbuildConfigs/web.ts +18 -18
- package/src/lib/abstractBase.ts +78 -125
- package/src/lib/basebuilder.ts +109 -134
- package/src/lib/classBuilder.ts +26 -45
- package/src/lib/core.ts +101 -69
- package/src/lib/index.ts +53 -52
- package/src/lib/types.ts +206 -0
- package/src/preload.ts +12 -28
- package/src/puppeteerConfiger.ts +26 -0
- package/src/web.html.ts +1 -1
- package/dist/common/lib/browser.js +0 -26
- package/dist/common/nodeWriterElectron.js +0 -55
- package/dist/module/lib/browser.js +0 -22
- package/dist/module/nodeWriterElectron.js +0 -52
- package/dist/types/lib/browser.d.ts +0 -6
- package/dist/types/nodeWriterElectron.d.ts +0 -2
- package/src/lib/browser.ts +0 -34
- package/src/nodeWriterElectron.ts +0 -71
package/dist/module/Node.js
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
import http from "http";
|
|
2
1
|
import puppeteer from "puppeteer-core";
|
|
3
2
|
import Testeranto from "./lib/core.js";
|
|
4
3
|
import { defaultTestResourceRequirement, } from "./lib/index.js";
|
|
5
4
|
import { NodeWriter } from "./NodeWriter.js";
|
|
6
|
-
import
|
|
7
|
-
const readJson = async (port) => new Promise((resolve, reject) => {
|
|
8
|
-
let json = "";
|
|
9
|
-
const request = http.request({
|
|
10
|
-
host: "127.0.0.1",
|
|
11
|
-
path: "/json/version",
|
|
12
|
-
port,
|
|
13
|
-
}, (response) => {
|
|
14
|
-
response.on("error", reject);
|
|
15
|
-
response.on("data", (chunk) => {
|
|
16
|
-
json += chunk.toString();
|
|
17
|
-
});
|
|
18
|
-
response.on("end", () => {
|
|
19
|
-
resolve(JSON.parse(json));
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
request.on("error", reject);
|
|
23
|
-
request.end();
|
|
24
|
-
});
|
|
5
|
+
import puppeteerConfiger from "./puppeteerConfiger.js";
|
|
25
6
|
class NodeTesteranto extends Testeranto {
|
|
26
7
|
constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
|
|
27
8
|
super(input, testSpecification, testImplementation, testResourceRequirement, NodeWriter, testInterface);
|
|
@@ -41,7 +22,7 @@ class NodeTesteranto extends Testeranto {
|
|
|
41
22
|
}
|
|
42
23
|
}
|
|
43
24
|
async receiveTestResourceConfig(t, partialTestResource) {
|
|
44
|
-
const browser = await
|
|
25
|
+
const browser = await puppeteerConfiger("2999").then(async (json) => {
|
|
45
26
|
const b = await puppeteer.connect({
|
|
46
27
|
browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
47
28
|
defaultViewport: null,
|
|
@@ -49,13 +30,15 @@ class NodeTesteranto extends Testeranto {
|
|
|
49
30
|
console.log("connected!", b.isConnected());
|
|
50
31
|
return b;
|
|
51
32
|
});
|
|
52
|
-
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(partialTestResource,
|
|
33
|
+
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(partialTestResource, {
|
|
34
|
+
browser,
|
|
35
|
+
ipc: process.parentPort,
|
|
36
|
+
});
|
|
53
37
|
Promise.all([...artifacts, logPromise]).then(async () => {
|
|
54
|
-
|
|
38
|
+
process.exit((await failed) ? 1 : 0);
|
|
55
39
|
});
|
|
56
40
|
}
|
|
57
41
|
}
|
|
58
|
-
;
|
|
59
42
|
export default async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = defaultTestResourceRequirement) => {
|
|
60
43
|
return new NodeTesteranto(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
|
|
61
44
|
};
|
|
@@ -2,14 +2,12 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
const fPaths = [];
|
|
4
4
|
export const NodeWriter = {
|
|
5
|
-
createWriteStream: (filepath) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
mkdirSync: async (fp) => {
|
|
12
|
-
await fs.mkdirSync(fp, { recursive: true });
|
|
5
|
+
createWriteStream: (filepath) => fs.createWriteStream(filepath),
|
|
6
|
+
writeFileSync: (fp, contents) => fs.writeFileSync(fp, contents),
|
|
7
|
+
mkdirSync: async (destFolder) => {
|
|
8
|
+
if (!fs.existsSync(destFolder)) {
|
|
9
|
+
fs.mkdirSync(destFolder, { recursive: true });
|
|
10
|
+
}
|
|
13
11
|
},
|
|
14
12
|
testArtiFactoryfileWriter: (tLog, callback) => (fPath, value) => {
|
|
15
13
|
callback(new Promise((res, rej) => {
|
|
@@ -46,5 +44,5 @@ export const NodeWriter = {
|
|
|
46
44
|
}
|
|
47
45
|
});
|
|
48
46
|
}));
|
|
49
|
-
}
|
|
47
|
+
},
|
|
50
48
|
};
|
package/dist/module/Project.js
CHANGED
|
@@ -1,115 +1,130 @@
|
|
|
1
1
|
import esbuild from "esbuild";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import readline from
|
|
4
|
+
import readline from "readline";
|
|
5
5
|
import { glob } from "glob";
|
|
6
6
|
import esbuildNodeConfiger from "./esbuildConfigs/node.js";
|
|
7
7
|
import esbuildWebConfiger from "./esbuildConfigs/web.js";
|
|
8
8
|
import esbuildFeaturesConfiger from "./esbuildConfigs/features.js";
|
|
9
9
|
import webHtmlFrame from "./web.html.js";
|
|
10
10
|
import reportHtmlFrame from "./report.html.js";
|
|
11
|
-
|
|
11
|
+
var mode = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
12
12
|
readline.emitKeypressEvents(process.stdin);
|
|
13
13
|
if (process.stdin.isTTY)
|
|
14
14
|
process.stdin.setRawMode(true);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
process.stdin.on("keypress", (str, key) => {
|
|
16
|
+
if (key.name === "q") {
|
|
17
|
+
console.log("Testeranto-EsBuild is shutting down...");
|
|
18
|
+
mode = "PROD";
|
|
19
|
+
onDone();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
// setInterval(() => {
|
|
23
|
+
// const memoryUsage = process.memoryUsage();
|
|
24
|
+
// console.log("Memory usage:", memoryUsage);
|
|
25
|
+
// }, 10000); // Check every 10 seconds
|
|
26
|
+
let featuresDone, nodeDone, webDone = false;
|
|
27
|
+
const onFeaturesDone = () => {
|
|
28
|
+
featuresDone = true;
|
|
29
|
+
onDone();
|
|
30
|
+
};
|
|
31
|
+
const onNodeDone = () => {
|
|
32
|
+
nodeDone = true;
|
|
33
|
+
onDone();
|
|
34
|
+
};
|
|
35
|
+
const onWebDone = () => {
|
|
36
|
+
webDone = true;
|
|
37
|
+
onDone();
|
|
38
|
+
};
|
|
39
|
+
const onDone = () => {
|
|
40
|
+
console.log(JSON.stringify({
|
|
41
|
+
featuresDone,
|
|
42
|
+
nodeDone,
|
|
43
|
+
webDone,
|
|
44
|
+
mode,
|
|
45
|
+
}, null, 2));
|
|
46
|
+
if (featuresDone && nodeDone && webDone && mode === "PROD") {
|
|
47
|
+
console.log("Testeranto-EsBuild is all done. Goodbye!");
|
|
48
|
+
process.exit();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
console.log("Testeranto-EsBuild is still working...");
|
|
52
|
+
}
|
|
28
53
|
};
|
|
29
54
|
export class ITProject {
|
|
30
55
|
constructor(config) {
|
|
31
|
-
var _a;
|
|
32
56
|
this.mode = `up`;
|
|
33
57
|
this.config = config;
|
|
34
|
-
|
|
35
|
-
if (key.name === 'q') {
|
|
36
|
-
this.initiateShutdown("'q' command");
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
process.stdin.on('keypress', (str, key) => {
|
|
40
|
-
if (key.name === 'x') {
|
|
41
|
-
console.log("Shutting down hard!");
|
|
42
|
-
process.exit(-1);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const childElectron = childProcess.spawn("yarn", ["electron", "node_modules/testeranto/dist/common/electron.js"]);
|
|
46
|
-
// childElectron.stdout.on('data', function (msg) {
|
|
47
|
-
// console.log(msg.toString())
|
|
48
|
-
// });
|
|
49
|
-
const fileStream = fs.createWriteStream(`./${this.config.outdir}/electron.log`);
|
|
50
|
-
(_a = childElectron.stdout) === null || _a === void 0 ? void 0 : _a.pipe(fileStream);
|
|
51
|
-
Promise.resolve(Promise.all([
|
|
52
|
-
...this.getSecondaryEndpointsPoints("web"),
|
|
53
|
-
]
|
|
54
|
-
.map(async (sourceFilePath) => {
|
|
58
|
+
Promise.resolve(Promise.all([...this.getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
|
|
55
59
|
const sourceFileSplit = sourceFilePath.split("/");
|
|
56
60
|
const sourceDir = sourceFileSplit.slice(0, -1);
|
|
57
61
|
const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
|
|
58
|
-
const sourceFileNameMinusJs = sourceFileName
|
|
62
|
+
const sourceFileNameMinusJs = sourceFileName
|
|
63
|
+
.split(".")
|
|
64
|
+
.slice(0, -1)
|
|
65
|
+
.join(".");
|
|
59
66
|
const htmlFilePath = path.normalize(`${process.cwd()}/${config.outdir}/web/${sourceDir.join("/")}/${sourceFileNameMinusJs}.html`);
|
|
60
67
|
const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
|
|
61
|
-
return fs.promises
|
|
68
|
+
return fs.promises
|
|
69
|
+
.mkdir(path.dirname(htmlFilePath), { recursive: true })
|
|
70
|
+
.then((x) => fs.writeFileSync(htmlFilePath, webHtmlFrame(jsfilePath, htmlFilePath)));
|
|
62
71
|
})));
|
|
63
72
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
64
|
-
glob(`./${config.outdir}/chunk-*.mjs`, { ignore:
|
|
65
|
-
console.log("deleting chunks", chunks);
|
|
73
|
+
glob(`./${config.outdir}/chunk-*.mjs`, { ignore: "node_modules/**" }).then((chunks) => {
|
|
66
74
|
chunks.forEach((chunk) => {
|
|
67
|
-
console.log("deleting chunk", chunk);
|
|
68
75
|
fs.unlinkSync(chunk);
|
|
69
76
|
});
|
|
70
77
|
});
|
|
71
|
-
fs.copyFileSync("node_modules/testeranto/dist/prebuild/
|
|
72
|
-
fs.copyFileSync("node_modules/testeranto/dist/prebuild/
|
|
78
|
+
fs.copyFileSync("./node_modules/testeranto/dist/prebuild/Report.js", "./docs/Report.js");
|
|
79
|
+
fs.copyFileSync("./node_modules/testeranto/dist/prebuild/Report.css", "./docs/Report.css");
|
|
73
80
|
fs.writeFileSync(`${config.outdir}/report.html`, reportHtmlFrame());
|
|
74
81
|
Promise.all([
|
|
75
|
-
|
|
82
|
+
fs.promises.writeFile(`${config.outdir}/testeranto.json`, JSON.stringify(Object.assign(Object.assign({}, config), { buildDir: process.cwd() + "/" + config.outdir }), null, 2)),
|
|
83
|
+
esbuild
|
|
84
|
+
.context(esbuildFeaturesConfiger(config))
|
|
76
85
|
.then(async (featuresContext) => {
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
if (mode == "DEV") {
|
|
87
|
+
await featuresContext.watch();
|
|
88
|
+
onFeaturesDone();
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
featuresContext.rebuild().then((v) => {
|
|
92
|
+
onFeaturesDone();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
79
95
|
return featuresContext;
|
|
80
96
|
}),
|
|
81
|
-
esbuild
|
|
97
|
+
esbuild
|
|
98
|
+
.context(esbuildNodeConfiger(config, nodeEntryPoints))
|
|
82
99
|
.then(async (nodeContext) => {
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
if (mode == "DEV") {
|
|
101
|
+
await nodeContext.watch().then((v) => {
|
|
102
|
+
onNodeDone();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
nodeContext.rebuild().then((v) => {
|
|
107
|
+
onNodeDone();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
85
110
|
return nodeContext;
|
|
86
111
|
}),
|
|
87
|
-
esbuild
|
|
88
|
-
.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
112
|
+
esbuild
|
|
113
|
+
.context(esbuildWebConfiger(config, webEntryPoints))
|
|
114
|
+
.then(async (webContext) => {
|
|
115
|
+
if (mode == "DEV") {
|
|
116
|
+
await webContext.watch().then((v) => {
|
|
117
|
+
onWebDone();
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
webContext.rebuild().then((v) => {
|
|
122
|
+
onWebDone();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return webContext;
|
|
92
126
|
}),
|
|
93
|
-
])
|
|
94
|
-
Promise.all(config.tests.map(async ([test, runtime]) => {
|
|
95
|
-
return {
|
|
96
|
-
test,
|
|
97
|
-
runtime
|
|
98
|
-
};
|
|
99
|
-
})).then(async (modules) => {
|
|
100
|
-
fs.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify({
|
|
101
|
-
modules,
|
|
102
|
-
buildDir: process.cwd() + "/" + config.outdir
|
|
103
|
-
}, null, 2));
|
|
104
|
-
});
|
|
105
|
-
if (config.devMode === false) {
|
|
106
|
-
console.log("Your tests were built but not run because devMode was false. Exiting gracefully");
|
|
107
|
-
process.exit(0);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
// no-op
|
|
111
|
-
}
|
|
112
|
-
});
|
|
127
|
+
]);
|
|
113
128
|
}
|
|
114
129
|
getSecondaryEndpointsPoints(runtime) {
|
|
115
130
|
const meta = (ts, st) => {
|
|
@@ -125,196 +140,18 @@ export class ITProject {
|
|
|
125
140
|
};
|
|
126
141
|
return Array.from(meta(this.config.tests, new Set()));
|
|
127
142
|
}
|
|
128
|
-
initiateShutdown(reason) {
|
|
129
|
-
console.log("Shutdown initiated because", reason);
|
|
130
|
-
this.mode = "down";
|
|
131
|
-
}
|
|
132
143
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
// });
|
|
148
|
-
// webSocketServer.on('close', (data) => {
|
|
149
|
-
// console.log('webSocketServer close: %s', data);
|
|
150
|
-
// });
|
|
151
|
-
// webSocketServer.on('listening', () => {
|
|
152
|
-
// console.log("webSocketServer listening", webSocketServer.address());
|
|
153
|
-
// });
|
|
154
|
-
// webSocketServer.on('connection', (webSocket: WebSocket) => {
|
|
155
|
-
// webSocket.on('message', (webSocketData) => {
|
|
156
|
-
// const payload = JSON.parse(webSocketData.valueOf().toString() as any);
|
|
157
|
-
// const messageType = payload.type;
|
|
158
|
-
// if (messageType === "testeranto:hola") {
|
|
159
|
-
// const name = payload.data.requirement.name;
|
|
160
|
-
// const requestedResources = payload.data;
|
|
161
|
-
// this.websockets[name] = webSocket
|
|
162
|
-
// console.log('hola WS! connected: ' + name + ' in ' + Object.getOwnPropertyNames(this.websockets))
|
|
163
|
-
// this.requestResource(requestedResources.requirement, 'ws');
|
|
164
|
-
// } else if (messageType === "testeranto:adios") {
|
|
165
|
-
// console.log("adios WS", payload.data.testResourceConfiguration.name);
|
|
166
|
-
// this.releaseTestResourceWs(payload as any);
|
|
167
|
-
// }
|
|
168
|
-
// });
|
|
169
|
-
// });
|
|
170
|
-
// const makePath = (fPath: string, rt: IRunTime): string => {
|
|
171
|
-
// return path.resolve("./" + config.outdir + "/" +
|
|
172
|
-
// rt +
|
|
173
|
-
// // (rt === "electron" || rt === "chromium" ? "web" : "node") +
|
|
174
|
-
// "/" + fPath.replace(path.extname(fPath), "") + ".mjs");
|
|
175
|
-
// };
|
|
176
|
-
// const bootInterval = setInterval(async () => {
|
|
177
|
-
// const filesToLookup = this.tests
|
|
178
|
-
// .map(([p, rt]) => {
|
|
179
|
-
// const filepath = makePath(p, rt);
|
|
180
|
-
// return {
|
|
181
|
-
// filepath,
|
|
182
|
-
// exists: fsExists(filepath),
|
|
183
|
-
// };
|
|
184
|
-
// });
|
|
185
|
-
// const allFilesExist = (
|
|
186
|
-
// await Promise.all(filesToLookup.map((f) => f.exists))
|
|
187
|
-
// ).every((b) => b);
|
|
188
|
-
// if (!allFilesExist) {
|
|
189
|
-
// console.log(this.spinner(), "waiting for files to build...")
|
|
190
|
-
// filesToLookup.forEach((f) => {
|
|
191
|
-
// console.log(f.exists, "\t", f.filepath);
|
|
192
|
-
// })
|
|
193
|
-
// } else {
|
|
194
|
-
// clearInterval(bootInterval);
|
|
195
|
-
// pm2.launchBus((err, pm2_bus) => {
|
|
196
|
-
// pm2_bus.on("testeranto:hola", (packet: { data: { requirement: ITTestResourceRequirement } }) => {
|
|
197
|
-
// this.requestResource(
|
|
198
|
-
// packet.data.requirement,
|
|
199
|
-
// 'ipc'
|
|
200
|
-
// );
|
|
201
|
-
// });
|
|
202
|
-
// pm2_bus.on("testeranto:adios", (payload: IAdiosIPC) => {
|
|
203
|
-
// this.releaseTestResourcePm2(payload.data);
|
|
204
|
-
// });
|
|
205
|
-
// });
|
|
206
|
-
// this
|
|
207
|
-
// .tests
|
|
208
|
-
// .reduce((m, [inputFilePath, runtime]) => {
|
|
209
|
-
// const script = makePath(inputFilePath, runtime);
|
|
210
|
-
// const partialTestResourceByCommandLineArg = `${script} '${JSON.stringify(
|
|
211
|
-
// {
|
|
212
|
-
// name: inputFilePath,
|
|
213
|
-
// ports: [],
|
|
214
|
-
// fs: path.resolve(
|
|
215
|
-
// process.cwd(),
|
|
216
|
-
// config.outdir,
|
|
217
|
-
// inputFilePath
|
|
218
|
-
// ),
|
|
219
|
-
// }
|
|
220
|
-
// )}'`;
|
|
221
|
-
// if (runtime === "web") {
|
|
222
|
-
// pm2.start(electron_pm2_StartOptions(
|
|
223
|
-
// partialTestResourceByCommandLineArg,
|
|
224
|
-
// inputFilePath,
|
|
225
|
-
// config
|
|
226
|
-
// ),
|
|
227
|
-
// (err, proc) => {
|
|
228
|
-
// if (err) {
|
|
229
|
-
// console.error(err);
|
|
230
|
-
// return pm2.disconnect();
|
|
231
|
-
// }
|
|
232
|
-
// }
|
|
233
|
-
// );
|
|
234
|
-
// // } else if (runtime === "chromium") {
|
|
235
|
-
// // pm2.start(
|
|
236
|
-
// // chromium_pm2_StartOptions(
|
|
237
|
-
// // partialTestResourceByCommandLineArg,
|
|
238
|
-
// // inputFilePath,
|
|
239
|
-
// // config,
|
|
240
|
-
// // ),
|
|
241
|
-
// // (err, proc) => {
|
|
242
|
-
// // if (err) {
|
|
243
|
-
// // console.error(err);
|
|
244
|
-
// // return pm2.disconnect();
|
|
245
|
-
// // }
|
|
246
|
-
// // }
|
|
247
|
-
// // );
|
|
248
|
-
// } else if (runtime === "node") {
|
|
249
|
-
// const resolvedPath = path.resolve(script);
|
|
250
|
-
// console.log("watching", resolvedPath);
|
|
251
|
-
// pm2.start(node_pm2_StartOptions(
|
|
252
|
-
// partialTestResourceByCommandLineArg,
|
|
253
|
-
// inputFilePath,
|
|
254
|
-
// config,
|
|
255
|
-
// resolvedPath
|
|
256
|
-
// ), (err, proc) => {
|
|
257
|
-
// if (err) {
|
|
258
|
-
// console.error(err);
|
|
259
|
-
// return pm2.disconnect();
|
|
260
|
-
// }
|
|
261
|
-
// });
|
|
262
|
-
// }
|
|
263
|
-
// this.exitCodes[inputFilePath] = null;
|
|
264
|
-
// return [inputFilePath, ...m];
|
|
265
|
-
// }, []);
|
|
266
|
-
// setInterval(this.mainLoop, TIMEOUT).unref();
|
|
267
|
-
// }
|
|
268
|
-
// }, TIMEOUT).unref();
|
|
269
|
-
// });
|
|
270
|
-
// public requestResource(
|
|
271
|
-
// requirement: ITTestResourceRequirement,
|
|
272
|
-
// protocol: ISchedulerProtocols
|
|
273
|
-
// ) {
|
|
274
|
-
// this.resourceQueue.push({ requirement, protocol });
|
|
275
|
-
// }
|
|
276
|
-
// const OPEN_PORT = "";
|
|
277
|
-
// type ISchedulerProtocols = `ipc` | `ws`;
|
|
278
|
-
// type IAdios = {
|
|
279
|
-
// name: string;
|
|
280
|
-
// failed: any;
|
|
281
|
-
// testResourceConfiguration: {
|
|
282
|
-
// name: string;
|
|
283
|
-
// };
|
|
284
|
-
// results: {
|
|
285
|
-
// fails: any[];
|
|
286
|
-
// givens: any[];
|
|
287
|
-
// name: string;
|
|
288
|
-
// };
|
|
289
|
-
// };
|
|
290
|
-
// type IAdiosIPC = {
|
|
291
|
-
// process: {
|
|
292
|
-
// namespace: string;
|
|
293
|
-
// versioning: object;
|
|
294
|
-
// name: string;
|
|
295
|
-
// pm_id: number;
|
|
296
|
-
// };
|
|
297
|
-
// data: IAdios
|
|
298
|
-
// at: string;
|
|
299
|
-
// };
|
|
300
|
-
// clearScreen: boolean;
|
|
301
|
-
// devMode: boolean;
|
|
302
|
-
// exitCodes: Record<number, string> = {};
|
|
303
|
-
// features: TesterantoFeatures;
|
|
304
|
-
// ports: Record<string, string> = {};
|
|
305
|
-
// tests: ITestTypes[];
|
|
306
|
-
// websockets: Record<string, WebSocket> = {};
|
|
307
|
-
// resourceQueue: {
|
|
308
|
-
// requirement: ITTestResourceRequirement,
|
|
309
|
-
// protocol: ISchedulerProtocols,
|
|
310
|
-
// }[] = [];
|
|
311
|
-
// private spinCycle = 0;
|
|
312
|
-
// private spinAnimation = "←↖↑↗→↘↓↙";
|
|
313
|
-
// console.log("sending", JSON.stringify(this.tests));
|
|
314
|
-
// childElectron.stdin.write(JSON.stringify(this.tests));
|
|
315
|
-
// not necessary
|
|
316
|
-
// this.esWebServerDetails = await eWeb.serve({
|
|
317
|
-
// servedir: jsonConfig.outdir,
|
|
318
|
-
// });
|
|
319
|
-
// fs.copyFileSync("node_modules/testeranto/dist/index.css", "index.css")
|
|
320
|
-
//
|
|
144
|
+
const getRunnables = (tests, payload = [new Set(), new Set()]) => {
|
|
145
|
+
return tests.reduce((pt, cv, cndx, cry) => {
|
|
146
|
+
if (cv[1] === "node") {
|
|
147
|
+
pt[0].add(cv[0]);
|
|
148
|
+
}
|
|
149
|
+
else if (cv[1] === "web") {
|
|
150
|
+
pt[1].add(cv[0]);
|
|
151
|
+
}
|
|
152
|
+
if (cv[2].length) {
|
|
153
|
+
getRunnables(cv[2], payload);
|
|
154
|
+
}
|
|
155
|
+
return pt;
|
|
156
|
+
}, payload);
|
|
157
|
+
};
|
|
@@ -2,7 +2,7 @@ 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(`/docs/web/src/ClassicalComponent/test.html`);
|
|
6
6
|
return x;
|
|
7
7
|
}, beforeEach: async () => {
|
|
8
8
|
return new Promise((resolve, rej) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Testeranto from "../../../Web.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
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
|
-
import { renderToStaticMarkup, renderToStaticNodeStream } from "react-dom/server";
|
|
3
|
-
import Stream from
|
|
2
|
+
import { renderToStaticMarkup, renderToStaticNodeStream, } from "react-dom/server";
|
|
3
|
+
import Stream from "stream";
|
|
4
4
|
import Testeranto from "../../../Node.js";
|
|
5
5
|
export { renderToStaticMarkup, renderToStaticNodeStream, Stream };
|
|
6
6
|
export default (testImplementations, testSpecifications, testInput) => {
|
|
@@ -29,7 +29,7 @@ export default (testInput, testSpecifications, testImplementations) => {
|
|
|
29
29
|
return new Promise((resolve, rej) => {
|
|
30
30
|
// console.log("beforeEach" + JSON.stringify(initializer) + JSON.stringify(initialValues));
|
|
31
31
|
// Ignore these type errors
|
|
32
|
-
ReactDom.createRoot(htmlElement).render(createElement(TesterantoComponent, Object.assign(Object.assign({}, initializer
|
|
32
|
+
ReactDom.createRoot(htmlElement).render(createElement(TesterantoComponent, Object.assign(Object.assign({}, initializer), { done: (reactElement) => {
|
|
33
33
|
resolve({
|
|
34
34
|
htmlElement,
|
|
35
35
|
reactElement,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React, { useEffect, useRef
|
|
2
|
-
import { createPortal } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
3
|
import Testeranto from "../../../Web.js";
|
|
4
4
|
export default (testImplementations, testSpecifications, testInput) => {
|
|
5
5
|
document.addEventListener("DOMContentLoaded", function () {
|
|
6
6
|
const rootElement = document.getElementById("root");
|
|
7
7
|
if (rootElement) {
|
|
8
|
-
const TesterantoComponent = function ({ done, innerComp }) {
|
|
8
|
+
const TesterantoComponent = function ({ done, innerComp, }) {
|
|
9
9
|
const myContainer = useRef(null);
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
console.log("useEffect called", myContainer.current);
|
|
12
12
|
done(myContainer.current);
|
|
13
13
|
}, []);
|
|
14
|
-
return React.createElement(
|
|
14
|
+
return React.createElement("div", { ref: myContainer }, innerComp());
|
|
15
15
|
};
|
|
16
16
|
Testeranto(testInput, testSpecifications, testImplementations, {
|
|
17
17
|
beforeAll: async (input, artificer) => {
|
|
@@ -27,28 +27,36 @@ export default (testImplementations, testSpecifications, testInput) => {
|
|
|
27
27
|
process.nextTick(() => {
|
|
28
28
|
resolve(reactElement);
|
|
29
29
|
});
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
31
|
}), rootElement);
|
|
32
32
|
});
|
|
33
33
|
},
|
|
34
34
|
andWhen: function (s, whenCB) {
|
|
35
35
|
return new Promise((resolve, rej) => {
|
|
36
|
-
process.nextTick(() => {
|
|
36
|
+
process.nextTick(() => {
|
|
37
|
+
resolve(whenCB()(s));
|
|
38
|
+
});
|
|
37
39
|
});
|
|
38
40
|
},
|
|
39
41
|
butThen: async function (s) {
|
|
40
42
|
return new Promise((resolve, rej) => {
|
|
41
|
-
process.nextTick(() => {
|
|
43
|
+
process.nextTick(() => {
|
|
44
|
+
resolve(s);
|
|
45
|
+
});
|
|
42
46
|
});
|
|
43
47
|
},
|
|
44
48
|
afterEach: async function (store, ndx, artificer) {
|
|
45
49
|
return new Promise((resolve, rej) => {
|
|
46
|
-
process.nextTick(() => {
|
|
50
|
+
process.nextTick(() => {
|
|
51
|
+
resolve({});
|
|
52
|
+
});
|
|
47
53
|
});
|
|
48
54
|
},
|
|
49
55
|
afterAll: (store, artificer) => {
|
|
50
56
|
return new Promise((resolve, rej) => {
|
|
51
|
-
process.nextTick(() => {
|
|
57
|
+
process.nextTick(() => {
|
|
58
|
+
resolve({});
|
|
59
|
+
});
|
|
52
60
|
});
|
|
53
61
|
},
|
|
54
62
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import test from "../../../Node";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import renderer, { act } from "react-test-renderer";
|
|
3
|
+
import test from "../../../Node";
|
|
4
4
|
export default (testImplementations, testSpecifications, testInput) => test(testInput, testSpecifications, testImplementations, {
|
|
5
5
|
beforeEach: function (CComponent, props) {
|
|
6
6
|
let component;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import test from "../../../Web.js";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import renderer, { act } from "react-test-renderer";
|
|
3
|
+
import test from "../../../Web.js";
|
|
4
4
|
export default (testImplementations, testSpecifications, testInput) => test(testInput, testSpecifications, testImplementations, {
|
|
5
5
|
beforeEach: function (CComponent, props) {
|
|
6
6
|
return new Promise((res, rej) => {
|
|
@@ -3,7 +3,6 @@ import renderer, { act } from "react-test-renderer";
|
|
|
3
3
|
export const testInterface = {
|
|
4
4
|
butThen: async function (s, thenCB, tr) {
|
|
5
5
|
console.log("butThen", thenCB.toString());
|
|
6
|
-
// debugger
|
|
7
6
|
return thenCB(s);
|
|
8
7
|
},
|
|
9
8
|
beforeEach: function (CComponent, props) {
|
|
@@ -17,5 +16,5 @@ export const testInterface = {
|
|
|
17
16
|
andWhen: async function (renderer, whenCB) {
|
|
18
17
|
await act(() => whenCB(renderer));
|
|
19
18
|
return renderer;
|
|
20
|
-
}
|
|
19
|
+
},
|
|
21
20
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { testInterface } from "./index.js";
|
|
2
1
|
import test from "../../../Web.js";
|
|
2
|
+
import { testInterface } from "./index.js";
|
|
3
3
|
export default (testImplementations, testSpecifications, testInput, testInterface2 = testInterface) => {
|
|
4
4
|
return test(testInput, testSpecifications, testImplementations, testInterface2);
|
|
5
5
|
};
|