testeranto 0.79.6 → 0.79.7

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