testeranto 0.49.9 → 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/.nvmrc +1 -0
  2. package/README.md +71 -9
  3. package/dist/cjs-shim.js +12 -0
  4. package/dist/common/Features.js +2 -3
  5. package/dist/common/Node.js +53 -61
  6. package/dist/common/Project.js +272 -606
  7. package/dist/common/SubPackages/puppeteer.js +19 -0
  8. package/dist/common/{subPackages → SubPackages}/react/component/node.js +4 -4
  9. package/dist/common/{subPackages → SubPackages}/react/component/web.js +4 -4
  10. package/dist/common/SubPackages/react/jsx/index.js +13 -0
  11. package/dist/common/SubPackages/react/jsx/node.js +10 -0
  12. package/dist/common/SubPackages/react/jsx/web.js +10 -0
  13. package/dist/common/{subPackages → SubPackages}/react-dom/component/node.js +6 -6
  14. package/dist/common/{subPackages → SubPackages}/react-dom/component/web.js +11 -12
  15. package/dist/common/SubPackages/react-dom/jsx/node.js +39 -0
  16. package/dist/common/{subPackages → SubPackages}/react-dom/jsx/web.js +6 -27
  17. package/dist/common/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +2 -2
  18. package/dist/common/{subPackages → SubPackages}/react-test-renderer/component/index.js +26 -15
  19. package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/node.js +3 -5
  20. package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/web.js +3 -5
  21. package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/node.js +4 -4
  22. package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/web.js +4 -4
  23. package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -2
  24. package/dist/common/{subPackages/react-test-renderer/jsx-promised → SubPackages/react-test-renderer/jsx}/node.js +4 -4
  25. package/dist/common/{subPackages/react → SubPackages/react-test-renderer}/jsx/web.js +4 -4
  26. package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +2 -2
  27. package/dist/common/{subPackages/react/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +2 -2
  28. package/dist/common/Types.js +32 -0
  29. package/dist/common/Web.js +41 -112
  30. package/dist/common/electron.js +188 -44
  31. package/dist/common/esbuildConfigs/features.js +14 -0
  32. package/dist/common/esbuildConfigs/index.js +20 -0
  33. package/dist/common/esbuildConfigs/node.js +35 -0
  34. package/dist/common/esbuildConfigs/report.js +48 -0
  35. package/dist/common/esbuildConfigs/tests.js +14 -0
  36. package/dist/common/esbuildConfigs/web.js +50 -0
  37. package/dist/common/lib/abstractBase.js +193 -0
  38. package/dist/common/lib/basebuilder.js +86 -0
  39. package/dist/common/lib/browser.js +26 -0
  40. package/dist/common/lib/classBuilder.js +41 -0
  41. package/dist/common/lib/core.js +52 -0
  42. package/dist/common/lib/index.js +19 -0
  43. package/dist/common/nodeWriterElectron.js +55 -0
  44. package/dist/common/preload.js +22 -21
  45. package/dist/common/report.html.js +31 -0
  46. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  47. package/dist/common/web.html.js +22 -0
  48. package/dist/module/Features.js +2 -3
  49. package/dist/module/Node.js +53 -61
  50. package/dist/module/Project.js +272 -583
  51. package/dist/module/SubPackages/puppeteer.js +14 -0
  52. package/dist/module/{subPackages → SubPackages}/react/component/node.js +3 -3
  53. package/dist/module/{subPackages → SubPackages}/react/component/web.js +3 -3
  54. package/dist/module/SubPackages/react/jsx/index.js +10 -0
  55. package/dist/module/SubPackages/react/jsx/node.js +5 -0
  56. package/dist/module/SubPackages/react/jsx/web.js +5 -0
  57. package/dist/module/{subPackages → SubPackages}/react-dom/component/node.js +5 -5
  58. package/dist/module/{subPackages → SubPackages}/react-dom/component/web.js +10 -11
  59. package/dist/module/SubPackages/react-dom/jsx/node.js +31 -0
  60. package/dist/module/{subPackages → SubPackages}/react-dom/jsx/web.js +5 -26
  61. package/dist/module/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +2 -2
  62. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/index.js +23 -15
  63. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/node.js +2 -2
  64. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/web.js +2 -2
  65. package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/node.js +3 -3
  66. package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/web.js +3 -3
  67. package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -2
  68. package/dist/module/SubPackages/react-test-renderer/jsx/node.js +5 -0
  69. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +5 -0
  70. package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +2 -2
  71. package/dist/module/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +1 -1
  72. package/dist/module/Types.js +30 -1
  73. package/dist/module/Web.js +41 -112
  74. package/dist/module/electron.js +189 -45
  75. package/dist/module/esbuildConfigs/features.js +12 -0
  76. package/dist/module/esbuildConfigs/index.js +18 -0
  77. package/dist/module/esbuildConfigs/node.js +30 -0
  78. package/dist/module/esbuildConfigs/report.js +48 -0
  79. package/dist/module/esbuildConfigs/tests.js +12 -0
  80. package/dist/module/esbuildConfigs/web.js +45 -0
  81. package/dist/module/lib/abstractBase.js +185 -0
  82. package/dist/module/lib/basebuilder.js +82 -0
  83. package/dist/module/lib/browser.js +22 -0
  84. package/dist/module/lib/classBuilder.js +37 -0
  85. package/dist/module/lib/core.js +49 -0
  86. package/dist/module/lib/index.js +15 -0
  87. package/dist/module/nodeWriterElectron.js +52 -0
  88. package/dist/module/preload.js +22 -21
  89. package/dist/module/report.html.js +29 -0
  90. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  91. package/dist/module/web.html.js +20 -0
  92. package/dist/prebuild/Report.css +10326 -0
  93. package/dist/prebuild/Report.js +37456 -0
  94. package/dist/types/Features.d.ts +5 -5
  95. package/dist/types/Node.d.ts +4 -11
  96. package/dist/types/NodeWriter.d.ts +1 -1
  97. package/dist/types/Project.d.ts +2 -27
  98. package/dist/types/SubPackages/puppeteer.d.ts +6 -0
  99. package/dist/types/SubPackages/react/component/node.d.ts +7 -0
  100. package/dist/types/SubPackages/react/component/web.d.ts +7 -0
  101. package/dist/types/SubPackages/react/jsx/index.d.ts +15 -0
  102. package/dist/types/SubPackages/react/jsx/node.d.ts +4 -0
  103. package/dist/types/SubPackages/react/jsx/web.d.ts +4 -0
  104. package/dist/types/{subPackages → SubPackages}/react-dom/component/node.d.ts +2 -4
  105. package/dist/types/SubPackages/react-dom/component/web.d.ts +5 -0
  106. package/dist/types/{subPackages → SubPackages}/react-dom/jsx/index.d.ts +3 -3
  107. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +6 -0
  108. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +5 -0
  109. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +5 -0
  110. package/dist/types/{subPackages → SubPackages}/react-test-renderer/component/index.d.ts +6 -6
  111. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +9 -0
  112. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +4 -0
  113. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +8 -0
  114. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +8 -0
  115. package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx/index.d.ts +5 -4
  116. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +9 -0
  117. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +9 -0
  118. package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.d.ts +4 -4
  119. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +5 -0
  120. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +5 -0
  121. package/dist/types/Types.d.ts +116 -3
  122. package/dist/types/Web.d.ts +4 -11
  123. package/dist/types/esbuildConfigs/features.d.ts +4 -0
  124. package/dist/types/esbuildConfigs/index.d.ts +4 -0
  125. package/dist/types/esbuildConfigs/node.d.ts +4 -0
  126. package/dist/types/esbuildConfigs/report.d.ts +0 -0
  127. package/dist/types/esbuildConfigs/tests.d.ts +4 -0
  128. package/dist/types/esbuildConfigs/web.d.ts +4 -0
  129. package/dist/types/lib/abstractBase.d.ts +102 -0
  130. package/dist/types/lib/basebuilder.d.ts +24 -0
  131. package/dist/types/lib/browser.d.ts +6 -0
  132. package/dist/types/lib/classBuilder.d.ts +6 -0
  133. package/dist/types/lib/core.d.ts +7 -0
  134. package/dist/types/lib/index.d.ts +57 -0
  135. package/dist/types/nodeWriterElectron.d.ts +2 -0
  136. package/dist/types/report.html.d.ts +2 -0
  137. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  138. package/dist/types/web.html.d.ts +2 -0
  139. package/electronBuild.ts +32 -0
  140. package/index.html +30 -0
  141. package/package.json +120 -85
  142. package/src/Features.ts +2 -4
  143. package/src/Node.ts +114 -160
  144. package/src/NodeWriter.ts +1 -4
  145. package/src/Project.ts +610 -753
  146. package/src/Report.tsx +30 -15
  147. package/src/SubPackages/puppeteer.ts +46 -0
  148. package/src/{subPackages → SubPackages}/react/component/node.ts +12 -32
  149. package/src/SubPackages/react/component/web.ts +53 -0
  150. package/src/SubPackages/react/jsx/index.ts +43 -0
  151. package/src/SubPackages/react/jsx/node.ts +29 -0
  152. package/src/SubPackages/react/jsx/web.ts +28 -0
  153. package/src/{subPackages → SubPackages}/react-dom/component/node.ts +11 -25
  154. package/src/{subPackages → SubPackages}/react-dom/component/web.ts +27 -32
  155. package/src/{subPackages → SubPackages}/react-dom/jsx/index.ts +3 -5
  156. package/src/SubPackages/react-dom/jsx/node.ts +68 -0
  157. package/src/{subPackages → SubPackages}/react-dom/jsx/web.ts +19 -62
  158. package/src/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.ts +9 -28
  159. package/src/{subPackages → SubPackages}/react-test-renderer/component/index.ts +31 -29
  160. package/src/SubPackages/react-test-renderer/component/node.ts +22 -0
  161. package/src/SubPackages/react-test-renderer/component/web.ts +22 -0
  162. package/src/{subPackages → SubPackages}/react-test-renderer/fc/node.ts +14 -28
  163. package/src/{subPackages → SubPackages}/react-test-renderer/fc/web.ts +9 -25
  164. package/src/{subPackages → SubPackages}/react-test-renderer/jsx/index.ts +19 -16
  165. package/src/SubPackages/react-test-renderer/jsx/node.ts +24 -0
  166. package/src/SubPackages/react-test-renderer/jsx/web.ts +20 -0
  167. package/src/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.ts +7 -15
  168. package/src/SubPackages/react-test-renderer/jsx-promised/node.ts +19 -0
  169. package/src/SubPackages/react-test-renderer/jsx-promised/web.ts +22 -0
  170. package/src/Types.ts +334 -3
  171. package/src/Web.ts +104 -230
  172. package/src/cjs-shim.js +12 -0
  173. package/src/electron.ts +237 -46
  174. package/src/esbuildConfigs/features.ts +18 -0
  175. package/src/esbuildConfigs/index.ts +22 -0
  176. package/src/esbuildConfigs/node.ts +59 -0
  177. package/src/esbuildConfigs/report.ts +51 -0
  178. package/src/esbuildConfigs/tests.ts +20 -0
  179. package/src/esbuildConfigs/web.ts +73 -0
  180. package/src/lib/abstractBase.ts +459 -0
  181. package/src/lib/basebuilder.ts +253 -0
  182. package/src/lib/browser.ts +34 -0
  183. package/src/lib/classBuilder.ts +137 -0
  184. package/src/lib/core.ts +182 -0
  185. package/src/lib/index.ts +116 -0
  186. package/src/nodeWriterElectron.ts +71 -0
  187. package/src/preload.ts +23 -21
  188. package/src/report.html.ts +29 -0
  189. package/src/web.html.ts +20 -0
  190. package/tests/Rectangle.test.ts +189 -0
  191. package/tsconfig.json +19 -6
  192. package/tsconfig.module.json +15 -4
  193. package/tsconfig.types.json +14 -4
  194. package/yarn-error.log +3144 -0
  195. package/dist/common/core.js +0 -397
  196. package/dist/common/subPackages/react/jsx/index.js +0 -26
  197. package/dist/common/subPackages/react-dom/jsx/node.js +0 -95
  198. package/dist/common/subPackages/react-test-renderer/component/node.js +0 -8
  199. package/dist/common/subPackages/react-test-renderer/component/web.js +0 -8
  200. package/dist/module/Report.js +0 -186
  201. package/dist/module/core.js +0 -388
  202. package/dist/module/subPackages/react/jsx/index.js +0 -22
  203. package/dist/module/subPackages/react/jsx/node.js +0 -5
  204. package/dist/module/subPackages/react/jsx/web.js +0 -5
  205. package/dist/module/subPackages/react-dom/jsx/node.js +0 -87
  206. package/dist/module/subPackages/react-test-renderer/jsx/web.js +0 -5
  207. package/dist/module/subPackages/react-test-renderer/jsx-promised/node.js +0 -5
  208. package/dist/types/core.d.ts +0 -220
  209. package/dist/types/subPackages/react/component/node.d.ts +0 -12
  210. package/dist/types/subPackages/react/component/web.d.ts +0 -12
  211. package/dist/types/subPackages/react/jsx/index.d.ts +0 -15
  212. package/dist/types/subPackages/react/jsx/node.d.ts +0 -4
  213. package/dist/types/subPackages/react/jsx/web.d.ts +0 -4
  214. package/dist/types/subPackages/react-dom/component/web.d.ts +0 -19
  215. package/dist/types/subPackages/react-dom/jsx/node.d.ts +0 -8
  216. package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -5
  217. package/dist/types/subPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -8
  218. package/dist/types/subPackages/react-test-renderer/component/node.d.ts +0 -9
  219. package/dist/types/subPackages/react-test-renderer/component/web.d.ts +0 -9
  220. package/dist/types/subPackages/react-test-renderer/fc/node.d.ts +0 -9
  221. package/dist/types/subPackages/react-test-renderer/fc/web.d.ts +0 -9
  222. package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +0 -4
  223. package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +0 -4
  224. package/dist/types/subPackages/react-test-renderer/jsx-promised/node.d.ts +0 -4
  225. package/dist/types/subPackages/react-test-renderer/jsx-promised/web.d.ts +0 -4
  226. package/src/core.ts +0 -1399
  227. package/src/subPackages/react/component/web.ts +0 -80
  228. package/src/subPackages/react/jsx/index.ts +0 -64
  229. package/src/subPackages/react/jsx/node.ts +0 -29
  230. package/src/subPackages/react/jsx/web.ts +0 -29
  231. package/src/subPackages/react-dom/jsx/node.ts +0 -146
  232. package/src/subPackages/react-test-renderer/component/node.ts +0 -30
  233. package/src/subPackages/react-test-renderer/component/web.ts +0 -30
  234. package/src/subPackages/react-test-renderer/jsx/node.ts +0 -31
  235. package/src/subPackages/react-test-renderer/jsx/web.ts +0 -31
  236. package/src/subPackages/react-test-renderer/jsx-promised/node.ts +0 -31
  237. package/src/subPackages/react-test-renderer/jsx-promised/web.ts +0 -31
  238. /package/dist/common/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
  239. /package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
  240. /package/dist/module/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
  241. /package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
@@ -0,0 +1,253 @@
1
+
2
+ import {
3
+ IBaseTest,
4
+ ICheckKlasser,
5
+ IGivenKlasser,
6
+ ISuiteKlasser,
7
+ ITestSpecification,
8
+ IThenKlasser,
9
+ IUtils,
10
+ IWhenKlasser
11
+ } from "../Types";
12
+
13
+ import {
14
+
15
+ BaseCheck,
16
+ BaseSuite,
17
+ BaseWhen,
18
+ BaseThen,
19
+ BaseGiven
20
+ } from "./abstractBase.js";
21
+
22
+ import {
23
+ ITTestResourceRequest,
24
+ ITestJob,
25
+ ITLog,
26
+ ILogWriter,
27
+ ITTestResourceConfiguration,
28
+ } from ".";
29
+ export abstract class BaseBuilder<
30
+ ITestShape extends IBaseTest,
31
+ SuiteExtensions,
32
+ GivenExtensions,
33
+ WhenExtensions,
34
+ ThenExtensions,
35
+ CheckExtensions,
36
+ > {
37
+
38
+ specs: any;
39
+
40
+ assertThis: (t: any) => {
41
+
42
+ }
43
+
44
+ testResourceRequirement: ITTestResourceRequest;
45
+ artifacts: Promise<unknown>[] = [];
46
+ testJobs: ITestJob[];
47
+ testSpecification: ITestSpecification<ITestShape>;
48
+ suitesOverrides: Record<keyof SuiteExtensions, ISuiteKlasser<ITestShape>>;
49
+ givenOverides: Record<keyof GivenExtensions, IGivenKlasser<ITestShape>>;
50
+ whenOverides: Record<keyof WhenExtensions, IWhenKlasser<ITestShape>>;
51
+ thenOverides: Record<keyof ThenExtensions, IThenKlasser<ITestShape>>;
52
+ checkOverides: Record<keyof CheckExtensions, ICheckKlasser<ITestShape>>;
53
+
54
+ constructor(
55
+ public readonly input: ITestShape['iinput'],
56
+ suitesOverrides: Record<keyof SuiteExtensions, ISuiteKlasser<ITestShape>>,
57
+ givenOverides: Record<keyof GivenExtensions, IGivenKlasser<ITestShape>>,
58
+ whenOverides: Record<keyof WhenExtensions, IWhenKlasser<ITestShape>>,
59
+ thenOverides: Record<keyof ThenExtensions, IThenKlasser<ITestShape>>,
60
+ checkOverides: Record<keyof CheckExtensions, ICheckKlasser<ITestShape>>,
61
+ logWriter: ILogWriter,
62
+ testResourceRequirement: ITTestResourceRequest,
63
+ testSpecification: any,
64
+ ) {
65
+ this.artifacts = [];
66
+ this.testResourceRequirement = testResourceRequirement;
67
+ this.suitesOverrides = suitesOverrides;
68
+ this.givenOverides = givenOverides;
69
+ this.whenOverides = whenOverides;
70
+ this.thenOverides = thenOverides;
71
+ this.checkOverides = checkOverides;
72
+ this.testSpecification = testSpecification;
73
+
74
+ this.specs = testSpecification(
75
+ this.Suites(),
76
+ this.Given(),
77
+ this.When(),
78
+ this.Then(),
79
+ this.Check(),
80
+ );
81
+
82
+ const suiteRunner = (
83
+ suite: BaseSuite<ITestShape>,
84
+ utils: IUtils
85
+ ) =>
86
+ async (
87
+ testResourceConfiguration: ITTestResourceConfiguration,
88
+ tLog: ITLog,
89
+ utils: IUtils
90
+ ): Promise<BaseSuite<
91
+ ITestShape
92
+ >> => {
93
+ return await suite.run(
94
+ input,
95
+ testResourceConfiguration,
96
+ (
97
+ fPath: string,
98
+ value: unknown
99
+ ) =>
100
+ logWriter.testArtiFactoryfileWriter(tLog, (p: Promise<void>) => {
101
+ this.artifacts.push(p);
102
+ })(
103
+ testResourceConfiguration.fs + "/" + fPath,
104
+ value
105
+ ),
106
+ tLog,
107
+ utils
108
+ );
109
+ };
110
+
111
+ this.testJobs = this.specs.map((
112
+ suite: BaseSuite<ITestShape>,
113
+ utils: IUtils
114
+ ) => {
115
+ const runner = suiteRunner(suite, utils);
116
+
117
+ return {
118
+ test: suite,
119
+ testResourceRequirement,
120
+
121
+ toObj: () => {
122
+ return suite.toObj();
123
+ },
124
+
125
+ runner,
126
+
127
+ receiveTestResourceConfig: async function (
128
+ testResourceConfiguration = {
129
+ name: "",
130
+ fs: ".",
131
+ ports: [],
132
+ scheduled: false
133
+ },
134
+ y: IUtils
135
+ ) {
136
+ console.log(
137
+ `testResourceConfiguration ${JSON.stringify(
138
+ testResourceConfiguration,
139
+ null,
140
+ 2
141
+ )}`
142
+ );
143
+ await logWriter.mkdirSync(testResourceConfiguration.fs);
144
+ logWriter.writeFileSync(
145
+ `${testResourceConfiguration.fs}/tests.json`,
146
+ JSON.stringify(this.toObj(), null, 2)
147
+ );
148
+
149
+ const logFilePath = `${testResourceConfiguration.fs}/log.txt`;
150
+
151
+ const access = await logWriter.createWriteStream(logFilePath);
152
+
153
+ const tLog = (...l: string[]) => {
154
+ // console.log(...l);
155
+ access.write(`${l.toString()}\n`);
156
+ };
157
+ const suiteDone: BaseSuite<
158
+ ITestShape
159
+ > = await runner(testResourceConfiguration, tLog, y);
160
+ const resultsFilePath = (
161
+ `${testResourceConfiguration.fs}/results.json`
162
+ );
163
+
164
+ logWriter.writeFileSync(
165
+ resultsFilePath,
166
+ JSON.stringify(suiteDone.toObj(), null, 2)
167
+ );
168
+
169
+ const logPromise = new Promise((res, rej) => {
170
+ access.on("finish", () => { res(true); });
171
+ })
172
+ access.end();
173
+
174
+ const numberOfFailures = Object.keys(suiteDone.givens).filter(
175
+ (k) => {
176
+ // console.log(`suiteDone.givens[k].error`, suiteDone.givens[k].error);
177
+ return suiteDone.givens[k].error
178
+ }
179
+ ).length;
180
+ console.log(`exiting gracefully with ${numberOfFailures} failures.`);
181
+ return {
182
+ failed: numberOfFailures,
183
+ artifacts: this.artifacts || [],
184
+ logPromise
185
+ };
186
+ },
187
+ };
188
+ });
189
+ }
190
+
191
+ Specs() {
192
+ return this.specs;
193
+ }
194
+ Suites() {
195
+ return this.suitesOverrides;
196
+ }
197
+
198
+ Given(): Record<
199
+ keyof GivenExtensions,
200
+ (
201
+ name: string,
202
+ features: string[],
203
+ whens: BaseWhen<
204
+ ITestShape
205
+ >[],
206
+ thens: BaseThen<
207
+ ITestShape
208
+ >[],
209
+ gcb,
210
+ ) => BaseGiven<
211
+ ITestShape
212
+ >
213
+ > {
214
+ return this.givenOverides;
215
+ }
216
+
217
+ When(): Record<
218
+ keyof WhenExtensions,
219
+ (arg0: ITestShape['istore'], ...arg1: any) =>
220
+ BaseWhen<
221
+ ITestShape
222
+ >
223
+ > {
224
+ return this.whenOverides;
225
+ }
226
+
227
+ Then(): Record<
228
+ keyof ThenExtensions,
229
+ (
230
+ selection: ITestShape['iselection'],
231
+ expectation: any
232
+ ) => BaseThen<
233
+ ITestShape
234
+ >
235
+ > {
236
+ return this.thenOverides;
237
+ }
238
+
239
+ Check(): Record<
240
+ keyof CheckExtensions,
241
+ (
242
+ feature: string,
243
+ callback: (whens, thens) => any,
244
+ whens,
245
+ thens,
246
+ x
247
+ ) => BaseCheck<
248
+ ITestShape
249
+ >
250
+ > {
251
+ return this.checkOverides;
252
+ }
253
+ }
@@ -0,0 +1,34 @@
1
+ import { Browser, Page } from "puppeteer-core";
2
+
3
+ export class TBrowser {
4
+ browser: Browser;
5
+ constructor(browser: Browser) {
6
+ this.browser = browser;
7
+ }
8
+ pages(): Promise<Page[]> {
9
+
10
+ return new Promise(async (res, rej) => {
11
+
12
+
13
+ res(
14
+ (await this.browser.pages()).map((p) => {
15
+ // const handler = {
16
+ // apply: function (target, thisArg, argumentsList) {
17
+ // console.log('screenshot was called with ' + JSON.stringify(argumentsList));
18
+ // const x: ScreenshotOptions = argumentsList[0]
19
+ // x.path = "./dist/" + x.path;
20
+ // console.log('x.path' + x.path, target, thisArg);
21
+ // return target(...argumentsList);
22
+ // }
23
+ // };
24
+ // p.screenshot = new Proxy(p.screenshot, handler);
25
+ return p;
26
+ })
27
+ );
28
+ });
29
+
30
+ }
31
+ // pages(): Promise<TPage[]> {
32
+ // return super.pages();
33
+ // }
34
+ }
@@ -0,0 +1,137 @@
1
+ import type {
2
+ IBaseTest,
3
+ ICheckKlasser,
4
+ IGivenKlasser,
5
+ ISuiteKlasser,
6
+ ITestImplementation,
7
+ ITestSpecification,
8
+ IThenKlasser,
9
+ IWhenKlasser,
10
+ } from "../Types";
11
+
12
+
13
+ import {
14
+ BaseBuilder
15
+ } from "./basebuilder.js";
16
+
17
+ import {
18
+ ILogWriter,
19
+ ITTestResourceRequest
20
+ } from ".";
21
+
22
+ export abstract class ClassBuilder<
23
+ ITestShape extends IBaseTest
24
+ > extends BaseBuilder<
25
+ ITestShape,
26
+ any,
27
+ any,
28
+ any,
29
+ any,
30
+ any
31
+ > {
32
+
33
+ constructor(
34
+ testImplementation: ITestImplementation<ITestShape, any>,
35
+ testSpecification: ITestSpecification<ITestShape>,
36
+ input: ITestShape['iinput'],
37
+ suiteKlasser: ISuiteKlasser<ITestShape>,
38
+ givenKlasser: IGivenKlasser<ITestShape>,
39
+ whenKlasser: IWhenKlasser<ITestShape>,
40
+ thenKlasser: IThenKlasser<ITestShape>,
41
+ checkKlasser: ICheckKlasser<ITestShape>,
42
+ testResourceRequirement: ITTestResourceRequest,
43
+ logWriter: ILogWriter
44
+ ) {
45
+ const classySuites = Object.entries(testImplementation.suites).reduce(
46
+ (a, [key], index) => {
47
+ a[key] = (somestring, givens, checks) => {
48
+ return new suiteKlasser.prototype.constructor(
49
+ somestring,
50
+ index,
51
+ givens,
52
+ checks
53
+ );
54
+ };
55
+ return a;
56
+ },
57
+ {}
58
+ );
59
+ const classyGivens = Object.entries(testImplementation.givens)
60
+ .reduce(
61
+ (a, [key, givEn]) => {
62
+ a[key] = (
63
+ features,
64
+ whens,
65
+ thens,
66
+ givEn,
67
+ ) => {
68
+ return new (givenKlasser.prototype).constructor(
69
+ key,
70
+ features,
71
+ whens,
72
+ thens,
73
+ testImplementation.givens[key],
74
+ givEn
75
+ );
76
+ };
77
+ return a;
78
+ },
79
+ {}
80
+ );
81
+
82
+ const classyWhens = Object.entries(testImplementation.whens).reduce(
83
+ (a, [key, whEn]: [string, (x) => any]) => {
84
+ a[key] = (payload?: any) => {
85
+ return new whenKlasser.prototype.constructor(
86
+ `${whEn.name}: ${payload && payload.toString()}`,
87
+ whEn(payload)
88
+ );
89
+ };
90
+ return a;
91
+ },
92
+ {}
93
+ );
94
+
95
+ const classyThens = Object.entries(testImplementation.thens).reduce(
96
+ (a, [key, thEn]: [string, (x) => any]) => {
97
+ a[key] = (expected: any, x) => {
98
+ return new thenKlasser.prototype.constructor(
99
+ `${thEn.name}: ${expected && expected.toString()}`,
100
+ thEn(expected)
101
+ );
102
+ };
103
+ return a;
104
+ },
105
+ {}
106
+ );
107
+
108
+ const classyChecks = Object.entries(testImplementation.checks).reduce(
109
+ (a, [key, z]) => {
110
+ a[key] = (somestring, features, callback) => {
111
+ return new checkKlasser.prototype.constructor(
112
+ somestring,
113
+ features,
114
+ callback,
115
+ classyWhens,
116
+ classyThens
117
+ );
118
+ };
119
+ return a;
120
+ },
121
+ {}
122
+ );
123
+
124
+ super(
125
+ input,
126
+ classySuites,
127
+ classyGivens,
128
+ classyWhens,
129
+ classyThens,
130
+ classyChecks,
131
+ logWriter,
132
+ testResourceRequirement,
133
+ testSpecification
134
+ );
135
+ }
136
+
137
+ }
@@ -0,0 +1,182 @@
1
+ import type {
2
+ IBaseTest, ITestImplementation, ITestInterface, ITestSpecification, IUtils
3
+ } from "../Types";
4
+
5
+ import {
6
+ DefaultTestInterface,
7
+ ILogWriter,
8
+ ITTestResourceConfiguration,
9
+ ITTestResourceRequest,
10
+ ITestArtifactory,
11
+ ITestJob,
12
+ defaultTestResourceRequirement
13
+ } from "./index.js";
14
+ import {
15
+ BaseSuite, BaseGiven, BaseWhen, BaseThen, BaseCheck
16
+ } from "./abstractBase.js";
17
+ import {
18
+ ClassBuilder
19
+ } from "./classBuilder.js";
20
+ import { IStore } from "../SubPackages/react/jsx";
21
+
22
+ export default abstract class Testeranto<ITestShape extends IBaseTest> extends ClassBuilder<ITestShape> {
23
+ constructor(
24
+ input: ITestShape['iinput'],
25
+ testSpecification: ITestSpecification<ITestShape>,
26
+ testImplementation: ITestImplementation<ITestShape, object>,
27
+ testResourceRequirement: ITTestResourceRequest = defaultTestResourceRequirement,
28
+ logWriter: ILogWriter,
29
+ testInterface: Partial<ITestInterface<ITestShape>>,
30
+ ) {
31
+ const fullTestInterface = DefaultTestInterface(testInterface);
32
+
33
+ super(
34
+ testImplementation,
35
+ testSpecification,
36
+ input,
37
+
38
+ class extends BaseSuite<
39
+ ITestShape
40
+ > {
41
+
42
+ assertThat(t) {
43
+ fullTestInterface.assertThis(t);
44
+ }
45
+
46
+ async setup(
47
+ s: ITestShape['iinput'],
48
+ artifactory: ITestArtifactory,
49
+ tr,
50
+ // utils: ITestInterface<ITestShape>
51
+ ): Promise<
52
+ ITestShape['isubject']
53
+ > {
54
+ return (fullTestInterface.beforeAll || (async (
55
+ input: ITestShape['iinput'],
56
+ artifactory: ITestArtifactory,
57
+ tr,
58
+ // utils: ITestInterface<ITestShape>
59
+ ) => input as any))(
60
+ s,
61
+ this.testResourceConfiguration,
62
+ artifactory
63
+ );
64
+ }
65
+ } as any,
66
+
67
+ class Given extends BaseGiven<
68
+ ITestShape
69
+ > {
70
+
71
+ async givenThat(subject, testResource, artifactory, initializer) {
72
+ return fullTestInterface.beforeEach(
73
+ subject,
74
+ initializer,
75
+ (fPath: string, value: unknown) =>
76
+ // TODO does not work?
77
+ artifactory(`beforeEach/${fPath}`, value),
78
+ testResource,
79
+ this.initialValues,
80
+ // utils,
81
+ );
82
+ }
83
+
84
+ afterEach(
85
+ store: ITestShape['istore'],
86
+ key: string,
87
+ artifactory
88
+ ): Promise<unknown> {
89
+ return new Promise((res) =>
90
+ res(fullTestInterface.afterEach(store, key, (fPath: string, value: unknown) =>
91
+ artifactory(`after/${fPath}`, value)))
92
+ );
93
+ }
94
+ afterAll(
95
+ store: IStore,
96
+ artifactory: ITestArtifactory,
97
+ utils: IUtils,
98
+ ) {
99
+ return fullTestInterface.afterAll(store, (fPath: string, value: unknown) =>
100
+ // TODO does not work?
101
+ { artifactory(`afterAll4-${this.name}/${fPath}`, value) },
102
+ utils
103
+ );
104
+ }
105
+ } as any,
106
+
107
+ class When extends BaseWhen<
108
+ ITestShape
109
+ > {
110
+ async andWhen(store, whenCB, testResource) {
111
+ return await fullTestInterface.andWhen(store, whenCB, testResource);
112
+ }
113
+ } as any,
114
+
115
+ class Then extends BaseThen<
116
+ ITestShape
117
+ > {
118
+
119
+ async butThen(
120
+ store: any,
121
+ thenCB,
122
+ testResourceConfiguration?: any
123
+ ): Promise<ITestShape['iselection']> {
124
+ return await fullTestInterface.butThen(
125
+ store,
126
+ thenCB,
127
+ testResourceConfiguration);
128
+ }
129
+ } as any,
130
+
131
+ class Check extends BaseCheck<
132
+ ITestShape
133
+ > {
134
+ initialValues: any;
135
+
136
+ constructor(
137
+ name: string,
138
+ features: string[],
139
+ checkCallback: (a, b) => any,
140
+ whens,
141
+ thens,
142
+ initialValues: any
143
+ ) {
144
+ super(name, features, checkCallback, whens, thens);
145
+ this.initialValues = initialValues;
146
+ }
147
+
148
+ async checkThat(subject, testResourceConfiguration, artifactory) {
149
+ return fullTestInterface.beforeEach(
150
+ subject,
151
+ this.initialValues,
152
+ (fPath: string, value: unknown) => artifactory(`before/${fPath}`, value),
153
+ testResourceConfiguration,
154
+ this.initialValues
155
+ );
156
+ }
157
+
158
+ afterEach(
159
+ store: ITestShape['istore'],
160
+ key: string,
161
+ artifactory
162
+ ): Promise<unknown> {
163
+ return new Promise((res) =>
164
+ res(fullTestInterface.afterEach(store, key, (fPath: string, value: unknown) =>
165
+ // TODO does not work?
166
+ artifactory(`afterEach2-${this.name}/${fPath}`, value)))
167
+ );
168
+ }
169
+ } as any,
170
+
171
+ testResourceRequirement,
172
+ logWriter,
173
+ );
174
+ }
175
+
176
+ abstract receiveTestResourceConfig(
177
+ t: ITestJob,
178
+ partialTestResource: ITTestResourceConfiguration,
179
+ utils: IUtils
180
+ );
181
+
182
+ }
@@ -0,0 +1,116 @@
1
+
2
+ import { IBaseTest, ITestInterface, IUtils } from "../Types.js";
3
+ import { IGivens, BaseCheck, BaseSuite, BaseWhen, BaseThen } from "./abstractBase.js";
4
+
5
+ export const BaseTestInterface: ITestInterface<IBaseTest> = {
6
+ beforeAll: (async (s) => s),
7
+ beforeEach: async function (subject: any, initialValues: any, testResource: any) { return subject as any; },
8
+ afterEach: (async (s) => s),
9
+ afterAll: ((store: IBaseTest['istore']) => undefined),
10
+ butThen: (async (store: IBaseTest['istore'], thenCb) => thenCb(store)),
11
+ andWhen: ((a) => a),
12
+ assertThis: (() => null),
13
+ };
14
+
15
+ export const DefaultTestInterface = (p: Partial<ITestInterface<any>>): ITestInterface<any> => {
16
+ return {
17
+ ...BaseTestInterface,
18
+ ...p
19
+ }
20
+ }
21
+
22
+ export type ITTestResourceConfiguration = {
23
+ name: string;
24
+ fs: string;
25
+ ports: number[];
26
+ scheduled: boolean;
27
+ };
28
+
29
+ export type ITTestResourceRequirement = {
30
+ name: string;
31
+ ports: number;
32
+ fs: string;
33
+ };
34
+
35
+ export type ITTestResourceRequest = {
36
+ ports: number;
37
+ };
38
+
39
+ export type ITLog = (...string) => void;
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
+ export type ITestArtificer = (key: string, data: any) => void;
51
+
52
+ type ITest = {
53
+ toObj(): object;
54
+ name: string;
55
+ givens: IGivens<
56
+ IBaseTest
57
+ >;
58
+ checks: BaseCheck<
59
+ IBaseTest
60
+ >[];
61
+ testResourceConfiguration: ITTestResourceConfiguration;
62
+ };
63
+
64
+ export type ITestJob = {
65
+ toObj(): object;
66
+ test: ITest;
67
+ runner: (x: ITTestResourceConfiguration, t: ITLog) => Promise<
68
+ BaseSuite<
69
+ IBaseTest
70
+ >
71
+ >;
72
+ testResourceRequirement: ITTestResourceRequirement;
73
+ receiveTestResourceConfig: (
74
+ testResource,
75
+ utils: IUtils
76
+ ) => Promise<{
77
+ failed: number,
78
+ artifacts: Promise<unknown>[],
79
+ logPromise: Promise<unknown>
80
+ }>
81
+ };
82
+
83
+ export type ITestResults = Promise<{ test: ITest }>[];
84
+
85
+ export const defaultTestResourceRequirement: ITTestResourceRequest = {
86
+ ports: 0
87
+ };
88
+
89
+ export type ITestArtifactory = (key: string, value: unknown) => unknown;
90
+
91
+ export type ITestCheckCallback<ITestShape extends IBaseTest> = {
92
+ [K in keyof ITestShape["checks"]]: (
93
+ name: string,
94
+ features: string[],
95
+ callbackA: (
96
+ whens: {
97
+ [K in keyof ITestShape["whens"]]: (
98
+ ...unknown
99
+ ) => BaseWhen<
100
+ ITestShape
101
+ >;
102
+ },
103
+ thens: {
104
+ [K in keyof ITestShape["thens"]]: (
105
+ ...unknown
106
+ ) => BaseThen<
107
+ ITestShape
108
+ >;
109
+ }
110
+ ) => Promise<any>,
111
+ ...xtrasA: ITestShape["checks"][K]
112
+ ) => BaseCheck<
113
+ ITestShape
114
+ >;
115
+ };
116
+