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.
Files changed (151) hide show
  1. package/README.md +42 -21
  2. package/dist/cjs-shim.js +2 -2
  3. package/dist/common/Node.js +7 -24
  4. package/dist/common/NodeWriter.js +7 -9
  5. package/dist/common/Project.js +103 -266
  6. package/dist/common/SubPackages/puppeteer.js +1 -1
  7. package/dist/common/SubPackages/react-dom/component/web.js +1 -1
  8. package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
  9. package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  10. package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
  11. package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
  12. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -2
  13. package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
  14. package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  15. package/dist/common/Types.js +2 -32
  16. package/dist/common/Web.js +25 -18
  17. package/dist/common/electron.js +177 -107
  18. package/dist/common/esbuildConfigs/index.js +5 -5
  19. package/dist/common/esbuildConfigs/node.js +17 -15
  20. package/dist/common/esbuildConfigs/report.js +12 -47
  21. package/dist/common/esbuildConfigs/tests.js +0 -1
  22. package/dist/common/esbuildConfigs/web.js +14 -11
  23. package/dist/common/lib/abstractBase.js +13 -6
  24. package/dist/common/lib/basebuilder.js +11 -11
  25. package/dist/common/lib/classBuilder.js +2 -3
  26. package/dist/common/lib/core.js +37 -8
  27. package/dist/common/lib/index.js +10 -8
  28. package/dist/common/lib/types.js +2 -0
  29. package/dist/common/preload.js +15 -25
  30. package/dist/common/puppeteerConfiger.js +24 -0
  31. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  32. package/dist/module/Node.js +7 -24
  33. package/dist/module/NodeWriter.js +7 -9
  34. package/dist/module/Project.js +104 -267
  35. package/dist/module/SubPackages/puppeteer.js +1 -1
  36. package/dist/module/SubPackages/react/jsx/web.js +1 -1
  37. package/dist/module/SubPackages/react-dom/component/node.js +2 -2
  38. package/dist/module/SubPackages/react-dom/component/web.js +1 -1
  39. package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
  40. package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  41. package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
  42. package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
  43. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -2
  44. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
  45. package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  46. package/dist/module/Types.js +3 -30
  47. package/dist/module/Web.js +26 -19
  48. package/dist/module/electron.js +179 -109
  49. package/dist/module/esbuildConfigs/index.js +5 -5
  50. package/dist/module/esbuildConfigs/node.js +17 -15
  51. package/dist/module/esbuildConfigs/report.js +11 -48
  52. package/dist/module/esbuildConfigs/tests.js +0 -1
  53. package/dist/module/esbuildConfigs/web.js +14 -11
  54. package/dist/module/lib/abstractBase.js +13 -6
  55. package/dist/module/lib/basebuilder.js +11 -11
  56. package/dist/module/lib/classBuilder.js +2 -3
  57. package/dist/module/lib/core.js +39 -10
  58. package/dist/module/lib/index.js +10 -8
  59. package/dist/module/lib/types.js +1 -0
  60. package/dist/module/preload.js +12 -25
  61. package/dist/module/puppeteerConfiger.js +19 -0
  62. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  63. package/dist/types/Node.d.ts +3 -2
  64. package/dist/types/Project.d.ts +1 -2
  65. package/dist/types/SubPackages/puppeteer.d.ts +3 -3
  66. package/dist/types/SubPackages/react/component/node.d.ts +1 -1
  67. package/dist/types/SubPackages/react/component/web.d.ts +1 -1
  68. package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
  69. package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
  70. package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
  71. package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
  72. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  73. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
  74. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
  75. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
  76. package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
  77. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
  78. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
  79. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
  80. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
  81. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
  82. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
  83. package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
  84. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
  85. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
  86. package/dist/types/Types.d.ts +19 -100
  87. package/dist/types/Web.d.ts +3 -2
  88. package/dist/types/esbuildConfigs/features.d.ts +1 -1
  89. package/dist/types/esbuildConfigs/index.d.ts +1 -1
  90. package/dist/types/esbuildConfigs/node.d.ts +1 -1
  91. package/dist/types/esbuildConfigs/report.d.ts +4 -0
  92. package/dist/types/esbuildConfigs/tests.d.ts +1 -1
  93. package/dist/types/esbuildConfigs/web.d.ts +1 -1
  94. package/dist/types/lib/abstractBase.d.ts +25 -24
  95. package/dist/types/lib/basebuilder.d.ts +8 -7
  96. package/dist/types/lib/classBuilder.d.ts +3 -2
  97. package/dist/types/lib/core.d.ts +3 -2
  98. package/dist/types/lib/index.d.ts +4 -3
  99. package/dist/types/lib/types.d.ts +70 -0
  100. package/dist/types/puppeteerConfiger.d.ts +4 -0
  101. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  102. package/package.json +4 -3
  103. package/src/Node.ts +24 -54
  104. package/src/NodeWriter.ts +21 -18
  105. package/src/Project.ts +165 -620
  106. package/src/Report.tsx +1 -1
  107. package/src/SubPackages/puppeteer.ts +19 -14
  108. package/src/SubPackages/react/component/node.ts +20 -32
  109. package/src/SubPackages/react/component/web.ts +20 -30
  110. package/src/SubPackages/react/jsx/index.ts +13 -24
  111. package/src/SubPackages/react/jsx/web.ts +10 -8
  112. package/src/SubPackages/react-dom/component/node.ts +17 -23
  113. package/src/SubPackages/react-dom/component/web.ts +30 -50
  114. package/src/SubPackages/react-dom/jsx/web.ts +41 -48
  115. package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
  116. package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
  117. package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
  118. package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
  119. package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
  120. package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
  121. package/src/SubPackages/react-test-renderer/jsx/index.ts +16 -21
  122. package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
  123. package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
  124. package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
  125. package/src/Types.ts +73 -307
  126. package/src/Web.ts +54 -53
  127. package/src/cjs-shim.js +2 -2
  128. package/src/electron.ts +258 -191
  129. package/src/esbuildConfigs/features.ts +3 -4
  130. package/src/esbuildConfigs/index.ts +8 -8
  131. package/src/esbuildConfigs/node.ts +21 -20
  132. package/src/esbuildConfigs/report.ts +15 -51
  133. package/src/esbuildConfigs/tests.ts +3 -9
  134. package/src/esbuildConfigs/web.ts +18 -18
  135. package/src/lib/abstractBase.ts +78 -125
  136. package/src/lib/basebuilder.ts +109 -134
  137. package/src/lib/classBuilder.ts +26 -45
  138. package/src/lib/core.ts +101 -69
  139. package/src/lib/index.ts +53 -52
  140. package/src/lib/types.ts +206 -0
  141. package/src/preload.ts +12 -28
  142. package/src/puppeteerConfiger.ts +26 -0
  143. package/src/web.html.ts +1 -1
  144. package/dist/common/lib/browser.js +0 -26
  145. package/dist/common/nodeWriterElectron.js +0 -55
  146. package/dist/module/lib/browser.js +0 -22
  147. package/dist/module/nodeWriterElectron.js +0 -52
  148. package/dist/types/lib/browser.d.ts +0 -6
  149. package/dist/types/nodeWriterElectron.d.ts +0 -2
  150. package/src/lib/browser.ts +0 -34
  151. package/src/nodeWriterElectron.ts +0 -71
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # testeranto
2
2
 
3
- 🚧 WARNING: Testeeranto is still under development and is not ready for production yet. 🚧
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) Write some code.
31
- 2) Write some tests of that code.
32
- 3) Write some features of that code.
33
- 1) Write a `testeranto.mts`, which acts as a config file.
34
- 3) Launch testeranto. The test runner is now rebuilding the docs folder.
35
- 4) Commit the results of those tests.
36
- 5) Your github pages now shows your report, showing your features, linked with your test results.
37
- 6) Optionally add testeranto to your CI.
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! For example, for a single react component, you could create 3 tests- 1 that runs with react-test-renderer on node, another on chromium which renders the component to the dom, and a 3rd node style test which invokes the component in the browser before interacting with it via puppeteer.
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. It is designed to run most tests in parallel, though it has support for tests which require a shared resource, like a port.
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
- 1) The build process reads a config and builds the docs folder, then launches 3 esbuild build processes.
80
- a) Build the features for the html report
81
- b) Build the node-style tests
82
- c) Build the web-style tests
83
- 2) The test runner is an electron app which watches the output of those build processes and launches the tests as those files change.
84
- 3) A Report which links your features, your tests and the results of those tests into a handy website.
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
- // globalThis.__filename = url.fileURLToPath(import.meta.url);
7
- // globalThis.__dirname = path.dirname(__filename);
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}/..`);
@@ -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 Types_js_1 = require("./Types.js");
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 readJson("2999").then(async (json) => {
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, new Types_js_1.TBrowser(browser));
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
- // process.exit(await failed ? 1 : 0);
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
- return fs_1.default.createWriteStream(filepath);
13
- },
14
- writeFileSync: (fp, contents) => {
15
- fs_1.default.writeFileSync(fp, contents);
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
  };
@@ -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
- const child_process_1 = __importDefault(require("child_process"));
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
- const getRunnables = (tests, payload = [new Set(), new Set()]) => {
22
- return tests.reduce((pt, cv, cndx, cry) => {
23
- if (cv[1] === "node") {
24
- pt[0].add(cv[0]);
25
- }
26
- else if (cv[1] === "web") {
27
- pt[1].add(cv[0]);
28
- }
29
- if (cv[2].length) {
30
- getRunnables(cv[2], payload);
31
- }
32
- return pt;
33
- }, payload);
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
- process.stdin.on('keypress', (str, key) => {
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.split(".").slice(0, -1).join(".");
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.mkdir(path_1.default.dirname(htmlFilePath), { recursive: true }).then(x => fs_1.default.writeFileSync(htmlFilePath, (0, web_html_js_1.default)(jsfilePath, htmlFilePath)));
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: 'node_modules/**' }).then((chunks) => {
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/report.js", "./docs/Report.js");
78
- fs_1.default.copyFileSync("node_modules/testeranto/dist/prebuild/report.css", "./docs/Report.css");
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
- esbuild_1.default.context((0, features_js_1.default)(config))
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
- console.log("features entry points", config.features);
84
- await featuresContext.watch();
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.context((0, node_js_1.default)(config, nodeEntryPoints))
103
+ esbuild_1.default
104
+ .context((0, node_js_1.default)(config, nodeEntryPoints))
88
105
  .then(async (nodeContext) => {
89
- console.log("node entry points", nodeEntryPoints);
90
- await nodeContext.watch();
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.context((0, web_js_1.default)(config, webEntryPoints))
94
- .then(async (esbuildWeb) => {
95
- console.log("web entry points", webEntryPoints);
96
- await esbuildWeb.watch();
97
- return esbuildWeb;
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
- ]).then(async (contexts) => {
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
- // pm2.connect(async (err) => {
141
- // if (err) {
142
- // console.error(err);
143
- // process.exit(-1);
144
- // } else {
145
- // console.log(`pm2 is connected`);
146
- // }
147
- // // run a websocket as an alternative to node IPC
148
- // webSocketServer = new WebSocketServer({
149
- // port: 8080,
150
- // host: "localhost",
151
- // });
152
- // webSocketServer.on('open', () => {
153
- // console.log('open');
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(`/dist/web/src/ClassicalComponent/test.html`);
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.props), { done: (reactElement) => {
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,