testeranto 0.49.10 → 0.62.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 (241) hide show
  1. package/.nvmrc +1 -0
  2. package/README.md +71 -9
  3. package/dist/cjs-shim.js +12 -0
  4. package/dist/common/Features.js +2 -3
  5. package/dist/common/Node.js +53 -61
  6. package/dist/common/Project.js +272 -606
  7. package/dist/common/SubPackages/puppeteer.js +19 -0
  8. package/dist/common/{subPackages → SubPackages}/react/component/node.js +4 -4
  9. package/dist/common/{subPackages → SubPackages}/react/component/web.js +4 -4
  10. package/dist/common/SubPackages/react/jsx/index.js +13 -0
  11. package/dist/common/SubPackages/react/jsx/node.js +10 -0
  12. package/dist/common/SubPackages/react/jsx/web.js +10 -0
  13. package/dist/common/{subPackages → SubPackages}/react-dom/component/node.js +6 -6
  14. package/dist/common/{subPackages → SubPackages}/react-dom/component/web.js +11 -12
  15. package/dist/common/SubPackages/react-dom/jsx/node.js +39 -0
  16. package/dist/common/{subPackages → SubPackages}/react-dom/jsx/web.js +5 -14
  17. package/dist/common/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +2 -2
  18. package/dist/common/{subPackages → SubPackages}/react-test-renderer/component/index.js +26 -15
  19. package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/node.js +3 -5
  20. package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/web.js +3 -5
  21. package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/node.js +4 -4
  22. package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/web.js +4 -4
  23. package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -2
  24. package/dist/common/{subPackages/react-test-renderer/jsx-promised → SubPackages/react-test-renderer/jsx}/node.js +4 -4
  25. package/dist/common/{subPackages/react → SubPackages/react-test-renderer}/jsx/web.js +4 -4
  26. package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +2 -2
  27. package/dist/common/{subPackages/react/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +2 -2
  28. package/dist/common/Types.js +32 -0
  29. package/dist/common/Web.js +41 -112
  30. package/dist/common/electron.js +188 -44
  31. package/dist/common/esbuildConfigs/features.js +14 -0
  32. package/dist/common/esbuildConfigs/index.js +20 -0
  33. package/dist/common/esbuildConfigs/node.js +35 -0
  34. package/dist/common/esbuildConfigs/report.js +48 -0
  35. package/dist/common/esbuildConfigs/tests.js +14 -0
  36. package/dist/common/esbuildConfigs/web.js +50 -0
  37. package/dist/common/lib/abstractBase.js +193 -0
  38. package/dist/common/lib/basebuilder.js +86 -0
  39. package/dist/common/lib/browser.js +26 -0
  40. package/dist/common/lib/classBuilder.js +41 -0
  41. package/dist/common/lib/core.js +52 -0
  42. package/dist/common/lib/index.js +19 -0
  43. package/dist/common/nodeWriterElectron.js +55 -0
  44. package/dist/common/preload.js +22 -21
  45. package/dist/common/report.html.js +31 -0
  46. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  47. package/dist/common/web.html.js +22 -0
  48. package/dist/module/Features.js +2 -3
  49. package/dist/module/Node.js +53 -61
  50. package/dist/module/Project.js +272 -583
  51. package/dist/module/SubPackages/puppeteer.js +14 -0
  52. package/dist/module/{subPackages → SubPackages}/react/component/node.js +3 -3
  53. package/dist/module/{subPackages → SubPackages}/react/component/web.js +3 -3
  54. package/dist/module/SubPackages/react/jsx/index.js +10 -0
  55. package/dist/module/SubPackages/react/jsx/node.js +5 -0
  56. package/dist/module/SubPackages/react/jsx/web.js +5 -0
  57. package/dist/module/{subPackages → SubPackages}/react-dom/component/node.js +5 -5
  58. package/dist/module/{subPackages → SubPackages}/react-dom/component/web.js +10 -11
  59. package/dist/module/SubPackages/react-dom/jsx/node.js +31 -0
  60. package/dist/module/{subPackages → SubPackages}/react-dom/jsx/web.js +4 -13
  61. package/dist/module/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +2 -2
  62. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/index.js +23 -15
  63. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/node.js +2 -2
  64. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/web.js +2 -2
  65. package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/node.js +3 -3
  66. package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/web.js +3 -3
  67. package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -2
  68. package/dist/module/SubPackages/react-test-renderer/jsx/node.js +5 -0
  69. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +5 -0
  70. package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +2 -2
  71. package/dist/module/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +1 -1
  72. package/dist/module/Types.js +30 -1
  73. package/dist/module/Web.js +41 -112
  74. package/dist/module/electron.js +189 -45
  75. package/dist/module/esbuildConfigs/features.js +12 -0
  76. package/dist/module/esbuildConfigs/index.js +18 -0
  77. package/dist/module/esbuildConfigs/node.js +30 -0
  78. package/dist/module/esbuildConfigs/report.js +48 -0
  79. package/dist/module/esbuildConfigs/tests.js +12 -0
  80. package/dist/module/esbuildConfigs/web.js +45 -0
  81. package/dist/module/lib/abstractBase.js +185 -0
  82. package/dist/module/lib/basebuilder.js +82 -0
  83. package/dist/module/lib/browser.js +22 -0
  84. package/dist/module/lib/classBuilder.js +37 -0
  85. package/dist/module/lib/core.js +49 -0
  86. package/dist/module/lib/index.js +15 -0
  87. package/dist/module/nodeWriterElectron.js +52 -0
  88. package/dist/module/preload.js +22 -21
  89. package/dist/module/report.html.js +29 -0
  90. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  91. package/dist/module/web.html.js +20 -0
  92. package/dist/prebuild/Report.css +10326 -0
  93. package/dist/prebuild/Report.js +37456 -0
  94. package/dist/types/Features.d.ts +5 -5
  95. package/dist/types/Node.d.ts +4 -11
  96. package/dist/types/NodeWriter.d.ts +1 -1
  97. package/dist/types/Project.d.ts +2 -27
  98. package/dist/types/SubPackages/puppeteer.d.ts +6 -0
  99. package/dist/types/SubPackages/react/component/node.d.ts +7 -0
  100. package/dist/types/SubPackages/react/component/web.d.ts +7 -0
  101. package/dist/types/SubPackages/react/jsx/index.d.ts +15 -0
  102. package/dist/types/SubPackages/react/jsx/node.d.ts +4 -0
  103. package/dist/types/SubPackages/react/jsx/web.d.ts +4 -0
  104. package/dist/types/{subPackages → SubPackages}/react-dom/component/node.d.ts +2 -4
  105. package/dist/types/SubPackages/react-dom/component/web.d.ts +5 -0
  106. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +6 -0
  107. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +5 -0
  108. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +5 -0
  109. package/dist/types/{subPackages → SubPackages}/react-test-renderer/component/index.d.ts +6 -6
  110. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +9 -0
  111. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +4 -0
  112. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +8 -0
  113. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +8 -0
  114. package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx/index.d.ts +5 -4
  115. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +9 -0
  116. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +9 -0
  117. package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.d.ts +4 -4
  118. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +5 -0
  119. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +5 -0
  120. package/dist/types/Types.d.ts +116 -3
  121. package/dist/types/Web.d.ts +4 -11
  122. package/dist/types/esbuildConfigs/features.d.ts +4 -0
  123. package/dist/types/esbuildConfigs/index.d.ts +4 -0
  124. package/dist/types/esbuildConfigs/node.d.ts +4 -0
  125. package/dist/types/esbuildConfigs/report.d.ts +0 -0
  126. package/dist/types/esbuildConfigs/tests.d.ts +4 -0
  127. package/dist/types/esbuildConfigs/web.d.ts +4 -0
  128. package/dist/types/lib/abstractBase.d.ts +102 -0
  129. package/dist/types/lib/basebuilder.d.ts +24 -0
  130. package/dist/types/lib/browser.d.ts +6 -0
  131. package/dist/types/lib/classBuilder.d.ts +6 -0
  132. package/dist/types/lib/core.d.ts +7 -0
  133. package/dist/types/lib/index.d.ts +57 -0
  134. package/dist/types/nodeWriterElectron.d.ts +2 -0
  135. package/dist/types/report.html.d.ts +2 -0
  136. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  137. package/dist/types/web.html.d.ts +2 -0
  138. package/electronBuild.ts +32 -0
  139. package/index.html +30 -0
  140. package/package.json +120 -85
  141. package/src/Features.ts +2 -4
  142. package/src/Node.ts +114 -160
  143. package/src/NodeWriter.ts +1 -4
  144. package/src/Project.ts +610 -753
  145. package/src/Report.tsx +30 -15
  146. package/src/SubPackages/puppeteer.ts +46 -0
  147. package/src/{subPackages → SubPackages}/react/component/node.ts +12 -32
  148. package/src/SubPackages/react/component/web.ts +53 -0
  149. package/src/SubPackages/react/jsx/index.ts +43 -0
  150. package/src/SubPackages/react/jsx/node.ts +29 -0
  151. package/src/SubPackages/react/jsx/web.ts +28 -0
  152. package/src/{subPackages → SubPackages}/react-dom/component/node.ts +11 -25
  153. package/src/{subPackages → SubPackages}/react-dom/component/web.ts +27 -32
  154. package/src/{subPackages → SubPackages}/react-dom/jsx/index.ts +0 -1
  155. package/src/SubPackages/react-dom/jsx/node.ts +68 -0
  156. package/src/{subPackages → SubPackages}/react-dom/jsx/web.ts +18 -54
  157. package/src/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.ts +9 -28
  158. package/src/{subPackages → SubPackages}/react-test-renderer/component/index.ts +31 -29
  159. package/src/SubPackages/react-test-renderer/component/node.ts +22 -0
  160. package/src/SubPackages/react-test-renderer/component/web.ts +22 -0
  161. package/src/{subPackages → SubPackages}/react-test-renderer/fc/node.ts +14 -28
  162. package/src/{subPackages → SubPackages}/react-test-renderer/fc/web.ts +9 -25
  163. package/src/{subPackages → SubPackages}/react-test-renderer/jsx/index.ts +19 -16
  164. package/src/SubPackages/react-test-renderer/jsx/node.ts +24 -0
  165. package/src/SubPackages/react-test-renderer/jsx/web.ts +20 -0
  166. package/src/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.ts +7 -15
  167. package/src/SubPackages/react-test-renderer/jsx-promised/node.ts +19 -0
  168. package/src/SubPackages/react-test-renderer/jsx-promised/web.ts +22 -0
  169. package/src/Types.ts +334 -3
  170. package/src/Web.ts +104 -230
  171. package/src/cjs-shim.js +12 -0
  172. package/src/electron.ts +237 -46
  173. package/src/esbuildConfigs/features.ts +18 -0
  174. package/src/esbuildConfigs/index.ts +22 -0
  175. package/src/esbuildConfigs/node.ts +59 -0
  176. package/src/esbuildConfigs/report.ts +51 -0
  177. package/src/esbuildConfigs/tests.ts +20 -0
  178. package/src/esbuildConfigs/web.ts +73 -0
  179. package/src/lib/abstractBase.ts +459 -0
  180. package/src/lib/basebuilder.ts +253 -0
  181. package/src/lib/browser.ts +34 -0
  182. package/src/lib/classBuilder.ts +137 -0
  183. package/src/lib/core.ts +182 -0
  184. package/src/lib/index.ts +116 -0
  185. package/src/nodeWriterElectron.ts +71 -0
  186. package/src/preload.ts +23 -21
  187. package/src/report.html.ts +29 -0
  188. package/src/web.html.ts +20 -0
  189. package/tests/Rectangle.test.ts +189 -0
  190. package/tsconfig.json +19 -6
  191. package/tsconfig.module.json +15 -4
  192. package/tsconfig.types.json +14 -4
  193. package/yarn-error.log +3144 -0
  194. package/dist/common/core.js +0 -397
  195. package/dist/common/subPackages/react/jsx/index.js +0 -26
  196. package/dist/common/subPackages/react-dom/jsx/node.js +0 -95
  197. package/dist/common/subPackages/react-test-renderer/component/node.js +0 -8
  198. package/dist/common/subPackages/react-test-renderer/component/web.js +0 -8
  199. package/dist/module/Report.js +0 -186
  200. package/dist/module/core.js +0 -388
  201. package/dist/module/subPackages/react/jsx/index.js +0 -22
  202. package/dist/module/subPackages/react/jsx/node.js +0 -5
  203. package/dist/module/subPackages/react/jsx/web.js +0 -5
  204. package/dist/module/subPackages/react-dom/jsx/node.js +0 -87
  205. package/dist/module/subPackages/react-test-renderer/jsx/web.js +0 -5
  206. package/dist/module/subPackages/react-test-renderer/jsx-promised/node.js +0 -5
  207. package/dist/types/core.d.ts +0 -220
  208. package/dist/types/subPackages/react/component/node.d.ts +0 -12
  209. package/dist/types/subPackages/react/component/web.d.ts +0 -12
  210. package/dist/types/subPackages/react/jsx/index.d.ts +0 -15
  211. package/dist/types/subPackages/react/jsx/node.d.ts +0 -4
  212. package/dist/types/subPackages/react/jsx/web.d.ts +0 -4
  213. package/dist/types/subPackages/react-dom/component/web.d.ts +0 -19
  214. package/dist/types/subPackages/react-dom/jsx/node.d.ts +0 -8
  215. package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -5
  216. package/dist/types/subPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -8
  217. package/dist/types/subPackages/react-test-renderer/component/node.d.ts +0 -9
  218. package/dist/types/subPackages/react-test-renderer/component/web.d.ts +0 -9
  219. package/dist/types/subPackages/react-test-renderer/fc/node.d.ts +0 -9
  220. package/dist/types/subPackages/react-test-renderer/fc/web.d.ts +0 -9
  221. package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +0 -4
  222. package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +0 -4
  223. package/dist/types/subPackages/react-test-renderer/jsx-promised/node.d.ts +0 -4
  224. package/dist/types/subPackages/react-test-renderer/jsx-promised/web.d.ts +0 -4
  225. package/src/core.ts +0 -1399
  226. package/src/subPackages/react/component/web.ts +0 -80
  227. package/src/subPackages/react/jsx/index.ts +0 -64
  228. package/src/subPackages/react/jsx/node.ts +0 -29
  229. package/src/subPackages/react/jsx/web.ts +0 -29
  230. package/src/subPackages/react-dom/jsx/node.ts +0 -145
  231. package/src/subPackages/react-test-renderer/component/node.ts +0 -30
  232. package/src/subPackages/react-test-renderer/component/web.ts +0 -30
  233. package/src/subPackages/react-test-renderer/jsx/node.ts +0 -31
  234. package/src/subPackages/react-test-renderer/jsx/web.ts +0 -31
  235. package/src/subPackages/react-test-renderer/jsx-promised/node.ts +0 -31
  236. package/src/subPackages/react-test-renderer/jsx-promised/web.ts +0 -31
  237. /package/dist/common/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
  238. /package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
  239. /package/dist/module/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
  240. /package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
  241. /package/dist/types/{subPackages → SubPackages}/react-dom/jsx/index.d.ts +0 -0
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ v18.18.0
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # testeranto
2
2
 
3
+ 🚧 WARNING: Testeeranto is still under development and is not ready for production yet. 🚧
4
+
3
5
  home: [adamwong246.github.io/testeranto](https://adamwong246.github.io/testeranto/)
4
6
 
5
7
  source: [github.com/adamwong246/testeranto](https://github.com/adamwong246/testeranto)
@@ -12,9 +14,10 @@ example repo: [kokomo bay](https://github.com/ChromaPDX/kokomoBay)
12
14
 
13
15
  ## tl;dr
14
16
 
15
- - Do you like BDD?
17
+ - Do you like TDD/BDD?
16
18
  - Do you love Typescript?
17
19
  - Do you hate Jira?
20
+ - Do you tolerate electron?
18
21
 
19
22
  If so, then testeranto might be the testing tool you have been looking for!
20
23
 
@@ -22,20 +25,38 @@ If so, then testeranto might be the testing tool you have been looking for!
22
25
 
23
26
  Testeranto.ts an Acceptance Test Driven Development ([ATDD](https://en.wikipedia.org/wiki/Acceptance_test-driven_development)) framework. It focuses on strongly-typed tests, specified in a gherkin-like syntax. Testeranto includes a framework to help write your tests, a test runner to schedule the tests and a reporter to display the results.
24
27
 
25
- ## 2 distinguishing features of testeranto
26
-
27
- 1. Rather than testing your code directly, Testeranto requires you wrap your code with a semantic interface which is based on TS type signatures. These interfaces can be shared and your code is now tested through the gherkin-ish directives provided by that interface.
28
+ ## Getting started
28
29
 
29
- 2. Testeranto tracks features and test results directly in the source code. You may be accustomed to using tools like Jira and Trello to define user stories and assign story points- Under Testeranto, this data lives within the code base _as_ typescript code. Features are defined as nodes within a directed graph, allowing the reporter to summarize these features and their test results.
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
38
 
31
39
  ## tech of note
32
40
 
41
+ - esm - Testeranto uses modern js.
33
42
  - typescript - tests are functions with type parameters
43
+ - electron - provides both a node and chrome runtime
44
+ - puppeteer - provides node-style tests with a handle to the browser
34
45
  - esbuild - used to quickly generate test bundles
35
46
  - graphology - used to store features within a semantic network
36
47
 
48
+ ## 3 distinguishing features of testeranto
49
+
50
+ 1. Rather than testing your code directly, Testeranto requires you wrap your code with a semantic interface which is based on TS type signatures. These interfaces can be shared and your code is now tested through the gherkin-ish directives provided by that interface.
51
+
52
+ 2. Testeranto tracks features and test results directly in the source code. You may be accustomed to using tools like Jira and Trello to define user stories and assign story points- Under Testeranto, this data lives within the code base _as_ typescript code. Features are defined as nodes within a directed graph, allowing the reporter to summarize these features and their test results.
53
+
54
+ 3. Testeranto is designed for both the backend and the frontend. It leverages electron to provide both of these runtimes. Each of your tests can be executed in the backend node runtime, within the frontend chromium browser runtime, or both.
55
+
37
56
  ## the good parts
38
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.
59
+
39
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.
40
61
 
41
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.
@@ -46,10 +67,51 @@ Rather than the traditional method of specifying tests in plain text, Testeranto
46
67
 
47
68
  ## the bad parts
48
69
 
49
- Testeranto does not (yet!) of a means of allowing non-coders to affect changes so, as they say, "get good 💪!"
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
+
72
+ Testeranto does not (yet!) of a means of allowing non-coders to affect changes so, as they say, "get good 💪!"
73
+
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
+
76
+ ## How it works
77
+
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.
85
+
86
+ ## Electron aka Node vs Chromium
87
+
88
+ At the heart of testeranto is the dual runtime provided by electron. The electron test runner creates an UtilityProcess for each node test and a BrowserWindow for each web test. Each of these processes can communicate to other artifacts over IPC. That is, a node test can invoke a web artifact and send it messages over the IPC channel, and vice-versa. Furthermore, node tests are provided with a puppeteer, providing it access to the web environment, while web tests are provided the electron BrowserWindow, which allows it to similarly bridge the gap between the web runtime and the node runtime.
89
+
90
+ ## Hybrid tests
91
+
92
+ Consider the a scenario: You have an http server which serves a frontend react component. You have multiple ways you can test this.
93
+
94
+ - A node test of the logic of the http server
95
+ - A node test of the full http server, tested over http request.
96
+ - A node test of the react component with react-test-render
97
+ - A web test of the react component rendering it to the dom.
98
+ - A node test of the logic of the server, rending the component as a paired artifact and communicated over IPC.
99
+ - A node test of the full server, invoking puppeteer to drive the browser.
100
+ - A web test, invoking the server as a shared artifact, serving http to the browser.
101
+
102
+ ## API
103
+
104
+ Testeranto's main API interface is 2 functions, 1 for each run time. You must pass to this function the following arguments
50
105
 
51
- Testeranto is not for testing pure functions. It's designed only to address _stateful_ logic.
106
+ - The "shape" - a TS type signature to which the other arguments must conform.
107
+ - The "input" - the test subject. The "thing that is to be tested"
108
+ - 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.
52
111
 
53
- Testeranto prefers TS and to be leveraged to it full potential requires at least some proficiency with the language.
112
+ 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.
54
113
 
55
- 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 I plan to have some sort of public repo of test interfaces someday 😅
114
+ - "Senior Engineer" handles the "shape" and "input"
115
+ - "Product Manager" handles the "specification"
116
+ - "Middle Engineer" handles the "interface"
117
+ - "Junior Engineer" handles the "implementation"
@@ -0,0 +1,12 @@
1
+ import { createRequire } from 'node:module';
2
+ import path from 'node:path';
3
+ import url from 'node:url';
4
+
5
+ // globalThis.require = createRequire(import.meta.url);
6
+ // globalThis.__filename = url.fileURLToPath(import.meta.url);
7
+ // globalThis.__dirname = path.dirname(__filename);
8
+
9
+ // const p = `${import.meta.url}/..`;
10
+ // globalThis.require = createRequire(`${import.meta.url}/..`);
11
+ // globalThis.__filename = url.fileURLToPath(`${import.meta.url}/..`);
12
+ // globalThis.__dirname = path.dirname(`${__filename}/..`);
@@ -4,9 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DirectedGraph = exports.TesterantoFeatures = exports.TesterantoGraphDirectedAcyclic = exports.TesterantoGraphDirected = exports.TesterantoGraphUndirected = exports.BaseFeature = void 0;
7
- const graphology_1 = __importDefault(require("graphology"));
8
- /* @ts-ignore:next-line */
9
- const { DirectedGraph, UndirectedGraph } = graphology_1.default;
7
+ const graphology_umd_js_1 = __importDefault(require("graphology/dist/graphology.umd.js"));
8
+ const { DirectedGraph, UndirectedGraph } = graphology_umd_js_1.default;
10
9
  exports.DirectedGraph = DirectedGraph;
11
10
  class TesterantoGraph {
12
11
  constructor(name) {
@@ -3,72 +3,64 @@ 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 core_js_1 = require("./core.js");
7
- const core_js_2 = __importDefault(require("./core.js"));
6
+ const http_1 = __importDefault(require("http"));
7
+ const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
8
+ const core_js_1 = __importDefault(require("./lib/core.js"));
9
+ const index_js_1 = require("./lib/index.js");
8
10
  const NodeWriter_js_1 = require("./NodeWriter.js");
9
- const receiveTestResourceConfigUnscheduled = async (t, testresource) => {
10
- const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(testresource);
11
- Promise.all([...artifacts, logPromise]).then(async () => {
12
- process.exit(await failed ? 1 : 0);
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
+ });
13
26
  });
14
- };
15
- const receiveTestResourceConfigScheduled = async (t, testresource) => {
16
- const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(testresource);
17
- /* @ts-ignore:next-line */
18
- process.send({
19
- type: "testeranto:adios",
20
- data: {
21
- failed,
22
- testResourceConfiguration: t.test.testResourceConfiguration,
23
- results: t.toObj(),
24
- },
25
- }, async (err) => {
26
- if (!err) {
27
- Promise.all([...artifacts, logPromise]).then(async () => {
28
- process.exit(await failed ? 1 : 0);
29
- });
30
- }
31
- else {
32
- console.error(err);
33
- process.exit(1);
34
- }
35
- });
36
- };
37
- exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = core_js_1.defaultTestResourceRequirement) => {
38
- const mrt = new core_js_2.default(input, testSpecification, testImplementation, testInterface, testResourceRequirement, testInterface.assertioner || (async (t) => t), testInterface.beforeEach || async function (subject, initialValues, testResource) {
39
- return subject;
40
- }, testInterface.afterEach || (async (s) => s), testInterface.afterAll || ((store) => undefined), testInterface.butThen || (async (a) => a), testInterface.andWhen, testInterface.actionHandler ||
41
- function (b) {
42
- return b;
43
- }, NodeWriter_js_1.NodeWriter);
44
- const tl2 = mrt;
45
- const t = tl2.testJobs[0];
46
- const testResourceArg = process.argv[2] || `{}`;
47
- try {
48
- const partialTestResource = JSON.parse(testResourceArg);
49
- if (partialTestResource.scheduled) {
50
- console.log("test is scheduled", partialTestResource);
51
- console.log("requesting test resources via IPC ...", testResourceRequirement);
52
- /* @ts-ignore:next-line */
53
- process.send({
54
- type: "testeranto:hola",
55
- data: {
56
- requirement: Object.assign(Object.assign({}, testResourceRequirement), { name: partialTestResource.name })
57
- },
58
- });
59
- console.log("awaiting test resources via IPC...");
60
- process.on("message", async function (packet) {
61
- const resourcesFromPm2 = packet.data.testResourceConfiguration;
62
- const secondTestResource = Object.assign(Object.assign({ fs: "." }, JSON.parse(JSON.stringify(partialTestResource))), JSON.parse(JSON.stringify(resourcesFromPm2)));
63
- receiveTestResourceConfigScheduled(t, secondTestResource);
64
- });
27
+ request.on("error", reject);
28
+ request.end();
29
+ });
30
+ class NodeTesteranto extends core_js_1.default {
31
+ constructor(input, testSpecification, testImplementation, testResourceRequirement, testInterface) {
32
+ super(input, testSpecification, testImplementation, testResourceRequirement, NodeWriter_js_1.NodeWriter, testInterface);
33
+ if (process.argv[2]) {
34
+ const testResourceArg = process.argv[2];
35
+ try {
36
+ const partialTestResource = JSON.parse(testResourceArg);
37
+ this.receiveTestResourceConfig(this.testJobs[0], partialTestResource);
38
+ }
39
+ catch (e) {
40
+ console.error(e);
41
+ // process.exit(-1);
42
+ }
65
43
  }
66
44
  else {
67
- receiveTestResourceConfigUnscheduled(t, partialTestResource);
45
+ // no-op
68
46
  }
69
47
  }
70
- catch (e) {
71
- console.error(e);
72
- process.exit(-1);
48
+ async receiveTestResourceConfig(t, partialTestResource) {
49
+ const browser = await readJson("2999").then(async (json) => {
50
+ const b = await puppeteer_core_1.default.connect({
51
+ browserWSEndpoint: json.webSocketDebuggerUrl,
52
+ defaultViewport: null,
53
+ });
54
+ console.log("connected!", b.isConnected());
55
+ return b;
56
+ });
57
+ const { failed, artifacts, logPromise } = await t.receiveTestResourceConfig(partialTestResource, new Types_js_1.TBrowser(browser));
58
+ Promise.all([...artifacts, logPromise]).then(async () => {
59
+ // process.exit(await failed ? 1 : 0);
60
+ });
73
61
  }
62
+ }
63
+ ;
64
+ exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = index_js_1.defaultTestResourceRequirement) => {
65
+ return new NodeTesteranto(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
74
66
  };