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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# testeranto
|
|
2
2
|
|
|
3
|
-
🚧 WARNING:
|
|
3
|
+
🚧 WARNING: Testeranto is still under development and is not ready for production yet. 🚧
|
|
4
4
|
|
|
5
5
|
home: [adamwong246.github.io/testeranto](https://adamwong246.github.io/testeranto/)
|
|
6
6
|
|
|
@@ -27,14 +27,14 @@ Testeranto.ts an Acceptance Test Driven Development ([ATDD](https://en.wikipedia
|
|
|
27
27
|
|
|
28
28
|
## Getting started
|
|
29
29
|
|
|
30
|
-
1
|
|
31
|
-
2
|
|
32
|
-
3
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
1. Write some code.
|
|
31
|
+
2. Write some tests of that code.
|
|
32
|
+
3. Write some features of that code.
|
|
33
|
+
4. Write a `testeranto.mts`, which acts as a config file.
|
|
34
|
+
5. Launch testeranto. The test runner is now rebuilding the docs folder.
|
|
35
|
+
6. Commit the results of those tests.
|
|
36
|
+
7. Your github pages now shows your report, showing your features, linked with your test results.
|
|
37
|
+
8. Optionally add testeranto to your CI.
|
|
38
38
|
|
|
39
39
|
## tech of note
|
|
40
40
|
|
|
@@ -55,9 +55,9 @@ Testeranto.ts an Acceptance Test Driven Development ([ATDD](https://en.wikipedia
|
|
|
55
55
|
|
|
56
56
|
## the good parts
|
|
57
57
|
|
|
58
|
-
Your tests can be run in node, chromium, or both
|
|
58
|
+
Your tests can be run in node, chromium, or both.
|
|
59
59
|
|
|
60
|
-
Testeranto includes a test runner which bundles and executes your tests, taking care to only run the tests which have changed.
|
|
60
|
+
Testeranto includes a test runner which bundles and executes your tests, taking care to only run the tests which have changed.
|
|
61
61
|
|
|
62
62
|
Testeranto includes a test reporter which displays the state of your code in a web app. ([see example](https://chromapdx.github.io/kokomoBay/report.html)) This reporter can also be run locally for the developer's convenience.
|
|
63
63
|
|
|
@@ -67,21 +67,24 @@ Rather than the traditional method of specifying tests in plain text, Testeranto
|
|
|
67
67
|
|
|
68
68
|
## the bad parts
|
|
69
69
|
|
|
70
|
-
Testeranto is not designed to maximize performance. In dev mode, it runs multiple esbuild processes, electron, 1 node process for each node test and 1 chromium processes for each web test.
|
|
70
|
+
Testeranto is not designed to maximize performance. In dev mode, it runs multiple esbuild processes, electron, 1 node process for each node test and 1 chromium processes for each web test.
|
|
71
71
|
|
|
72
|
-
Testeranto does not (yet!) of a means of allowing non-coders to affect changes so, as they say, "get good 💪!"
|
|
72
|
+
Testeranto does not (yet!) of a means of allowing non-coders to affect changes so, as they say, "get good 💪!"
|
|
73
73
|
|
|
74
74
|
Because Testeranto is so un-opinionated that it does not provide test infrastructure. You will need to find an existing recipe or implement it yourself, though a public repo of test interfaces exists.
|
|
75
75
|
|
|
76
76
|
## How it works
|
|
77
77
|
|
|
78
78
|
Testeranto is comprised of 3 parts
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
|
|
80
|
+
1. The build process reads a config and builds the docs folder, then launches 3 esbuild build processes.
|
|
81
|
+
|
|
82
|
+
- Build the features for the html report
|
|
83
|
+
- Build the node-style tests
|
|
84
|
+
- Build the web-style tests
|
|
85
|
+
|
|
86
|
+
2. The test runner is an electron app which watches the output of those build processes and launches the tests as those files change.
|
|
87
|
+
3. A Report which links your features, your tests and the results of those tests into a handy website.
|
|
85
88
|
|
|
86
89
|
## Electron aka Node vs Chromium
|
|
87
90
|
|
|
@@ -106,8 +109,8 @@ Testeranto's main API interface is 2 functions, 1 for each run time. You must pa
|
|
|
106
109
|
- The "shape" - a TS type signature to which the other arguments must conform.
|
|
107
110
|
- The "input" - the test subject. The "thing that is to be tested"
|
|
108
111
|
- the "specification" - This is the Cucumber-style Given/When/Then steps.
|
|
109
|
-
- the "implementation" - This is the code which implements the "test specification" in code.
|
|
110
|
-
- the "interface" - The code which sets up the test.
|
|
112
|
+
- the "implementation" - This is the code which implements the "test specification" in code.
|
|
113
|
+
- the "interface" - The code which sets up the test.
|
|
111
114
|
|
|
112
115
|
This is designed so that each piece can be worked upon separately. You can think of each argument as the responsibility of a different member of your team.
|
|
113
116
|
|
|
@@ -115,3 +118,21 @@ This is designed so that each piece can be worked upon separately. You can think
|
|
|
115
118
|
- "Product Manager" handles the "specification"
|
|
116
119
|
- "Middle Engineer" handles the "interface"
|
|
117
120
|
- "Junior Engineer" handles the "implementation"
|
|
121
|
+
|
|
122
|
+
## CLI
|
|
123
|
+
|
|
124
|
+
There are 4 commands you should add to your `package.json`
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
// build the tests
|
|
128
|
+
"testeranto-esbuild": "ts-node-esm testeranto.mts",
|
|
129
|
+
|
|
130
|
+
// run the tests
|
|
131
|
+
"testeranto-electron": "electron node_modules/testeranto/dist/common/electron.js",
|
|
132
|
+
|
|
133
|
+
// build and run the tests as src files change
|
|
134
|
+
"testeranto-dev": "yarn testeranto-esbuild -devmode ; yarn testeranto-electron -devmode"
|
|
135
|
+
|
|
136
|
+
// build the tests, then run the tests
|
|
137
|
+
"testeranto": "yarn testeranto-esbuild && yarn testeranto-electron"
|
|
138
|
+
```
|
package/dist/cjs-shim.js
CHANGED
|
@@ -3,8 +3,8 @@ import path from 'node:path';
|
|
|
3
3
|
import url from 'node:url';
|
|
4
4
|
|
|
5
5
|
// globalThis.require = createRequire(import.meta.url);
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
globalThis.__filename = url.fileURLToPath(import.meta.url);
|
|
7
|
+
globalThis.__dirname = path.dirname(__filename);
|
|
8
8
|
|
|
9
9
|
// const p = `${import.meta.url}/..`;
|
|
10
10
|
// globalThis.require = createRequire(`${import.meta.url}/..`);
|
package/dist/common/Node.js
CHANGED
|
@@ -3,30 +3,11 @@ 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 http_1 = __importDefault(require("http"));
|
|
7
6
|
const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
|
|
8
7
|
const core_js_1 = __importDefault(require("./lib/core.js"));
|
|
9
8
|
const index_js_1 = require("./lib/index.js");
|
|
10
9
|
const NodeWriter_js_1 = require("./NodeWriter.js");
|
|
11
|
-
const
|
|
12
|
-
const readJson = async (port) => new Promise((resolve, reject) => {
|
|
13
|
-
let json = "";
|
|
14
|
-
const request = http_1.default.request({
|
|
15
|
-
host: "127.0.0.1",
|
|
16
|
-
path: "/json/version",
|
|
17
|
-
port,
|
|
18
|
-
}, (response) => {
|
|
19
|
-
response.on("error", reject);
|
|
20
|
-
response.on("data", (chunk) => {
|
|
21
|
-
json += chunk.toString();
|
|
22
|
-
});
|
|
23
|
-
response.on("end", () => {
|
|
24
|
-
resolve(JSON.parse(json));
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
request.on("error", reject);
|
|
28
|
-
request.end();
|
|
29
|
-
});
|
|
10
|
+
const puppeteerConfiger_js_1 = __importDefault(require("./puppeteerConfiger.js"));
|
|
30
11
|
class NodeTesteranto extends core_js_1.default {
|
|
31
12
|
constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
|
|
32
13
|
super(input, testSpecification, testImplementation, testResourceRequirement, NodeWriter_js_1.NodeWriter, testInterface);
|
|
@@ -46,7 +27,7 @@ class NodeTesteranto extends core_js_1.default {
|
|
|
46
27
|
}
|
|
47
28
|
}
|
|
48
29
|
async receiveTestResourceConfig(t, partialTestResource) {
|
|
49
|
-
const browser = await
|
|
30
|
+
const browser = await (0, puppeteerConfiger_js_1.default)("2999").then(async (json) => {
|
|
50
31
|
const b = await puppeteer_core_1.default.connect({
|
|
51
32
|
browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
52
33
|
defaultViewport: null,
|
|
@@ -54,13 +35,15 @@ class NodeTesteranto extends core_js_1.default {
|
|
|
54
35
|
console.log("connected!", b.isConnected());
|
|
55
36
|
return b;
|
|
56
37
|
});
|
|
57
|
-
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(partialTestResource,
|
|
38
|
+
const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(partialTestResource, {
|
|
39
|
+
browser,
|
|
40
|
+
ipc: process.parentPort,
|
|
41
|
+
});
|
|
58
42
|
Promise.all([...artifacts, logPromise]).then(async () => {
|
|
59
|
-
|
|
43
|
+
process.exit((await failed) ? 1 : 0);
|
|
60
44
|
});
|
|
61
45
|
}
|
|
62
46
|
}
|
|
63
|
-
;
|
|
64
47
|
exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = index_js_1.defaultTestResourceRequirement) => {
|
|
65
48
|
return new NodeTesteranto(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
|
|
66
49
|
};
|
|
@@ -8,14 +8,12 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fPaths = [];
|
|
10
10
|
exports.NodeWriter = {
|
|
11
|
-
createWriteStream: (filepath) =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
mkdirSync: async (fp) => {
|
|
18
|
-
await fs_1.default.mkdirSync(fp, { recursive: true });
|
|
11
|
+
createWriteStream: (filepath) => fs_1.default.createWriteStream(filepath),
|
|
12
|
+
writeFileSync: (fp, contents) => fs_1.default.writeFileSync(fp, contents),
|
|
13
|
+
mkdirSync: async (destFolder) => {
|
|
14
|
+
if (!fs_1.default.existsSync(destFolder)) {
|
|
15
|
+
fs_1.default.mkdirSync(destFolder, { recursive: true });
|
|
16
|
+
}
|
|
19
17
|
},
|
|
20
18
|
testArtiFactoryfileWriter: (tLog, callback) => (fPath, value) => {
|
|
21
19
|
callback(new Promise((res, rej) => {
|
|
@@ -52,5 +50,5 @@ exports.NodeWriter = {
|
|
|
52
50
|
}
|
|
53
51
|
});
|
|
54
52
|
}));
|
|
55
|
-
}
|
|
53
|
+
},
|
|
56
54
|
};
|
package/dist/common/Project.js
CHANGED
|
@@ -14,108 +14,123 @@ const web_js_1 = __importDefault(require("./esbuildConfigs/web.js"));
|
|
|
14
14
|
const features_js_1 = __importDefault(require("./esbuildConfigs/features.js"));
|
|
15
15
|
const web_html_js_1 = __importDefault(require("./web.html.js"));
|
|
16
16
|
const report_html_js_1 = __importDefault(require("./report.html.js"));
|
|
17
|
-
|
|
17
|
+
var mode = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
18
18
|
readline_1.default.emitKeypressEvents(process.stdin);
|
|
19
19
|
if (process.stdin.isTTY)
|
|
20
20
|
process.stdin.setRawMode(true);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
process.stdin.on("keypress", (str, key) => {
|
|
22
|
+
if (key.name === "q") {
|
|
23
|
+
console.log("Testeranto-EsBuild is shutting down...");
|
|
24
|
+
mode = "PROD";
|
|
25
|
+
onDone();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
// setInterval(() => {
|
|
29
|
+
// const memoryUsage = process.memoryUsage();
|
|
30
|
+
// console.log("Memory usage:", memoryUsage);
|
|
31
|
+
// }, 10000); // Check every 10 seconds
|
|
32
|
+
let featuresDone, nodeDone, webDone = false;
|
|
33
|
+
const onFeaturesDone = () => {
|
|
34
|
+
featuresDone = true;
|
|
35
|
+
onDone();
|
|
36
|
+
};
|
|
37
|
+
const onNodeDone = () => {
|
|
38
|
+
nodeDone = true;
|
|
39
|
+
onDone();
|
|
40
|
+
};
|
|
41
|
+
const onWebDone = () => {
|
|
42
|
+
webDone = true;
|
|
43
|
+
onDone();
|
|
44
|
+
};
|
|
45
|
+
const onDone = () => {
|
|
46
|
+
console.log(JSON.stringify({
|
|
47
|
+
featuresDone,
|
|
48
|
+
nodeDone,
|
|
49
|
+
webDone,
|
|
50
|
+
mode,
|
|
51
|
+
}, null, 2));
|
|
52
|
+
if (featuresDone && nodeDone && webDone && mode === "PROD") {
|
|
53
|
+
console.log("Testeranto-EsBuild is all done. Goodbye!");
|
|
54
|
+
process.exit();
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
console.log("Testeranto-EsBuild is still working...");
|
|
58
|
+
}
|
|
34
59
|
};
|
|
35
60
|
class ITProject {
|
|
36
61
|
constructor(config) {
|
|
37
|
-
var _a;
|
|
38
62
|
this.mode = `up`;
|
|
39
63
|
this.config = config;
|
|
40
|
-
|
|
41
|
-
if (key.name === 'q') {
|
|
42
|
-
this.initiateShutdown("'q' command");
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
process.stdin.on('keypress', (str, key) => {
|
|
46
|
-
if (key.name === 'x') {
|
|
47
|
-
console.log("Shutting down hard!");
|
|
48
|
-
process.exit(-1);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
const childElectron = child_process_1.default.spawn("yarn", ["electron", "node_modules/testeranto/dist/common/electron.js"]);
|
|
52
|
-
// childElectron.stdout.on('data', function (msg) {
|
|
53
|
-
// console.log(msg.toString())
|
|
54
|
-
// });
|
|
55
|
-
const fileStream = fs_1.default.createWriteStream(`./${this.config.outdir}/electron.log`);
|
|
56
|
-
(_a = childElectron.stdout) === null || _a === void 0 ? void 0 : _a.pipe(fileStream);
|
|
57
|
-
Promise.resolve(Promise.all([
|
|
58
|
-
...this.getSecondaryEndpointsPoints("web"),
|
|
59
|
-
]
|
|
60
|
-
.map(async (sourceFilePath) => {
|
|
64
|
+
Promise.resolve(Promise.all([...this.getSecondaryEndpointsPoints("web")].map(async (sourceFilePath) => {
|
|
61
65
|
const sourceFileSplit = sourceFilePath.split("/");
|
|
62
66
|
const sourceDir = sourceFileSplit.slice(0, -1);
|
|
63
67
|
const sourceFileName = sourceFileSplit[sourceFileSplit.length - 1];
|
|
64
|
-
const sourceFileNameMinusJs = sourceFileName
|
|
68
|
+
const sourceFileNameMinusJs = sourceFileName
|
|
69
|
+
.split(".")
|
|
70
|
+
.slice(0, -1)
|
|
71
|
+
.join(".");
|
|
65
72
|
const htmlFilePath = path_1.default.normalize(`${process.cwd()}/${config.outdir}/web/${sourceDir.join("/")}/${sourceFileNameMinusJs}.html`);
|
|
66
73
|
const jsfilePath = `./${sourceFileNameMinusJs}.mjs`;
|
|
67
|
-
return fs_1.default.promises
|
|
74
|
+
return fs_1.default.promises
|
|
75
|
+
.mkdir(path_1.default.dirname(htmlFilePath), { recursive: true })
|
|
76
|
+
.then((x) => fs_1.default.writeFileSync(htmlFilePath, (0, web_html_js_1.default)(jsfilePath, htmlFilePath)));
|
|
68
77
|
})));
|
|
69
78
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
70
|
-
(0, glob_1.glob)(`./${config.outdir}/chunk-*.mjs`, { ignore:
|
|
71
|
-
console.log("deleting chunks", chunks);
|
|
79
|
+
(0, glob_1.glob)(`./${config.outdir}/chunk-*.mjs`, { ignore: "node_modules/**" }).then((chunks) => {
|
|
72
80
|
chunks.forEach((chunk) => {
|
|
73
|
-
console.log("deleting chunk", chunk);
|
|
74
81
|
fs_1.default.unlinkSync(chunk);
|
|
75
82
|
});
|
|
76
83
|
});
|
|
77
|
-
fs_1.default.copyFileSync("node_modules/testeranto/dist/prebuild/
|
|
78
|
-
fs_1.default.copyFileSync("node_modules/testeranto/dist/prebuild/
|
|
84
|
+
fs_1.default.copyFileSync("./node_modules/testeranto/dist/prebuild/Report.js", "./docs/Report.js");
|
|
85
|
+
fs_1.default.copyFileSync("./node_modules/testeranto/dist/prebuild/Report.css", "./docs/Report.css");
|
|
79
86
|
fs_1.default.writeFileSync(`${config.outdir}/report.html`, (0, report_html_js_1.default)());
|
|
80
87
|
Promise.all([
|
|
81
|
-
|
|
88
|
+
fs_1.default.promises.writeFile(`${config.outdir}/testeranto.json`, JSON.stringify(Object.assign(Object.assign({}, config), { buildDir: process.cwd() + "/" + config.outdir }), null, 2)),
|
|
89
|
+
esbuild_1.default
|
|
90
|
+
.context((0, features_js_1.default)(config))
|
|
82
91
|
.then(async (featuresContext) => {
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
if (mode == "DEV") {
|
|
93
|
+
await featuresContext.watch();
|
|
94
|
+
onFeaturesDone();
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
featuresContext.rebuild().then((v) => {
|
|
98
|
+
onFeaturesDone();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
85
101
|
return featuresContext;
|
|
86
102
|
}),
|
|
87
|
-
esbuild_1.default
|
|
103
|
+
esbuild_1.default
|
|
104
|
+
.context((0, node_js_1.default)(config, nodeEntryPoints))
|
|
88
105
|
.then(async (nodeContext) => {
|
|
89
|
-
|
|
90
|
-
|
|
106
|
+
if (mode == "DEV") {
|
|
107
|
+
await nodeContext.watch().then((v) => {
|
|
108
|
+
onNodeDone();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
nodeContext.rebuild().then((v) => {
|
|
113
|
+
onNodeDone();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
91
116
|
return nodeContext;
|
|
92
117
|
}),
|
|
93
|
-
esbuild_1.default
|
|
94
|
-
.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
118
|
+
esbuild_1.default
|
|
119
|
+
.context((0, web_js_1.default)(config, webEntryPoints))
|
|
120
|
+
.then(async (webContext) => {
|
|
121
|
+
if (mode == "DEV") {
|
|
122
|
+
await webContext.watch().then((v) => {
|
|
123
|
+
onWebDone();
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
webContext.rebuild().then((v) => {
|
|
128
|
+
onWebDone();
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return webContext;
|
|
98
132
|
}),
|
|
99
|
-
])
|
|
100
|
-
Promise.all(config.tests.map(async ([test, runtime]) => {
|
|
101
|
-
return {
|
|
102
|
-
test,
|
|
103
|
-
runtime
|
|
104
|
-
};
|
|
105
|
-
})).then(async (modules) => {
|
|
106
|
-
fs_1.default.writeFileSync(`${config.outdir}/testeranto.json`, JSON.stringify({
|
|
107
|
-
modules,
|
|
108
|
-
buildDir: process.cwd() + "/" + config.outdir
|
|
109
|
-
}, null, 2));
|
|
110
|
-
});
|
|
111
|
-
if (config.devMode === false) {
|
|
112
|
-
console.log("Your tests were built but not run because devMode was false. Exiting gracefully");
|
|
113
|
-
process.exit(0);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
// no-op
|
|
117
|
-
}
|
|
118
|
-
});
|
|
133
|
+
]);
|
|
119
134
|
}
|
|
120
135
|
getSecondaryEndpointsPoints(runtime) {
|
|
121
136
|
const meta = (ts, st) => {
|
|
@@ -131,197 +146,19 @@ class ITProject {
|
|
|
131
146
|
};
|
|
132
147
|
return Array.from(meta(this.config.tests, new Set()));
|
|
133
148
|
}
|
|
134
|
-
initiateShutdown(reason) {
|
|
135
|
-
console.log("Shutdown initiated because", reason);
|
|
136
|
-
this.mode = "down";
|
|
137
|
-
}
|
|
138
149
|
}
|
|
139
150
|
exports.ITProject = ITProject;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// });
|
|
155
|
-
// webSocketServer.on('close', (data) => {
|
|
156
|
-
// console.log('webSocketServer close: %s', data);
|
|
157
|
-
// });
|
|
158
|
-
// webSocketServer.on('listening', () => {
|
|
159
|
-
// console.log("webSocketServer listening", webSocketServer.address());
|
|
160
|
-
// });
|
|
161
|
-
// webSocketServer.on('connection', (webSocket: WebSocket) => {
|
|
162
|
-
// webSocket.on('message', (webSocketData) => {
|
|
163
|
-
// const payload = JSON.parse(webSocketData.valueOf().toString() as any);
|
|
164
|
-
// const messageType = payload.type;
|
|
165
|
-
// if (messageType === "testeranto:hola") {
|
|
166
|
-
// const name = payload.data.requirement.name;
|
|
167
|
-
// const requestedResources = payload.data;
|
|
168
|
-
// this.websockets[name] = webSocket
|
|
169
|
-
// console.log('hola WS! connected: ' + name + ' in ' + Object.getOwnPropertyNames(this.websockets))
|
|
170
|
-
// this.requestResource(requestedResources.requirement, 'ws');
|
|
171
|
-
// } else if (messageType === "testeranto:adios") {
|
|
172
|
-
// console.log("adios WS", payload.data.testResourceConfiguration.name);
|
|
173
|
-
// this.releaseTestResourceWs(payload as any);
|
|
174
|
-
// }
|
|
175
|
-
// });
|
|
176
|
-
// });
|
|
177
|
-
// const makePath = (fPath: string, rt: IRunTime): string => {
|
|
178
|
-
// return path.resolve("./" + config.outdir + "/" +
|
|
179
|
-
// rt +
|
|
180
|
-
// // (rt === "electron" || rt === "chromium" ? "web" : "node") +
|
|
181
|
-
// "/" + fPath.replace(path.extname(fPath), "") + ".mjs");
|
|
182
|
-
// };
|
|
183
|
-
// const bootInterval = setInterval(async () => {
|
|
184
|
-
// const filesToLookup = this.tests
|
|
185
|
-
// .map(([p, rt]) => {
|
|
186
|
-
// const filepath = makePath(p, rt);
|
|
187
|
-
// return {
|
|
188
|
-
// filepath,
|
|
189
|
-
// exists: fsExists(filepath),
|
|
190
|
-
// };
|
|
191
|
-
// });
|
|
192
|
-
// const allFilesExist = (
|
|
193
|
-
// await Promise.all(filesToLookup.map((f) => f.exists))
|
|
194
|
-
// ).every((b) => b);
|
|
195
|
-
// if (!allFilesExist) {
|
|
196
|
-
// console.log(this.spinner(), "waiting for files to build...")
|
|
197
|
-
// filesToLookup.forEach((f) => {
|
|
198
|
-
// console.log(f.exists, "\t", f.filepath);
|
|
199
|
-
// })
|
|
200
|
-
// } else {
|
|
201
|
-
// clearInterval(bootInterval);
|
|
202
|
-
// pm2.launchBus((err, pm2_bus) => {
|
|
203
|
-
// pm2_bus.on("testeranto:hola", (packet: { data: { requirement: ITTestResourceRequirement } }) => {
|
|
204
|
-
// this.requestResource(
|
|
205
|
-
// packet.data.requirement,
|
|
206
|
-
// 'ipc'
|
|
207
|
-
// );
|
|
208
|
-
// });
|
|
209
|
-
// pm2_bus.on("testeranto:adios", (payload: IAdiosIPC) => {
|
|
210
|
-
// this.releaseTestResourcePm2(payload.data);
|
|
211
|
-
// });
|
|
212
|
-
// });
|
|
213
|
-
// this
|
|
214
|
-
// .tests
|
|
215
|
-
// .reduce((m, [inputFilePath, runtime]) => {
|
|
216
|
-
// const script = makePath(inputFilePath, runtime);
|
|
217
|
-
// const partialTestResourceByCommandLineArg = `${script} '${JSON.stringify(
|
|
218
|
-
// {
|
|
219
|
-
// name: inputFilePath,
|
|
220
|
-
// ports: [],
|
|
221
|
-
// fs: path.resolve(
|
|
222
|
-
// process.cwd(),
|
|
223
|
-
// config.outdir,
|
|
224
|
-
// inputFilePath
|
|
225
|
-
// ),
|
|
226
|
-
// }
|
|
227
|
-
// )}'`;
|
|
228
|
-
// if (runtime === "web") {
|
|
229
|
-
// pm2.start(electron_pm2_StartOptions(
|
|
230
|
-
// partialTestResourceByCommandLineArg,
|
|
231
|
-
// inputFilePath,
|
|
232
|
-
// config
|
|
233
|
-
// ),
|
|
234
|
-
// (err, proc) => {
|
|
235
|
-
// if (err) {
|
|
236
|
-
// console.error(err);
|
|
237
|
-
// return pm2.disconnect();
|
|
238
|
-
// }
|
|
239
|
-
// }
|
|
240
|
-
// );
|
|
241
|
-
// // } else if (runtime === "chromium") {
|
|
242
|
-
// // pm2.start(
|
|
243
|
-
// // chromium_pm2_StartOptions(
|
|
244
|
-
// // partialTestResourceByCommandLineArg,
|
|
245
|
-
// // inputFilePath,
|
|
246
|
-
// // config,
|
|
247
|
-
// // ),
|
|
248
|
-
// // (err, proc) => {
|
|
249
|
-
// // if (err) {
|
|
250
|
-
// // console.error(err);
|
|
251
|
-
// // return pm2.disconnect();
|
|
252
|
-
// // }
|
|
253
|
-
// // }
|
|
254
|
-
// // );
|
|
255
|
-
// } else if (runtime === "node") {
|
|
256
|
-
// const resolvedPath = path.resolve(script);
|
|
257
|
-
// console.log("watching", resolvedPath);
|
|
258
|
-
// pm2.start(node_pm2_StartOptions(
|
|
259
|
-
// partialTestResourceByCommandLineArg,
|
|
260
|
-
// inputFilePath,
|
|
261
|
-
// config,
|
|
262
|
-
// resolvedPath
|
|
263
|
-
// ), (err, proc) => {
|
|
264
|
-
// if (err) {
|
|
265
|
-
// console.error(err);
|
|
266
|
-
// return pm2.disconnect();
|
|
267
|
-
// }
|
|
268
|
-
// });
|
|
269
|
-
// }
|
|
270
|
-
// this.exitCodes[inputFilePath] = null;
|
|
271
|
-
// return [inputFilePath, ...m];
|
|
272
|
-
// }, []);
|
|
273
|
-
// setInterval(this.mainLoop, TIMEOUT).unref();
|
|
274
|
-
// }
|
|
275
|
-
// }, TIMEOUT).unref();
|
|
276
|
-
// });
|
|
277
|
-
// public requestResource(
|
|
278
|
-
// requirement: ITTestResourceRequirement,
|
|
279
|
-
// protocol: ISchedulerProtocols
|
|
280
|
-
// ) {
|
|
281
|
-
// this.resourceQueue.push({ requirement, protocol });
|
|
282
|
-
// }
|
|
283
|
-
// const OPEN_PORT = "";
|
|
284
|
-
// type ISchedulerProtocols = `ipc` | `ws`;
|
|
285
|
-
// type IAdios = {
|
|
286
|
-
// name: string;
|
|
287
|
-
// failed: any;
|
|
288
|
-
// testResourceConfiguration: {
|
|
289
|
-
// name: string;
|
|
290
|
-
// };
|
|
291
|
-
// results: {
|
|
292
|
-
// fails: any[];
|
|
293
|
-
// givens: any[];
|
|
294
|
-
// name: string;
|
|
295
|
-
// };
|
|
296
|
-
// };
|
|
297
|
-
// type IAdiosIPC = {
|
|
298
|
-
// process: {
|
|
299
|
-
// namespace: string;
|
|
300
|
-
// versioning: object;
|
|
301
|
-
// name: string;
|
|
302
|
-
// pm_id: number;
|
|
303
|
-
// };
|
|
304
|
-
// data: IAdios
|
|
305
|
-
// at: string;
|
|
306
|
-
// };
|
|
307
|
-
// clearScreen: boolean;
|
|
308
|
-
// devMode: boolean;
|
|
309
|
-
// exitCodes: Record<number, string> = {};
|
|
310
|
-
// features: TesterantoFeatures;
|
|
311
|
-
// ports: Record<string, string> = {};
|
|
312
|
-
// tests: ITestTypes[];
|
|
313
|
-
// websockets: Record<string, WebSocket> = {};
|
|
314
|
-
// resourceQueue: {
|
|
315
|
-
// requirement: ITTestResourceRequirement,
|
|
316
|
-
// protocol: ISchedulerProtocols,
|
|
317
|
-
// }[] = [];
|
|
318
|
-
// private spinCycle = 0;
|
|
319
|
-
// private spinAnimation = "←↖↑↗→↘↓↙";
|
|
320
|
-
// console.log("sending", JSON.stringify(this.tests));
|
|
321
|
-
// childElectron.stdin.write(JSON.stringify(this.tests));
|
|
322
|
-
// not necessary
|
|
323
|
-
// this.esWebServerDetails = await eWeb.serve({
|
|
324
|
-
// servedir: jsonConfig.outdir,
|
|
325
|
-
// });
|
|
326
|
-
// fs.copyFileSync("node_modules/testeranto/dist/index.css", "index.css")
|
|
327
|
-
//
|
|
151
|
+
const getRunnables = (tests, payload = [new Set(), new Set()]) => {
|
|
152
|
+
return tests.reduce((pt, cv, cndx, cry) => {
|
|
153
|
+
if (cv[1] === "node") {
|
|
154
|
+
pt[0].add(cv[0]);
|
|
155
|
+
}
|
|
156
|
+
else if (cv[1] === "web") {
|
|
157
|
+
pt[1].add(cv[0]);
|
|
158
|
+
}
|
|
159
|
+
if (cv[2].length) {
|
|
160
|
+
getRunnables(cv[2], payload);
|
|
161
|
+
}
|
|
162
|
+
return pt;
|
|
163
|
+
}, payload);
|
|
164
|
+
};
|
|
@@ -7,7 +7,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
7
7
|
const Node_js_1 = __importDefault(require("../Node.js"));
|
|
8
8
|
exports.default = (testInput, testSpecifications, testImplementations, testInterface) => {
|
|
9
9
|
return (0, Node_js_1.default)(testInput, testSpecifications, testImplementations, Object.assign({ beforeAll(x) {
|
|
10
|
-
process.parentPort.postMessage(`/
|
|
10
|
+
process.parentPort.postMessage(`/docs/web/src/ClassicalComponent/test.html`);
|
|
11
11
|
return x;
|
|
12
12
|
}, beforeEach: async () => {
|
|
13
13
|
return new Promise((resolve, rej) => {
|
|
@@ -34,7 +34,7 @@ exports.default = (testInput, testSpecifications, testImplementations) => {
|
|
|
34
34
|
return new Promise((resolve, rej) => {
|
|
35
35
|
// console.log("beforeEach" + JSON.stringify(initializer) + JSON.stringify(initialValues));
|
|
36
36
|
// Ignore these type errors
|
|
37
|
-
client_1.default.createRoot(htmlElement).render((0, react_1.createElement)(TesterantoComponent, Object.assign(Object.assign({}, initializer
|
|
37
|
+
client_1.default.createRoot(htmlElement).render((0, react_1.createElement)(TesterantoComponent, Object.assign(Object.assign({}, initializer), { done: (reactElement) => {
|
|
38
38
|
resolve({
|
|
39
39
|
htmlElement,
|
|
40
40
|
reactElement,
|