testeranto 0.111.0 → 0.112.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 (177) hide show
  1. package/dist/common/Init.js +68 -0
  2. package/dist/common/Node.js +27 -0
  3. package/dist/common/PM/index.js +7 -0
  4. package/dist/common/PM/main.js +1176 -0
  5. package/dist/common/PM/node.js +128 -0
  6. package/dist/common/PM/web.js +121 -0
  7. package/dist/common/ReportServer.js +22 -0
  8. package/dist/common/SubPackages/react/component/node.js +19 -0
  9. package/dist/common/SubPackages/react/component/web.js +19 -0
  10. package/dist/common/SubPackages/react/jsx/index.js +21 -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/react-dom/component/node.js +88 -0
  14. package/dist/common/SubPackages/react-dom/component/web.js +67 -0
  15. package/dist/common/SubPackages/react-dom/jsx/index.js +2 -0
  16. package/dist/common/SubPackages/react-dom/jsx/node.js +39 -0
  17. package/dist/common/SubPackages/react-dom/jsx/web.js +128 -0
  18. package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +54 -0
  19. package/dist/common/SubPackages/react-test-renderer/component/index.js +2 -0
  20. package/dist/common/SubPackages/react-test-renderer/component/interface.js +70 -0
  21. package/dist/common/SubPackages/react-test-renderer/component/node.js +8 -0
  22. package/dist/common/SubPackages/react-test-renderer/component/web.js +8 -0
  23. package/dist/common/SubPackages/react-test-renderer/fc/node.js +60 -0
  24. package/dist/common/SubPackages/react-test-renderer/fc/web.js +60 -0
  25. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +67 -0
  26. package/dist/common/SubPackages/react-test-renderer/jsx/node.js +10 -0
  27. package/dist/common/SubPackages/react-test-renderer/jsx/web.js +10 -0
  28. package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +52 -0
  29. package/dist/common/SubPackages/react-test-renderer/jsx-promised/node.js +10 -0
  30. package/dist/common/SubPackages/react-test-renderer/jsx-promised/web.js +10 -0
  31. package/dist/common/Types.js +2 -0
  32. package/dist/common/Web.js +49 -0
  33. package/dist/common/build.js +222 -0
  34. package/dist/common/defaultConfig.js +20 -0
  35. package/dist/common/esbuildConfigs/eslint-formatter-testeranto.js +6 -0
  36. package/dist/common/esbuildConfigs/featuresPlugin.js +39 -0
  37. package/dist/common/esbuildConfigs/index.js +21 -0
  38. package/dist/common/esbuildConfigs/inputFilesPlugin.js +27 -0
  39. package/dist/common/esbuildConfigs/node.js +37 -0
  40. package/dist/common/esbuildConfigs/web.js +50 -0
  41. package/dist/common/init-docs.js +53 -0
  42. package/dist/common/lib/abstractBase.js +329 -0
  43. package/dist/common/lib/basebuilder.js +98 -0
  44. package/dist/common/lib/classBuilder.js +40 -0
  45. package/dist/common/lib/core.js +117 -0
  46. package/dist/common/lib/index.js +21 -0
  47. package/dist/common/lib/types.js +2 -0
  48. package/dist/common/package.json +3 -0
  49. package/dist/common/puppeteerConfiger.js +24 -0
  50. package/dist/common/run.js +62 -0
  51. package/dist/common/tsconfig.common.tsbuildinfo +1 -0
  52. package/dist/common/utils.js +43 -0
  53. package/dist/common/web.html.js +22 -0
  54. package/dist/module/Footer.js +4 -0
  55. package/dist/module/Init.js +63 -0
  56. package/dist/module/Node.js +20 -0
  57. package/dist/module/PM/index.js +3 -0
  58. package/dist/module/PM/main.js +1136 -0
  59. package/dist/module/PM/node.js +121 -0
  60. package/dist/module/PM/web.js +117 -0
  61. package/dist/module/ReportClient.js +97 -0
  62. package/dist/module/ReportServer.js +17 -0
  63. package/dist/module/SubPackages/react/component/node.js +14 -0
  64. package/dist/module/SubPackages/react/component/web.js +14 -0
  65. package/dist/module/SubPackages/react/jsx/index.js +15 -0
  66. package/dist/module/SubPackages/react/jsx/node.js +5 -0
  67. package/dist/module/SubPackages/react/jsx/web.js +5 -0
  68. package/dist/module/SubPackages/react-dom/component/node.js +80 -0
  69. package/dist/module/SubPackages/react-dom/component/web.js +62 -0
  70. package/dist/module/SubPackages/react-dom/jsx/index.js +1 -0
  71. package/dist/module/SubPackages/react-dom/jsx/node.js +31 -0
  72. package/dist/module/SubPackages/react-dom/jsx/web.js +90 -0
  73. package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +16 -0
  74. package/dist/module/SubPackages/react-test-renderer/component/index.js +1 -0
  75. package/dist/module/SubPackages/react-test-renderer/component/interface.js +31 -0
  76. package/dist/module/SubPackages/react-test-renderer/component/node.js +3 -0
  77. package/dist/module/SubPackages/react-test-renderer/component/web.js +3 -0
  78. package/dist/module/SubPackages/react-test-renderer/fc/node.js +22 -0
  79. package/dist/module/SubPackages/react-test-renderer/fc/web.js +22 -0
  80. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +28 -0
  81. package/dist/module/SubPackages/react-test-renderer/jsx/node.js +5 -0
  82. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +5 -0
  83. package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +16 -0
  84. package/dist/module/SubPackages/react-test-renderer/jsx-promised/node.js +5 -0
  85. package/dist/module/SubPackages/react-test-renderer/jsx-promised/web.js +5 -0
  86. package/dist/module/TestReport.js +91 -0
  87. package/dist/module/Types.js +1 -0
  88. package/dist/module/Web.js +42 -0
  89. package/dist/module/build.js +184 -0
  90. package/dist/module/defaultConfig.js +18 -0
  91. package/dist/module/esbuildConfigs/eslint-formatter-testeranto.js +3 -0
  92. package/dist/module/esbuildConfigs/featuresPlugin.js +34 -0
  93. package/dist/module/esbuildConfigs/index.js +19 -0
  94. package/dist/module/esbuildConfigs/inputFilesPlugin.js +22 -0
  95. package/dist/module/esbuildConfigs/node.js +32 -0
  96. package/dist/module/esbuildConfigs/web.js +45 -0
  97. package/dist/module/init-docs.js +15 -0
  98. package/dist/module/lib/abstractBase.js +321 -0
  99. package/dist/module/lib/basebuilder.js +94 -0
  100. package/dist/module/lib/classBuilder.js +36 -0
  101. package/dist/module/lib/core.js +114 -0
  102. package/dist/module/lib/index.js +17 -0
  103. package/dist/module/lib/types.js +1 -0
  104. package/dist/module/package.json +3 -0
  105. package/dist/module/puppeteerConfiger.js +19 -0
  106. package/dist/module/run.js +24 -0
  107. package/dist/module/tsconfig.module.tsbuildinfo +1 -0
  108. package/dist/module/utils.js +29 -0
  109. package/dist/module/web.html.js +20 -0
  110. package/dist/prebuild/ReportClient.css +11367 -0
  111. package/dist/prebuild/ReportClient.js +24641 -0
  112. package/dist/prebuild/ReportServer.mjs +16 -0
  113. package/dist/prebuild/TestReport.css +11367 -0
  114. package/dist/prebuild/TestReport.js +27484 -0
  115. package/dist/prebuild/build.mjs +376 -0
  116. package/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs +9 -0
  117. package/dist/prebuild/init-docs.mjs +104 -0
  118. package/dist/prebuild/run.mjs +1153 -0
  119. package/dist/tsconfig.tsbuildinfo +1 -0
  120. package/dist/types/Init.d.ts +2 -0
  121. package/dist/types/Node.d.ts +12 -0
  122. package/dist/types/PM/index.d.ts +34 -0
  123. package/dist/types/PM/main.d.ts +66 -0
  124. package/dist/types/PM/node.d.ts +40 -0
  125. package/dist/types/PM/web.d.ts +38 -0
  126. package/dist/types/ReportServer.d.ts +1 -0
  127. package/dist/types/SubPackages/react/component/node.d.ts +7 -0
  128. package/dist/types/SubPackages/react/component/web.d.ts +7 -0
  129. package/dist/types/SubPackages/react/jsx/index.d.ts +12 -0
  130. package/dist/types/SubPackages/react/jsx/node.d.ts +4 -0
  131. package/dist/types/SubPackages/react/jsx/web.d.ts +4 -0
  132. package/dist/types/SubPackages/react-dom/component/node.d.ts +11 -0
  133. package/dist/types/SubPackages/react-dom/component/web.d.ts +20 -0
  134. package/dist/types/SubPackages/react-dom/jsx/index.d.ts +6 -0
  135. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +7 -0
  136. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +5 -0
  137. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +6 -0
  138. package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +13 -0
  139. package/dist/types/SubPackages/react-test-renderer/component/interface.d.ts +9 -0
  140. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +4 -0
  141. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +4 -0
  142. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +8 -0
  143. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +9 -0
  144. package/dist/types/SubPackages/react-test-renderer/jsx/index.d.ts +16 -0
  145. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +9 -0
  146. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +9 -0
  147. package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +15 -0
  148. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +5 -0
  149. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +5 -0
  150. package/dist/types/Types.d.ts +61 -0
  151. package/dist/types/Web.d.ts +9 -0
  152. package/dist/types/build.d.ts +1 -0
  153. package/dist/types/defaultConfig.d.ts +3 -0
  154. package/dist/types/esbuildConfigs/eslint-formatter-testeranto.d.ts +2 -0
  155. package/dist/types/esbuildConfigs/featuresPlugin.d.ts +5 -0
  156. package/dist/types/esbuildConfigs/index.d.ts +4 -0
  157. package/dist/types/esbuildConfigs/inputFilesPlugin.d.ts +6 -0
  158. package/dist/types/esbuildConfigs/node.d.ts +4 -0
  159. package/dist/types/esbuildConfigs/web.d.ts +4 -0
  160. package/dist/types/init-docs.d.ts +1 -0
  161. package/dist/types/lib/abstractBase.d.ts +110 -0
  162. package/dist/types/lib/basebuilder.d.ts +27 -0
  163. package/dist/types/lib/classBuilder.d.ts +7 -0
  164. package/dist/types/lib/core.d.ts +7 -0
  165. package/dist/types/lib/index.d.ts +83 -0
  166. package/dist/types/lib/types.d.ts +14 -0
  167. package/dist/types/puppeteerConfiger.d.ts +4 -0
  168. package/dist/types/run.d.ts +1 -0
  169. package/dist/types/tsconfig.types.tsbuildinfo +1 -0
  170. package/dist/types/utils.d.ts +15 -0
  171. package/dist/types/web.html.d.ts +2 -0
  172. package/package.json +1 -1
  173. package/src/PM/main.ts +25 -57
  174. package/src/ReportClient.tsx +43 -41
  175. package/src/run.ts +8 -5
  176. package/src/utils.ts +10 -0
  177. package/tsc.log +8 -8
@@ -0,0 +1,329 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseCheck = exports.BaseThen = exports.BaseWhen = exports.BaseGiven = exports.BaseSuite = void 0;
4
+ class BaseSuite {
5
+ constructor(name, index, givens = {}, checks = []) {
6
+ this.name = name;
7
+ this.index = index;
8
+ this.givens = givens;
9
+ this.checks = checks;
10
+ this.fails = [];
11
+ }
12
+ features() {
13
+ const features = Object.keys(this.givens)
14
+ .map((k) => this.givens[k].features)
15
+ .flat()
16
+ .filter((value, index, array) => {
17
+ return array.indexOf(value) === index;
18
+ });
19
+ // .reduce((mm, lm) => {
20
+ // mm[lm] = lm;
21
+ // return mm;
22
+ // }, {});
23
+ return features || [];
24
+ }
25
+ toObj() {
26
+ const givens = Object.keys(this.givens).map((k) => this.givens[k].toObj());
27
+ return {
28
+ name: this.name,
29
+ givens,
30
+ fails: this.fails,
31
+ features: this.features(),
32
+ };
33
+ }
34
+ setup(s, artifactory, tr, pm) {
35
+ return new Promise((res) => res(s));
36
+ }
37
+ assertThat(t) {
38
+ return t;
39
+ }
40
+ afterAll(store, artifactory, pm) {
41
+ return store;
42
+ }
43
+ async run(input, testResourceConfiguration, artifactory, tLog, pm) {
44
+ this.testResourceConfiguration = testResourceConfiguration;
45
+ tLog("test resources: ", JSON.stringify(testResourceConfiguration));
46
+ const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
47
+ // console.log("\nSuite:", this.index, this.name);
48
+ tLog("\nSuite:", this.index, this.name);
49
+ const sNdx = this.index;
50
+ const sName = this.name;
51
+ for (const [gKey, g] of Object.entries(this.givens)) {
52
+ // console.log("gKey", gKey);
53
+ const beforeAllProxy = new Proxy(pm, {
54
+ get(target, prop, receiver) {
55
+ if (prop === "customScreenShot") {
56
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
57
+ // path: `${filepath}/${opts.path}`,
58
+ path: `suite-${sNdx}/beforeAll/${opts.path}` }), p);
59
+ }
60
+ if (prop === "writeFileSync") {
61
+ return (fp, contents) => target[prop](`suite-${sNdx}/beforeAll/${fp}`, contents);
62
+ }
63
+ /* @ts-ignore:next-line */
64
+ return Reflect.get(...arguments);
65
+ },
66
+ });
67
+ const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, beforeAllProxy);
68
+ const giver = this.givens[gKey];
69
+ try {
70
+ this.store = await giver.give(subject, gKey, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
71
+ }
72
+ catch (e) {
73
+ console.error(e);
74
+ this.fails.push(giver);
75
+ // return this;
76
+ }
77
+ }
78
+ try {
79
+ this.afterAll(this.store, artifactory,
80
+ // afterAllProxy
81
+ pm);
82
+ }
83
+ catch (e) {
84
+ console.error(e);
85
+ // this.fails.push(this);
86
+ // return this;
87
+ }
88
+ // for (const [ndx, thater] of this.checks.entries()) {
89
+ // await thater.check(
90
+ // subject,
91
+ // thater.name,
92
+ // testResourceConfiguration,
93
+ // this.assertThat,
94
+ // suiteArtifactory,
95
+ // tLog,
96
+ // pm
97
+ // );
98
+ // }
99
+ // @TODO fix me
100
+ // for (const k of Object.keys(this.givens)) {
101
+ // const giver = this.givens[k];
102
+ // try {
103
+ // giver.afterAll(this.store, artifactory, pm);
104
+ // } catch (e) {
105
+ // console.error(e);
106
+ // this.fails.push(giver);
107
+ // return this;
108
+ // }
109
+ // }
110
+ ////////////////
111
+ return this;
112
+ }
113
+ }
114
+ exports.BaseSuite = BaseSuite;
115
+ class BaseGiven {
116
+ constructor(name, features, whens, thens, givenCB, initialValues
117
+ // key: string
118
+ ) {
119
+ this.name = name;
120
+ this.features = features;
121
+ this.whens = whens;
122
+ this.thens = thens;
123
+ this.givenCB = givenCB;
124
+ this.initialValues = initialValues;
125
+ }
126
+ beforeAll(store,
127
+ // artifactory: ITestArtifactory
128
+ // subject,
129
+ initializer, artifactory, testResource, initialValues, pm) {
130
+ return store;
131
+ }
132
+ toObj() {
133
+ return {
134
+ key: this.key,
135
+ name: this.name,
136
+ whens: this.whens.map((w) => w.toObj()),
137
+ thens: this.thens.map((t) => t.toObj()),
138
+ error: this.error ? [this.error, this.error.stack] : null,
139
+ // fail: this.fail ? [this.fail] : false,
140
+ features: this.features,
141
+ };
142
+ }
143
+ async afterEach(store, key, artifactory, pm) {
144
+ return store;
145
+ }
146
+ async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
147
+ this.key = key;
148
+ tLog(`\n ${this.key}`);
149
+ tLog(`\n Given: ${this.name}`);
150
+ const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
151
+ try {
152
+ // tLog(`\n Given this.store`, this.store);
153
+ const beforeEachProxy = new Proxy(pm, {
154
+ get(target, prop, receiver) {
155
+ if (prop === "writeFileSync") {
156
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
157
+ }
158
+ if (prop === "customScreenShot") {
159
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/when/beforeEach/${opts.path}` }), p);
160
+ }
161
+ if (prop === "screencast") {
162
+ return (opts, p) => target.screencast(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/when/beforeEach/${opts.path}` }), p);
163
+ }
164
+ /* @ts-ignore:next-line */
165
+ return Reflect.get(...arguments);
166
+ },
167
+ });
168
+ this.uberCatcher((e) => {
169
+ console.error(e);
170
+ this.error = e.error;
171
+ tLog(e.stack);
172
+ });
173
+ this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, this.initialValues, beforeEachProxy);
174
+ for (const [whenNdx, whenStep] of this.whens.entries()) {
175
+ await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
176
+ }
177
+ for (const [thenNdx, thenStep] of this.thens.entries()) {
178
+ const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/then-${thenNdx}`);
179
+ tester(t);
180
+ }
181
+ }
182
+ catch (e) {
183
+ console.error(e);
184
+ this.error = e;
185
+ tLog(e.stack);
186
+ // tLog("\u0007"); // bell
187
+ // throw e;
188
+ }
189
+ finally {
190
+ try {
191
+ const afterEachProxy = new Proxy(pm, {
192
+ get(target, prop, receiver) {
193
+ if (prop === "customScreenShot") {
194
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/afterEach/${opts.path}` }), p);
195
+ }
196
+ if (prop === "writeFileSync") {
197
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterEach/${fp}`, contents);
198
+ }
199
+ /* @ts-ignore:next-line */
200
+ return Reflect.get(...arguments);
201
+ },
202
+ });
203
+ await this.afterEach(this.store, this.key, givenArtifactory,
204
+ // pm
205
+ afterEachProxy);
206
+ }
207
+ catch (e) {
208
+ console.error("afterEach failed! no error will be recorded!", e);
209
+ }
210
+ }
211
+ return this.store;
212
+ }
213
+ }
214
+ exports.BaseGiven = BaseGiven;
215
+ class BaseWhen {
216
+ constructor(name, whenCB) {
217
+ this.name = name;
218
+ this.whenCB = whenCB;
219
+ }
220
+ toObj() {
221
+ return {
222
+ name: this.name,
223
+ error: this.error,
224
+ };
225
+ }
226
+ async test(store, testResourceConfiguration, tLog, pm, filepath) {
227
+ tLog(" When:", this.name);
228
+ const name = this.name;
229
+ const andWhenProxy = new Proxy(pm, {
230
+ get(target, prop, receiver) {
231
+ if (prop === "customScreenShot") {
232
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }), p);
233
+ }
234
+ if (prop === "writeFileSync") {
235
+ return (fp, contents) => target[prop](`${filepath}/andWhen/${fp}`, contents);
236
+ }
237
+ /* @ts-ignore:next-line */
238
+ return Reflect.get(...arguments);
239
+ },
240
+ });
241
+ return await this.andWhen(store, this.whenCB, testResourceConfiguration, andWhenProxy).catch((e) => {
242
+ this.error = true;
243
+ // throw e;
244
+ });
245
+ // try {
246
+ // return await this.andWhen(
247
+ // store,
248
+ // this.whenCB,
249
+ // testResourceConfiguration,
250
+ // andWhenProxy
251
+ // );
252
+ // } catch (e) {
253
+ // this.error = true;
254
+ // throw e;
255
+ // }
256
+ }
257
+ }
258
+ exports.BaseWhen = BaseWhen;
259
+ class BaseThen {
260
+ constructor(name, thenCB) {
261
+ this.name = name;
262
+ this.thenCB = thenCB;
263
+ this.error = false;
264
+ }
265
+ toObj() {
266
+ return {
267
+ name: this.name,
268
+ error: this.error,
269
+ };
270
+ }
271
+ async test(store, testResourceConfiguration, tLog, pm, filepath) {
272
+ tLog(" Then:", this.name);
273
+ try {
274
+ const butThenProxy = new Proxy(pm, {
275
+ get(target, prop, receiver) {
276
+ if (prop === "customScreenShot") {
277
+ return (opts, p) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `${filepath}/${opts.path}` }), p);
278
+ }
279
+ if (prop === "writeFileSync") {
280
+ return (fp, contents) => target[prop](`${filepath}/${fp}`, contents);
281
+ }
282
+ /* @ts-ignore:next-line */
283
+ return Reflect.get(...arguments);
284
+ },
285
+ });
286
+ return this.butThen(store, this.thenCB, testResourceConfiguration, butThenProxy).catch((e) => {
287
+ this.error = true;
288
+ throw e;
289
+ });
290
+ }
291
+ catch (e) {
292
+ console.log("test failed", e);
293
+ this.error = e.message;
294
+ throw e;
295
+ }
296
+ }
297
+ }
298
+ exports.BaseThen = BaseThen;
299
+ class BaseCheck {
300
+ constructor(name, features, checkCB, whens, thens) {
301
+ this.name = name;
302
+ this.features = features;
303
+ this.checkCB = checkCB;
304
+ this.whens = whens;
305
+ this.thens = thens;
306
+ }
307
+ async afterEach(store, key, cb, pm) {
308
+ return;
309
+ }
310
+ async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
311
+ tLog(`\n Check: ${this.name}`);
312
+ const store = await this.checkThat(subject, testResourceConfiguration, artifactory, pm);
313
+ await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
314
+ a[key] = async (payload) => {
315
+ return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
316
+ };
317
+ return a;
318
+ }, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
319
+ a[key] = async (payload) => {
320
+ const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
321
+ tester(t);
322
+ };
323
+ return a;
324
+ }, {}));
325
+ await this.afterEach(store, key, () => { }, pm);
326
+ return;
327
+ }
328
+ }
329
+ exports.BaseCheck = BaseCheck;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseBuilder = void 0;
4
+ class BaseBuilder {
5
+ constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification) {
6
+ this.input = input;
7
+ this.artifacts = [];
8
+ this.artifacts = [];
9
+ this.testResourceRequirement = testResourceRequirement;
10
+ this.suitesOverrides = suitesOverrides;
11
+ this.givenOverides = givenOverides;
12
+ this.whenOverides = whenOverides;
13
+ this.thenOverides = thenOverides;
14
+ this.checkOverides = checkOverides;
15
+ this.testSpecification = testSpecification;
16
+ this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
17
+ this.testJobs = this.specs.map((suite) => {
18
+ const suiteRunner = (suite) => async (puppetMaster, tLog) => {
19
+ const x = await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
20
+ this.artifacts.push(p);
21
+ })(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
22
+ return x;
23
+ };
24
+ const runner = suiteRunner(suite);
25
+ return {
26
+ test: suite,
27
+ toObj: () => {
28
+ return suite.toObj();
29
+ },
30
+ runner,
31
+ receiveTestResourceConfig: async function (puppetMaster) {
32
+ const logFilePath = "log.txt";
33
+ const access = await puppetMaster.createWriteStream(logFilePath);
34
+ const tLog = (...l) => {
35
+ puppetMaster.write(access, `${l.toString()}\n`);
36
+ };
37
+ const suiteDone = await runner(puppetMaster, tLog);
38
+ const logPromise = new Promise((res, rej) => {
39
+ puppetMaster.end(access);
40
+ res(true);
41
+ });
42
+ const numberOfFailures = Object.keys(suiteDone.givens).filter((k) => {
43
+ return suiteDone.givens[k].error;
44
+ }).length;
45
+ puppetMaster.writeFileSync(`bdd_errors.txt`, numberOfFailures.toString());
46
+ const o = this.toObj();
47
+ puppetMaster.writeFileSync(`littleBoard.html`, `
48
+ <!DOCTYPE html>
49
+ <html lang="en">
50
+
51
+ <head>
52
+ <meta name="description" content="Webpage description goes here" />
53
+ <meta charset="utf-8" />
54
+ <title>kokomoBay - testeranto</title>
55
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
56
+ <meta name="author" content="" />
57
+
58
+ <link rel="stylesheet" href="/kokomoBay/docs/TestReport.css" />
59
+ <script src="/kokomoBay/docs/TestReport.js"></script>
60
+
61
+ </head>
62
+
63
+ <body>
64
+ <h1>Test report</h1>
65
+ <div id="root"/>
66
+ </body>
67
+ `);
68
+ puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
69
+ return {
70
+ failed: numberOfFailures,
71
+ artifacts: this.artifacts || [],
72
+ logPromise,
73
+ features: suiteDone.features(),
74
+ };
75
+ },
76
+ };
77
+ });
78
+ }
79
+ Specs() {
80
+ return this.specs;
81
+ }
82
+ Suites() {
83
+ return this.suitesOverrides;
84
+ }
85
+ Given() {
86
+ return this.givenOverides;
87
+ }
88
+ When() {
89
+ return this.whenOverides;
90
+ }
91
+ Then() {
92
+ return this.thenOverides;
93
+ }
94
+ Check() {
95
+ return this.checkOverides;
96
+ }
97
+ }
98
+ exports.BaseBuilder = BaseBuilder;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassBuilder = void 0;
4
+ const basebuilder_js_1 = require("./basebuilder.js");
5
+ class ClassBuilder extends basebuilder_js_1.BaseBuilder {
6
+ constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement) {
7
+ const classySuites = Object.entries(testImplementation.suites).reduce((a, [key], index) => {
8
+ a[key] = (somestring, givens, checks) => {
9
+ return new suiteKlasser.prototype.constructor(somestring, index, givens, checks);
10
+ };
11
+ return a;
12
+ }, {});
13
+ const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, g]) => {
14
+ a[key] = (features, whens, thens, givEn) => {
15
+ return new givenKlasser.prototype.constructor(key, features, whens, thens, testImplementation.givens[key], givEn);
16
+ };
17
+ return a;
18
+ }, {});
19
+ const classyWhens = Object.entries(testImplementation.whens).reduce((a, [key, whEn]) => {
20
+ a[key] = (payload) => {
21
+ return new whenKlasser.prototype.constructor(`${whEn.name}: ${payload && payload.toString()}`, whEn(payload));
22
+ };
23
+ return a;
24
+ }, {});
25
+ const classyThens = Object.entries(testImplementation.thens).reduce((a, [key, thEn]) => {
26
+ a[key] = (expected, x) => {
27
+ return new thenKlasser.prototype.constructor(`${thEn.name}: ${expected && expected.toString()}`, thEn(expected));
28
+ };
29
+ return a;
30
+ }, {});
31
+ const classyChecks = Object.entries(testImplementation.checks).reduce((a, [key, z]) => {
32
+ a[key] = (somestring, features, callback) => {
33
+ return new checkKlasser.prototype.constructor(somestring, features, callback, classyWhens, classyThens);
34
+ };
35
+ return a;
36
+ }, {});
37
+ super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks, testResourceRequirement, testSpecification);
38
+ }
39
+ }
40
+ exports.ClassBuilder = ClassBuilder;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_js_1 = require("./index.js");
4
+ const abstractBase_js_1 = require("./abstractBase.js");
5
+ const classBuilder_js_1 = require("./classBuilder.js");
6
+ class Testeranto extends classBuilder_js_1.ClassBuilder {
7
+ constructor(input, testSpecification, testImplementation, testResourceRequirement = index_js_1.defaultTestResourceRequirement, testInterface, uberCatcher) {
8
+ const fullTestInterface = (0, index_js_1.DefaultTestInterface)(testInterface);
9
+ super(testImplementation, testSpecification, input, class extends abstractBase_js_1.BaseSuite {
10
+ afterAll(store, artifactory, pm) {
11
+ return fullTestInterface.afterAll(store,
12
+ // (fPath: string, value: unknown) =>
13
+ // // TODO does not work?
14
+ // {
15
+ // artifactory(`afterAll4-${this.name}/${fPath}`, value);
16
+ // },
17
+ pm);
18
+ }
19
+ assertThat(t) {
20
+ fullTestInterface.assertThis(t);
21
+ }
22
+ async setup(s, artifactory, tr, pm) {
23
+ return (fullTestInterface.beforeAll ||
24
+ (async (input, artifactory, tr, pm) => input))(s, this.testResourceConfiguration,
25
+ // artifactory,
26
+ pm);
27
+ }
28
+ }, class Given extends abstractBase_js_1.BaseGiven {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.uberCatcher = uberCatcher;
32
+ }
33
+ async givenThat(subject, testResource, artifactory, initializer, initialValues, pm) {
34
+ return fullTestInterface.beforeEach(subject, initializer,
35
+ // artifactory,
36
+ testResource, initialValues, pm);
37
+ }
38
+ afterEach(store, key, artifactory, pm) {
39
+ return new Promise((res) => res(fullTestInterface.afterEach(store, key,
40
+ // (fPath: string, value: unknown) =>
41
+ // artifactory(`after/${fPath}`, value),
42
+ pm)));
43
+ }
44
+ }, class When extends abstractBase_js_1.BaseWhen {
45
+ async andWhen(store, whenCB, testResource, pm) {
46
+ try {
47
+ return await fullTestInterface.andWhen(store, whenCB, testResource, pm);
48
+ }
49
+ catch (e) {
50
+ throw e;
51
+ }
52
+ // return fullTestInterface
53
+ // .andWhen(store, whenCB, testResource, pm)
54
+ // .catch((e) => {
55
+ // throw e;
56
+ // });
57
+ // return new Promise((res, rej) => {
58
+ // fullTestInterface.andWhen(store, whenCB, testResource, pm);
59
+ // });
60
+ // return await fullTestInterface.andWhen(
61
+ // store,
62
+ // whenCB,
63
+ // testResource,
64
+ // pm
65
+ // );
66
+ }
67
+ }, class Then extends abstractBase_js_1.BaseThen {
68
+ async butThen(store, thenCB, testResource, pm) {
69
+ return await fullTestInterface
70
+ .butThen(store, thenCB, testResource, pm)
71
+ .then((v) => {
72
+ return v;
73
+ }, (e) => {
74
+ console.log(" ERROR ", e);
75
+ throw e;
76
+ });
77
+ // try {
78
+ // console.log("mark 4");
79
+ // return await fullTestInterface.butThen(
80
+ // store,
81
+ // thenCB,
82
+ // testResource,
83
+ // pm
84
+ // );
85
+ // } catch (e) {
86
+ // console.log("mar123");
87
+ // throw e;
88
+ // }
89
+ // return await fullTestInterface.butThen(
90
+ // store,
91
+ // thenCB,
92
+ // testResourceConfiguration,
93
+ // pm
94
+ // );
95
+ }
96
+ }, class Check extends abstractBase_js_1.BaseCheck {
97
+ constructor(name, features, checkCallback, whens, thens, initialValues) {
98
+ super(name, features, checkCallback, whens, thens);
99
+ this.initialValues = initialValues;
100
+ }
101
+ async checkThat(subject, testResourceConfiguration, artifactory, pm) {
102
+ return fullTestInterface.beforeEach(subject, this.initialValues,
103
+ // (fPath: string, value: unknown) =>
104
+ // artifactory(`before/${fPath}`, value),
105
+ testResourceConfiguration, this.initialValues, pm);
106
+ }
107
+ afterEach(store, key, artifactory, pm) {
108
+ return new Promise((res) => res(fullTestInterface.afterEach(store, key,
109
+ // (fPath: string, value: unknown) =>
110
+ // // TODO does not work?
111
+ // artifactory(`afterEach2-${this.name}/${fPath}`, value),
112
+ pm)));
113
+ }
114
+ }, testResourceRequirement);
115
+ }
116
+ }
117
+ exports.default = Testeranto;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultTestResourceRequirement = exports.DefaultTestInterface = exports.BaseTestInterface = void 0;
4
+ exports.BaseTestInterface = {
5
+ beforeAll: async (s) => s,
6
+ beforeEach: async function (subject, initialValues, x, testResource, pm) {
7
+ return subject;
8
+ },
9
+ afterEach: async (s) => s,
10
+ afterAll: (store) => undefined,
11
+ butThen: async (store, thenCb) => thenCb(store),
12
+ andWhen: (a) => a,
13
+ assertThis: () => null,
14
+ };
15
+ const DefaultTestInterface = (p) => {
16
+ return Object.assign(Object.assign({}, exports.BaseTestInterface), p);
17
+ };
18
+ exports.DefaultTestInterface = DefaultTestInterface;
19
+ exports.defaultTestResourceRequirement = {
20
+ ports: 0,
21
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const http_1 = __importDefault(require("http"));
7
+ exports.default = async (port) => new Promise((resolve, reject) => {
8
+ let json = "";
9
+ const request = http_1.default.request({
10
+ host: "127.0.0.1",
11
+ path: "/json/version",
12
+ port,
13
+ }, (response) => {
14
+ response.on("error", reject);
15
+ response.on("data", (chunk) => {
16
+ json += chunk.toString();
17
+ });
18
+ response.on("end", () => {
19
+ resolve(JSON.parse(json));
20
+ });
21
+ });
22
+ request.on("error", reject);
23
+ request.end();
24
+ });