testeranto 0.49.10 → 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/.nvmrc +1 -0
  2. package/README.md +71 -9
  3. package/dist/cjs-shim.js +12 -0
  4. package/dist/common/Features.js +2 -3
  5. package/dist/common/Node.js +53 -61
  6. package/dist/common/Project.js +272 -606
  7. package/dist/common/SubPackages/puppeteer.js +19 -0
  8. package/dist/common/{subPackages → SubPackages}/react/component/node.js +4 -4
  9. package/dist/common/{subPackages → SubPackages}/react/component/web.js +4 -4
  10. package/dist/common/SubPackages/react/jsx/index.js +13 -0
  11. package/dist/common/SubPackages/react/jsx/node.js +10 -0
  12. package/dist/common/SubPackages/react/jsx/web.js +10 -0
  13. package/dist/common/{subPackages → SubPackages}/react-dom/component/node.js +6 -6
  14. package/dist/common/{subPackages → SubPackages}/react-dom/component/web.js +11 -12
  15. package/dist/common/SubPackages/react-dom/jsx/node.js +39 -0
  16. package/dist/common/{subPackages → SubPackages}/react-dom/jsx/web.js +5 -14
  17. package/dist/common/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +2 -2
  18. package/dist/common/{subPackages → SubPackages}/react-test-renderer/component/index.js +26 -15
  19. package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/node.js +3 -5
  20. package/dist/common/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/component}/web.js +3 -5
  21. package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/node.js +4 -4
  22. package/dist/common/{subPackages → SubPackages}/react-test-renderer/fc/web.js +4 -4
  23. package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -2
  24. package/dist/common/{subPackages/react-test-renderer/jsx-promised → SubPackages/react-test-renderer/jsx}/node.js +4 -4
  25. package/dist/common/{subPackages/react → SubPackages/react-test-renderer}/jsx/web.js +4 -4
  26. package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +2 -2
  27. package/dist/common/{subPackages/react/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +2 -2
  28. package/dist/common/Types.js +32 -0
  29. package/dist/common/Web.js +41 -112
  30. package/dist/common/electron.js +188 -44
  31. package/dist/common/esbuildConfigs/features.js +14 -0
  32. package/dist/common/esbuildConfigs/index.js +20 -0
  33. package/dist/common/esbuildConfigs/node.js +35 -0
  34. package/dist/common/esbuildConfigs/report.js +48 -0
  35. package/dist/common/esbuildConfigs/tests.js +14 -0
  36. package/dist/common/esbuildConfigs/web.js +50 -0
  37. package/dist/common/lib/abstractBase.js +193 -0
  38. package/dist/common/lib/basebuilder.js +86 -0
  39. package/dist/common/lib/browser.js +26 -0
  40. package/dist/common/lib/classBuilder.js +41 -0
  41. package/dist/common/lib/core.js +52 -0
  42. package/dist/common/lib/index.js +19 -0
  43. package/dist/common/nodeWriterElectron.js +55 -0
  44. package/dist/common/preload.js +22 -21
  45. package/dist/common/report.html.js +31 -0
  46. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  47. package/dist/common/web.html.js +22 -0
  48. package/dist/module/Features.js +2 -3
  49. package/dist/module/Node.js +53 -61
  50. package/dist/module/Project.js +272 -583
  51. package/dist/module/SubPackages/puppeteer.js +14 -0
  52. package/dist/module/{subPackages → SubPackages}/react/component/node.js +3 -3
  53. package/dist/module/{subPackages → SubPackages}/react/component/web.js +3 -3
  54. package/dist/module/SubPackages/react/jsx/index.js +10 -0
  55. package/dist/module/SubPackages/react/jsx/node.js +5 -0
  56. package/dist/module/SubPackages/react/jsx/web.js +5 -0
  57. package/dist/module/{subPackages → SubPackages}/react-dom/component/node.js +5 -5
  58. package/dist/module/{subPackages → SubPackages}/react-dom/component/web.js +10 -11
  59. package/dist/module/SubPackages/react-dom/jsx/node.js +31 -0
  60. package/dist/module/{subPackages → SubPackages}/react-dom/jsx/web.js +4 -13
  61. package/dist/module/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.js +2 -2
  62. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/index.js +23 -15
  63. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/node.js +2 -2
  64. package/dist/module/{subPackages → SubPackages}/react-test-renderer/component/web.js +2 -2
  65. package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/node.js +3 -3
  66. package/dist/module/{subPackages → SubPackages}/react-test-renderer/fc/web.js +3 -3
  67. package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx/index.js +8 -2
  68. package/dist/module/SubPackages/react-test-renderer/jsx/node.js +5 -0
  69. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +5 -0
  70. package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.js +2 -2
  71. package/dist/module/{subPackages/react-test-renderer/jsx → SubPackages/react-test-renderer/jsx-promised}/node.js +1 -1
  72. package/dist/module/Types.js +30 -1
  73. package/dist/module/Web.js +41 -112
  74. package/dist/module/electron.js +189 -45
  75. package/dist/module/esbuildConfigs/features.js +12 -0
  76. package/dist/module/esbuildConfigs/index.js +18 -0
  77. package/dist/module/esbuildConfigs/node.js +30 -0
  78. package/dist/module/esbuildConfigs/report.js +48 -0
  79. package/dist/module/esbuildConfigs/tests.js +12 -0
  80. package/dist/module/esbuildConfigs/web.js +45 -0
  81. package/dist/module/lib/abstractBase.js +185 -0
  82. package/dist/module/lib/basebuilder.js +82 -0
  83. package/dist/module/lib/browser.js +22 -0
  84. package/dist/module/lib/classBuilder.js +37 -0
  85. package/dist/module/lib/core.js +49 -0
  86. package/dist/module/lib/index.js +15 -0
  87. package/dist/module/nodeWriterElectron.js +52 -0
  88. package/dist/module/preload.js +22 -21
  89. package/dist/module/report.html.js +29 -0
  90. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  91. package/dist/module/web.html.js +20 -0
  92. package/dist/prebuild/Report.css +10326 -0
  93. package/dist/prebuild/Report.js +37456 -0
  94. package/dist/types/Features.d.ts +5 -5
  95. package/dist/types/Node.d.ts +4 -11
  96. package/dist/types/NodeWriter.d.ts +1 -1
  97. package/dist/types/Project.d.ts +2 -27
  98. package/dist/types/SubPackages/puppeteer.d.ts +6 -0
  99. package/dist/types/SubPackages/react/component/node.d.ts +7 -0
  100. package/dist/types/SubPackages/react/component/web.d.ts +7 -0
  101. package/dist/types/SubPackages/react/jsx/index.d.ts +15 -0
  102. package/dist/types/SubPackages/react/jsx/node.d.ts +4 -0
  103. package/dist/types/SubPackages/react/jsx/web.d.ts +4 -0
  104. package/dist/types/{subPackages → SubPackages}/react-dom/component/node.d.ts +2 -4
  105. package/dist/types/SubPackages/react-dom/component/web.d.ts +5 -0
  106. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +6 -0
  107. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +5 -0
  108. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +5 -0
  109. package/dist/types/{subPackages → SubPackages}/react-test-renderer/component/index.d.ts +6 -6
  110. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +9 -0
  111. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +4 -0
  112. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +8 -0
  113. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +8 -0
  114. package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx/index.d.ts +5 -4
  115. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +9 -0
  116. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +9 -0
  117. package/dist/types/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.d.ts +4 -4
  118. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +5 -0
  119. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +5 -0
  120. package/dist/types/Types.d.ts +116 -3
  121. package/dist/types/Web.d.ts +4 -11
  122. package/dist/types/esbuildConfigs/features.d.ts +4 -0
  123. package/dist/types/esbuildConfigs/index.d.ts +4 -0
  124. package/dist/types/esbuildConfigs/node.d.ts +4 -0
  125. package/dist/types/esbuildConfigs/report.d.ts +0 -0
  126. package/dist/types/esbuildConfigs/tests.d.ts +4 -0
  127. package/dist/types/esbuildConfigs/web.d.ts +4 -0
  128. package/dist/types/lib/abstractBase.d.ts +102 -0
  129. package/dist/types/lib/basebuilder.d.ts +24 -0
  130. package/dist/types/lib/browser.d.ts +6 -0
  131. package/dist/types/lib/classBuilder.d.ts +6 -0
  132. package/dist/types/lib/core.d.ts +7 -0
  133. package/dist/types/lib/index.d.ts +57 -0
  134. package/dist/types/nodeWriterElectron.d.ts +2 -0
  135. package/dist/types/report.html.d.ts +2 -0
  136. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  137. package/dist/types/web.html.d.ts +2 -0
  138. package/electronBuild.ts +32 -0
  139. package/index.html +30 -0
  140. package/package.json +120 -85
  141. package/src/Features.ts +2 -4
  142. package/src/Node.ts +114 -160
  143. package/src/NodeWriter.ts +1 -4
  144. package/src/Project.ts +610 -753
  145. package/src/Report.tsx +30 -15
  146. package/src/SubPackages/puppeteer.ts +46 -0
  147. package/src/{subPackages → SubPackages}/react/component/node.ts +12 -32
  148. package/src/SubPackages/react/component/web.ts +53 -0
  149. package/src/SubPackages/react/jsx/index.ts +43 -0
  150. package/src/SubPackages/react/jsx/node.ts +29 -0
  151. package/src/SubPackages/react/jsx/web.ts +28 -0
  152. package/src/{subPackages → SubPackages}/react-dom/component/node.ts +11 -25
  153. package/src/{subPackages → SubPackages}/react-dom/component/web.ts +27 -32
  154. package/src/{subPackages → SubPackages}/react-dom/jsx/index.ts +0 -1
  155. package/src/SubPackages/react-dom/jsx/node.ts +68 -0
  156. package/src/{subPackages → SubPackages}/react-dom/jsx/web.ts +18 -54
  157. package/src/{subPackages → SubPackages}/react-test-renderer/MemoExoticComponent/node.ts +9 -28
  158. package/src/{subPackages → SubPackages}/react-test-renderer/component/index.ts +31 -29
  159. package/src/SubPackages/react-test-renderer/component/node.ts +22 -0
  160. package/src/SubPackages/react-test-renderer/component/web.ts +22 -0
  161. package/src/{subPackages → SubPackages}/react-test-renderer/fc/node.ts +14 -28
  162. package/src/{subPackages → SubPackages}/react-test-renderer/fc/web.ts +9 -25
  163. package/src/{subPackages → SubPackages}/react-test-renderer/jsx/index.ts +19 -16
  164. package/src/SubPackages/react-test-renderer/jsx/node.ts +24 -0
  165. package/src/SubPackages/react-test-renderer/jsx/web.ts +20 -0
  166. package/src/{subPackages → SubPackages}/react-test-renderer/jsx-promised/index.ts +7 -15
  167. package/src/SubPackages/react-test-renderer/jsx-promised/node.ts +19 -0
  168. package/src/SubPackages/react-test-renderer/jsx-promised/web.ts +22 -0
  169. package/src/Types.ts +334 -3
  170. package/src/Web.ts +104 -230
  171. package/src/cjs-shim.js +12 -0
  172. package/src/electron.ts +237 -46
  173. package/src/esbuildConfigs/features.ts +18 -0
  174. package/src/esbuildConfigs/index.ts +22 -0
  175. package/src/esbuildConfigs/node.ts +59 -0
  176. package/src/esbuildConfigs/report.ts +51 -0
  177. package/src/esbuildConfigs/tests.ts +20 -0
  178. package/src/esbuildConfigs/web.ts +73 -0
  179. package/src/lib/abstractBase.ts +459 -0
  180. package/src/lib/basebuilder.ts +253 -0
  181. package/src/lib/browser.ts +34 -0
  182. package/src/lib/classBuilder.ts +137 -0
  183. package/src/lib/core.ts +182 -0
  184. package/src/lib/index.ts +116 -0
  185. package/src/nodeWriterElectron.ts +71 -0
  186. package/src/preload.ts +23 -21
  187. package/src/report.html.ts +29 -0
  188. package/src/web.html.ts +20 -0
  189. package/tests/Rectangle.test.ts +189 -0
  190. package/tsconfig.json +19 -6
  191. package/tsconfig.module.json +15 -4
  192. package/tsconfig.types.json +14 -4
  193. package/yarn-error.log +3144 -0
  194. package/dist/common/core.js +0 -397
  195. package/dist/common/subPackages/react/jsx/index.js +0 -26
  196. package/dist/common/subPackages/react-dom/jsx/node.js +0 -95
  197. package/dist/common/subPackages/react-test-renderer/component/node.js +0 -8
  198. package/dist/common/subPackages/react-test-renderer/component/web.js +0 -8
  199. package/dist/module/Report.js +0 -186
  200. package/dist/module/core.js +0 -388
  201. package/dist/module/subPackages/react/jsx/index.js +0 -22
  202. package/dist/module/subPackages/react/jsx/node.js +0 -5
  203. package/dist/module/subPackages/react/jsx/web.js +0 -5
  204. package/dist/module/subPackages/react-dom/jsx/node.js +0 -87
  205. package/dist/module/subPackages/react-test-renderer/jsx/web.js +0 -5
  206. package/dist/module/subPackages/react-test-renderer/jsx-promised/node.js +0 -5
  207. package/dist/types/core.d.ts +0 -220
  208. package/dist/types/subPackages/react/component/node.d.ts +0 -12
  209. package/dist/types/subPackages/react/component/web.d.ts +0 -12
  210. package/dist/types/subPackages/react/jsx/index.d.ts +0 -15
  211. package/dist/types/subPackages/react/jsx/node.d.ts +0 -4
  212. package/dist/types/subPackages/react/jsx/web.d.ts +0 -4
  213. package/dist/types/subPackages/react-dom/component/web.d.ts +0 -19
  214. package/dist/types/subPackages/react-dom/jsx/node.d.ts +0 -8
  215. package/dist/types/subPackages/react-dom/jsx/web.d.ts +0 -5
  216. package/dist/types/subPackages/react-test-renderer/MemoExoticComponent/node.d.ts +0 -8
  217. package/dist/types/subPackages/react-test-renderer/component/node.d.ts +0 -9
  218. package/dist/types/subPackages/react-test-renderer/component/web.d.ts +0 -9
  219. package/dist/types/subPackages/react-test-renderer/fc/node.d.ts +0 -9
  220. package/dist/types/subPackages/react-test-renderer/fc/web.d.ts +0 -9
  221. package/dist/types/subPackages/react-test-renderer/jsx/node.d.ts +0 -4
  222. package/dist/types/subPackages/react-test-renderer/jsx/web.d.ts +0 -4
  223. package/dist/types/subPackages/react-test-renderer/jsx-promised/node.d.ts +0 -4
  224. package/dist/types/subPackages/react-test-renderer/jsx-promised/web.d.ts +0 -4
  225. package/src/core.ts +0 -1399
  226. package/src/subPackages/react/component/web.ts +0 -80
  227. package/src/subPackages/react/jsx/index.ts +0 -64
  228. package/src/subPackages/react/jsx/node.ts +0 -29
  229. package/src/subPackages/react/jsx/web.ts +0 -29
  230. package/src/subPackages/react-dom/jsx/node.ts +0 -145
  231. package/src/subPackages/react-test-renderer/component/node.ts +0 -30
  232. package/src/subPackages/react-test-renderer/component/web.ts +0 -30
  233. package/src/subPackages/react-test-renderer/jsx/node.ts +0 -31
  234. package/src/subPackages/react-test-renderer/jsx/web.ts +0 -31
  235. package/src/subPackages/react-test-renderer/jsx-promised/node.ts +0 -31
  236. package/src/subPackages/react-test-renderer/jsx-promised/web.ts +0 -31
  237. /package/dist/common/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
  238. /package/dist/common/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
  239. /package/dist/module/{subPackages → SubPackages}/react-dom/jsx/index.js +0 -0
  240. /package/dist/module/{subPackages → SubPackages}/react-test-renderer/jsx-promised/web.js +0 -0
  241. /package/dist/types/{subPackages → SubPackages}/react-dom/jsx/index.d.ts +0 -0
@@ -0,0 +1,459 @@
1
+ import { ITTestResourceConfiguration, ITestArtifactory, ITLog } from ".";
2
+ import { IBaseTest, IUtils } from "../Types";
3
+
4
+ export type IGivens<
5
+ ITestShape extends IBaseTest
6
+ > = Record<
7
+ string,
8
+ BaseGiven<
9
+ ITestShape
10
+ >
11
+ >;
12
+
13
+ export abstract class BaseSuite<
14
+ ITestShape extends IBaseTest
15
+ > {
16
+ name: string;
17
+ givens: IGivens<
18
+ ITestShape
19
+ >;
20
+ checks: BaseCheck<
21
+ ITestShape
22
+ >[];
23
+ store: ITestShape['istore'];
24
+ fails: BaseGiven<
25
+ ITestShape
26
+ >[];
27
+ testResourceConfiguration: ITTestResourceConfiguration;
28
+ index: number;
29
+
30
+ constructor(
31
+ name: string,
32
+ index: number,
33
+ givens: IGivens<
34
+ ITestShape
35
+ > = {},
36
+ checks: BaseCheck<
37
+ ITestShape
38
+ >[] = []
39
+ ) {
40
+ this.name = name;
41
+ this.index = index;
42
+ this.givens = givens;
43
+ this.checks = checks;
44
+ this.fails = [];
45
+ }
46
+
47
+ public toObj() {
48
+ return {
49
+ name: this.name,
50
+ givens: Object.keys(this.givens).map((k) => this.givens[k].toObj()),
51
+ fails: this.fails,
52
+ };
53
+ }
54
+
55
+ setup(
56
+ s: ITestShape['iinput'],
57
+ artifactory: ITestArtifactory,
58
+ tr: ITTestResourceConfiguration,
59
+ utils: IUtils
60
+ ): Promise<ITestShape['isubject']> {
61
+ return new Promise((res) => res(s as unknown as ITestShape['isubject']));
62
+ }
63
+
64
+ assertThat(t: ITestShape['then']): unknown {
65
+ // console.log("base assertThat")
66
+ return t;
67
+ }
68
+
69
+ async run(
70
+ input: ITestShape['iinput'],
71
+ testResourceConfiguration: ITTestResourceConfiguration,
72
+ artifactory: (
73
+ fPath: string,
74
+ value: unknown
75
+ ) => void,
76
+ tLog: (...string) => void,
77
+ utils: IUtils
78
+ ): Promise<
79
+ BaseSuite<
80
+ ITestShape
81
+ >
82
+ > {
83
+ this.testResourceConfiguration = testResourceConfiguration;
84
+ tLog("test resources: ", testResourceConfiguration);
85
+
86
+ const suiteArtifactory = (fPath: string, value: unknown) =>
87
+ artifactory(`suite-${this.index}-${this.name}/${fPath}`, value)
88
+ const subject = await this.setup(
89
+ input,
90
+ suiteArtifactory,
91
+ testResourceConfiguration,
92
+ utils
93
+ );
94
+
95
+ tLog("\nSuite:", this.index, this.name);
96
+ for (const k of Object.keys(this.givens)) {
97
+ const giver = this.givens[k];
98
+ try {
99
+ this.store = await giver.give(
100
+ subject,
101
+ k,
102
+ testResourceConfiguration,
103
+ this.assertThat,
104
+ suiteArtifactory,
105
+ tLog,
106
+ utils
107
+ );
108
+ } catch (e) {
109
+ console.error(e);
110
+ this.fails.push(giver);
111
+ return this;
112
+ }
113
+ }
114
+ for (const [ndx, thater] of this.checks.entries()) {
115
+ await thater.check(
116
+ subject,
117
+ thater.name,
118
+ testResourceConfiguration,
119
+ this.assertThat,
120
+ suiteArtifactory,
121
+ tLog,
122
+ utils
123
+ );
124
+ }
125
+
126
+ // @TODO fix me
127
+ for (const k of Object.keys(this.givens)) {
128
+ const giver = this.givens[k];
129
+ giver.afterAll(this.store, artifactory, utils);
130
+ }
131
+ ////////////////
132
+
133
+ return this;
134
+ }
135
+ }
136
+
137
+ export abstract class BaseGiven<
138
+ ITestShape extends IBaseTest
139
+ > {
140
+ name: string;
141
+ features: string[];
142
+ whens: BaseWhen<
143
+ ITestShape
144
+ >[];
145
+ thens: BaseThen<
146
+ ITestShape
147
+ >[];
148
+ error: Error;
149
+ store: ITestShape['istore'];
150
+ recommendedFsPath: string;
151
+ givenCB: ITestShape['given'];
152
+ initialValues: any;
153
+
154
+ constructor(
155
+ name: string,
156
+ features: string[],
157
+ whens: BaseWhen<
158
+ ITestShape
159
+ >[],
160
+ thens: BaseThen<
161
+ ITestShape
162
+ >[],
163
+ givenCB: ITestShape['given'],
164
+ initialValues: any
165
+ ) {
166
+ this.name = name;
167
+ this.features = features;
168
+ this.whens = whens;
169
+ this.thens = thens;
170
+ this.givenCB = givenCB;
171
+ this.initialValues = initialValues;
172
+ }
173
+
174
+ beforeAll(
175
+ store: ITestShape['istore'],
176
+ artifactory: ITestArtifactory,
177
+
178
+ ) {
179
+ return store;
180
+ }
181
+
182
+ afterAll(
183
+ store: ITestShape['istore'],
184
+ artifactory: ITestArtifactory,
185
+ utils: IUtils
186
+ ) {
187
+ return store;
188
+ }
189
+
190
+ toObj() {
191
+ return {
192
+ name: this.name,
193
+ whens: this.whens.map((w) => w.toObj()),
194
+ thens: this.thens.map((t) => t.toObj()),
195
+ error: this.error ? [this.error, this.error.stack] : null,
196
+ features: this.features,
197
+ };
198
+ }
199
+
200
+ abstract givenThat(
201
+ subject: ITestShape['isubject'],
202
+ testResourceConfiguration,
203
+ artifactory: ITestArtifactory,
204
+ givenCB: ITestShape['given']
205
+ ): Promise<ITestShape['istore']>;
206
+
207
+ async afterEach(
208
+ store: ITestShape['istore'],
209
+ key: string,
210
+ artifactory: ITestArtifactory
211
+ ): Promise<unknown> {
212
+ return store;
213
+ }
214
+
215
+ async give(
216
+ subject: ITestShape['isubject'],
217
+ key: string,
218
+ testResourceConfiguration,
219
+ tester,
220
+ artifactory: ITestArtifactory,
221
+ tLog: ITLog,
222
+ utils: IUtils
223
+ ) {
224
+ tLog(`\n Given: ${this.name}`);
225
+
226
+ const givenArtifactory = (fPath: string, value: unknown) =>
227
+ artifactory(`given-${key}/${fPath}`, value)
228
+ try {
229
+ this.store = await this.givenThat(
230
+ subject,
231
+ testResourceConfiguration,
232
+ givenArtifactory,
233
+ this.givenCB
234
+ );
235
+
236
+ // tLog(`\n Given this.store`, this.store);
237
+ for (const whenStep of this.whens) {
238
+ await whenStep.test(
239
+ this.store,
240
+ testResourceConfiguration,
241
+ tLog,
242
+ utils
243
+ );
244
+ }
245
+ for (const thenStep of this.thens) {
246
+ const t = await thenStep.test(
247
+ this.store,
248
+ testResourceConfiguration,
249
+ tLog,
250
+ utils
251
+ );
252
+ tester(t);
253
+ }
254
+ } catch (e) {
255
+ this.error = e;
256
+ tLog(e);
257
+ tLog("\u0007"); // bell
258
+ // throw e;
259
+ } finally {
260
+ try {
261
+ await this.afterEach(this.store, key, givenArtifactory);
262
+ } catch (e) {
263
+ console.error("afterEach failed! no error will be recorded!", e);
264
+ }
265
+ }
266
+ return this.store;
267
+ }
268
+ }
269
+
270
+ export abstract class BaseWhen<
271
+ ITestShape extends IBaseTest
272
+ > {
273
+ public name: string;
274
+ whenCB: (x: ITestShape['iselection']) => ITestShape['then'];
275
+ error: boolean;
276
+
277
+ constructor(
278
+ name: string,
279
+ whenCB: (xyz: ITestShape['iselection']) => ITestShape['then']) {
280
+ this.name = name;
281
+ this.whenCB = whenCB;
282
+ }
283
+
284
+ abstract andWhen(
285
+ store: ITestShape['istore'],
286
+ whenCB: (x: ITestShape['iselection']) => ITestShape['then'],
287
+ testResource
288
+ );
289
+
290
+ toObj() {
291
+ return {
292
+ name: this.name,
293
+ error: this.error,
294
+ };
295
+ }
296
+
297
+ async test(
298
+ store: ITestShape['istore'],
299
+ testResourceConfiguration,
300
+ tLog: ITLog,
301
+ utils: IUtils
302
+ ) {
303
+ tLog(" When:", this.name);
304
+ try {
305
+ return await this.andWhen(
306
+ store,
307
+ this.whenCB,
308
+ testResourceConfiguration
309
+ );
310
+ } catch (e) {
311
+ this.error = true;
312
+ throw e;
313
+ }
314
+ }
315
+ }
316
+
317
+ export abstract class BaseThen<
318
+ ITestShape extends IBaseTest
319
+ > {
320
+ public name: string;
321
+ thenCB: (storeState: ITestShape['iselection']) => ITestShape['then'];
322
+ error: boolean;
323
+
324
+ constructor(name: string, thenCB: (val: ITestShape['iselection']) => ITestShape['then']) {
325
+ this.name = name;
326
+ this.thenCB = thenCB;
327
+ }
328
+
329
+ toObj() {
330
+ return {
331
+ name: this.name,
332
+ error: this.error,
333
+ };
334
+ }
335
+
336
+ abstract butThen(
337
+ store: ITestShape['istore'],
338
+ thenCB,
339
+ testResourceConfiguration?
340
+ ): Promise<ITestShape['iselection']>;
341
+
342
+ async test(
343
+ store: ITestShape['istore'],
344
+ testResourceConfiguration,
345
+ tLog: ITLog,
346
+ utils: IUtils
347
+ ): Promise<ITestShape['then'] | undefined> {
348
+ tLog(" Then:", this.name);
349
+ try {
350
+ const x = (await this.butThen(
351
+ store,
352
+ this.thenCB,
353
+ testResourceConfiguration
354
+ ));
355
+ return x;
356
+ } catch (e) {
357
+ console.log("test failed", e);
358
+ this.error = true;
359
+ throw e;
360
+ }
361
+ }
362
+ }
363
+
364
+ export abstract class BaseCheck<
365
+ ITestShape extends IBaseTest
366
+ > {
367
+ name: string;
368
+ features: string[];
369
+ checkCB: (whens, thens) => any;
370
+ whens: {
371
+ [K in keyof ITestShape["whens"]]: (
372
+ p,
373
+ tc
374
+ ) => BaseWhen<
375
+ ITestShape
376
+ >;
377
+ };
378
+ thens: {
379
+ [K in keyof ITestShape["thens"]]: (
380
+ p,
381
+ tc
382
+ ) => BaseThen<
383
+ ITestShape
384
+ >;
385
+ };
386
+
387
+ constructor(
388
+ name: string,
389
+ features: string[],
390
+ checkCB: (whens, thens) => any,
391
+ whens,
392
+ thens
393
+ ) {
394
+ this.name = name;
395
+ this.features = features;
396
+ this.checkCB = checkCB;
397
+ this.whens = whens;
398
+ this.thens = thens;
399
+ }
400
+
401
+ abstract checkThat(
402
+ subject: ITestShape['isubject'],
403
+ testResourceConfiguration,
404
+ artifactory: ITestArtifactory
405
+ ): Promise<ITestShape['istore']>;
406
+
407
+ async afterEach(
408
+ store: ITestShape['istore'],
409
+ key: string,
410
+ cb?
411
+ ): Promise<unknown> {
412
+ return;
413
+ }
414
+
415
+ async check(
416
+ subject: ITestShape['isubject'],
417
+ key: string,
418
+ testResourceConfiguration,
419
+ tester,
420
+ artifactory: ITestArtifactory,
421
+ tLog: ITLog,
422
+ utils: IUtils
423
+ ) {
424
+ tLog(`\n Check: ${this.name}`);
425
+ const store = await this.checkThat(
426
+ subject,
427
+ testResourceConfiguration,
428
+ artifactory
429
+ );
430
+ await this.checkCB(
431
+ Object.entries(this.whens).reduce((a, [key, when]) => {
432
+ a[key] = async (payload) => {
433
+ return await when(payload, testResourceConfiguration).test(
434
+ store,
435
+ testResourceConfiguration,
436
+ tLog,
437
+ utils
438
+ );
439
+ };
440
+ return a;
441
+ }, {}),
442
+ Object.entries(this.thens).reduce((a, [key, then]) => {
443
+ a[key] = async (payload) => {
444
+ const t = await then(payload, testResourceConfiguration).test(
445
+ store,
446
+ testResourceConfiguration,
447
+ tLog,
448
+ utils
449
+ );
450
+ tester(t);
451
+ };
452
+ return a;
453
+ }, {})
454
+ );
455
+
456
+ await this.afterEach(store, key);
457
+ return;
458
+ }
459
+ }
@@ -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
+ }