testeranto 0.62.0 → 0.73.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 (186) hide show
  1. package/README.md +38 -26
  2. package/dist/cjs-shim.js +2 -2
  3. package/dist/common/Node.js +14 -51
  4. package/dist/common/PM/index.js +71 -0
  5. package/dist/common/PM/main.js +361 -0
  6. package/dist/common/PM/node.js +176 -0
  7. package/dist/common/PM/web.js +174 -0
  8. package/dist/common/Project.js +121 -266
  9. package/dist/common/Puppeteer.js +109 -0
  10. package/dist/common/Reporter.js +119 -0
  11. package/dist/common/Scheduler.js +1 -0
  12. package/dist/common/SubPackages/puppeteer.js +3 -1
  13. package/dist/common/SubPackages/react-dom/component/web.js +98 -45
  14. package/dist/common/SubPackages/react-dom/jsx/web.js +15 -7
  15. package/dist/common/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  16. package/dist/common/SubPackages/react-test-renderer/component/index.js +0 -1
  17. package/dist/common/SubPackages/react-test-renderer/fc/web.js +1 -1
  18. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +1 -3
  19. package/dist/common/SubPackages/react-test-renderer/jsx/web.js +1 -1
  20. package/dist/common/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  21. package/dist/common/Types.js +2 -32
  22. package/dist/common/Web.js +25 -37
  23. package/dist/common/esbuildConfigs/index.js +5 -5
  24. package/dist/common/esbuildConfigs/node.js +17 -15
  25. package/dist/common/esbuildConfigs/report.js +12 -47
  26. package/dist/common/esbuildConfigs/tests.js +0 -1
  27. package/dist/common/esbuildConfigs/web.js +17 -12
  28. package/dist/common/lib/abstractBase.js +190 -35
  29. package/dist/common/lib/basebuilder.js +56 -29
  30. package/dist/common/lib/classBuilder.js +8 -5
  31. package/dist/common/lib/core.js +42 -17
  32. package/dist/common/lib/index.js +11 -8
  33. package/dist/common/lib/types.js +2 -0
  34. package/dist/common/preload.js +14 -28
  35. package/dist/common/puppeteerConfiger.js +24 -0
  36. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  37. package/dist/module/Node.js +14 -51
  38. package/dist/module/PM/index.js +67 -0
  39. package/dist/module/PM/main.js +331 -0
  40. package/dist/module/PM/node.js +168 -0
  41. package/dist/module/PM/web.js +167 -0
  42. package/dist/module/Project.js +122 -267
  43. package/dist/module/Puppeteer.js +104 -0
  44. package/dist/module/Reporter.js +114 -0
  45. package/dist/module/Scheduler.js +1 -0
  46. package/dist/module/SubPackages/puppeteer.js +3 -1
  47. package/dist/module/SubPackages/react/jsx/node.js +1 -1
  48. package/dist/module/SubPackages/react/jsx/web.js +1 -1
  49. package/dist/module/SubPackages/react-dom/component/node.js +2 -2
  50. package/dist/module/SubPackages/react-dom/component/web.js +98 -45
  51. package/dist/module/SubPackages/react-dom/jsx/web.js +17 -9
  52. package/dist/module/SubPackages/react-test-renderer/MemoExoticComponent/node.js +1 -1
  53. package/dist/module/SubPackages/react-test-renderer/component/index.js +0 -1
  54. package/dist/module/SubPackages/react-test-renderer/fc/web.js +1 -1
  55. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +1 -3
  56. package/dist/module/SubPackages/react-test-renderer/jsx/web.js +1 -1
  57. package/dist/module/SubPackages/react-test-renderer/jsx-promised/index.js +1 -1
  58. package/dist/module/Types.js +3 -30
  59. package/dist/module/Web.js +26 -38
  60. package/dist/module/esbuildConfigs/index.js +5 -5
  61. package/dist/module/esbuildConfigs/node.js +17 -15
  62. package/dist/module/esbuildConfigs/report.js +11 -48
  63. package/dist/module/esbuildConfigs/tests.js +0 -1
  64. package/dist/module/esbuildConfigs/web.js +17 -12
  65. package/dist/module/lib/abstractBase.js +190 -35
  66. package/dist/module/lib/basebuilder.js +56 -29
  67. package/dist/module/lib/classBuilder.js +8 -5
  68. package/dist/module/lib/core.js +44 -19
  69. package/dist/module/lib/index.js +11 -8
  70. package/dist/module/preload.js +15 -27
  71. package/dist/module/puppeteerConfiger.js +19 -0
  72. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  73. package/dist/prebuild/Report.css +1616 -584
  74. package/dist/prebuild/Report.js +2635 -2506
  75. package/dist/types/Node.d.ts +3 -2
  76. package/dist/types/PM/index.d.ts +19 -0
  77. package/dist/types/PM/main.d.ts +28 -0
  78. package/dist/types/PM/node.d.ts +26 -0
  79. package/dist/types/PM/web.d.ts +24 -0
  80. package/dist/types/Project.d.ts +1 -2
  81. package/dist/types/Puppeteer.d.ts +1 -0
  82. package/dist/types/Reporter.d.ts +1 -0
  83. package/dist/types/Scheduler.d.ts +0 -0
  84. package/dist/types/SubPackages/puppeteer.d.ts +3 -3
  85. package/dist/types/SubPackages/react/component/node.d.ts +1 -1
  86. package/dist/types/SubPackages/react/component/web.d.ts +1 -1
  87. package/dist/types/SubPackages/react/jsx/index.d.ts +1 -1
  88. package/dist/types/SubPackages/react/jsx/node.d.ts +1 -1
  89. package/dist/types/SubPackages/react/jsx/web.d.ts +2 -2
  90. package/dist/types/SubPackages/react-dom/component/node.d.ts +2 -2
  91. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  92. package/dist/types/SubPackages/react-dom/jsx/node.d.ts +1 -1
  93. package/dist/types/SubPackages/react-dom/jsx/web.d.ts +1 -1
  94. package/dist/types/SubPackages/react-test-renderer/MemoExoticComponent/node.d.ts +1 -1
  95. package/dist/types/SubPackages/react-test-renderer/component/index.d.ts +1 -1
  96. package/dist/types/SubPackages/react-test-renderer/component/node.d.ts +1 -1
  97. package/dist/types/SubPackages/react-test-renderer/component/web.d.ts +1 -1
  98. package/dist/types/SubPackages/react-test-renderer/fc/node.d.ts +1 -1
  99. package/dist/types/SubPackages/react-test-renderer/fc/web.d.ts +1 -1
  100. package/dist/types/SubPackages/react-test-renderer/jsx/node.d.ts +1 -1
  101. package/dist/types/SubPackages/react-test-renderer/jsx/web.d.ts +3 -3
  102. package/dist/types/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -1
  103. package/dist/types/SubPackages/react-test-renderer/jsx-promised/node.d.ts +1 -1
  104. package/dist/types/SubPackages/react-test-renderer/jsx-promised/web.d.ts +1 -1
  105. package/dist/types/Types.d.ts +19 -100
  106. package/dist/types/Web.d.ts +3 -2
  107. package/dist/types/esbuildConfigs/features.d.ts +1 -1
  108. package/dist/types/esbuildConfigs/index.d.ts +1 -1
  109. package/dist/types/esbuildConfigs/node.d.ts +1 -1
  110. package/dist/types/esbuildConfigs/report.d.ts +4 -0
  111. package/dist/types/esbuildConfigs/tests.d.ts +1 -1
  112. package/dist/types/esbuildConfigs/web.d.ts +1 -1
  113. package/dist/types/lib/abstractBase.d.ts +26 -24
  114. package/dist/types/lib/basebuilder.d.ts +10 -7
  115. package/dist/types/lib/classBuilder.d.ts +4 -3
  116. package/dist/types/lib/core.d.ts +5 -4
  117. package/dist/types/lib/index.d.ts +7 -5
  118. package/dist/types/lib/types.d.ts +62 -0
  119. package/dist/types/preload.d.ts +0 -1
  120. package/dist/types/puppeteerConfiger.d.ts +4 -0
  121. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  122. package/package.json +6 -7
  123. package/src/Node.ts +30 -85
  124. package/src/PM/index.ts +102 -0
  125. package/src/PM/main.ts +420 -0
  126. package/src/PM/node.ts +515 -0
  127. package/src/PM/web.ts +497 -0
  128. package/src/Project.ts +183 -619
  129. package/src/Puppeteer.ts +131 -0
  130. package/src/Report.tsx +158 -44
  131. package/src/Reporter.ts +134 -0
  132. package/src/Scheduler.ts +0 -0
  133. package/src/SubPackages/puppeteer.ts +19 -14
  134. package/src/SubPackages/react/component/node.ts +20 -32
  135. package/src/SubPackages/react/component/web.ts +20 -30
  136. package/src/SubPackages/react/jsx/index.ts +13 -24
  137. package/src/SubPackages/react/jsx/node.ts +5 -8
  138. package/src/SubPackages/react/jsx/web.ts +10 -8
  139. package/src/SubPackages/react-dom/component/node.ts +17 -23
  140. package/src/SubPackages/react-dom/component/web.ts +134 -95
  141. package/src/SubPackages/react-dom/jsx/web.ts +41 -48
  142. package/src/SubPackages/react-test-renderer/MemoExoticComponent/node.ts +27 -37
  143. package/src/SubPackages/react-test-renderer/component/index.ts +16 -30
  144. package/src/SubPackages/react-test-renderer/component/node.ts +5 -11
  145. package/src/SubPackages/react-test-renderer/component/web.ts +5 -11
  146. package/src/SubPackages/react-test-renderer/fc/node.ts +36 -50
  147. package/src/SubPackages/react-test-renderer/fc/web.ts +37 -50
  148. package/src/SubPackages/react-test-renderer/jsx/index.ts +15 -21
  149. package/src/SubPackages/react-test-renderer/jsx/node.ts +6 -10
  150. package/src/SubPackages/react-test-renderer/jsx/web.ts +7 -7
  151. package/src/SubPackages/react-test-renderer/jsx-promised/index.ts +13 -16
  152. package/src/Types.ts +73 -307
  153. package/src/Web.ts +40 -81
  154. package/src/cjs-shim.js +2 -2
  155. package/src/esbuildConfigs/features.ts +3 -4
  156. package/src/esbuildConfigs/index.ts +8 -8
  157. package/src/esbuildConfigs/node.ts +21 -20
  158. package/src/esbuildConfigs/report.ts +15 -51
  159. package/src/esbuildConfigs/tests.ts +3 -9
  160. package/src/esbuildConfigs/web.ts +22 -20
  161. package/src/lib/abstractBase.ts +312 -164
  162. package/src/lib/basebuilder.ts +123 -127
  163. package/src/lib/classBuilder.ts +30 -48
  164. package/src/lib/core.ts +115 -84
  165. package/src/lib/index.ts +58 -56
  166. package/src/lib/types.ts +197 -0
  167. package/src/preload.ts +14 -30
  168. package/src/puppeteerConfiger.ts +26 -0
  169. package/src/web.html.ts +1 -1
  170. package/dist/common/NodeWriter.js +0 -56
  171. package/dist/common/electron.js +0 -196
  172. package/dist/common/lib/browser.js +0 -26
  173. package/dist/common/nodeWriterElectron.js +0 -55
  174. package/dist/module/NodeWriter.js +0 -50
  175. package/dist/module/electron.js +0 -191
  176. package/dist/module/lib/browser.js +0 -22
  177. package/dist/module/nodeWriterElectron.js +0 -52
  178. package/dist/types/NodeWriter.d.ts +0 -2
  179. package/dist/types/lib/browser.d.ts +0 -6
  180. package/dist/types/nodeWriterElectron.d.ts +0 -2
  181. package/src/NodeWriter.ts +0 -69
  182. package/src/electron.ts +0 -250
  183. package/src/lib/browser.ts +0 -34
  184. package/src/nodeWriterElectron.ts +0 -71
  185. package/yarn-error.log +0 -3144
  186. /package/dist/{types/electron.d.ts → module/lib/types.js} +0 -0
@@ -16,38 +16,114 @@ class BaseSuite {
16
16
  fails: this.fails,
17
17
  };
18
18
  }
19
- setup(s, artifactory, tr, utils) {
19
+ setup(s, artifactory, tr, pm) {
20
20
  return new Promise((res) => res(s));
21
21
  }
22
22
  assertThat(t) {
23
- // console.log("base assertThat")
24
23
  return t;
25
24
  }
26
- async run(input, testResourceConfiguration, artifactory, tLog, utils) {
25
+ afterAll(store, artifactory, pm) {
26
+ return store;
27
+ }
28
+ async run(input, testResourceConfiguration, artifactory, tLog, pm) {
27
29
  this.testResourceConfiguration = testResourceConfiguration;
28
- tLog("test resources: ", testResourceConfiguration);
30
+ tLog("test resources: ", JSON.stringify(testResourceConfiguration));
29
31
  const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
30
- const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, utils);
32
+ console.log("\nSuite:", this.index, this.name);
31
33
  tLog("\nSuite:", this.index, this.name);
32
- for (const k of Object.keys(this.givens)) {
33
- const giver = this.givens[k];
34
+ const sNdx = this.index;
35
+ const sName = this.name;
36
+ for (const [gNdx, g] of Object.entries(this.givens)) {
37
+ const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, pm);
38
+ const giver = this.givens[gNdx];
34
39
  try {
35
- this.store = await giver.give(subject, k, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
40
+ this.store = await giver.give(subject, gNdx, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
36
41
  }
37
42
  catch (e) {
38
43
  console.error(e);
39
44
  this.fails.push(giver);
40
- return this;
45
+ // return this;
41
46
  }
42
47
  }
43
- for (const [ndx, thater] of this.checks.entries()) {
44
- await thater.check(subject, thater.name, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, utils);
48
+ const afterAllProxy = new Proxy(pm, {
49
+ get(target, prop, receiver) {
50
+ if (prop === "writeFileSync") {
51
+ return (fp, contents) => target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
52
+ }
53
+ if (prop === "browser") {
54
+ return new Proxy(target[prop], {
55
+ get(bTarget, bProp, bReceiver) {
56
+ if (bProp === "pages") {
57
+ return async () => {
58
+ return bTarget.pages().then((pages) => {
59
+ return pages.map((page) => {
60
+ return new Proxy(page, {
61
+ get(pTarget, pProp, pReciever) {
62
+ if (pProp === "screenshot") {
63
+ return async (x) => {
64
+ // console.log(
65
+ // "custom-screenshot-MARK-afterAllProxy",
66
+ // // arguments,
67
+ // // x,
68
+ // window["custom-screenshot"].toString()
69
+ // );
70
+ return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
71
+ "/" +
72
+ x.path }));
73
+ };
74
+ }
75
+ // else if (pProp === "mainFrame") {
76
+ // return () => target[pProp](...arguments);
77
+ // }
78
+ else {
79
+ return Reflect.get(...arguments);
80
+ }
81
+ },
82
+ });
83
+ });
84
+ });
85
+ // return (await target.pages()).map((page) => {
86
+ // return new Proxy(page, handler2);
87
+ // });
88
+ };
89
+ }
90
+ },
91
+ });
92
+ }
93
+ return Reflect.get(...arguments);
94
+ },
95
+ });
96
+ // pm.browser
97
+ try {
98
+ this.afterAll(this.store, artifactory, afterAllProxy);
45
99
  }
46
- // @TODO fix me
47
- for (const k of Object.keys(this.givens)) {
48
- const giver = this.givens[k];
49
- giver.afterAll(this.store, artifactory, utils);
100
+ catch (e) {
101
+ console.error(e);
102
+ // this.fails.push(this);
103
+ // return this;
50
104
  }
105
+ // for (const [ndx, thater] of this.checks.entries()) {
106
+ // await thater.check(
107
+ // subject,
108
+ // thater.name,
109
+ // testResourceConfiguration,
110
+ // this.assertThat,
111
+ // suiteArtifactory,
112
+ // tLog,
113
+ // pm
114
+ // );
115
+ // }
116
+ // @TODO fix me
117
+ // for (const k of Object.keys(this.givens)) {
118
+ // const giver = this.givens[k];
119
+ // try {
120
+ // giver.afterAll(this.store, artifactory, pm);
121
+ // } catch (e) {
122
+ // console.error(e);
123
+ // this.fails.push(giver);
124
+ // return this;
125
+ // }
126
+ // }
51
127
  ////////////////
52
128
  return this;
53
129
  }
@@ -65,32 +141,39 @@ class BaseGiven {
65
141
  beforeAll(store, artifactory) {
66
142
  return store;
67
143
  }
68
- afterAll(store, artifactory, utils) {
69
- return store;
70
- }
71
144
  toObj() {
72
145
  return {
73
146
  name: this.name,
74
147
  whens: this.whens.map((w) => w.toObj()),
75
148
  thens: this.thens.map((t) => t.toObj()),
76
149
  error: this.error ? [this.error, this.error.stack] : null,
150
+ // fail: this.fail ? [this.fail] : false,
77
151
  features: this.features,
78
152
  };
79
153
  }
80
- async afterEach(store, key, artifactory) {
154
+ async afterEach(store, key, artifactory, pm) {
81
155
  return store;
82
156
  }
83
- async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
157
+ async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
84
158
  tLog(`\n Given: ${this.name}`);
85
159
  const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
86
160
  try {
87
- this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB);
88
161
  // tLog(`\n Given this.store`, this.store);
89
- for (const whenStep of this.whens) {
90
- await whenStep.test(this.store, testResourceConfiguration, tLog, utils);
162
+ const beforeEachProxy = new Proxy(pm, {
163
+ get(target, prop, receiver) {
164
+ if (prop === "writeFileSync") {
165
+ console.log("beforeEachProx", arguments, target[prop]);
166
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
167
+ }
168
+ return Reflect.get(...arguments);
169
+ },
170
+ });
171
+ this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, beforeEachProxy);
172
+ for (const [whenNdx, whenStep] of this.whens.entries()) {
173
+ await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
91
174
  }
92
175
  for (const thenStep of this.thens) {
93
- const t = await thenStep.test(this.store, testResourceConfiguration, tLog, utils);
176
+ const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm);
94
177
  tester(t);
95
178
  }
96
179
  }
@@ -102,7 +185,66 @@ class BaseGiven {
102
185
  }
103
186
  finally {
104
187
  try {
105
- await this.afterEach(this.store, key, givenArtifactory);
188
+ // const afterEachProxy = new Proxy(pm, {
189
+ // get(target, prop, receiver) {
190
+ // if (prop === "writeFileSync") {
191
+ // console.log("afterEachProxy", arguments, target[prop]);
192
+ // return (fp, contents) =>
193
+ // // target[prop](`${key}/andWhen/${fp}`, contents);
194
+ // target[prop](`${key}/afterEach/${fp}`, contents);
195
+ // }
196
+ // return Reflect.get(...arguments);
197
+ // },
198
+ // });
199
+ // await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
200
+ // await this.afterEach(this.store, key, givenArtifactory, pm);
201
+ const afterEachProxy = new Proxy(pm, {
202
+ get(target, prop, receiver) {
203
+ if (prop === "writeFileSync") {
204
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterAll/${fp}`, contents);
205
+ }
206
+ if (prop === "browser") {
207
+ return new Proxy(target[prop], {
208
+ get(bTarget, bProp, bReceiver) {
209
+ if (bProp === "pages") {
210
+ return async () => {
211
+ return bTarget.pages().then((pages) => {
212
+ return pages.map((page) => {
213
+ return new Proxy(page, {
214
+ get(pTarget, pProp, pReciever) {
215
+ if (pProp === "screenshot") {
216
+ return async (x) => {
217
+ // console.log(
218
+ // "custom-screenshot-MARK-afterEachProxy",
219
+ // window["custom-screenshot"].toString()
220
+ // );
221
+ return await window["custom-screenshot"](Object.assign(Object.assign({}, x), { path: `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
222
+ "/" +
223
+ x.path }));
224
+ };
225
+ }
226
+ // else if (pProp === "mainFrame") {
227
+ // return () => target[pProp](...arguments);
228
+ // }
229
+ else {
230
+ return Reflect.get(...arguments);
231
+ }
232
+ },
233
+ });
234
+ });
235
+ });
236
+ // return (await target.pages()).map((page) => {
237
+ // return new Proxy(page, handler2);
238
+ // });
239
+ };
240
+ }
241
+ },
242
+ });
243
+ }
244
+ return Reflect.get(...arguments);
245
+ },
246
+ });
247
+ await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
106
248
  }
107
249
  catch (e) {
108
250
  console.error("afterEach failed! no error will be recorded!", e);
@@ -123,10 +265,22 @@ class BaseWhen {
123
265
  error: this.error,
124
266
  };
125
267
  }
126
- async test(store, testResourceConfiguration, tLog, utils) {
268
+ async test(store, testResourceConfiguration, tLog, pm, key) {
127
269
  tLog(" When:", this.name);
270
+ const name = this.name;
271
+ const andWhenProxy = new Proxy(pm, {
272
+ get(target, prop, receiver) {
273
+ if (prop === "writeFileSync") {
274
+ console.log("andWhenProxy", arguments, target[prop]);
275
+ return (fp, contents) =>
276
+ // target[prop](`${key}/andWhen/${fp}`, contents);
277
+ target[prop](`${key}/andWhen/${fp}`, contents);
278
+ }
279
+ return Reflect.get(...arguments);
280
+ },
281
+ });
128
282
  try {
129
- return await this.andWhen(store, this.whenCB, testResourceConfiguration);
283
+ return await this.andWhen(store, this.whenCB, testResourceConfiguration, andWhenProxy);
130
284
  }
131
285
  catch (e) {
132
286
  this.error = true;
@@ -139,6 +293,7 @@ class BaseThen {
139
293
  constructor(name, thenCB) {
140
294
  this.name = name;
141
295
  this.thenCB = thenCB;
296
+ this.error = false;
142
297
  }
143
298
  toObj() {
144
299
  return {
@@ -146,15 +301,15 @@ class BaseThen {
146
301
  error: this.error,
147
302
  };
148
303
  }
149
- async test(store, testResourceConfiguration, tLog, utils) {
304
+ async test(store, testResourceConfiguration, tLog, pm) {
150
305
  tLog(" Then:", this.name);
151
306
  try {
152
- const x = (await this.butThen(store, this.thenCB, testResourceConfiguration));
307
+ const x = await this.butThen(store, this.thenCB, testResourceConfiguration);
153
308
  return x;
154
309
  }
155
310
  catch (e) {
156
311
  console.log("test failed", e);
157
- this.error = true;
312
+ this.error = e.message;
158
313
  throw e;
159
314
  }
160
315
  }
@@ -168,25 +323,25 @@ class BaseCheck {
168
323
  this.whens = whens;
169
324
  this.thens = thens;
170
325
  }
171
- async afterEach(store, key, cb) {
326
+ async afterEach(store, key, cb, pm) {
172
327
  return;
173
328
  }
174
- async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, utils) {
329
+ async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
175
330
  tLog(`\n Check: ${this.name}`);
176
331
  const store = await this.checkThat(subject, testResourceConfiguration, artifactory);
177
332
  await this.checkCB(Object.entries(this.whens).reduce((a, [key, when]) => {
178
333
  a[key] = async (payload) => {
179
- return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, utils);
334
+ return await when(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm, "x");
180
335
  };
181
336
  return a;
182
337
  }, {}), Object.entries(this.thens).reduce((a, [key, then]) => {
183
338
  a[key] = async (payload) => {
184
- const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, utils);
339
+ const t = await then(payload, testResourceConfiguration).test(store, testResourceConfiguration, tLog, pm);
185
340
  tester(t);
186
341
  };
187
342
  return a;
188
343
  }, {}));
189
- await this.afterEach(store, key);
344
+ await this.afterEach(store, key, () => { }, pm);
190
345
  return;
191
346
  }
192
347
  }
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseBuilder = void 0;
4
4
  class BaseBuilder {
5
- constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, logWriter, testResourceRequirement, testSpecification) {
5
+ constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification
6
+ // puppetMaster: PM
7
+ ) {
6
8
  this.input = input;
7
9
  this.artifacts = [];
8
10
  this.artifacts = [];
@@ -13,52 +15,77 @@ class BaseBuilder {
13
15
  this.thenOverides = thenOverides;
14
16
  this.checkOverides = checkOverides;
15
17
  this.testSpecification = testSpecification;
18
+ // this.puppetMaster = puppetMaster;
16
19
  this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
17
- const suiteRunner = (suite, utils) => async (testResourceConfiguration, tLog, utils) => {
18
- return await suite.run(input, testResourceConfiguration, (fPath, value) => logWriter.testArtiFactoryfileWriter(tLog, (p) => {
19
- this.artifacts.push(p);
20
- })(testResourceConfiguration.fs + "/" + fPath, value), tLog, utils);
21
- };
22
- this.testJobs = this.specs.map((suite, utils) => {
23
- const runner = suiteRunner(suite, utils);
20
+ this.testJobs = this.specs.map((suite) => {
21
+ const suiteRunner = (suite) => async (
22
+ // testResourceConfiguration: ITTestResourceConfiguration,
23
+ puppetMaster, tLog) => {
24
+ await puppetMaster.startPuppeteer({
25
+ browserWSEndpoint: puppetMaster.testResourceConfiguration.browserWSEndpoint,
26
+ }, puppetMaster.testResourceConfiguration.fs);
27
+ return await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
28
+ this.artifacts.push(p);
29
+ })(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
30
+ };
31
+ const runner = suiteRunner(suite);
24
32
  return {
25
33
  test: suite,
26
- testResourceRequirement,
34
+ // testResourceRequirement,
27
35
  toObj: () => {
28
36
  return suite.toObj();
29
37
  },
30
38
  runner,
31
- receiveTestResourceConfig: async function (testResourceConfiguration = {
32
- name: "",
33
- fs: ".",
34
- ports: [],
35
- scheduled: false
36
- }, y) {
37
- console.log(`testResourceConfiguration ${JSON.stringify(testResourceConfiguration, null, 2)}`);
38
- await logWriter.mkdirSync(testResourceConfiguration.fs);
39
- logWriter.writeFileSync(`${testResourceConfiguration.fs}/tests.json`, JSON.stringify(this.toObj(), null, 2));
40
- const logFilePath = `${testResourceConfiguration.fs}/log.txt`;
41
- const access = await logWriter.createWriteStream(logFilePath);
39
+ receiveTestResourceConfig: async function (
40
+ // testResourceConfiguration = {
41
+ // name: "",
42
+ // fs: ".",
43
+ // ports: [],
44
+ // browserWSEndpoint: "",
45
+ // },
46
+ puppetMaster) {
47
+ // console.log(
48
+ // `testResourceConfiguration! ${JSON.stringify(
49
+ // testResourceConfiguration,
50
+ // null,
51
+ // 2
52
+ // )}`
53
+ // );
54
+ // console.log("puppetMaster", puppetMaster);
55
+ await puppetMaster
56
+ .mkdirSync();
57
+ // if (!puppetMaster.existsSync(destFolder)) {
58
+ // puppetMaster.mkdirSync(destFolder, { recursive: true });
59
+ // }
60
+ // puppetMaster.writeFileSync(
61
+ // // puppetMaster.testResourceConfiguration.fs + `/tests.json`,
62
+ // `tests.json`,
63
+ // JSON.stringify(this.toObj(), null, 2)
64
+ // );
65
+ const logFilePath = "log.txt";
66
+ // puppetMaster.testResourceConfiguration.fs + `/log.txt`;
67
+ const access = await puppetMaster.createWriteStream(logFilePath);
68
+ // console.log("access", access);
42
69
  const tLog = (...l) => {
43
- // console.log(...l);
44
- access.write(`${l.toString()}\n`);
70
+ // access.write(`${l.toString()}\n`);
71
+ // console.log("tLog", l);
72
+ puppetMaster.write(access, `${l.toString()}\n`);
45
73
  };
46
- const suiteDone = await runner(testResourceConfiguration, tLog, y);
47
- const resultsFilePath = (`${testResourceConfiguration.fs}/results.json`);
48
- logWriter.writeFileSync(resultsFilePath, JSON.stringify(suiteDone.toObj(), null, 2));
74
+ const suiteDone = await runner(puppetMaster, tLog);
49
75
  const logPromise = new Promise((res, rej) => {
50
- access.on("finish", () => { res(true); });
76
+ puppetMaster.end(access);
77
+ res(true);
51
78
  });
52
- access.end();
53
79
  const numberOfFailures = Object.keys(suiteDone.givens).filter((k) => {
54
- // console.log(`suiteDone.givens[k].error`, suiteDone.givens[k].error);
55
80
  return suiteDone.givens[k].error;
56
81
  }).length;
82
+ puppetMaster.writeFileSync(`exitcode`, numberOfFailures.toString());
83
+ puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
57
84
  console.log(`exiting gracefully with ${numberOfFailures} failures.`);
58
85
  return {
59
86
  failed: numberOfFailures,
60
87
  artifacts: this.artifacts || [],
61
- logPromise
88
+ logPromise,
62
89
  };
63
90
  },
64
91
  };
@@ -3,17 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClassBuilder = void 0;
4
4
  const basebuilder_js_1 = require("./basebuilder.js");
5
5
  class ClassBuilder extends basebuilder_js_1.BaseBuilder {
6
- constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement, logWriter) {
6
+ constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement
7
+ // puppetMaster: PM
8
+ ) {
7
9
  const classySuites = Object.entries(testImplementation.suites).reduce((a, [key], index) => {
8
10
  a[key] = (somestring, givens, checks) => {
9
11
  return new suiteKlasser.prototype.constructor(somestring, index, givens, checks);
10
12
  };
11
13
  return a;
12
14
  }, {});
13
- const classyGivens = Object.entries(testImplementation.givens)
14
- .reduce((a, [key, givEn]) => {
15
+ const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, givEn]) => {
15
16
  a[key] = (features, whens, thens, givEn) => {
16
- return new (givenKlasser.prototype).constructor(key, features, whens, thens, testImplementation.givens[key], givEn);
17
+ return new givenKlasser.prototype.constructor(key, features, whens, thens, testImplementation.givens[key], givEn);
17
18
  };
18
19
  return a;
19
20
  }, {});
@@ -35,7 +36,9 @@ class ClassBuilder extends basebuilder_js_1.BaseBuilder {
35
36
  };
36
37
  return a;
37
38
  }, {});
38
- super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks, logWriter, testResourceRequirement, testSpecification);
39
+ super(input, classySuites, classyGivens, classyWhens, classyThens, classyChecks, testResourceRequirement, testSpecification
40
+ // puppetMaster
41
+ );
39
42
  }
40
43
  }
41
44
  exports.ClassBuilder = ClassBuilder;
@@ -4,30 +4,53 @@ const index_js_1 = require("./index.js");
4
4
  const abstractBase_js_1 = require("./abstractBase.js");
5
5
  const classBuilder_js_1 = require("./classBuilder.js");
6
6
  class Testeranto extends classBuilder_js_1.ClassBuilder {
7
- constructor(input, testSpecification, testImplementation, testResourceRequirement = index_js_1.defaultTestResourceRequirement, logWriter, testInterface) {
7
+ constructor(input, testSpecification, testImplementation, testResourceRequirement = index_js_1.defaultTestResourceRequirement, testInterface
8
+ // puppetMaster: PM
9
+ ) {
8
10
  const fullTestInterface = (0, index_js_1.DefaultTestInterface)(testInterface);
9
11
  super(testImplementation, testSpecification, input, class extends abstractBase_js_1.BaseSuite {
12
+ afterAll(store, artifactory, pm) {
13
+ // const pagesHandler = {
14
+ // get(target, prop) {
15
+ // console.log(`Getting pages property ${prop}`);
16
+ // return target[prop];
17
+ // },
18
+ // };
19
+ // const browserHandler = {
20
+ // get(target, prop) {
21
+ // console.log(`Getting browser property ${prop}`);
22
+ // if (prop === "pages") {
23
+ // // return target[prop];
24
+ // return new Proxy(target[prop], pagesHandler);
25
+ // } else {
26
+ // return target[prop];
27
+ // }
28
+ // },
29
+ // };
30
+ // const proxy = new Proxy(utils.browser, browserHandler);
31
+ return fullTestInterface.afterAll(store, (fPath, value) => {
32
+ artifactory(`afterAll4-${this.name}/${fPath}`, value);
33
+ }, pm);
34
+ }
10
35
  assertThat(t) {
11
36
  fullTestInterface.assertThis(t);
12
37
  }
13
- async setup(s, artifactory, tr) {
14
- return (fullTestInterface.beforeAll || (async (input, artifactory, tr) => input))(s, this.testResourceConfiguration, artifactory);
38
+ async setup(s, artifactory, tr, pm) {
39
+ return (fullTestInterface.beforeAll ||
40
+ (async (input, artifactory, tr, pm) => input))(s, this.testResourceConfiguration, artifactory, pm);
15
41
  }
16
42
  }, class Given extends abstractBase_js_1.BaseGiven {
17
- async givenThat(subject, testResource, artifactory, initializer) {
43
+ async givenThat(subject, testResource, artifactory, initializer, pm) {
18
44
  return fullTestInterface.beforeEach(subject, initializer, (fPath, value) =>
19
45
  // TODO does not work?
20
- artifactory(`beforeEach/${fPath}`, value), testResource, this.initialValues);
21
- }
22
- afterEach(store, key, artifactory) {
23
- return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value))));
46
+ artifactory(`beforeEach/${fPath}`, value), testResource, this.initialValues, pm);
24
47
  }
25
- afterAll(store, artifactory, utils) {
26
- return fullTestInterface.afterAll(store, (fPath, value) => { artifactory(`afterAll4-${this.name}/${fPath}`, value); }, utils);
48
+ afterEach(store, key, artifactory, pm) {
49
+ return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value), pm)));
27
50
  }
28
51
  }, class When extends abstractBase_js_1.BaseWhen {
29
- async andWhen(store, whenCB, testResource) {
30
- return await fullTestInterface.andWhen(store, whenCB, testResource);
52
+ async andWhen(store, whenCB, testResource, pm) {
53
+ return await fullTestInterface.andWhen(store, whenCB, testResource, pm);
31
54
  }
32
55
  }, class Then extends abstractBase_js_1.BaseThen {
33
56
  async butThen(store, thenCB, testResourceConfiguration) {
@@ -38,15 +61,17 @@ class Testeranto extends classBuilder_js_1.ClassBuilder {
38
61
  super(name, features, checkCallback, whens, thens);
39
62
  this.initialValues = initialValues;
40
63
  }
41
- async checkThat(subject, testResourceConfiguration, artifactory) {
42
- return fullTestInterface.beforeEach(subject, this.initialValues, (fPath, value) => artifactory(`before/${fPath}`, value), testResourceConfiguration, this.initialValues);
64
+ async checkThat(subject, testResourceConfiguration, artifactory, pm) {
65
+ return fullTestInterface.beforeEach(subject, this.initialValues, (fPath, value) => artifactory(`before/${fPath}`, value), testResourceConfiguration, this.initialValues, pm);
43
66
  }
44
- afterEach(store, key, artifactory) {
67
+ afterEach(store, key, artifactory, pm) {
45
68
  return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) =>
46
69
  // TODO does not work?
47
- artifactory(`afterEach2-${this.name}/${fPath}`, value))));
70
+ artifactory(`afterEach2-${this.name}/${fPath}`, value), pm)));
48
71
  }
49
- }, testResourceRequirement, logWriter);
72
+ }, testResourceRequirement
73
+ // puppetMaster
74
+ );
50
75
  }
51
76
  }
52
77
  exports.default = Testeranto;
@@ -1,19 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultTestResourceRequirement = exports.DefaultTestInterface = exports.BaseTestInterface = void 0;
4
+ // import { INodeUtils, ITestInterface, IUtils, IWebUtils } from "./types.js";
4
5
  exports.BaseTestInterface = {
5
- beforeAll: (async (s) => s),
6
- beforeEach: async function (subject, initialValues, testResource) { return subject; },
7
- afterEach: (async (s) => s),
8
- afterAll: ((store) => undefined),
9
- butThen: (async (store, thenCb) => thenCb(store)),
10
- andWhen: ((a) => a),
11
- assertThis: (() => null),
6
+ beforeAll: async (s) => s,
7
+ beforeEach: async function (subject, initialValues, x, testResource, pm) {
8
+ return subject;
9
+ },
10
+ afterEach: async (s) => s,
11
+ afterAll: (store) => undefined,
12
+ butThen: async (store, thenCb) => thenCb(store),
13
+ andWhen: (a) => a,
14
+ assertThis: () => null,
12
15
  };
13
16
  const DefaultTestInterface = (p) => {
14
17
  return Object.assign(Object.assign({}, exports.BaseTestInterface), p);
15
18
  };
16
19
  exports.DefaultTestInterface = DefaultTestInterface;
17
20
  exports.defaultTestResourceRequirement = {
18
- ports: 0
21
+ ports: 0,
19
22
  };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,29 +1,15 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const electron_1 = require("electron");
4
- console.log("hello preloader");
5
- const NodeWriter_1 = require("./NodeWriter");
6
- window.NodeWriter = NodeWriter_1.NodeWriter;
7
- window.exit = (x) => {
8
- electron_1.ipcRenderer.invoke('quit-app', x);
9
- };
10
- // var oldLog = console.log;
11
- // console.log = function (message) {
12
- // ipcRenderer.invoke('web-log', message.toString());
13
- // oldLog.apply(console, arguments);
14
- // };
15
- // var oldLog = console.error;
16
- // console.error = function (message) {
17
- // ipcRenderer.invoke('web-error', message.toString());
18
- // oldLog.apply(console, arguments);
19
- // };
20
- // var oldLog = console.warn;
21
- // console.warn = function (message) {
22
- // ipcRenderer.invoke('web-warn', message.toString());
23
- // oldLog.apply(console, arguments);
24
- // };
25
- // var oldLog = console.info;
26
- // console.info = function (message) {
27
- // ipcRenderer.invoke('web-info', message.toString());
28
- // oldLog.apply(console, arguments);
29
- // };
2
+ // import puppeteer from "puppeteer-core";
3
+ // import { NodeWriter } from "./NodeWriter";
4
+ // import puppeteerConfiger from "./puppeteerConfiger";
5
+ // (window as any).NodeWriter = NodeWriter;
6
+ // (window as any).browser = new Promise(async (res, rej) => {
7
+ // const browser = await puppeteerConfiger("2999").then(async (json) => {
8
+ // const b = await puppeteer.connect({
9
+ // browserWSEndpoint: json.webSocketDebuggerUrl,
10
+ // defaultViewport: null,
11
+ // });
12
+ // console.log("connected!", b.isConnected());
13
+ // return res(b);
14
+ // });
15
+ // });