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
|
@@ -33,13 +33,13 @@ exports.default = (testImplementations, testSpecifications, testInput) => {
|
|
|
33
33
|
document.addEventListener("DOMContentLoaded", function () {
|
|
34
34
|
const rootElement = document.getElementById("root");
|
|
35
35
|
if (rootElement) {
|
|
36
|
-
const TesterantoComponent = function ({ done, innerComp }) {
|
|
36
|
+
const TesterantoComponent = function ({ done, innerComp, }) {
|
|
37
37
|
const myContainer = (0, react_1.useRef)(null);
|
|
38
38
|
(0, react_1.useEffect)(() => {
|
|
39
39
|
console.log("useEffect called", myContainer.current);
|
|
40
40
|
done(myContainer.current);
|
|
41
41
|
}, []);
|
|
42
|
-
return react_1.default.createElement(
|
|
42
|
+
return react_1.default.createElement("div", { ref: myContainer }, innerComp());
|
|
43
43
|
};
|
|
44
44
|
(0, Web_js_1.default)(testInput, testSpecifications, testImplementations, {
|
|
45
45
|
beforeAll: async (input, artificer) => {
|
|
@@ -55,28 +55,36 @@ exports.default = (testImplementations, testSpecifications, testInput) => {
|
|
|
55
55
|
process.nextTick(() => {
|
|
56
56
|
resolve(reactElement);
|
|
57
57
|
});
|
|
58
|
-
}
|
|
58
|
+
},
|
|
59
59
|
}), rootElement);
|
|
60
60
|
});
|
|
61
61
|
},
|
|
62
62
|
andWhen: function (s, whenCB) {
|
|
63
63
|
return new Promise((resolve, rej) => {
|
|
64
|
-
process.nextTick(() => {
|
|
64
|
+
process.nextTick(() => {
|
|
65
|
+
resolve(whenCB()(s));
|
|
66
|
+
});
|
|
65
67
|
});
|
|
66
68
|
},
|
|
67
69
|
butThen: async function (s) {
|
|
68
70
|
return new Promise((resolve, rej) => {
|
|
69
|
-
process.nextTick(() => {
|
|
71
|
+
process.nextTick(() => {
|
|
72
|
+
resolve(s);
|
|
73
|
+
});
|
|
70
74
|
});
|
|
71
75
|
},
|
|
72
76
|
afterEach: async function (store, ndx, artificer) {
|
|
73
77
|
return new Promise((resolve, rej) => {
|
|
74
|
-
process.nextTick(() => {
|
|
78
|
+
process.nextTick(() => {
|
|
79
|
+
resolve({});
|
|
80
|
+
});
|
|
75
81
|
});
|
|
76
82
|
},
|
|
77
83
|
afterAll: (store, artificer) => {
|
|
78
84
|
return new Promise((resolve, rej) => {
|
|
79
|
-
process.nextTick(() => {
|
|
85
|
+
process.nextTick(() => {
|
|
86
|
+
resolve({});
|
|
87
|
+
});
|
|
80
88
|
});
|
|
81
89
|
},
|
|
82
90
|
});
|
|
@@ -26,9 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const Node_1 = __importDefault(require("../../../Node"));
|
|
30
29
|
const react_1 = __importDefault(require("react"));
|
|
31
30
|
const react_test_renderer_1 = __importStar(require("react-test-renderer"));
|
|
31
|
+
const Node_1 = __importDefault(require("../../../Node"));
|
|
32
32
|
exports.default = (testImplementations, testSpecifications, testInput) => (0, Node_1.default)(testInput, testSpecifications, testImplementations, {
|
|
33
33
|
beforeEach: function (CComponent, props) {
|
|
34
34
|
let component;
|
|
@@ -26,9 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const Web_js_1 = __importDefault(require("../../../Web.js"));
|
|
30
29
|
const react_1 = __importDefault(require("react"));
|
|
31
30
|
const react_test_renderer_1 = __importStar(require("react-test-renderer"));
|
|
31
|
+
const Web_js_1 = __importDefault(require("../../../Web.js"));
|
|
32
32
|
exports.default = (testImplementations, testSpecifications, testInput) => (0, Web_js_1.default)(testInput, testSpecifications, testImplementations, {
|
|
33
33
|
beforeEach: function (CComponent, props) {
|
|
34
34
|
return new Promise((res, rej) => {
|
|
@@ -32,7 +32,6 @@ const react_test_renderer_1 = __importStar(require("react-test-renderer"));
|
|
|
32
32
|
exports.testInterface = {
|
|
33
33
|
butThen: async function (s, thenCB, tr) {
|
|
34
34
|
console.log("butThen", thenCB.toString());
|
|
35
|
-
// debugger
|
|
36
35
|
return thenCB(s);
|
|
37
36
|
},
|
|
38
37
|
beforeEach: function (CComponent, props) {
|
|
@@ -46,5 +45,5 @@ exports.testInterface = {
|
|
|
46
45
|
andWhen: async function (renderer, whenCB) {
|
|
47
46
|
await (0, react_test_renderer_1.act)(() => whenCB(renderer));
|
|
48
47
|
return renderer;
|
|
49
|
-
}
|
|
48
|
+
},
|
|
50
49
|
};
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const index_js_1 = require("./index.js");
|
|
7
6
|
const Web_js_1 = __importDefault(require("../../../Web.js"));
|
|
7
|
+
const index_js_1 = require("./index.js");
|
|
8
8
|
exports.default = (testImplementations, testSpecifications, testInput, testInterface2 = index_js_1.testInterface) => {
|
|
9
9
|
return (0, Web_js_1.default)(testInput, testSpecifications, testImplementations, testInterface2);
|
|
10
10
|
};
|
package/dist/common/Types.js
CHANGED
|
@@ -1,34 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
// // screenshot(options?: puppeteer.ScreenshotOptions) {
|
|
6
|
-
// // return super.screenshot({
|
|
7
|
-
// // ...options,
|
|
8
|
-
// // path: "dist/" + (options ? options : { path: "" }).path,
|
|
9
|
-
// // });
|
|
10
|
-
// // }
|
|
11
|
-
// }
|
|
12
|
-
class TBrowser {
|
|
13
|
-
constructor(browser) {
|
|
14
|
-
this.browser = browser;
|
|
15
|
-
}
|
|
16
|
-
pages() {
|
|
17
|
-
return new Promise(async (res, rej) => {
|
|
18
|
-
res((await this.browser.pages()).map((p) => {
|
|
19
|
-
// const handler = {
|
|
20
|
-
// apply: function (target, thisArg, argumentsList) {
|
|
21
|
-
// console.log('screenshot was called with ' + JSON.stringify(argumentsList));
|
|
22
|
-
// const x: ScreenshotOptions = argumentsList[0]
|
|
23
|
-
// x.path = "./dist/" + x.path;
|
|
24
|
-
// console.log('x.path' + x.path, target, thisArg);
|
|
25
|
-
// return target(...argumentsList);
|
|
26
|
-
// }
|
|
27
|
-
// };
|
|
28
|
-
// p.screenshot = new Proxy(p.screenshot, handler);
|
|
29
|
-
return p;
|
|
30
|
-
}));
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.TBrowser = TBrowser;
|
|
3
|
+
// export type ITTestShape = {
|
|
4
|
+
// };
|
package/dist/common/Web.js
CHANGED
|
@@ -5,25 +5,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const core_js_1 = __importDefault(require("./lib/core.js"));
|
|
7
7
|
const index_js_1 = require("./lib/index.js");
|
|
8
|
-
const remote = require(
|
|
8
|
+
// const remote = require("@electron/remote");
|
|
9
|
+
// import remote from "@electron/remote";
|
|
10
|
+
// const electron = require("electron");
|
|
11
|
+
// const remote =
|
|
12
|
+
// process.type === "browser" ? electron : require("@electron/remote");
|
|
9
13
|
class WebTesteranto extends core_js_1.default {
|
|
10
14
|
constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
|
|
11
15
|
super(input, testSpecification, testImplementation, testResourceRequirement, window.NodeWriter, testInterface);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
console.error(e);
|
|
20
|
-
// process.exit(-1);
|
|
21
|
-
}
|
|
16
|
+
const testResourceArg = decodeURIComponent(new URLSearchParams(location.search).get("requesting") || "");
|
|
17
|
+
try {
|
|
18
|
+
const partialTestResource = JSON.parse(testResourceArg);
|
|
19
|
+
this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.error(e);
|
|
23
|
+
// process.exit(-1);
|
|
25
24
|
}
|
|
26
|
-
const requesting = new URLSearchParams(location.search).get(
|
|
25
|
+
const requesting = new URLSearchParams(location.search).get("requesting");
|
|
27
26
|
if (requesting) {
|
|
28
27
|
const testResourceArg = decodeURIComponent(requesting);
|
|
29
28
|
try {
|
|
@@ -36,17 +35,25 @@ class WebTesteranto extends core_js_1.default {
|
|
|
36
35
|
// process.exit(-1);
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
// const t: ITestJob = this.testJobs[0];
|
|
40
38
|
}
|
|
41
39
|
async receiveTestResourceConfig(t, partialTestResource) {
|
|
42
|
-
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(partialTestResource,
|
|
40
|
+
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(partialTestResource, {
|
|
41
|
+
browser: await window.browser,
|
|
42
|
+
ipc: window.ipcRenderer,
|
|
43
|
+
});
|
|
44
|
+
console.log("test is done, awaiting test result write to fs");
|
|
43
45
|
Promise.all([...artifacts, logPromise]).then(async () => {
|
|
44
|
-
|
|
46
|
+
// we can't close the window becuase we might be taking a screenshot
|
|
45
47
|
// window.close();
|
|
48
|
+
// console.log(
|
|
49
|
+
// "(window as any).browser",
|
|
50
|
+
// JSON.stringify(await (window as any).browser)
|
|
51
|
+
// );
|
|
52
|
+
// var currentWindow = (await (window as any).browser).getCurrentWindow();
|
|
53
|
+
// currentWindow.close();
|
|
46
54
|
});
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
|
-
;
|
|
50
57
|
exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = index_js_1.defaultTestResourceRequirement) => {
|
|
51
58
|
return new WebTesteranto(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
|
|
52
59
|
};
|
package/dist/common/electron.js
CHANGED
|
@@ -3,12 +3,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const readline_1 = __importDefault(require("readline"));
|
|
6
7
|
const electron_1 = require("electron");
|
|
7
8
|
const puppeteer_in_electron_1 = __importDefault(require("puppeteer-in-electron"));
|
|
8
9
|
const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
|
|
9
10
|
const fs_1 = __importDefault(require("fs"));
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
11
12
|
const jsonc_1 = require("jsonc");
|
|
13
|
+
const uuid_1 = require("uuid");
|
|
14
|
+
var mode = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
15
|
+
console.log("hello electron", mode);
|
|
16
|
+
const nodeChildren = {};
|
|
17
|
+
const webChildren = {};
|
|
18
|
+
const node2web = {};
|
|
19
|
+
const web2node = {};
|
|
20
|
+
const childProcesses = {};
|
|
21
|
+
readline_1.default.emitKeypressEvents(process.stdin);
|
|
22
|
+
if (process.stdin.isTTY)
|
|
23
|
+
process.stdin.setRawMode(true);
|
|
24
|
+
console.log("\n Electron is running. Press 'q' to quit\n");
|
|
25
|
+
process.stdin.on("keypress", (str, key) => {
|
|
26
|
+
if (key.name === "q") {
|
|
27
|
+
mode = "PROD";
|
|
28
|
+
// process.exit();
|
|
29
|
+
console.log("Switching to prod mode. Begin shutdown sequence...");
|
|
30
|
+
// process.exit(-1);
|
|
31
|
+
const allDone = Object.values(childProcesses).every((v) => v === "done");
|
|
32
|
+
if (allDone && mode === "PROD") {
|
|
33
|
+
console.log("Goodbye Testeranto by manual shutdown");
|
|
34
|
+
process.exit();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.log(childProcesses);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const onDone = (test) => {
|
|
42
|
+
console.log("onDone", test);
|
|
43
|
+
childProcesses[test] = "done";
|
|
44
|
+
const allDone = Object.values(childProcesses).every((v) => v === "done");
|
|
45
|
+
if (allDone && mode === "PROD") {
|
|
46
|
+
console.log("Goodbye Testeranto by auto shutdown");
|
|
47
|
+
process.exit();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.log(childProcesses);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
process.on("message", function (message) {
|
|
54
|
+
console.log("message: " + message);
|
|
55
|
+
process.exit();
|
|
56
|
+
});
|
|
12
57
|
const remoteMain = require("@electron/remote/main");
|
|
13
58
|
remoteMain.initialize();
|
|
14
59
|
const main = async () => {
|
|
@@ -19,7 +64,7 @@ const main = async () => {
|
|
|
19
64
|
webPreferences: {
|
|
20
65
|
offscreen: false,
|
|
21
66
|
devTools: true,
|
|
22
|
-
}
|
|
67
|
+
},
|
|
23
68
|
});
|
|
24
69
|
win.loadFile(`/${configs.buildDir}/report.html`).then(async (x) => {
|
|
25
70
|
// pie.connect(app, puppeteer).then(async (browser) => {
|
|
@@ -31,135 +76,184 @@ const main = async () => {
|
|
|
31
76
|
// })
|
|
32
77
|
});
|
|
33
78
|
};
|
|
34
|
-
const launchNode = (
|
|
35
|
-
var _a;
|
|
36
|
-
|
|
37
|
-
|
|
79
|
+
const launchNode = (src, dest) => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
console.log("launchNode", src);
|
|
82
|
+
childProcesses[src] = "running";
|
|
83
|
+
const destFolder = dest.replace(".mjs", "");
|
|
84
|
+
const argz = JSON.stringify({
|
|
38
85
|
scheduled: true,
|
|
39
|
-
name:
|
|
40
|
-
ports: [],
|
|
41
|
-
fs:
|
|
86
|
+
name: src,
|
|
87
|
+
ports: [3333],
|
|
88
|
+
// fs: path.resolve(configs.buildDir, "web", destFolder + "/"),
|
|
89
|
+
// fs: destFolder,
|
|
90
|
+
fs: ".",
|
|
42
91
|
});
|
|
43
|
-
console.log("launchNode",
|
|
44
|
-
const child = electron_1.utilityProcess.fork(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
console.log("from child", data);
|
|
48
|
-
launchWebSecondary(process.cwd() + data);
|
|
92
|
+
// console.log("launchNode", src, dest, " -> ", destFolder, argz);
|
|
93
|
+
const child = electron_1.utilityProcess.fork(dest + ".mjs", [argz], {
|
|
94
|
+
cwd: destFolder,
|
|
95
|
+
stdio: "pipe",
|
|
49
96
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
97
|
+
const nodeGuid = (0, uuid_1.v4)();
|
|
98
|
+
nodeChildren[nodeGuid] = child;
|
|
99
|
+
if (!fs_1.default.existsSync(destFolder)) {
|
|
100
|
+
fs_1.default.mkdirSync(destFolder, { recursive: true });
|
|
101
|
+
}
|
|
102
|
+
fs_1.default.rmSync(`${destFolder}/stdout.log`, { force: true });
|
|
103
|
+
fs_1.default.rmSync(`${destFolder}/stderr.log`, { force: true });
|
|
104
|
+
const stdout = fs_1.default.createWriteStream(`${destFolder}/stdout.log`);
|
|
105
|
+
const stderr = fs_1.default.createWriteStream(`${destFolder}/stderr.log`);
|
|
106
|
+
child
|
|
107
|
+
.on("message", (data) => {
|
|
108
|
+
console.log("from child", JSON.stringify(data));
|
|
109
|
+
if (data.launchWeb) {
|
|
110
|
+
const guid = (0, uuid_1.v4)();
|
|
111
|
+
const webChild = launchWebSecondary(process.cwd() + data.launchWeb);
|
|
112
|
+
// child.postMessage({ webLaunched: guid });
|
|
113
|
+
webChild.webContents.on("did-finish-load", () => {
|
|
114
|
+
// webChild.webContents.send("message", "hello world");
|
|
115
|
+
child.postMessage({ webLaunched: guid });
|
|
116
|
+
webChildren[guid] = webChild;
|
|
117
|
+
node2web[nodeGuid] = [...(node2web[nodeGuid] || []), guid];
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (data.teardown) {
|
|
121
|
+
webChildren[data.teardown].close();
|
|
122
|
+
delete webChildren[data.teardown];
|
|
123
|
+
node2web[nodeGuid] = node2web[nodeGuid].filter((x) => x !== data.teardown);
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
.on("exit", (data) => {
|
|
127
|
+
stdout.close();
|
|
128
|
+
stderr.close();
|
|
129
|
+
console.log(`ending node ${src}`);
|
|
130
|
+
onDone(src);
|
|
53
131
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// console.log("from child", data) // hello world!
|
|
57
|
-
// launchWebSecondary(process.cwd() + data);
|
|
58
|
-
// })
|
|
59
|
-
// Create a write stream for the file
|
|
60
|
-
const fileStream = fs_1.default.createWriteStream('errors.txt');
|
|
61
|
-
// Pipe the child process's stdout to the file
|
|
62
|
-
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.pipe(fileStream);
|
|
63
|
-
// // Handle errors
|
|
64
|
-
// child.on('error', (err) => {
|
|
65
|
-
// console.error('Error spawning child process:', err);
|
|
66
|
-
// });
|
|
67
|
-
// fileStream.on('error', (err) => {
|
|
68
|
-
// console.error('Error writing to file:', err);
|
|
69
|
-
// });
|
|
70
|
-
// // Log a message when the child process exits
|
|
71
|
-
// child.on('close', (code) => {
|
|
72
|
-
// console.log(`Child process exited with code ${code}`);
|
|
73
|
-
// });
|
|
74
|
-
// console.log("child", child);
|
|
75
|
-
// child.stdout?.on("data", (x) => {
|
|
76
|
-
// console.log("x", x)
|
|
77
|
-
// })
|
|
132
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.pipe(stdout);
|
|
133
|
+
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.pipe(stderr);
|
|
78
134
|
};
|
|
79
135
|
const launchWebSecondary = (htmlFile) => {
|
|
80
136
|
console.log("launchWebSecondary", htmlFile);
|
|
81
137
|
const subWin = new electron_1.BrowserWindow({
|
|
82
|
-
show:
|
|
138
|
+
show: false,
|
|
83
139
|
webPreferences: {
|
|
84
140
|
nodeIntegration: true,
|
|
85
141
|
nodeIntegrationInWorker: true,
|
|
86
142
|
contextIsolation: false,
|
|
87
|
-
preload: path_1.default.join(electron_1.app.getAppPath(),
|
|
143
|
+
preload: path_1.default.join(electron_1.app.getAppPath(), "preload.js"),
|
|
88
144
|
offscreen: false,
|
|
89
|
-
devTools:
|
|
90
|
-
}
|
|
145
|
+
devTools: true,
|
|
146
|
+
},
|
|
91
147
|
});
|
|
92
148
|
remoteMain.enable(subWin.webContents);
|
|
93
149
|
subWin.webContents.openDevTools();
|
|
94
150
|
subWin.loadFile(htmlFile);
|
|
151
|
+
return subWin;
|
|
152
|
+
// const uuid = uuidv4();
|
|
153
|
+
// windows[uuid] = subWin;
|
|
154
|
+
// return uuid;
|
|
95
155
|
};
|
|
96
|
-
const launchWeb = (t,
|
|
97
|
-
console.log("launchWeb",
|
|
156
|
+
const launchWeb = (t, dest) => {
|
|
157
|
+
console.log("launchWeb", t);
|
|
158
|
+
childProcesses[t] = "running";
|
|
159
|
+
const destFolder = dest.replace(".mjs", "");
|
|
98
160
|
const subWin = new electron_1.BrowserWindow({
|
|
99
161
|
show: true,
|
|
100
162
|
webPreferences: {
|
|
101
163
|
nodeIntegration: true,
|
|
102
164
|
nodeIntegrationInWorker: true,
|
|
103
165
|
contextIsolation: false,
|
|
104
|
-
preload: path_1.default.join(electron_1.app.getAppPath(),
|
|
166
|
+
preload: path_1.default.join(electron_1.app.getAppPath(), "preload.js"),
|
|
105
167
|
offscreen: false,
|
|
106
168
|
devTools: true,
|
|
107
|
-
}
|
|
169
|
+
},
|
|
108
170
|
});
|
|
171
|
+
webChildren[(0, uuid_1.v4)()] = subWin;
|
|
109
172
|
remoteMain.enable(subWin.webContents);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
173
|
+
const webArgz = JSON.stringify({
|
|
174
|
+
name: dest,
|
|
175
|
+
ports: [].toString(),
|
|
176
|
+
fs: destFolder,
|
|
177
|
+
});
|
|
178
|
+
// console.log("webArgz", webArgz);
|
|
179
|
+
subWin.loadFile(`${dest}.html`, {
|
|
113
180
|
query: {
|
|
114
|
-
requesting: encodeURIComponent(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
181
|
+
requesting: encodeURIComponent(webArgz),
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
if (!fs_1.default.existsSync(destFolder)) {
|
|
185
|
+
fs_1.default.mkdirSync(destFolder, { recursive: true });
|
|
186
|
+
}
|
|
187
|
+
const stdout = fs_1.default.createWriteStream(`${destFolder}/stdout.log`);
|
|
188
|
+
subWin.webContents.on("console-message", (event, level, message, line, sourceId) => {
|
|
189
|
+
stdout.write(JSON.stringify({
|
|
190
|
+
event,
|
|
191
|
+
level,
|
|
192
|
+
message: JSON.stringify(message),
|
|
193
|
+
line,
|
|
194
|
+
sourceId,
|
|
195
|
+
}, null, 2));
|
|
196
|
+
stdout.write("\n");
|
|
197
|
+
});
|
|
198
|
+
subWin.on("closed", () => {
|
|
199
|
+
stdout.close();
|
|
200
|
+
console.log(`ending web ${t}`);
|
|
201
|
+
// childProcesses[t] = "done";
|
|
202
|
+
onDone(t);
|
|
203
|
+
});
|
|
204
|
+
electron_1.ipcMain.on("message", (message, data) => {
|
|
205
|
+
console.log("ipcMain message: " + JSON.stringify(data));
|
|
206
|
+
// process.exit();
|
|
120
207
|
});
|
|
121
208
|
};
|
|
122
|
-
const
|
|
123
|
-
return path_1.default
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const changer2 = (f, r) => {
|
|
129
|
-
return path_1.default.normalize(`${configs.buildDir}/${r}/${f}`);
|
|
209
|
+
const destinationOfRuntime = (f, r) => {
|
|
210
|
+
return path_1.default
|
|
211
|
+
.normalize(`${configs.buildDir}/${r}/${f}`)
|
|
212
|
+
.split(".")
|
|
213
|
+
.slice(0, -1)
|
|
214
|
+
.join(".");
|
|
130
215
|
};
|
|
131
216
|
puppeteer_in_electron_1.default.initialize(electron_1.app, 2999).then(async () => {
|
|
132
217
|
electron_1.app.on("ready", () => {
|
|
133
218
|
loadReport(configs);
|
|
134
219
|
console.log("running all the tests once initially");
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (
|
|
138
|
-
launchNode(
|
|
220
|
+
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
221
|
+
childProcesses[test] = "loaded";
|
|
222
|
+
if (runtime === "node") {
|
|
223
|
+
launchNode(test, destinationOfRuntime(test, "node"));
|
|
139
224
|
}
|
|
140
|
-
else if (
|
|
141
|
-
launchWeb(
|
|
225
|
+
else if (runtime === "web") {
|
|
226
|
+
launchWeb(test, destinationOfRuntime(test, "web"));
|
|
142
227
|
}
|
|
143
228
|
else {
|
|
144
|
-
console.error("runtime makes no sense",
|
|
229
|
+
console.error("runtime makes no sense", runtime);
|
|
145
230
|
}
|
|
146
231
|
});
|
|
147
232
|
console.log("ready and watching for changes...", configs.buildDir);
|
|
148
233
|
fs_1.default.watch(configs.buildDir, {
|
|
149
234
|
recursive: true,
|
|
150
235
|
}, (eventType, changedFile) => {
|
|
151
|
-
console.log(eventType
|
|
236
|
+
// console.log(eventType);
|
|
152
237
|
if (changedFile) {
|
|
153
|
-
configs.
|
|
154
|
-
if (
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
238
|
+
configs.tests.forEach(([test, runtime, secondaryArtifacts]) => {
|
|
239
|
+
if (eventType === "change" || eventType === "rename") {
|
|
240
|
+
if (changedFile ===
|
|
241
|
+
test
|
|
242
|
+
.replace("./", "node/")
|
|
243
|
+
.split(".")
|
|
244
|
+
.slice(0, -1)
|
|
245
|
+
.concat("mjs")
|
|
246
|
+
.join(".")) {
|
|
247
|
+
launchNode(test, destinationOfRuntime(test, "node"));
|
|
160
248
|
}
|
|
161
|
-
|
|
162
|
-
|
|
249
|
+
if (changedFile ===
|
|
250
|
+
test
|
|
251
|
+
.replace("./", "web/")
|
|
252
|
+
.split(".")
|
|
253
|
+
.slice(0, -1)
|
|
254
|
+
.concat("mjs")
|
|
255
|
+
.join(".")) {
|
|
256
|
+
launchWeb(test, destinationOfRuntime(test, "web"));
|
|
163
257
|
}
|
|
164
258
|
}
|
|
165
259
|
});
|
|
@@ -170,27 +264,3 @@ const main = async () => {
|
|
|
170
264
|
await puppeteer_in_electron_1.default.connect(electron_1.app, puppeteer_core_1.default);
|
|
171
265
|
};
|
|
172
266
|
main();
|
|
173
|
-
// ipcMain.handle('web-log', (x, message: string) => {
|
|
174
|
-
// console.log("web-log)", message);
|
|
175
|
-
// });
|
|
176
|
-
// ipcMain.handle('web-error', (x, message: string) => {
|
|
177
|
-
// console.log("web-error)", message);
|
|
178
|
-
// });
|
|
179
|
-
// ipcMain.handle('web-warn', (x, message: string) => {
|
|
180
|
-
// console.log("web-warn)", message);
|
|
181
|
-
// });
|
|
182
|
-
// ipcMain.handle('web-info', (x, message: string) => {
|
|
183
|
-
// console.log("web-info)", message);
|
|
184
|
-
// });
|
|
185
|
-
// ipcMain.handle('quit-app', (x, failed: number) => {
|
|
186
|
-
// console.log("quit-app", failed);
|
|
187
|
-
// app.exit(failed);
|
|
188
|
-
// });
|
|
189
|
-
// process.stdin.on("data", (configTests) => {
|
|
190
|
-
// main(JSON.parse(configTests.toString()) as ITestTypes[]);
|
|
191
|
-
// });
|
|
192
|
-
// const watchables = (tests: ITestTypes[]) => {
|
|
193
|
-
// return tests.map((t) => {
|
|
194
|
-
// return [t[1], `dist/${t[1]}/${t[0].replace(".mts", ".mjs")}`]
|
|
195
|
-
// })
|
|
196
|
-
// }
|
|
@@ -5,16 +5,16 @@ exports.default = (config) => {
|
|
|
5
5
|
target: "esnext",
|
|
6
6
|
format: "esm",
|
|
7
7
|
splitting: true,
|
|
8
|
-
outExtension: {
|
|
8
|
+
outExtension: { ".js": ".mjs" },
|
|
9
9
|
outbase: config.outbase,
|
|
10
|
-
jsx:
|
|
10
|
+
jsx: "transform",
|
|
11
11
|
bundle: true,
|
|
12
12
|
minify: config.minify === true,
|
|
13
13
|
write: true,
|
|
14
14
|
loader: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
".js": "jsx",
|
|
16
|
+
".png": "binary",
|
|
17
|
+
".jpg": "binary",
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
};
|