testeranto 0.74.0 → 0.79.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 (257) hide show
  1. package/.eslintrc.js +5 -2
  2. package/Bundle.Dockerfile +52 -0
  3. package/README.md +25 -24
  4. package/build-tests.ts +16 -0
  5. package/dist/common/build-tests.js +38 -0
  6. package/dist/common/init-docs.js +8 -0
  7. package/dist/common/run-tests.js +34 -0
  8. package/dist/common/src/Aider.js +96 -0
  9. package/dist/common/src/Init.js +10 -0
  10. package/dist/common/{Node.js → src/Node.js} +1 -0
  11. package/dist/common/src/PM/index.js +7 -0
  12. package/dist/common/{PM → src/PM}/main.js +287 -10
  13. package/dist/common/{PM → src/PM}/node.js +4 -0
  14. package/dist/common/{PM → src/PM}/web.js +3 -0
  15. package/dist/common/{Project.js → src/Project.js} +15 -57
  16. package/dist/common/{Puppeteer.js → src/Puppeteer.js} +65 -26
  17. package/dist/common/{SubPackages → src/SubPackages}/react-dom/component/web.js +5 -25
  18. package/dist/common/src/SubPackages/react-dom/jsx/web.js +117 -0
  19. package/dist/common/{SubPackages/react-test-renderer/component/index.js → src/SubPackages/react-test-renderer/component/interface.js} +0 -20
  20. package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/component/node.js +2 -2
  21. package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/component/web.js +2 -2
  22. package/dist/common/{Types.js → src/Types.js} +0 -2
  23. package/dist/common/{esbuildConfigs → src/esbuildConfigs}/index.js +1 -0
  24. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +52 -0
  25. package/dist/common/{esbuildConfigs → src/esbuildConfigs}/node.js +5 -1
  26. package/dist/common/src/esbuildConfigs/report.js +14 -0
  27. package/dist/common/{esbuildConfigs → src/esbuildConfigs}/web.js +3 -1
  28. package/dist/common/src/lib/abstractBase.js +581 -0
  29. package/dist/common/{lib → src/lib}/basebuilder.js +12 -38
  30. package/dist/common/{lib → src/lib}/classBuilder.js +1 -3
  31. package/dist/common/{lib → src/lib}/core.js +3 -5
  32. package/dist/common/src/lib/types.js +2 -0
  33. package/dist/common/src/utils.js +16 -0
  34. package/dist/common/testeranto.js +15 -0
  35. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  36. package/dist/module/build-tests.js +10 -0
  37. package/dist/module/init-docs.js +3 -0
  38. package/dist/module/run-tests.js +6 -0
  39. package/dist/module/src/Aider.js +89 -0
  40. package/dist/module/src/Init.js +5 -0
  41. package/dist/module/{Node.js → src/Node.js} +1 -0
  42. package/dist/module/src/PM/index.js +3 -0
  43. package/dist/module/src/PM/main.js +617 -0
  44. package/dist/module/{PM → src/PM}/node.js +4 -0
  45. package/dist/module/{PM → src/PM}/web.js +3 -0
  46. package/dist/module/{Project.js → src/Project.js} +15 -57
  47. package/dist/module/{Puppeteer.js → src/Puppeteer.js} +65 -26
  48. package/dist/module/{SubPackages → src/SubPackages}/react-dom/component/web.js +5 -25
  49. package/dist/module/src/SubPackages/react-dom/jsx/web.js +89 -0
  50. package/dist/module/{SubPackages/react-test-renderer/component/index.js → src/SubPackages/react-test-renderer/component/interface.js} +0 -20
  51. package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/component/node.js +1 -1
  52. package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/component/web.js +1 -1
  53. package/dist/module/{esbuildConfigs → src/esbuildConfigs}/index.js +1 -0
  54. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +47 -0
  55. package/dist/module/{esbuildConfigs → src/esbuildConfigs}/node.js +5 -1
  56. package/dist/module/src/esbuildConfigs/report.js +14 -0
  57. package/dist/module/{esbuildConfigs → src/esbuildConfigs}/web.js +3 -1
  58. package/dist/module/src/lib/abstractBase.js +573 -0
  59. package/dist/module/{lib → src/lib}/basebuilder.js +12 -38
  60. package/dist/module/{lib → src/lib}/classBuilder.js +1 -3
  61. package/dist/module/{lib → src/lib}/core.js +3 -5
  62. package/dist/module/src/utils.js +9 -0
  63. package/dist/module/testeranto.js +13 -0
  64. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  65. package/dist/types/build-tests.d.ts +3 -0
  66. package/dist/types/init-docs.d.ts +2 -0
  67. package/dist/types/run-tests.d.ts +2 -0
  68. package/dist/types/src/Aider.d.ts +1 -0
  69. package/dist/types/src/Init.d.ts +2 -0
  70. package/dist/types/src/Node.d.ts +6 -0
  71. package/dist/types/{PM → src/PM}/index.d.ts +3 -2
  72. package/dist/types/{PM → src/PM}/main.d.ts +8 -3
  73. package/dist/types/{PM → src/PM}/node.d.ts +2 -0
  74. package/dist/types/{PM → src/PM}/web.d.ts +1 -0
  75. package/dist/types/{Project.d.ts → src/Project.d.ts} +1 -1
  76. package/dist/types/src/Puppeteer.d.ts +2 -0
  77. package/dist/types/src/SubPackages/puppeteer.d.ts +6 -0
  78. package/dist/types/{SubPackages → src/SubPackages}/react/component/node.d.ts +1 -1
  79. package/dist/types/{SubPackages → src/SubPackages}/react/component/web.d.ts +1 -1
  80. package/dist/types/src/SubPackages/react/jsx/node.d.ts +4 -0
  81. package/dist/types/src/SubPackages/react/jsx/web.d.ts +4 -0
  82. package/dist/types/{SubPackages → src/SubPackages}/react-dom/component/node.d.ts +2 -2
  83. package/dist/types/src/SubPackages/react-dom/component/web.d.ts +11 -0
  84. package/dist/types/src/SubPackages/react-dom/jsx/node.d.ts +6 -0
  85. package/dist/types/src/SubPackages/react-dom/jsx/web.d.ts +5 -0
  86. package/dist/types/src/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +5 -0
  87. package/dist/types/{SubPackages → src/SubPackages}/react-test-renderer/component/index.d.ts +0 -7
  88. package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +9 -0
  89. package/dist/types/{SubPackages → src/SubPackages}/react-test-renderer/component/node.d.ts +1 -2
  90. package/dist/types/src/SubPackages/react-test-renderer/component/web.d.ts +3 -0
  91. package/dist/types/{SubPackages → src/SubPackages}/react-test-renderer/fc/node.d.ts +1 -1
  92. package/dist/types/{SubPackages → src/SubPackages}/react-test-renderer/fc/web.d.ts +1 -1
  93. package/dist/types/{SubPackages → src/SubPackages}/react-test-renderer/jsx/node.d.ts +1 -2
  94. package/dist/types/{SubPackages → src/SubPackages}/react-test-renderer/jsx/web.d.ts +1 -2
  95. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/node.d.ts +4 -0
  96. package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/web.d.ts +4 -0
  97. package/dist/types/src/Types.d.ts +51 -0
  98. package/dist/types/src/Web.d.ts +6 -0
  99. package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +5 -0
  100. package/dist/types/{lib → src/lib}/abstractBase.d.ts +8 -8
  101. package/dist/types/{lib → src/lib}/basebuilder.d.ts +1 -1
  102. package/dist/types/{lib → src/lib}/classBuilder.d.ts +1 -1
  103. package/dist/types/{lib → src/lib}/core.d.ts +1 -1
  104. package/dist/types/{lib → src/lib}/index.d.ts +5 -5
  105. package/dist/types/{lib → src/lib}/types.d.ts +15 -15
  106. package/dist/types/src/utils.d.ts +2 -0
  107. package/dist/types/testeranto.d.ts +16 -0
  108. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  109. package/docker-compose.yml +37 -0
  110. package/init-docs.ts +5 -0
  111. package/package.json +72 -25
  112. package/run-tests.ts +9 -0
  113. package/src/Aider.ts +125 -0
  114. package/src/Init.ts +20 -0
  115. package/src/Node.ts +31 -2
  116. package/src/PM/index.ts +7 -84
  117. package/src/PM/main.ts +400 -16
  118. package/src/PM/node.ts +6 -0
  119. package/src/PM/web.ts +4 -0
  120. package/src/Project.ts +33 -84
  121. package/src/Puppeteer.ts +115 -62
  122. package/src/SubPackages/react-dom/component/web.ts +10 -30
  123. package/src/SubPackages/react-dom/jsx/web.ts +110 -76
  124. package/src/SubPackages/react-test-renderer/component/index.ts +0 -66
  125. package/src/SubPackages/react-test-renderer/component/interface.ts +48 -0
  126. package/src/SubPackages/react-test-renderer/component/node.ts +2 -1
  127. package/src/SubPackages/react-test-renderer/component/web.ts +2 -1
  128. package/src/Types.ts +138 -29
  129. package/src/Web.ts +32 -2
  130. package/src/esbuildConfigs/index.ts +1 -0
  131. package/src/esbuildConfigs/inputFilesPlugin.ts +67 -0
  132. package/src/esbuildConfigs/node.ts +4 -2
  133. package/src/esbuildConfigs/report.ts +13 -13
  134. package/src/esbuildConfigs/web.ts +4 -0
  135. package/src/lib/abstractBase.ts +366 -36
  136. package/src/lib/basebuilder.ts +26 -52
  137. package/src/lib/classBuilder.ts +14 -2
  138. package/src/lib/core.ts +18 -7
  139. package/src/lib/index.ts +115 -7
  140. package/src/lib/types.ts +143 -37
  141. package/src/utils.ts +15 -0
  142. package/testeranto.ts +13 -0
  143. package/tsconfig.common.json +12 -4
  144. package/tsconfig.json +9 -3
  145. package/tsconfig.module.json +2 -3
  146. package/tsconfig.types.json +1 -2
  147. package/dist/common/Features.js +0 -84
  148. package/dist/common/PM/index.js +0 -71
  149. package/dist/common/Reporter.js +0 -119
  150. package/dist/common/Scheduler.js +0 -1
  151. package/dist/common/SubPackages/react-dom/jsx/web.js +0 -93
  152. package/dist/common/esbuildConfigs/report.js +0 -13
  153. package/dist/common/lib/abstractBase.js +0 -348
  154. package/dist/common/preload.js +0 -15
  155. package/dist/common/report.html.js +0 -31
  156. package/dist/module/Features.js +0 -73
  157. package/dist/module/PM/index.js +0 -67
  158. package/dist/module/PM/main.js +0 -340
  159. package/dist/module/Reporter.js +0 -114
  160. package/dist/module/Scheduler.js +0 -1
  161. package/dist/module/SubPackages/react-dom/jsx/web.js +0 -65
  162. package/dist/module/Types.js +0 -3
  163. package/dist/module/esbuildConfigs/report.js +0 -11
  164. package/dist/module/lib/abstractBase.js +0 -340
  165. package/dist/module/preload.js +0 -15
  166. package/dist/module/report.html.js +0 -29
  167. package/dist/prebuild/Report.css +0 -11358
  168. package/dist/prebuild/Report.js +0 -37585
  169. package/dist/types/Features.d.ts +0 -68
  170. package/dist/types/Node.d.ts +0 -6
  171. package/dist/types/SubPackages/puppeteer.d.ts +0 -6
  172. package/dist/types/SubPackages/react/jsx/node.d.ts +0 -4
  173. package/dist/types/SubPackages/react/jsx/web.d.ts +0 -4
  174. package/dist/types/SubPackages/react-dom/component/web.d.ts +0 -5
  175. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +0 -6
  176. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +0 -5
  177. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -5
  178. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +0 -4
  179. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +0 -5
  180. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +0 -5
  181. package/dist/types/Types.d.ts +0 -50
  182. package/dist/types/Web.d.ts +0 -6
  183. package/dist/types/esbuildConfigs/report.d.ts +0 -4
  184. package/dist/types/preload.d.ts +0 -0
  185. package/dist/types/report.html.d.ts +0 -2
  186. package/electronBuild.ts +0 -32
  187. package/src/Features.ts +0 -118
  188. package/src/Report.tsx +0 -521
  189. package/src/Reporter.ts +0 -134
  190. package/src/Scheduler.ts +0 -0
  191. package/src/preload.ts +0 -17
  192. package/src/report.html.ts +0 -29
  193. package/tests/Rectangle.test.ts +0 -189
  194. /package/dist/common/{SubPackages → src/SubPackages}/puppeteer.js +0 -0
  195. /package/dist/common/{SubPackages → src/SubPackages}/react/component/node.js +0 -0
  196. /package/dist/common/{SubPackages → src/SubPackages}/react/component/web.js +0 -0
  197. /package/dist/common/{SubPackages → src/SubPackages}/react/jsx/index.js +0 -0
  198. /package/dist/common/{SubPackages → src/SubPackages}/react/jsx/node.js +0 -0
  199. /package/dist/common/{SubPackages → src/SubPackages}/react/jsx/web.js +0 -0
  200. /package/dist/common/{SubPackages → src/SubPackages}/react-dom/component/node.js +0 -0
  201. /package/dist/common/{SubPackages → src/SubPackages}/react-dom/jsx/index.js +0 -0
  202. /package/dist/common/{SubPackages → src/SubPackages}/react-dom/jsx/node.js +0 -0
  203. /package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/MemoExoticComponent/node.js +0 -0
  204. /package/dist/common/{lib/types.js → src/SubPackages/react-test-renderer/component/index.js} +0 -0
  205. /package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/fc/node.js +0 -0
  206. /package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/fc/web.js +0 -0
  207. /package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/jsx/index.js +0 -0
  208. /package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/jsx/node.js +0 -0
  209. /package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/jsx/web.js +0 -0
  210. /package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/jsx-promised/index.js +0 -0
  211. /package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/jsx-promised/node.js +0 -0
  212. /package/dist/common/{SubPackages → src/SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
  213. /package/dist/common/{Web.js → src/Web.js} +0 -0
  214. /package/dist/common/{esbuildConfigs → src/esbuildConfigs}/features.js +0 -0
  215. /package/dist/common/{esbuildConfigs → src/esbuildConfigs}/tests.js +0 -0
  216. /package/dist/common/{lib → src/lib}/index.js +0 -0
  217. /package/dist/common/{puppeteerConfiger.js → src/puppeteerConfiger.js} +0 -0
  218. /package/dist/common/{web.html.js → src/web.html.js} +0 -0
  219. /package/dist/module/{SubPackages → src/SubPackages}/puppeteer.js +0 -0
  220. /package/dist/module/{SubPackages → src/SubPackages}/react/component/node.js +0 -0
  221. /package/dist/module/{SubPackages → src/SubPackages}/react/component/web.js +0 -0
  222. /package/dist/module/{SubPackages → src/SubPackages}/react/jsx/index.js +0 -0
  223. /package/dist/module/{SubPackages → src/SubPackages}/react/jsx/node.js +0 -0
  224. /package/dist/module/{SubPackages → src/SubPackages}/react/jsx/web.js +0 -0
  225. /package/dist/module/{SubPackages → src/SubPackages}/react-dom/component/node.js +0 -0
  226. /package/dist/module/{SubPackages → src/SubPackages}/react-dom/jsx/index.js +0 -0
  227. /package/dist/module/{SubPackages → src/SubPackages}/react-dom/jsx/node.js +0 -0
  228. /package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/MemoExoticComponent/node.js +0 -0
  229. /package/dist/module/{lib/types.js → src/SubPackages/react-test-renderer/component/index.js} +0 -0
  230. /package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/fc/node.js +0 -0
  231. /package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/fc/web.js +0 -0
  232. /package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/jsx/index.js +0 -0
  233. /package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/jsx/node.js +0 -0
  234. /package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/jsx/web.js +0 -0
  235. /package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/jsx-promised/index.js +0 -0
  236. /package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/jsx-promised/node.js +0 -0
  237. /package/dist/module/{SubPackages → src/SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
  238. /package/dist/{types/Puppeteer.d.ts → module/src/Types.js} +0 -0
  239. /package/dist/module/{Web.js → src/Web.js} +0 -0
  240. /package/dist/module/{esbuildConfigs → src/esbuildConfigs}/features.js +0 -0
  241. /package/dist/module/{esbuildConfigs → src/esbuildConfigs}/tests.js +0 -0
  242. /package/dist/module/{lib → src/lib}/index.js +0 -0
  243. /package/dist/{types/Reporter.d.ts → module/src/lib/types.js} +0 -0
  244. /package/dist/module/{puppeteerConfiger.js → src/puppeteerConfiger.js} +0 -0
  245. /package/dist/module/{web.html.js → src/web.html.js} +0 -0
  246. /package/dist/types/{SubPackages → src/SubPackages}/react/jsx/index.d.ts +0 -0
  247. /package/dist/types/{SubPackages → src/SubPackages}/react-dom/jsx/index.d.ts +0 -0
  248. /package/dist/types/{SubPackages → src/SubPackages}/react-test-renderer/jsx/index.d.ts +0 -0
  249. /package/dist/types/{SubPackages → src/SubPackages}/react-test-renderer/jsx-promised/index.d.ts +0 -0
  250. /package/dist/types/{esbuildConfigs → src/esbuildConfigs}/features.d.ts +0 -0
  251. /package/dist/types/{esbuildConfigs → src/esbuildConfigs}/index.d.ts +0 -0
  252. /package/dist/types/{esbuildConfigs → src/esbuildConfigs}/node.d.ts +0 -0
  253. /package/dist/types/{Scheduler.d.ts → src/esbuildConfigs/report.d.ts} +0 -0
  254. /package/dist/types/{esbuildConfigs → src/esbuildConfigs}/tests.d.ts +0 -0
  255. /package/dist/types/{esbuildConfigs → src/esbuildConfigs}/web.d.ts +0 -0
  256. /package/dist/types/{puppeteerConfiger.d.ts → src/puppeteerConfiger.d.ts} +0 -0
  257. /package/dist/types/{web.html.d.ts → src/web.html.d.ts} +0 -0
@@ -0,0 +1,573 @@
1
+ export class BaseSuite {
2
+ constructor(name, index, givens = {}, checks = []) {
3
+ this.name = name;
4
+ this.index = index;
5
+ this.givens = givens;
6
+ this.checks = checks;
7
+ this.fails = [];
8
+ }
9
+ toObj() {
10
+ return {
11
+ name: this.name,
12
+ givens: Object.keys(this.givens).map((k) => this.givens[k].toObj()),
13
+ fails: this.fails,
14
+ };
15
+ }
16
+ setup(s, artifactory, tr, pm) {
17
+ return new Promise((res) => res(s));
18
+ }
19
+ assertThat(t) {
20
+ return t;
21
+ }
22
+ afterAll(store, artifactory, pm) {
23
+ return store;
24
+ }
25
+ async run(input, testResourceConfiguration, artifactory, tLog, pm) {
26
+ this.testResourceConfiguration = testResourceConfiguration;
27
+ tLog("test resources: ", JSON.stringify(testResourceConfiguration));
28
+ const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
29
+ console.log("\nSuite:", this.index, this.name);
30
+ tLog("\nSuite:", this.index, this.name);
31
+ const sNdx = this.index;
32
+ const sName = this.name;
33
+ for (const [gNdx, g] of Object.entries(this.givens)) {
34
+ const beforeAllProxy = new Proxy(pm, {
35
+ get(target, prop, receiver) {
36
+ if (prop === "writeFileSync") {
37
+ return (fp, contents) => target[prop](`suite-${sNdx}/beforeAll/${fp}`, contents);
38
+ }
39
+ if (prop === "browser") {
40
+ return new Proxy(target[prop], {
41
+ get(bTarget, bProp, bReceiver) {
42
+ if (bProp === "pages") {
43
+ return async () => {
44
+ return bTarget.pages().then((pages) => {
45
+ return pages.map((page) => {
46
+ return new Proxy(page, {
47
+ get(pTarget, pProp, pReciever) {
48
+ if (pProp === "screenshot") {
49
+ return async (x) => {
50
+ return pm.customScreenShot(Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${sNdx}/beforeAll` +
51
+ "/" +
52
+ x.path }), page);
53
+ // return await window["custom-screenshot"]({
54
+ // ...x,
55
+ // path:
56
+ // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
57
+ // "/" +
58
+ // x.path,
59
+ // });
60
+ };
61
+ }
62
+ else if (pProp === "mainFrame") {
63
+ return () => pTarget[pProp]();
64
+ }
65
+ else if (pProp === "close") {
66
+ return () => pTarget[pProp]();
67
+ }
68
+ // else if (pProp === "mainFrame") {
69
+ // return () => target[pProp](...arguments);
70
+ // }
71
+ else {
72
+ return Reflect.get(...arguments);
73
+ }
74
+ },
75
+ });
76
+ });
77
+ });
78
+ // return (await target.pages()).map((page) => {
79
+ // return new Proxy(page, handler2);
80
+ // });
81
+ };
82
+ }
83
+ },
84
+ });
85
+ }
86
+ return Reflect.get(...arguments);
87
+ },
88
+ });
89
+ const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, beforeAllProxy);
90
+ const giver = this.givens[gNdx];
91
+ try {
92
+ this.store = await giver.give(subject, gNdx, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
93
+ }
94
+ catch (e) {
95
+ console.error(e);
96
+ this.fails.push(giver);
97
+ // return this;
98
+ }
99
+ }
100
+ const afterAllProxy = new Proxy(pm, {
101
+ get(target, prop, receiver) {
102
+ if (prop === "writeFileSync") {
103
+ return (fp, contents) => target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
104
+ }
105
+ if (prop === "browser") {
106
+ return new Proxy(target[prop], {
107
+ get(bTarget, bProp, bReceiver) {
108
+ if (bProp === "pages") {
109
+ return async () => {
110
+ return bTarget.pages().then((pages) => {
111
+ return pages.map((page) => {
112
+ return new Proxy(page, {
113
+ get(pTarget, pProp, pReciever) {
114
+ if (pProp === "screenshot") {
115
+ return async (x) => {
116
+ return pm.customScreenShot(Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
117
+ "/" +
118
+ x.path }));
119
+ // return await window["custom-screenshot"]({
120
+ // ...x,
121
+ // path:
122
+ // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
123
+ // "/" +
124
+ // x.path,
125
+ // });
126
+ };
127
+ }
128
+ else if (pProp === "mainFrame") {
129
+ return () => pTarget[pProp]();
130
+ }
131
+ else if (pProp === "close") {
132
+ return () => pTarget[pProp]();
133
+ }
134
+ // else if (pProp === "mainFrame") {
135
+ // return () => target[pProp](...arguments);
136
+ // }
137
+ else {
138
+ return Reflect.get(...arguments);
139
+ }
140
+ },
141
+ });
142
+ });
143
+ });
144
+ // return (await target.pages()).map((page) => {
145
+ // return new Proxy(page, handler2);
146
+ // });
147
+ };
148
+ }
149
+ },
150
+ });
151
+ }
152
+ return Reflect.get(...arguments);
153
+ },
154
+ });
155
+ // pm.browser
156
+ try {
157
+ this.afterAll(this.store, artifactory, afterAllProxy);
158
+ }
159
+ catch (e) {
160
+ console.error(e);
161
+ // this.fails.push(this);
162
+ // return this;
163
+ }
164
+ // for (const [ndx, thater] of this.checks.entries()) {
165
+ // await thater.check(
166
+ // subject,
167
+ // thater.name,
168
+ // testResourceConfiguration,
169
+ // this.assertThat,
170
+ // suiteArtifactory,
171
+ // tLog,
172
+ // pm
173
+ // );
174
+ // }
175
+ // @TODO fix me
176
+ // for (const k of Object.keys(this.givens)) {
177
+ // const giver = this.givens[k];
178
+ // try {
179
+ // giver.afterAll(this.store, artifactory, pm);
180
+ // } catch (e) {
181
+ // console.error(e);
182
+ // this.fails.push(giver);
183
+ // return this;
184
+ // }
185
+ // }
186
+ ////////////////
187
+ return this;
188
+ }
189
+ }
190
+ export class BaseGiven {
191
+ constructor(name, features, whens, thens, givenCB, initialValues) {
192
+ this.name = name;
193
+ this.features = features;
194
+ this.whens = whens;
195
+ this.thens = thens;
196
+ this.givenCB = givenCB;
197
+ this.initialValues = initialValues;
198
+ }
199
+ beforeAll(store, artifactory) {
200
+ return store;
201
+ }
202
+ toObj() {
203
+ return {
204
+ name: this.name,
205
+ whens: this.whens.map((w) => w.toObj()),
206
+ thens: this.thens.map((t) => t.toObj()),
207
+ error: this.error ? [this.error, this.error.stack] : null,
208
+ // fail: this.fail ? [this.fail] : false,
209
+ features: this.features,
210
+ };
211
+ }
212
+ async afterEach(store, key, artifactory, pm) {
213
+ return store;
214
+ }
215
+ async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
216
+ tLog(`\n Given: ${this.name}`);
217
+ const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
218
+ try {
219
+ // tLog(`\n Given this.store`, this.store);
220
+ const beforeEachProxy = new Proxy(pm, {
221
+ get(target, prop, receiver) {
222
+ if (prop === "writeFileSync") {
223
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
224
+ }
225
+ return Reflect.get(...arguments);
226
+ },
227
+ });
228
+ this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, beforeEachProxy);
229
+ console.log("mark6", this.store);
230
+ for (const [whenNdx, whenStep] of this.whens.entries()) {
231
+ await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
232
+ }
233
+ for (const [thenNdx, thenStep] of this.thens.entries()) {
234
+ const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/then-${thenNdx}`);
235
+ tester(t);
236
+ }
237
+ }
238
+ catch (e) {
239
+ console.error(e);
240
+ this.error = e;
241
+ tLog(e.stack);
242
+ // tLog("\u0007"); // bell
243
+ // throw e;
244
+ }
245
+ finally {
246
+ try {
247
+ // const afterEachProxy = new Proxy(pm, {
248
+ // get(target, prop, receiver) {
249
+ // if (prop === "writeFileSync") {
250
+ // console.log("afterEachProxy", arguments, target[prop]);
251
+ // return (fp, contents) =>
252
+ // // target[prop](`${key}/andWhen/${fp}`, contents);
253
+ // target[prop](`${key}/afterEach/${fp}`, contents);
254
+ // }
255
+ // return Reflect.get(...arguments);
256
+ // },
257
+ // });
258
+ // await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
259
+ // await this.afterEach(this.store, key, givenArtifactory, pm);
260
+ const afterEachProxy = new Proxy(pm, {
261
+ get(target, prop, receiver) {
262
+ if (prop === "writeFileSync") {
263
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterAll/${fp}`, contents);
264
+ }
265
+ if (prop === "browser") {
266
+ return new Proxy(target[prop], {
267
+ get(bTarget, bProp, bReceiver) {
268
+ if (bProp === "pages") {
269
+ return async () => {
270
+ return bTarget.pages().then((pages) => {
271
+ return pages.map((page) => {
272
+ return new Proxy(page, {
273
+ get(pTarget, pProp, pReciever) {
274
+ if (pProp === "screenshot") {
275
+ return async (x) => {
276
+ // console.log(
277
+ // "custom-screenshot-MARK-afterEachProxy",
278
+ // window["custom-screenshot"].toString()
279
+ // );
280
+ return pm.customScreenShot(Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
281
+ "/" +
282
+ x.path }), page);
283
+ // return await pTarget[pProp]({
284
+ // ...x,
285
+ // path:
286
+ // `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
287
+ // "/" +
288
+ // x.path,
289
+ // });
290
+ };
291
+ }
292
+ else if (pProp === "mainFrame") {
293
+ return () => pTarget[pProp]();
294
+ // return target[pProp];
295
+ // return Reflect.get(...arguments);
296
+ }
297
+ else if (pProp === "exposeFunction") {
298
+ // return Reflect.get(target, prop, receiver);
299
+ return (...a) => pTarget[pProp](...a);
300
+ // return target[pProp];
301
+ }
302
+ else if (pProp === "removeExposedFunction") {
303
+ // return Reflect.get(target, prop, receiver);
304
+ return pTarget[pProp].bind(pTarget);
305
+ // return target[pProp];
306
+ }
307
+ // else if (pProp === "#frameManager") {
308
+ // return () => target[pProp](...arguments);
309
+ // }
310
+ else {
311
+ return Reflect.get(...arguments);
312
+ }
313
+ },
314
+ });
315
+ });
316
+ });
317
+ // return (await target.pages()).map((page) => {
318
+ // return new Proxy(page, handler2);
319
+ // });
320
+ };
321
+ }
322
+ },
323
+ });
324
+ }
325
+ return Reflect.get(...arguments);
326
+ },
327
+ });
328
+ console.log("mark5", this.store, key);
329
+ await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
330
+ }
331
+ catch (e) {
332
+ console.error("afterEach failed! no error will be recorded!", e);
333
+ }
334
+ }
335
+ return this.store;
336
+ }
337
+ }
338
+ export class BaseWhen {
339
+ constructor(name, whenCB) {
340
+ this.name = name;
341
+ this.whenCB = whenCB;
342
+ }
343
+ toObj() {
344
+ return {
345
+ name: this.name,
346
+ error: this.error,
347
+ };
348
+ }
349
+ async test(store, testResourceConfiguration, tLog, pm, key) {
350
+ tLog(" When:", this.name);
351
+ const name = this.name;
352
+ const andWhenProxy = new Proxy(pm, {
353
+ // set(obj, prop, value) {
354
+ // return Reflect.set(...arguments);
355
+ // // if (prop === "eyeCount" && value % 2 !== 0) {
356
+ // // console.log("Monsters must have an even number of eyes");
357
+ // // } else {
358
+ // // return Reflect.set(...arguments);
359
+ // // }
360
+ // },
361
+ get(target, prop, receiver) {
362
+ if (prop === "writeFileSync") {
363
+ return (fp, contents) =>
364
+ // target[prop](`${key}/andWhen/${fp}`, contents);
365
+ target[prop](`${key}/andWhen/${fp}`, contents);
366
+ }
367
+ /////////////////////
368
+ if (prop === "browser") {
369
+ return new Proxy(target[prop], {
370
+ get(bTarget, bProp, bReceiver) {
371
+ if (bProp === "pages") {
372
+ return async () => {
373
+ return bTarget.pages().then((pages) => {
374
+ return pages.map((page) => {
375
+ return new Proxy(page, {
376
+ get(pTarget, pProp, pReciever) {
377
+ // console.log("mark get", pTarget, pProp, pReciever);
378
+ if (pProp === "screenshot") {
379
+ return async (x) => {
380
+ return pm.customScreenShot(Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/${key}/afterEach` +
381
+ "/" +
382
+ x.path }), page);
383
+ };
384
+ }
385
+ else if (pProp === "mainFrame") {
386
+ return () => pTarget[pProp]();
387
+ // return target[pProp];
388
+ // return Reflect.get(...arguments);
389
+ }
390
+ else if (pProp === "exposeFunction") {
391
+ // return Reflect.get(target, prop, receiver);
392
+ return pTarget[pProp].bind(pTarget);
393
+ // return target[pProp];
394
+ }
395
+ else if (pProp === "removeExposedFunction") {
396
+ // return Reflect.get(target, prop, receiver);
397
+ return pTarget[pProp].bind(pTarget);
398
+ // return target[pProp];
399
+ }
400
+ else if (pProp === "click") {
401
+ // console.log("mark12", arguments);
402
+ // return Reflect.get(target, prop, receiver);
403
+ // return pTarget[pProp].bind(pTarget);
404
+ // return target[pProp];
405
+ return (selector, options) => {
406
+ // console.log("mark13", selector, options);
407
+ // debugger;
408
+ pTarget[pProp](selector, options);
409
+ };
410
+ }
411
+ else if (pProp === "$") {
412
+ return Reflect.get(...arguments);
413
+ // return Reflect.get(target, prop, receiver);
414
+ // return pTarget[pProp].bind(pTarget);
415
+ // return target[pProp];
416
+ // return pTarget[pProp].bind(pTarget);
417
+ // return async (s) => {
418
+ // console.log("mark17", s);
419
+ // console.log("pTarget", pTarget);
420
+ // console.log("pProp", pProp);
421
+ // console.log("pReciever", pReciever);
422
+ // // return "XXX";
423
+ // // debugger;
424
+ // return await pTarget[pProp](s);
425
+ // };
426
+ }
427
+ else {
428
+ return Reflect.get(...arguments);
429
+ }
430
+ },
431
+ });
432
+ });
433
+ });
434
+ // return (await target.pages()).map((page) => {
435
+ // return new Proxy(page, handler2);
436
+ // });
437
+ };
438
+ }
439
+ },
440
+ });
441
+ }
442
+ ///////////////////////
443
+ return Reflect.get(...arguments);
444
+ },
445
+ });
446
+ try {
447
+ return await this.andWhen(store, this.whenCB, testResourceConfiguration, andWhenProxy);
448
+ }
449
+ catch (e) {
450
+ this.error = true;
451
+ throw e;
452
+ }
453
+ }
454
+ }
455
+ export class BaseThen {
456
+ constructor(name, thenCB) {
457
+ this.name = name;
458
+ this.thenCB = thenCB;
459
+ this.error = false;
460
+ }
461
+ toObj() {
462
+ return {
463
+ name: this.name,
464
+ error: this.error,
465
+ };
466
+ }
467
+ async test(store, testResourceConfiguration, tLog, pm, filepath) {
468
+ tLog(" Then:", this.name);
469
+ try {
470
+ const butThenProxy = new Proxy(pm, {
471
+ get(target, prop, receiver) {
472
+ if (prop === "writeFileSync") {
473
+ return (fp, contents) => target[prop](`${filepath}/${fp}`, contents);
474
+ }
475
+ if (prop === "browser") {
476
+ return new Proxy(target[prop], {
477
+ get(bTarget, bProp, bReceiver) {
478
+ if (bProp === "pages") {
479
+ return async () => {
480
+ return bTarget.pages().then((pages) => {
481
+ return pages.map((page) => {
482
+ return new Proxy(page, {
483
+ get(pTarget, pProp, pReciever) {
484
+ if (pProp === "screenshot") {
485
+ return async (x) => {
486
+ return pm.customScreenShot(Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/${filepath}/butThen` +
487
+ "/" +
488
+ x.path }), page);
489
+ // return await window["custom-screenshot"]({
490
+ // ...x,
491
+ // path:
492
+ // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
493
+ // "/" +
494
+ // x.path,
495
+ // });
496
+ };
497
+ }
498
+ else if (pProp === "close") {
499
+ return () => pTarget[pProp]();
500
+ }
501
+ else if (pProp === "mainFrame") {
502
+ return () => pTarget[pProp]();
503
+ }
504
+ else if (pProp === "exposeFunction") {
505
+ // return Reflect.get(target, prop, receiver);
506
+ return (...a) => pTarget[pProp](...a);
507
+ // return target[pProp];
508
+ }
509
+ else if (pProp === "removeExposedFunction") {
510
+ // return Reflect.get(target, prop, receiver);
511
+ return pTarget[pProp].bind(pTarget);
512
+ // return target[pProp];
513
+ }
514
+ else {
515
+ return Reflect.get(...arguments);
516
+ }
517
+ },
518
+ });
519
+ });
520
+ });
521
+ // return (await target.pages()).map((page) => {
522
+ // return new Proxy(page, handler2);
523
+ // });
524
+ };
525
+ }
526
+ },
527
+ });
528
+ }
529
+ return Reflect.get(...arguments);
530
+ },
531
+ });
532
+ const x = await this.butThen(store, this.thenCB, testResourceConfiguration, butThenProxy
533
+ // pm
534
+ );
535
+ return x;
536
+ }
537
+ catch (e) {
538
+ console.log("test failed", e);
539
+ this.error = e.message;
540
+ throw e;
541
+ }
542
+ }
543
+ }
544
+ export class BaseCheck {
545
+ constructor(name, features, checkCB, whens, thens) {
546
+ this.name = name;
547
+ this.features = features;
548
+ this.checkCB = checkCB;
549
+ this.whens = whens;
550
+ this.thens = thens;
551
+ }
552
+ async afterEach(store, key, cb, pm) {
553
+ return;
554
+ }
555
+ async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
556
+ tLog(`\n Check: ${this.name}`);
557
+ const store = await this.checkThat(subject, testResourceConfiguration, artifactory);
558
+ await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
559
+ a[key] = async (payload) => {
560
+ return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
561
+ };
562
+ return a;
563
+ }, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
564
+ a[key] = async (payload) => {
565
+ const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
566
+ tester(t);
567
+ };
568
+ return a;
569
+ }, {}));
570
+ await this.afterEach(store, key, () => { }, pm);
571
+ return;
572
+ }
573
+ }
@@ -1,7 +1,5 @@
1
1
  export class BaseBuilder {
2
- constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification
3
- // puppetMaster: PM
4
- ) {
2
+ constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification) {
5
3
  this.input = input;
6
4
  this.artifacts = [];
7
5
  this.artifacts = [];
@@ -12,12 +10,9 @@ export class BaseBuilder {
12
10
  this.thenOverides = thenOverides;
13
11
  this.checkOverides = checkOverides;
14
12
  this.testSpecification = testSpecification;
15
- // this.puppetMaster = puppetMaster;
16
13
  this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
17
14
  this.testJobs = this.specs.map((suite) => {
18
- const suiteRunner = (suite) => async (
19
- // testResourceConfiguration: ITTestResourceConfiguration,
20
- puppetMaster, tLog) => {
15
+ const suiteRunner = (suite) => async (puppetMaster, tLog) => {
21
16
  await puppetMaster.startPuppeteer({
22
17
  browserWSEndpoint: puppetMaster.testResourceConfiguration.browserWSEndpoint,
23
18
  }, puppetMaster.testResourceConfiguration.fs);
@@ -28,44 +23,15 @@ export class BaseBuilder {
28
23
  const runner = suiteRunner(suite);
29
24
  return {
30
25
  test: suite,
31
- // testResourceRequirement,
32
26
  toObj: () => {
33
27
  return suite.toObj();
34
28
  },
35
29
  runner,
36
- receiveTestResourceConfig: async function (
37
- // testResourceConfiguration = {
38
- // name: "",
39
- // fs: ".",
40
- // ports: [],
41
- // browserWSEndpoint: "",
42
- // },
43
- puppetMaster) {
44
- // console.log(
45
- // `testResourceConfiguration! ${JSON.stringify(
46
- // testResourceConfiguration,
47
- // null,
48
- // 2
49
- // )}`
50
- // );
51
- // console.log("puppetMaster", puppetMaster);
52
- await puppetMaster
53
- .mkdirSync();
54
- // if (!puppetMaster.existsSync(destFolder)) {
55
- // puppetMaster.mkdirSync(destFolder, { recursive: true });
56
- // }
57
- // puppetMaster.writeFileSync(
58
- // // puppetMaster.testResourceConfiguration.fs + `/tests.json`,
59
- // `tests.json`,
60
- // JSON.stringify(this.toObj(), null, 2)
61
- // );
30
+ receiveTestResourceConfig: async function (puppetMaster) {
31
+ await puppetMaster.mkdirSync();
62
32
  const logFilePath = "log.txt";
63
- // puppetMaster.testResourceConfiguration.fs + `/log.txt`;
64
33
  const access = await puppetMaster.createWriteStream(logFilePath);
65
- // console.log("access", access);
66
34
  const tLog = (...l) => {
67
- // access.write(`${l.toString()}\n`);
68
- // console.log("tLog", l);
69
35
  puppetMaster.write(access, `${l.toString()}\n`);
70
36
  };
71
37
  const suiteDone = await runner(puppetMaster, tLog);
@@ -77,6 +43,14 @@ export class BaseBuilder {
77
43
  return suiteDone.givens[k].error;
78
44
  }).length;
79
45
  puppetMaster.writeFileSync(`exitcode`, numberOfFailures.toString());
46
+ // if (numberOfFailures > 0) {
47
+ // puppetMaster.writeFileSync(
48
+ // `prompt`,
49
+ // `
50
+ // aider --message "make a script that prints hello" hello.js
51
+ // `
52
+ // );
53
+ // }
80
54
  puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
81
55
  console.log(`exiting gracefully with ${numberOfFailures} failures.`);
82
56
  return {
@@ -1,8 +1,6 @@
1
1
  import { BaseBuilder } from "./basebuilder.js";
2
2
  export class ClassBuilder extends BaseBuilder {
3
- constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement
4
- // puppetMaster: PM
5
- ) {
3
+ constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement) {
6
4
  const classySuites = Object.entries(testImplementation.suites).reduce((a, [key], index) => {
7
5
  a[key] = (somestring, givens, checks) => {
8
6
  return new suiteKlasser.prototype.constructor(somestring, index, givens, checks);