testeranto 0.47.34 → 0.47.52

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 (309) hide show
  1. package/.nvmrc +1 -0
  2. package/Bundle.Dockerfile +45 -0
  3. package/README.md +86 -11
  4. package/Report.Dockerfile +43 -0
  5. package/dist/cjs-shim.js +12 -0
  6. package/dist/common/Features.js +3 -37
  7. package/dist/common/Init.js +30 -0
  8. package/dist/common/Node.js +15 -66
  9. package/dist/common/PM/index.js +7 -0
  10. package/dist/common/PM/main.js +641 -0
  11. package/dist/common/PM/node.js +88 -0
  12. package/dist/common/PM/web.js +132 -0
  13. package/dist/common/Project.js +109 -637
  14. package/dist/common/Puppeteer.js +103 -0
  15. package/dist/common/Reporter.js +112 -0
  16. package/dist/common/Scheduler.js +1 -0
  17. package/dist/common/SubPackages/puppeteer.js +21 -0
  18. package/dist/common/{subPackages → SubPackages}/react/component/node.js +4 -4
  19. package/dist/common/{subPackages → SubPackages}/react/component/web.js +4 -4
  20. package/dist/common/SubPackages/react/jsx/index.js +25 -0
  21. package/dist/common/SubPackages/react/jsx/node.js +10 -0
  22. package/dist/common/SubPackages/react/jsx/web.js +10 -0
  23. package/dist/common/{subPackages/react-dom/jsx → SubPackages/react-dom/component}/node.js +6 -6
  24. package/dist/common/SubPackages/react-dom/component/web.js +93 -0
  25. package/dist/common/SubPackages/react-dom/jsx/index.js +2 -0
  26. package/dist/common/SubPackages/react-dom/jsx/node.js +39 -0
  27. package/dist/common/SubPackages/react-dom/jsx/web.js +118 -0
  28. package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +44 -0
  29. package/dist/common/SubPackages/react-test-renderer/component/index.js +2 -0
  30. package/dist/common/{subPackages/react-test-renderer/component/index.js → SubPackages/react-test-renderer/component/interface.js} +23 -33
  31. package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/node.js +3 -5
  32. package/dist/common/{subPackages/react/jsx → SubPackages/react-test-renderer/component}/web.js +3 -5
  33. package/dist/common/SubPackages/react-test-renderer/fc/node.js +50 -0
  34. package/dist/common/SubPackages/react-test-renderer/fc/web.js +50 -0
  35. package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +7 -3
  36. package/dist/common/SubPackages/react-test-renderer/jsx/node.js +10 -0
  37. package/dist/common/SubPackages/react-test-renderer/jsx/web.js +10 -0
  38. package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +42 -0
  39. package/dist/common/{subPackages/react/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +2 -2
  40. package/dist/common/TaskManBackEnd.js +174 -0
  41. package/dist/common/Web.js +31 -108
  42. package/dist/common/esbuildConfigs/features.js +14 -0
  43. package/dist/common/esbuildConfigs/index.js +21 -0
  44. package/dist/common/esbuildConfigs/inputFilesPlugin.js +49 -0
  45. package/dist/common/esbuildConfigs/node.js +39 -0
  46. package/dist/common/esbuildConfigs/report.js +14 -0
  47. package/dist/common/esbuildConfigs/tests.js +13 -0
  48. package/dist/common/esbuildConfigs/web.js +57 -0
  49. package/dist/common/lib/abstractBase.js +553 -0
  50. package/dist/common/lib/basebuilder.js +79 -0
  51. package/dist/common/lib/classBuilder.js +42 -0
  52. package/dist/common/lib/core.js +75 -0
  53. package/dist/common/lib/index.js +22 -0
  54. package/dist/common/lib/types.js +2 -0
  55. package/dist/common/mongooseSchemas.js +56 -0
  56. package/dist/common/preload.js +14 -27
  57. package/dist/common/puppeteerConfiger.js +24 -0
  58. package/dist/common/report.html.js +31 -0
  59. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  60. package/dist/common/utils.js +16 -0
  61. package/dist/common/web.html.js +22 -0
  62. package/dist/module/ExampleTab.js +112 -0
  63. package/dist/module/Features.js +2 -35
  64. package/dist/module/Init.js +25 -0
  65. package/dist/module/Node.js +15 -66
  66. package/dist/module/PM/index.js +3 -0
  67. package/dist/module/PM/main.js +611 -0
  68. package/dist/module/PM/node.js +81 -0
  69. package/dist/module/PM/web.js +125 -0
  70. package/dist/module/Project.js +110 -615
  71. package/dist/module/Puppeteer.js +98 -0
  72. package/dist/module/Reporter.js +107 -0
  73. package/dist/module/Scheduler.js +1 -0
  74. package/dist/module/SubPackages/puppeteer.js +16 -0
  75. package/dist/module/{subPackages → SubPackages}/react/component/node.js +3 -3
  76. package/dist/module/{subPackages → SubPackages}/react/component/web.js +3 -3
  77. package/dist/module/SubPackages/react/jsx/index.js +19 -0
  78. package/dist/module/SubPackages/react/jsx/node.js +5 -0
  79. package/dist/module/SubPackages/react/jsx/web.js +5 -0
  80. package/dist/module/{subPackages → SubPackages}/react-dom/component/node.js +7 -7
  81. package/dist/module/SubPackages/react-dom/component/web.js +88 -0
  82. package/dist/module/SubPackages/react-dom/jsx/node.js +31 -0
  83. package/dist/module/SubPackages/react-dom/jsx/web.js +90 -0
  84. package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +16 -0
  85. package/dist/module/SubPackages/react-test-renderer/component/index.js +1 -0
  86. package/dist/module/SubPackages/react-test-renderer/component/interface.js +39 -0
  87. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/node.js +2 -2
  88. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/web.js +2 -2
  89. package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/node.js +3 -3
  90. package/dist/module/SubPackages/react-test-renderer/fc/web.js +22 -0
  91. package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +7 -3
  92. package/dist/module/SubPackages/react-test-renderer/jsx/node.js +5 -0
  93. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +5 -0
  94. package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +16 -0
  95. package/dist/module/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +1 -1
  96. package/dist/module/TaskManBackEnd.js +169 -0
  97. package/dist/module/TaskManFrontEnd.js +600 -0
  98. package/dist/module/Web.js +31 -108
  99. package/dist/module/esbuildConfigs/features.js +12 -0
  100. package/dist/module/esbuildConfigs/index.js +19 -0
  101. package/dist/module/esbuildConfigs/inputFilesPlugin.js +44 -0
  102. package/dist/module/esbuildConfigs/node.js +34 -0
  103. package/dist/module/esbuildConfigs/report.js +14 -0
  104. package/dist/module/esbuildConfigs/tests.js +11 -0
  105. package/dist/module/esbuildConfigs/web.js +52 -0
  106. package/dist/module/lib/abstractBase.js +545 -0
  107. package/dist/module/lib/basebuilder.js +75 -0
  108. package/dist/module/lib/classBuilder.js +38 -0
  109. package/dist/module/lib/core.js +72 -0
  110. package/dist/module/lib/index.js +18 -0
  111. package/dist/module/lib/types.js +1 -0
  112. package/dist/module/mongooseSchemas.js +50 -0
  113. package/dist/module/preload.js +15 -26
  114. package/dist/module/puppeteerConfiger.js +19 -0
  115. package/dist/module/report.html.js +29 -0
  116. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  117. package/dist/module/utils.js +9 -0
  118. package/dist/module/web.html.js +20 -0
  119. package/dist/prebuild/TaskManBackEnd.mjs +174 -0
  120. package/dist/prebuild/TaskManFrontEnd.css +12301 -0
  121. package/dist/prebuild/TaskManFrontEnd.js +81264 -0
  122. package/dist/types/Features.d.ts +1 -34
  123. package/dist/types/Init.d.ts +2 -0
  124. package/dist/types/Node.d.ts +5 -11
  125. package/dist/types/PM/index.d.ts +20 -0
  126. package/dist/types/PM/main.d.ts +31 -0
  127. package/dist/types/PM/node.d.ts +27 -0
  128. package/dist/types/PM/web.d.ts +25 -0
  129. package/dist/types/Project.d.ts +3 -29
  130. package/dist/types/Puppeteer.d.ts +2 -0
  131. package/dist/types/Reporter.d.ts +1 -0
  132. package/dist/types/Scheduler.d.ts +0 -0
  133. package/dist/types/SubPackages/puppeteer.d.ts +6 -0
  134. package/dist/types/SubPackages/react/component/node.d.ts +7 -0
  135. package/dist/types/SubPackages/react/component/web.d.ts +7 -0
  136. package/dist/types/SubPackages/react/jsx/index.d.ts +12 -0
  137. package/dist/types/SubPackages/react/jsx/node.d.ts +4 -0
  138. package/dist/types/SubPackages/react/jsx/web.d.ts +4 -0
  139. package/dist/types/SubPackages/react-dom/component/node.d.ts +12 -0
  140. package/dist/types/SubPackages/react-dom/component/web.d.ts +11 -0
  141. package/dist/types/SubPackages/react-dom/jsx/index.d.ts +6 -0
  142. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +6 -0
  143. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +5 -0
  144. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +5 -0
  145. package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +13 -0
  146. package/dist/types/SubPackages/react-test-renderer/component/interface.d.ts +9 -0
  147. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +8 -0
  148. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +3 -0
  149. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +8 -0
  150. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +8 -0
  151. package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx/index.d.ts +5 -4
  152. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +8 -0
  153. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +8 -0
  154. package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +15 -0
  155. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +4 -0
  156. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +4 -0
  157. package/dist/types/TaskManBackEnd.d.ts +3 -0
  158. package/dist/types/Types.d.ts +49 -16
  159. package/dist/types/Web.d.ts +5 -11
  160. package/dist/types/esbuildConfigs/features.d.ts +4 -0
  161. package/dist/types/esbuildConfigs/index.d.ts +4 -0
  162. package/dist/types/esbuildConfigs/inputFilesPlugin.d.ts +5 -0
  163. package/dist/types/esbuildConfigs/node.d.ts +4 -0
  164. package/dist/types/esbuildConfigs/report.d.ts +0 -0
  165. package/dist/types/esbuildConfigs/tests.d.ts +4 -0
  166. package/dist/types/esbuildConfigs/web.d.ts +4 -0
  167. package/dist/types/lib/abstractBase.d.ts +104 -0
  168. package/dist/types/lib/basebuilder.d.ts +27 -0
  169. package/dist/types/lib/classBuilder.d.ts +7 -0
  170. package/dist/types/lib/core.d.ts +8 -0
  171. package/dist/types/lib/index.d.ts +59 -0
  172. package/dist/types/lib/types.d.ts +62 -0
  173. package/dist/types/mongooseSchemas.d.ts +124 -0
  174. package/dist/types/preload.d.ts +0 -1
  175. package/dist/types/puppeteerConfiger.d.ts +4 -0
  176. package/dist/types/report.html.d.ts +2 -0
  177. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  178. package/dist/types/utils.d.ts +2 -0
  179. package/dist/types/web.html.d.ts +2 -0
  180. package/index.html +30 -0
  181. package/package.json +151 -79
  182. package/src/ExampleTab.tsx +219 -0
  183. package/src/Features.ts +2 -58
  184. package/src/Init.ts +51 -0
  185. package/src/Node.ts +71 -157
  186. package/src/PM/index.ts +25 -0
  187. package/src/PM/main.ts +830 -0
  188. package/src/PM/node.ts +128 -0
  189. package/src/PM/web.ts +166 -0
  190. package/src/Project.ts +158 -797
  191. package/src/Puppeteer.ts +141 -0
  192. package/src/Reporter.ts +126 -0
  193. package/src/Scheduler.ts +0 -0
  194. package/src/SubPackages/puppeteer.ts +51 -0
  195. package/src/SubPackages/react/component/node.ts +43 -0
  196. package/src/SubPackages/react/component/web.ts +43 -0
  197. package/src/SubPackages/react/jsx/index.ts +42 -0
  198. package/src/SubPackages/react/jsx/node.ts +26 -0
  199. package/src/SubPackages/react/jsx/web.ts +30 -0
  200. package/src/{subPackages → SubPackages}/react-dom/component/node.ts +24 -44
  201. package/src/SubPackages/react-dom/component/web.ts +143 -0
  202. package/src/SubPackages/react-dom/jsx/index.ts +6 -0
  203. package/src/SubPackages/react-dom/jsx/node.ts +68 -0
  204. package/src/SubPackages/react-dom/jsx/web.ts +139 -0
  205. package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +38 -0
  206. package/src/SubPackages/react-test-renderer/component/index.ts +23 -0
  207. package/src/SubPackages/react-test-renderer/component/interface.ts +48 -0
  208. package/src/SubPackages/react-test-renderer/component/node.ts +17 -0
  209. package/src/SubPackages/react-test-renderer/component/web.ts +17 -0
  210. package/src/SubPackages/react-test-renderer/fc/node.ts +49 -0
  211. package/src/SubPackages/react-test-renderer/fc/web.ts +48 -0
  212. package/src/SubPackages/react-test-renderer/jsx/index.ts +48 -0
  213. package/src/SubPackages/react-test-renderer/jsx/node.ts +20 -0
  214. package/src/SubPackages/react-test-renderer/jsx/web.ts +20 -0
  215. package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +40 -0
  216. package/src/SubPackages/react-test-renderer/jsx-promised/node.ts +19 -0
  217. package/src/SubPackages/react-test-renderer/jsx-promised/web.ts +22 -0
  218. package/src/TaskManBackEnd.ts +228 -0
  219. package/src/TaskManFrontEnd.tsx +1222 -0
  220. package/src/Types.ts +222 -17
  221. package/src/Web.ts +86 -217
  222. package/src/cjs-shim.js +12 -0
  223. package/src/esbuildConfigs/features.ts +17 -0
  224. package/src/esbuildConfigs/index.ts +23 -0
  225. package/src/esbuildConfigs/inputFilesPlugin.ts +65 -0
  226. package/src/esbuildConfigs/node.ts +62 -0
  227. package/src/esbuildConfigs/report.ts +15 -0
  228. package/src/esbuildConfigs/tests.ts +14 -0
  229. package/src/esbuildConfigs/web.ts +79 -0
  230. package/src/lib/abstractBase.ts +910 -0
  231. package/src/lib/basebuilder.ts +214 -0
  232. package/src/lib/classBuilder.ts +131 -0
  233. package/src/lib/core.ts +224 -0
  234. package/src/lib/index.ts +226 -0
  235. package/src/lib/types.ts +303 -0
  236. package/src/mongooseSchemas.ts +105 -0
  237. package/src/preload.ts +14 -28
  238. package/src/puppeteerConfiger.ts +26 -0
  239. package/src/report.html.ts +29 -0
  240. package/src/utils.ts +15 -0
  241. package/src/web.html.ts +20 -0
  242. package/tests/Rectangle.test.ts +189 -0
  243. package/trash/TaskMan.Dockerfile +23 -0
  244. package/trash/TaskMan1.Dockerfile +43 -0
  245. package/trash/devBot.dockerfile +12 -0
  246. package/trash/docker-compose-dev.yml +9 -0
  247. package/trash/docker-compose-prod.yml +18 -0
  248. package/trash/electronBuild.ts +32 -0
  249. package/tsconfig.json +18 -6
  250. package/tsconfig.module.json +14 -4
  251. package/tsconfig.types.json +13 -4
  252. package/dist/common/NodeWriter.js +0 -56
  253. package/dist/common/core.js +0 -396
  254. package/dist/common/electron.js +0 -52
  255. package/dist/common/subPackages/react/jsx/index.js +0 -26
  256. package/dist/common/subPackages/react-dom/component/node.js +0 -101
  257. package/dist/common/subPackages/react-dom/component/web.js +0 -61
  258. package/dist/common/subPackages/react-dom/jsx/web.js +0 -76
  259. package/dist/common/subPackages/react-test-renderer/component/node.js +0 -8
  260. package/dist/common/subPackages/react-test-renderer/component/web.js +0 -8
  261. package/dist/module/NodeWriter.js +0 -50
  262. package/dist/module/Report.js +0 -186
  263. package/dist/module/core.js +0 -387
  264. package/dist/module/electron.js +0 -47
  265. package/dist/module/subPackages/react/jsx/index.js +0 -22
  266. package/dist/module/subPackages/react/jsx/node.js +0 -5
  267. package/dist/module/subPackages/react/jsx/web.js +0 -5
  268. package/dist/module/subPackages/react-dom/component/web.js +0 -56
  269. package/dist/module/subPackages/react-dom/jsx/node.js +0 -93
  270. package/dist/module/subPackages/react-dom/jsx/web.js +0 -48
  271. package/dist/module/subPackages/react-test-renderer/component/index.js +0 -52
  272. package/dist/types/NodeWriter.d.ts +0 -2
  273. package/dist/types/core.d.ts +0 -220
  274. package/dist/types/subPackages/react/component/node.d.ts +0 -12
  275. package/dist/types/subPackages/react/component/web.d.ts +0 -12
  276. package/dist/types/subPackages/react/jsx/index.d.ts +0 -15
  277. package/dist/types/subPackages/react/jsx/node.d.ts +0 -4
  278. package/dist/types/subPackages/react/jsx/web.d.ts +0 -4
  279. package/dist/types/subPackages/react-dom/component/node.d.ts +0 -14
  280. package/dist/types/subPackages/react-dom/component/web.d.ts +0 -19
  281. package/dist/types/subPackages/react-dom/jsx/node.d.ts +0 -14
  282. package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -15
  283. package/dist/types/subPackages/react-test-renderer/component/index.d.ts +0 -20
  284. package/dist/types/subPackages/react-test-renderer/component/node.d.ts +0 -9
  285. package/dist/types/subPackages/react-test-renderer/component/web.d.ts +0 -9
  286. package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +0 -4
  287. package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +0 -4
  288. package/src/NodeWriter.ts +0 -72
  289. package/src/Report.tsx +0 -392
  290. package/src/core.ts +0 -1396
  291. package/src/electron.ts +0 -59
  292. package/src/subPackages/react/component/node.ts +0 -75
  293. package/src/subPackages/react/component/web.ts +0 -80
  294. package/src/subPackages/react/jsx/index.ts +0 -64
  295. package/src/subPackages/react/jsx/node.ts +0 -29
  296. package/src/subPackages/react/jsx/web.ts +0 -29
  297. package/src/subPackages/react-dom/component/web.ts +0 -129
  298. package/src/subPackages/react-dom/jsx/node.ts +0 -150
  299. package/src/subPackages/react-dom/jsx/web.ts +0 -117
  300. package/src/subPackages/react-test-renderer/component/index.ts +0 -101
  301. package/src/subPackages/react-test-renderer/component/node.ts +0 -30
  302. package/src/subPackages/react-test-renderer/component/web.ts +0 -30
  303. package/src/subPackages/react-test-renderer/fc/node.tsx +0 -77
  304. package/src/subPackages/react-test-renderer/jsx/index.ts +0 -51
  305. package/src/subPackages/react-test-renderer/jsx/node.ts +0 -31
  306. package/src/subPackages/react-test-renderer/jsx/web.ts +0 -31
  307. /package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/web.js +0 -0
  308. /package/dist/{types/electron.d.ts → module/SubPackages/react-dom/jsx/index.js} +0 -0
  309. /package/dist/module/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/web.js +0 -0
package/src/core.ts DELETED
@@ -1,1396 +0,0 @@
1
- const defaultTestResource: ITTestResourceConfiguration = {
2
- name: "",
3
- fs: ".",
4
- ports: [],
5
- scheduled: false
6
- };
7
-
8
- export type IImplementer<IImplementation> = {
9
- name: string;
10
- fs: string;
11
- ports: number[];
12
- };
13
-
14
- export type ITTestResourceConfiguration = {
15
- name: string;
16
- fs: string;
17
- ports: number[];
18
- scheduled: boolean;
19
- };
20
-
21
- export type ITTestResourceRequirement = {
22
- name: string;
23
- ports: number;
24
- fs: string;
25
- };
26
-
27
- export type ITTestResourceRequest = {
28
- ports: number;
29
- };
30
-
31
- export type Modify<Type, Replace> = Omit<Type, keyof Replace> & Replace;
32
-
33
- export type ITTestShape = {
34
- suites;
35
- givens;
36
- whens;
37
- thens;
38
- checks;
39
- };
40
-
41
- export type ILogWriter = {
42
- createWriteStream: (line: string) => any | any,
43
- writeFileSync: (fp: string, contents: string) => any
44
- mkdirSync: (fp: string) => any
45
- testArtiFactoryfileWriter: (tLog: ITLog, n: (Promise) => void) =>
46
- (fPath: string, value: unknown) =>
47
- void
48
- }
49
-
50
- type IGivens<
51
- ISubject,
52
- IStore,
53
- ISelection,
54
- IThenShape
55
- > = Record<
56
- string,
57
- BaseGiven<
58
- ISubject,
59
- IStore,
60
- ISelection,
61
- IThenShape
62
- >
63
- >;
64
-
65
- type ITestCheckCallback<ITestShape extends ITTestShape> = {
66
- [K in keyof ITestShape["checks"]]: (
67
- name: string,
68
- features: string[],
69
- callbackA: (
70
- whens: {
71
- [K in keyof ITestShape["whens"]]: (
72
- ...unknown
73
- ) => BaseWhen<unknown, unknown, unknown>;
74
- },
75
- thens: {
76
- [K in keyof ITestShape["thens"]]: (
77
- ...unknown
78
- ) => BaseThen<unknown, unknown, unknown>;
79
- }
80
- ) => Promise<any>,
81
- ...xtrasA: ITestShape["checks"][K]
82
- ) => BaseCheck<unknown, unknown, unknown, unknown, ITestShape>;
83
- };
84
-
85
- export type ITestArtificer = (key: string, data: any) => void;
86
- export type IRunTimeAndSubject = {
87
- runtime: "just node" | "just web" | "both web and node";
88
- entrypoint: string;
89
- };
90
-
91
- type IRunner = (x: ITTestResourceConfiguration, t: ITLog) => Promise<
92
- BaseSuite<any, any, any, any, any, any>
93
- >;
94
-
95
- export type IT = {
96
- toObj(): object;
97
- name: string;
98
- givens: IGivens<unknown, unknown, unknown, unknown>;
99
- checks: BaseCheck<unknown, unknown, unknown, unknown, ITTestShape>[];
100
- testResourceConfiguration: ITTestResourceConfiguration;
101
- };
102
-
103
- export type ITestJob = {
104
- toObj(): object;
105
- test: IT;
106
- runner: IRunner;
107
- testResourceRequirement: ITTestResourceRequirement;
108
- receiveTestResourceConfig: (testResource?) => Promise<{
109
- failed: number,
110
- artifacts: Promise<unknown>[],
111
- logPromise: Promise<unknown>
112
- }>
113
- };
114
-
115
- export type ITestResults = Promise<{ test: IT }>[];
116
-
117
- export const defaultTestResourceRequirement: ITTestResourceRequest = {
118
- ports: 0
119
- };
120
-
121
- export type ITestArtifactory = (key: string, value: unknown) => unknown;
122
- export type ITLog = (...string) => void;
123
-
124
- export abstract class BaseSuite<
125
- IInput,
126
- ISubject,
127
- IStore,
128
- ISelection,
129
- IThenShape,
130
- ITestShape extends ITTestShape
131
- > {
132
- name: string;
133
- givens: IGivens<ISubject, IStore, ISelection, IThenShape>;
134
- checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape>[];
135
- store: IStore;
136
- fails: BaseGiven<ISubject, IStore, ISelection, IThenShape>[];
137
- testResourceConfiguration: ITTestResourceConfiguration;
138
- index: number;
139
-
140
- constructor(
141
- name: string,
142
- index: number,
143
- givens: IGivens<ISubject, IStore, ISelection, IThenShape> = {},
144
- checks: BaseCheck<
145
- ISubject,
146
- IStore,
147
- ISelection,
148
- IThenShape,
149
- ITestShape
150
- >[] = []
151
- ) {
152
- this.name = name;
153
- this.index = index;
154
- this.givens = givens;
155
- this.checks = checks;
156
- this.fails = [];
157
- }
158
-
159
- public toObj() {
160
- return {
161
- name: this.name,
162
- givens: Object.keys(this.givens).map((k) => this.givens[k].toObj()),
163
- fails: this.fails,
164
- };
165
- }
166
-
167
- setup(s: IInput, artifactory: ITestArtifactory): Promise<ISubject> {
168
- return new Promise((res) => res(s as unknown as ISubject));
169
- }
170
-
171
- test(t: IThenShape): unknown {
172
- return t;
173
- }
174
-
175
- async run(
176
- input,
177
- testResourceConfiguration: ITTestResourceConfiguration,
178
- artifactory: (
179
- fPath: string,
180
- value: unknown
181
- ) => void,
182
- tLog: (...string) => void
183
- ): Promise<
184
- BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITestShape>
185
- > {
186
- this.testResourceConfiguration = testResourceConfiguration;
187
-
188
- const suiteArtifactory = (fPath: string, value: unknown) =>
189
- artifactory(`suite-${this.index}-${this.name}/${fPath}`, value)
190
- const subject = await this.setup(input, suiteArtifactory);
191
-
192
- tLog("\nSuite:", this.index, this.name);
193
- for (const k of Object.keys(this.givens)) {
194
- const giver = this.givens[k];
195
- try {
196
- this.store = await giver.give(
197
- subject,
198
- k,
199
- testResourceConfiguration,
200
- this.test,
201
- suiteArtifactory,
202
- tLog
203
- );
204
- } catch (e) {
205
- console.error(e);
206
- this.fails.push(giver);
207
- return this;
208
- }
209
- }
210
- for (const [ndx, thater] of this.checks.entries()) {
211
- await thater.check(
212
- subject,
213
- thater.name,
214
- testResourceConfiguration,
215
- this.test,
216
- suiteArtifactory,
217
- tLog
218
- );
219
- }
220
-
221
- // @TODO fix me
222
- for (const k of Object.keys(this.givens)) {
223
- const giver = this.givens[k];
224
- giver.afterAll(this.store, artifactory);
225
- }
226
- ////////////////
227
-
228
- return this;
229
- }
230
- }
231
-
232
- export abstract class BaseGiven<ISubject, IStore, ISelection, IThenShape> {
233
- name: string;
234
- features: string[];
235
- whens: BaseWhen<IStore, ISelection, IThenShape>[];
236
- thens: BaseThen<ISelection, IStore, IThenShape>[];
237
- error: Error;
238
- store: IStore;
239
- recommendedFsPath: string;
240
-
241
- constructor(
242
- name: string,
243
- features: string[],
244
- whens: BaseWhen<IStore, ISelection, IThenShape>[],
245
- thens: BaseThen<ISelection, IStore, IThenShape>[]
246
- ) {
247
- this.name = name;
248
- this.features = features;
249
- this.whens = whens;
250
- this.thens = thens;
251
- }
252
-
253
- beforeAll(store: IStore, artifactory: ITestArtifactory) {
254
- return store;
255
- }
256
-
257
- afterAll(store: IStore, artifactory: ITestArtifactory) {
258
- return store;
259
- }
260
-
261
- toObj() {
262
- return {
263
- name: this.name,
264
- whens: this.whens.map((w) => w.toObj()),
265
- thens: this.thens.map((t) => t.toObj()),
266
- error: this.error ? [this.error, this.error.stack] : null,
267
- features: this.features,
268
- };
269
- }
270
-
271
- abstract givenThat(
272
- subject: ISubject,
273
- testResourceConfiguration,
274
- artifactory: ITestArtifactory
275
- ): Promise<IStore>;
276
-
277
- async afterEach(
278
- store: IStore,
279
- key: string,
280
- artifactory: ITestArtifactory
281
- ): Promise<unknown> {
282
- return store;
283
- }
284
-
285
- async give(
286
- subject: ISubject,
287
- key: string,
288
- testResourceConfiguration,
289
- tester,
290
- artifactory: ITestArtifactory,
291
- tLog: ITLog
292
- ) {
293
- tLog(`\n Given: ${this.name}`);
294
-
295
- const givenArtifactory = (fPath: string, value: unknown) =>
296
- artifactory(`given-${key}/${fPath}`, value)
297
-
298
- try {
299
- this.store = await this.givenThat(
300
- subject,
301
- testResourceConfiguration,
302
- givenArtifactory
303
- );
304
-
305
- // tLog(`\n Given this.store`, this.store);
306
- for (const whenStep of this.whens) {
307
- await whenStep.test(this.store, testResourceConfiguration, tLog);
308
- }
309
- for (const thenStep of this.thens) {
310
- const t = await thenStep.test(
311
- this.store,
312
- testResourceConfiguration,
313
- tLog
314
- );
315
- tester(t);
316
- }
317
- } catch (e) {
318
- this.error = e;
319
- tLog(e);
320
- tLog("\u0007"); // bell
321
- // throw e;
322
- } finally {
323
- try {
324
- await this.afterEach(this.store, key, givenArtifactory);
325
- } catch (e) {
326
- console.error("afterEach failed! no error will be recorded!", e);
327
- }
328
- }
329
- return this.store;
330
- }
331
- }
332
-
333
- export abstract class BaseWhen<IStore, ISelection, IThenShape> {
334
- public name: string;
335
- actioner: (x: ISelection) => IThenShape;
336
- error: boolean;
337
-
338
- constructor(
339
- name: string,
340
- actioner: (xyz: ISelection) => IThenShape) {
341
- this.name = name;
342
- this.actioner = actioner;
343
- }
344
-
345
- abstract andWhen(
346
- store: IStore,
347
- actioner: (x: ISelection) => IThenShape,
348
- testResource
349
- );
350
-
351
- toObj() {
352
- return {
353
- name: this.name,
354
- error: this.error,
355
- };
356
- }
357
-
358
- async test(store: IStore, testResourceConfiguration, tLog: ITLog) {
359
- tLog(" When:", this.name);
360
- try {
361
- return await this.andWhen(
362
- store,
363
- this.actioner,
364
- testResourceConfiguration
365
- );
366
- } catch (e) {
367
- this.error = true;
368
- throw e;
369
- }
370
- }
371
- }
372
-
373
- export abstract class BaseThen<ISelection, IStore, IThenShape> {
374
- public name: string;
375
- thenCB: (storeState: ISelection) => IThenShape;
376
- error: boolean;
377
-
378
- constructor(name: string, thenCB: (val: ISelection) => IThenShape) {
379
- this.name = name;
380
- this.thenCB = thenCB;
381
- }
382
-
383
- toObj() {
384
- return {
385
- name: this.name,
386
- error: this.error,
387
- };
388
- }
389
-
390
- abstract butThen(store: any, testResourceConfiguration?): Promise<ISelection>;
391
-
392
- async test(
393
- store: IStore,
394
- testResourceConfiguration,
395
- tLog: ITLog
396
- ): Promise<IThenShape | undefined> {
397
- tLog(" Then:", this.name);
398
- try {
399
- return this.thenCB(await this.butThen(store, testResourceConfiguration));
400
- } catch (e) {
401
- console.log("test failed", e);
402
- this.error = true;
403
- throw e;
404
- }
405
-
406
- // try {
407
- // return await (this.thenCB(
408
- // await (async () => {
409
- // try {
410
- // return await (
411
- // (() => {
412
- // try {
413
- // return this.butThen(store, testResourceConfiguration)
414
- // } catch (e) {
415
- // this.error = true;
416
- // throw e
417
- // }
418
- // })()
419
- // );
420
- // } catch (e) {
421
- // this.error = true;
422
- // throw e
423
- // }
424
- // })()
425
- // ));
426
- // } catch (e) {
427
- // this.error = true;
428
- // throw e
429
- // }
430
- }
431
- }
432
-
433
- export abstract class BaseCheck<
434
- ISubject,
435
- IStore,
436
- ISelection,
437
- IThenShape,
438
- ITestShape extends ITTestShape
439
- > {
440
- name: string;
441
- features: string[];
442
- checkCB: (whens, thens) => any;
443
- whens: {
444
- [K in keyof ITestShape["whens"]]: (
445
- p,
446
- tc
447
- ) => BaseWhen<IStore, ISelection, IThenShape>;
448
- };
449
- thens: {
450
- [K in keyof ITestShape["thens"]]: (
451
- p,
452
- tc
453
- ) => BaseThen<ISelection, IStore, IThenShape>;
454
- };
455
-
456
- constructor(
457
- name: string,
458
- features: string[],
459
- checkCB: (whens, thens) => any,
460
- whens,
461
- thens
462
- ) {
463
- this.name = name;
464
- this.features = features;
465
- this.checkCB = checkCB;
466
- this.whens = whens;
467
- this.thens = thens;
468
- }
469
-
470
- abstract checkThat(
471
- subject: ISubject,
472
- testResourceConfiguration,
473
- artifactory: ITestArtifactory
474
- ): Promise<IStore>;
475
-
476
- async afterEach(store: IStore, key: string, cb?): Promise<unknown> {
477
- return;
478
- }
479
-
480
- async check(
481
- subject: ISubject,
482
- key: string,
483
- testResourceConfiguration,
484
- tester,
485
- artifactory: ITestArtifactory,
486
- tLog: ITLog
487
- ) {
488
- tLog(`\n Check: ${this.name}`);
489
- const store = await this.checkThat(
490
- subject,
491
- testResourceConfiguration,
492
- artifactory
493
- );
494
- await this.checkCB(
495
- Object.entries(this.whens).reduce((a, [key, when]) => {
496
- a[key] = async (payload) => {
497
- return await when(payload, testResourceConfiguration).test(
498
- store,
499
- testResourceConfiguration,
500
- tLog
501
- );
502
- };
503
- return a;
504
- }, {}),
505
- Object.entries(this.thens).reduce((a, [key, then]) => {
506
- a[key] = async (payload) => {
507
- const t = await then(payload, testResourceConfiguration).test(
508
- store,
509
- testResourceConfiguration,
510
- tLog
511
- );
512
- tester(t);
513
- };
514
- return a;
515
- }, {})
516
- );
517
-
518
- await this.afterEach(store, key);
519
- return;
520
- }
521
- }
522
-
523
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
524
-
525
- abstract class TesterantoLevelZero<
526
- IInput,
527
- ISubject,
528
- IStore,
529
- ISelection,
530
- SuiteExtensions,
531
- GivenExtensions,
532
- WhenExtensions,
533
- ThenExtensions,
534
- CheckExtensions,
535
- IThenShape
536
- > {
537
- constructorator: IStore;
538
-
539
- suitesOverrides: Record<
540
- keyof SuiteExtensions,
541
- (
542
- name: string,
543
- index: number,
544
- givens: IGivens<ISubject, IStore, ISelection, IThenShape>,
545
- checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape>[]
546
- ) => BaseSuite<
547
- IInput,
548
- ISubject,
549
- IStore,
550
- ISelection,
551
- IThenShape,
552
- ITTestShape
553
- >
554
- >;
555
-
556
- givenOverides: Record<
557
- keyof GivenExtensions,
558
- (
559
- name: string,
560
- features: string[],
561
- whens: BaseWhen<IStore, ISelection, IThenShape>[],
562
- thens: BaseThen<ISelection, IStore, IThenShape>[],
563
- ...xtraArgs
564
- ) => BaseGiven<ISubject, IStore, ISelection, IThenShape>
565
- >;
566
-
567
- whenOverides: Record<
568
- keyof WhenExtensions,
569
- (any) => BaseWhen<IStore, ISelection, IThenShape>
570
- >;
571
-
572
- thenOverides: Record<
573
- keyof ThenExtensions,
574
- (
575
- selection: ISelection,
576
- expectation: any
577
- ) => BaseThen<ISelection, IStore, IThenShape>
578
- >;
579
-
580
- checkOverides: Record<
581
- keyof CheckExtensions,
582
- (
583
- feature: string,
584
- callback: (whens, thens) => any,
585
- ...xtraArgs
586
- ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape>
587
- >;
588
-
589
- constructor(
590
- public readonly cc: IStore,
591
- suitesOverrides: Record<
592
- keyof SuiteExtensions,
593
- (
594
- name: string,
595
- index: number,
596
- givens: IGivens<ISubject, IStore, ISelection, IThenShape>,
597
- checks: BaseCheck<
598
- ISubject,
599
- IStore,
600
- ISelection,
601
- IThenShape,
602
- ITTestShape
603
- >[]
604
- ) => BaseSuite<
605
- IInput,
606
- ISubject,
607
- IStore,
608
- ISelection,
609
- IThenShape,
610
- ITTestShape
611
- >
612
- >,
613
-
614
- givenOverides: Record<
615
- keyof GivenExtensions,
616
- (
617
- name: string,
618
- features: string[],
619
- whens: BaseWhen<IStore, ISelection, IThenShape>[],
620
- thens: BaseThen<ISelection, IStore, IThenShape>[],
621
- ...xtraArgs
622
- ) => BaseGiven<ISubject, IStore, ISelection, IThenShape>
623
- >,
624
-
625
- whenOverides: Record<
626
- keyof WhenExtensions,
627
- (c: any) => BaseWhen<IStore, ISelection, IThenShape>
628
- >,
629
-
630
- thenOverides: Record<
631
- keyof ThenExtensions,
632
- (
633
- selection: ISelection,
634
- expectation: any
635
- ) => BaseThen<ISelection, IStore, IThenShape>
636
- >,
637
-
638
- checkOverides: Record<
639
- keyof CheckExtensions,
640
- (
641
- feature: string,
642
- callback: (whens, thens) => any,
643
- ...xtraArgs
644
- ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape>
645
- >
646
- ) {
647
- this.constructorator = cc;
648
- this.suitesOverrides = suitesOverrides;
649
- this.givenOverides = givenOverides;
650
- this.whenOverides = whenOverides;
651
- this.thenOverides = thenOverides;
652
- this.checkOverides = checkOverides;
653
- }
654
-
655
- Suites() {
656
- return this.suitesOverrides;
657
- }
658
-
659
- Given(): Record<
660
- keyof GivenExtensions,
661
- (
662
- name: string,
663
- features: string[],
664
- whens: BaseWhen<IStore, ISelection, IThenShape>[],
665
- thens: BaseThen<ISelection, IStore, IThenShape>[],
666
- ...xtraArgs
667
- ) => BaseGiven<ISubject, IStore, ISelection, IThenShape>
668
- > {
669
- return this.givenOverides;
670
- }
671
-
672
- When(): Record<
673
- keyof WhenExtensions,
674
- (arg0: IStore, ...arg1: any) => BaseWhen<IStore, ISelection, IThenShape>
675
- > {
676
- return this.whenOverides;
677
- }
678
-
679
- Then(): Record<
680
- keyof ThenExtensions,
681
- (
682
- selection: ISelection,
683
- expectation: any
684
- ) => BaseThen<ISelection, IStore, IThenShape>
685
- > {
686
- return this.thenOverides;
687
- }
688
-
689
- Check(): Record<
690
- keyof CheckExtensions,
691
- (
692
- feature: string,
693
- callback: (whens, thens) => any,
694
- whens,
695
- thens
696
- ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape>
697
- > {
698
- return this.checkOverides;
699
- }
700
- }
701
-
702
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
703
-
704
- abstract class TesterantoLevelOne<
705
- ITestShape extends ITTestShape,
706
- IInitialState,
707
- ISelection,
708
- IStore,
709
- ISubject,
710
- IWhenShape,
711
- IThenShape,
712
- IInput
713
- > {
714
-
715
- artifacts: Promise<unknown>[] = [];
716
- testJobs: ITestJob[];
717
-
718
- constructor(
719
- testImplementation: ITestImplementation<
720
- IInitialState,
721
- ISelection,
722
- IWhenShape,
723
- IThenShape,
724
- ITestShape
725
- >,
726
-
727
- testSpecification: (
728
- Suite: {
729
- [K in keyof ITestShape["suites"]]: (
730
- feature: string,
731
- givens: IGivens<ISubject, IStore, ISelection, IThenShape>,
732
- checks: BaseCheck<
733
- ISubject,
734
- IStore,
735
- ISelection,
736
- IThenShape,
737
- ITestShape
738
- >[]
739
- ) => BaseSuite<
740
- IInput,
741
- ISubject,
742
- IStore,
743
- ISelection,
744
- IThenShape,
745
- ITestShape
746
- >;
747
- },
748
- Given: {
749
- [K in keyof ITestShape["givens"]]: (
750
- features: string[],
751
- whens: BaseWhen<IStore, ISelection, IThenShape>[],
752
- thens: BaseThen<ISelection, IStore, IThenShape>[],
753
- ...a: ITestShape["givens"][K]
754
- ) => BaseGiven<ISubject, IStore, ISelection, IThenShape>;
755
- },
756
- When: {
757
- [K in keyof ITestShape["whens"]]: (
758
- ...a: ITestShape["whens"][K]
759
- ) => BaseWhen<IStore, ISelection, IThenShape>;
760
- },
761
- Then: {
762
- [K in keyof ITestShape["thens"]]: (
763
- ...a: ITestShape["thens"][K]
764
- ) => BaseThen<ISelection, IStore, IThenShape>;
765
- },
766
- Check: ITestCheckCallback<ITestShape>,
767
- logWriter: ILogWriter
768
- ) => BaseSuite<
769
- IInput,
770
- ISubject,
771
- IStore,
772
- ISelection,
773
- IThenShape,
774
- ITestShape
775
- >[],
776
-
777
- input: IInput,
778
-
779
- suiteKlasser: (
780
- name: string,
781
- index: number,
782
- givens: IGivens<ISubject, IStore, ISelection, IThenShape>,
783
- checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape>[]
784
- ) => BaseSuite<
785
- IInput,
786
- ISubject,
787
- IStore,
788
- ISelection,
789
- IThenShape,
790
- ITestShape
791
- >,
792
- givenKlasser: (
793
- n,
794
- f,
795
- w,
796
- t,
797
- z?
798
- ) => BaseGiven<ISubject, IStore, ISelection, IThenShape>,
799
- whenKlasser: (s, o) => BaseWhen<IStore, ISelection, IThenShape>,
800
- thenKlasser: (s, o) => BaseThen<IStore, ISelection, IThenShape>,
801
- checkKlasser: (
802
- n,
803
- f,
804
- cb,
805
- w,
806
- t
807
- ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape>,
808
-
809
- testResourceRequirement,
810
- logWriter: ILogWriter
811
- ) {
812
- const classySuites = Object.entries(testImplementation.Suites).reduce(
813
- (a, [key], index) => {
814
- a[key] = (somestring, givens, checks) => {
815
- return new suiteKlasser.prototype.constructor(
816
- somestring,
817
- index,
818
- givens,
819
- checks
820
- );
821
- };
822
- return a;
823
- },
824
- {}
825
- );
826
-
827
- const classyGivens = Object.keys(testImplementation.Givens)
828
- .reduce(
829
- (a, key: string) => {
830
- a[key] = (
831
- features,
832
- whens,
833
- thens,
834
- ...xtrasW
835
- ) => {
836
- return new givenKlasser.prototype.constructor(
837
- key,
838
- features,
839
- whens,
840
- thens,
841
- testImplementation.Givens[key](...xtrasW)
842
- );
843
- };
844
- return a;
845
- },
846
- {}
847
- );
848
-
849
- const classyWhens = Object.entries(testImplementation.Whens).reduce(
850
- (a, [key, whEn]) => {
851
- a[key] = (payload?: any) => {
852
- return new whenKlasser.prototype.constructor(
853
- `${whEn.name}: ${payload && payload.toString()}`,
854
- whEn(payload)
855
- );
856
- };
857
- return a;
858
- },
859
- {}
860
- );
861
-
862
- const classyThens = Object.entries(testImplementation.Thens).reduce(
863
- (a, [key, thEn]) => {
864
- a[key] = (expected: any, x) => {
865
- return new thenKlasser.prototype.constructor(
866
- `${thEn.name}: ${expected && expected.toString()}`,
867
- thEn(expected)
868
- );
869
- };
870
- return a;
871
- },
872
- {}
873
- );
874
-
875
- const classyChecks = Object.entries(testImplementation.Checks).reduce(
876
- (a, [key, z]) => {
877
- a[key] = (somestring, features, callback) => {
878
- return new checkKlasser.prototype.constructor(
879
- somestring,
880
- features,
881
- callback,
882
- classyWhens,
883
- classyThens
884
- );
885
- };
886
- return a;
887
- },
888
- {}
889
- );
890
-
891
- const classyTesteranto = new (class <
892
- IInput,
893
- ISubject,
894
- IStore,
895
- ISelection,
896
- SuiteExtensions,
897
- GivenExtensions,
898
- WhenExtensions,
899
- ThenExtensions,
900
- ICheckExtensions,
901
- IThenShape
902
- > extends TesterantoLevelZero<
903
- IInput,
904
- ISubject,
905
- IStore,
906
- ISelection,
907
- SuiteExtensions,
908
- GivenExtensions,
909
- WhenExtensions,
910
- ThenExtensions,
911
- ICheckExtensions,
912
- IThenShape
913
- > { })(
914
- input,
915
- classySuites,
916
- classyGivens,
917
- classyWhens,
918
- classyThens,
919
- classyChecks
920
- );
921
-
922
- const suites = testSpecification(
923
- /* @ts-ignore:next-line */
924
- classyTesteranto.Suites(),
925
- classyTesteranto.Given(),
926
- classyTesteranto.When(),
927
- classyTesteranto.Then(),
928
- classyTesteranto.Check(),
929
- logWriter
930
- );
931
-
932
- const suiteRunner =
933
- (suite: BaseSuite<
934
- IInput,
935
- ISubject,
936
- IStore,
937
- ISelection,
938
- IThenShape,
939
- ITestShape
940
- >) =>
941
- async (
942
- testResourceConfiguration: ITTestResourceConfiguration,
943
- tLog: ITLog
944
- ): Promise<BaseSuite<
945
- IInput, ISubject, IStore, ISelection, IThenShape, ITestShape
946
- >> => {
947
- return await suite.run(
948
- input,
949
- testResourceConfiguration,
950
- (
951
- fPath: string,
952
- value: unknown
953
- ) =>
954
- logWriter.testArtiFactoryfileWriter(tLog, (p: Promise<void>) => {
955
- artifacts.push(p);
956
- })(
957
- testResourceConfiguration.fs + "/" + fPath,
958
- value
959
- ),
960
- tLog
961
- );
962
- };
963
-
964
- const artifacts = this.artifacts;
965
-
966
- this.testJobs = suites.map((suite) => {
967
- const runner = suiteRunner(suite);
968
-
969
- return {
970
- test: suite,
971
- testResourceRequirement,
972
-
973
- toObj: () => {
974
- return suite.toObj();
975
- },
976
-
977
- runner,
978
-
979
- receiveTestResourceConfig: async function (
980
- testResourceConfiguration = defaultTestResource
981
- ) {
982
- console.log(
983
- `testResourceConfiguration ${JSON.stringify(
984
- testResourceConfiguration,
985
- null,
986
- 2
987
- )}`
988
- );
989
-
990
- await logWriter.mkdirSync(testResourceConfiguration.fs);
991
-
992
- const logFilePath = (
993
- `${testResourceConfiguration.fs}/log.txt`
994
- );
995
-
996
- const access = await logWriter.createWriteStream(logFilePath);
997
-
998
- const tLog = (...l: string[]) => {
999
- console.log(...l);
1000
- access.write(`${l.toString()}\n`);
1001
- };
1002
- const suiteDone: BaseSuite<
1003
- IInput,
1004
- ISubject,
1005
- IStore,
1006
- ISelection,
1007
- IThenShape,
1008
- ITestShape
1009
- > = await runner(testResourceConfiguration, tLog);
1010
- const resultsFilePath = (
1011
- `${testResourceConfiguration.fs}/results.json`
1012
- );
1013
-
1014
- logWriter.writeFileSync(
1015
- resultsFilePath,
1016
- JSON.stringify(suiteDone.toObj(), null, 2)
1017
- );
1018
-
1019
- const logPromise = new Promise((res, rej) => {
1020
- access.on("finish", () => { res(true); });
1021
- })
1022
- access.end();
1023
-
1024
- const numberOfFailures = Object.keys(suiteDone.givens).filter(
1025
- (k) => {
1026
- // console.log(`suiteDone.givens[k].error`, suiteDone.givens[k].error);
1027
- return suiteDone.givens[k].error
1028
- }
1029
- ).length;
1030
- console.log(`exiting gracefully with ${numberOfFailures} failures.`);
1031
- return {
1032
- failed: numberOfFailures,
1033
- artifacts,
1034
- logPromise
1035
- };
1036
- },
1037
- };
1038
- });
1039
- }
1040
-
1041
- }
1042
-
1043
- ////////////////////////////////////////////////////////////////////////////////////////////////
1044
-
1045
- export default class TesterantoLevelTwo<TestShape extends ITTestShape,
1046
- IState,
1047
- ISelection,
1048
- IStore,
1049
- ISubject,
1050
- WhenShape,
1051
- ThenShape,
1052
- IInput
1053
- > extends TesterantoLevelOne<
1054
- TestShape,
1055
- IState,
1056
- ISelection,
1057
- IStore,
1058
- ISubject,
1059
- WhenShape,
1060
- ThenShape,
1061
- IInput
1062
- > {
1063
- constructor(
1064
- input: IInput,
1065
- testSpecification: ITestSpecification<
1066
- TestShape,
1067
- ISubject,
1068
- IStore,
1069
- ISelection,
1070
- ThenShape
1071
- >,
1072
- testImplementation,
1073
- testInterface: {
1074
- actionHandler?: (b: (...any) => any) => any;
1075
- andWhen: (
1076
- store: IStore,
1077
- actioner,
1078
- testResource: ITTestResourceConfiguration
1079
- ) => Promise<ISelection>;
1080
- butThen?: (
1081
- store: IStore,
1082
- callback,
1083
- testResource: ITTestResourceConfiguration
1084
- ) => Promise<ISelection>;
1085
- assertioner?: (t: ThenShape) => any;
1086
-
1087
- afterAll?: (store: IStore, artificer: ITestArtificer) => any;
1088
- afterEach?: (
1089
- store: IStore,
1090
- key: string,
1091
- artificer: ITestArtificer
1092
- ) => Promise<unknown>;
1093
-
1094
- beforeAll?: (
1095
- input: IInput,
1096
- artificer: ITestArtificer,
1097
- testResource: ITTestResourceConfiguration
1098
- ) => Promise<ISubject>;
1099
-
1100
- beforeEach?: (
1101
- subject: ISubject,
1102
- initialValues,
1103
- testResource: ITTestResourceConfiguration,
1104
- artificer: ITestArtificer
1105
- ) => Promise<IStore>;
1106
- },
1107
- testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement,
1108
- assertioner: (t: ThenShape) => any,
1109
- beforeEach: (
1110
- subject: ISubject,
1111
- initialValues,
1112
- testResource: ITTestResourceConfiguration,
1113
- artificer: ITestArtificer
1114
- ) => Promise<IStore>,
1115
- afterEach: (
1116
- store: IStore,
1117
- key: string,
1118
- artificer: ITestArtificer
1119
- ) => Promise<unknown>,
1120
- afterAll: (store: IStore, artificer: ITestArtificer) => any,
1121
- butThen: (
1122
- s: IStore,
1123
- bt: (storeState: ISelection) => ThenShape,
1124
- testResource: ITTestResourceConfiguration,
1125
- ) => any,
1126
- andWhen: (
1127
- store: IStore,
1128
- actioner,
1129
- testResource: ITTestResourceConfiguration
1130
- ) => Promise<ISelection>,
1131
- actionHandler: (b: (...any) => any) => any,
1132
- logWriter: ILogWriter
1133
- ) {
1134
- super(
1135
- testImplementation,
1136
- testSpecification,
1137
- input,
1138
-
1139
- class extends BaseSuite<
1140
- IInput,
1141
- ISubject,
1142
- IStore,
1143
- ISelection,
1144
- ThenShape,
1145
- TestShape
1146
- > {
1147
- async setup(s: IInput, artifactory): Promise<ISubject> {
1148
- return (testInterface.beforeAll || (async (
1149
- input: IInput,
1150
- artificer: ITestArtificer,
1151
- ) => input as any))(
1152
- s,
1153
- artifactory,
1154
- this.testResourceConfiguration
1155
- );
1156
- }
1157
- test(t: ThenShape): unknown {
1158
- return assertioner(t);
1159
- }
1160
- } as any,
1161
-
1162
- class Given extends BaseGiven<ISubject, IStore, ISelection, ThenShape> {
1163
- initialValues: any;
1164
- constructor(
1165
- name: string,
1166
- features: string[],
1167
- whens: BaseWhen<IStore, ISelection, ThenShape>[],
1168
- thens: BaseThen<ISelection, IStore, ThenShape>[],
1169
- initialValues: any
1170
- ) {
1171
- super(
1172
- name,
1173
- features,
1174
- whens,
1175
- thens
1176
- );
1177
- this.initialValues = initialValues;
1178
- }
1179
- async givenThat(subject, testResource, artifactory) {
1180
- return beforeEach(
1181
- subject,
1182
- this.initialValues,
1183
- testResource,
1184
- (fPath: string, value: unknown) =>
1185
- // TODO does not work?
1186
- artifactory(`beforeEach/${fPath}`, value)
1187
- );
1188
- }
1189
- afterEach(
1190
- store: IStore,
1191
- key: string,
1192
- artifactory
1193
- ): Promise<unknown> {
1194
- return new Promise((res) =>
1195
- res(afterEach(store, key, (fPath: string, value: unknown) =>
1196
- artifactory(`after/${fPath}`, value)))
1197
- );
1198
- }
1199
- afterAll(store, artifactory) {
1200
- return afterAll(store, (fPath: string, value: unknown) =>
1201
- // TODO does not work?
1202
- artifactory(`afterAll4-${this.name}/${fPath}`, value));
1203
- }
1204
- } as any,
1205
-
1206
- class When extends BaseWhen<IStore, ISelection, WhenShape> {
1207
- payload?: any;
1208
-
1209
- constructor(
1210
- name: string,
1211
- actioner: (...any) => any, payload?: any) {
1212
- super(
1213
- name,
1214
- (store) => {
1215
- return actionHandler(actioner);
1216
- });
1217
- this.payload = payload;
1218
- }
1219
-
1220
- async andWhen(store, actioner, testResource) {
1221
- return await andWhen(store, actioner, testResource);
1222
- }
1223
- } as any,
1224
-
1225
- class Then extends BaseThen<ISelection, IStore, ThenShape> {
1226
- constructor(name: string, callback: (val: ISelection) => ThenShape) {
1227
- super(name, callback);
1228
- }
1229
-
1230
- async butThen(
1231
- store: any,
1232
- testResourceConfiguration?: any
1233
- ): Promise<ISelection> {
1234
- return await butThen(store, this.thenCB, testResourceConfiguration);
1235
- }
1236
- } as any,
1237
-
1238
- class Check extends BaseCheck<
1239
- ISubject,
1240
- IStore,
1241
- ISelection,
1242
- ThenShape,
1243
- TestShape
1244
- > {
1245
- initialValues: any;
1246
-
1247
- constructor(
1248
- name: string,
1249
- features: string[],
1250
- checkCallback: (a, b) => any,
1251
- whens,
1252
- thens,
1253
- initialValues: any
1254
- ) {
1255
- super(name, features, checkCallback, whens, thens);
1256
- this.initialValues = initialValues;
1257
- }
1258
-
1259
- async checkThat(subject, testResourceConfiguration, artifactory) {
1260
- return beforeEach(
1261
- subject,
1262
- this.initialValues,
1263
- testResourceConfiguration,
1264
- (fPath: string, value: unknown) => artifactory(`before/${fPath}`, value)
1265
- );
1266
- }
1267
-
1268
- afterEach(
1269
- store: IStore,
1270
- key: string,
1271
- artifactory
1272
- ): Promise<unknown> {
1273
- return new Promise((res) =>
1274
- res(afterEach(store, key, (fPath: string, value: unknown) =>
1275
- // TODO does not work?
1276
- artifactory(`afterEach2-${this.name}/${fPath}`, value)))
1277
- );
1278
- }
1279
- } as any,
1280
-
1281
- testResourceRequirement,
1282
- logWriter
1283
- );
1284
- }
1285
- }
1286
-
1287
- ////////////////////////////////////////////////////////////////////////////////////////////////
1288
-
1289
- export type ITestSpecification<
1290
- ITestShape extends ITTestShape,
1291
- ISubject,
1292
- IStore,
1293
- ISelection,
1294
- IThenShape
1295
- > = (
1296
- Suite: {
1297
- [K in keyof ITestShape["suites"]]: (
1298
- name: string,
1299
- givens: IGivens<
1300
- ISubject,
1301
- IStore,
1302
- ISelection,
1303
- IThenShape
1304
- >,
1305
- checks: BaseCheck<
1306
- ISubject,
1307
- IStore,
1308
- ISelection,
1309
- IThenShape,
1310
- ITestShape
1311
- >[]
1312
- ) => BaseSuite<
1313
- unknown,
1314
- ISubject,
1315
- IStore,
1316
- ISelection,
1317
- IThenShape,
1318
- ITestShape
1319
- >;
1320
- },
1321
- Given: {
1322
- [K in keyof ITestShape["givens"]]: (
1323
- features: string[],
1324
- whens: BaseWhen<
1325
- IStore,
1326
- ISelection,
1327
- IThenShape
1328
- >[],
1329
- thens: BaseThen<
1330
- ISelection,
1331
- IStore,
1332
- IThenShape
1333
- >[],
1334
- ...xtrasB: ITestShape["givens"][K]
1335
- ) => BaseGiven<
1336
- ISubject,
1337
- IStore,
1338
- ISelection,
1339
- IThenShape
1340
- >;
1341
- },
1342
- When: {
1343
- [K in keyof ITestShape["whens"]]: (
1344
- ...xtrasC: ITestShape["whens"][K]
1345
- ) => BaseWhen<
1346
- IStore,
1347
- ISelection,
1348
- IThenShape
1349
- >;
1350
- },
1351
- Then: {
1352
- [K in keyof ITestShape["thens"]]: (
1353
- ...xtrasD: ITestShape["thens"][K]
1354
- ) => BaseThen<
1355
- ISelection,
1356
- IStore,
1357
- IThenShape>;
1358
- },
1359
- Check: ITestCheckCallback<ITestShape>
1360
- ) => any[];
1361
-
1362
- ////////////////////////////////////////////////////////////////////////////////////////////////
1363
-
1364
- export type ITestImplementation<
1365
- IState,
1366
- ISelection,
1367
- IWhenShape,
1368
- IThenShape,
1369
- ITestShape extends ITTestShape
1370
- > = {
1371
- Suites: {
1372
- [K in keyof ITestShape["suites"]]: string;
1373
- };
1374
- Givens: {
1375
- [K in keyof ITestShape["givens"]]: (
1376
- ...Ig: ITestShape["givens"][K]
1377
- ) => IState;
1378
- };
1379
- Whens: {
1380
- [K in keyof ITestShape["whens"]]: (
1381
- ...Iw: ITestShape["whens"][K]
1382
- ) =>
1383
- (zel: ISelection) =>
1384
- IWhenShape;
1385
- };
1386
- Thens: {
1387
- [K in keyof ITestShape["thens"]]: (
1388
- ...It: ITestShape["thens"][K]
1389
- ) => (ssel: ISelection) => IThenShape;
1390
- };
1391
- Checks: {
1392
- [K in keyof ITestShape["checks"]]: (
1393
- ...Ic: ITestShape["checks"][K]
1394
- ) => IState;
1395
- };
1396
- };