testeranto 0.70.0 → 0.74.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 (98) hide show
  1. package/README.md +9 -18
  2. package/dist/common/Node.js +7 -34
  3. package/dist/common/PM/index.js +71 -0
  4. package/dist/common/PM/main.js +370 -0
  5. package/dist/common/PM/node.js +84 -0
  6. package/dist/common/PM/web.js +129 -0
  7. package/dist/common/Project.js +20 -2
  8. package/dist/common/Puppeteer.js +109 -0
  9. package/dist/common/Reporter.js +119 -0
  10. package/dist/common/Scheduler.js +1 -0
  11. package/dist/common/SubPackages/puppeteer.js +3 -1
  12. package/dist/common/SubPackages/react/jsx/index.js +14 -2
  13. package/dist/common/SubPackages/react-dom/component/web.js +98 -45
  14. package/dist/common/SubPackages/react-test-renderer/jsx/index.js +0 -1
  15. package/dist/common/Web.js +24 -44
  16. package/dist/common/esbuildConfigs/web.js +3 -1
  17. package/dist/common/lib/abstractBase.js +189 -41
  18. package/dist/common/lib/basebuilder.js +56 -29
  19. package/dist/common/lib/classBuilder.js +6 -2
  20. package/dist/common/lib/core.js +41 -45
  21. package/dist/common/lib/index.js +2 -1
  22. package/dist/common/preload.js +14 -18
  23. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  24. package/dist/module/Node.js +7 -34
  25. package/dist/module/PM/index.js +67 -0
  26. package/dist/module/PM/main.js +340 -0
  27. package/dist/module/PM/node.js +77 -0
  28. package/dist/module/PM/web.js +122 -0
  29. package/dist/module/Project.js +20 -2
  30. package/dist/module/Puppeteer.js +104 -0
  31. package/dist/module/Reporter.js +114 -0
  32. package/dist/module/Scheduler.js +1 -0
  33. package/dist/module/SubPackages/puppeteer.js +3 -1
  34. package/dist/module/SubPackages/react/jsx/index.js +11 -2
  35. package/dist/module/SubPackages/react/jsx/node.js +1 -1
  36. package/dist/module/SubPackages/react-dom/component/web.js +98 -45
  37. package/dist/module/SubPackages/react-test-renderer/jsx/index.js +0 -1
  38. package/dist/module/Web.js +24 -44
  39. package/dist/module/esbuildConfigs/web.js +3 -1
  40. package/dist/module/lib/abstractBase.js +189 -41
  41. package/dist/module/lib/basebuilder.js +56 -29
  42. package/dist/module/lib/classBuilder.js +6 -2
  43. package/dist/module/lib/core.js +41 -45
  44. package/dist/module/lib/index.js +2 -1
  45. package/dist/module/preload.js +15 -14
  46. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  47. package/dist/prebuild/Report.css +1616 -584
  48. package/dist/prebuild/Report.js +2635 -2506
  49. package/dist/types/PM/index.d.ts +19 -0
  50. package/dist/types/PM/main.d.ts +26 -0
  51. package/dist/types/PM/node.d.ts +25 -0
  52. package/dist/types/PM/web.d.ts +24 -0
  53. package/dist/types/Reporter.d.ts +1 -0
  54. package/dist/types/Scheduler.d.ts +0 -0
  55. package/dist/types/SubPackages/react/jsx/index.d.ts +2 -5
  56. package/dist/types/SubPackages/react-dom/component/web.d.ts +1 -1
  57. package/dist/types/lib/abstractBase.d.ts +13 -12
  58. package/dist/types/lib/basebuilder.d.ts +4 -2
  59. package/dist/types/lib/classBuilder.d.ts +2 -2
  60. package/dist/types/lib/core.d.ts +4 -4
  61. package/dist/types/lib/index.d.ts +6 -5
  62. package/dist/types/lib/types.d.ts +16 -24
  63. package/dist/types/preload.d.ts +0 -1
  64. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  65. package/package.json +3 -5
  66. package/src/Node.ts +8 -47
  67. package/src/PM/index.ts +102 -0
  68. package/src/PM/main.ts +452 -0
  69. package/src/PM/node.ts +122 -0
  70. package/src/PM/web.ts +162 -0
  71. package/src/Project.ts +21 -2
  72. package/src/Puppeteer.ts +131 -0
  73. package/src/Report.tsx +160 -46
  74. package/src/Reporter.ts +134 -0
  75. package/src/Scheduler.ts +0 -0
  76. package/src/SubPackages/puppeteer.ts +3 -3
  77. package/src/SubPackages/react/jsx/index.ts +13 -3
  78. package/src/SubPackages/react/jsx/node.ts +5 -8
  79. package/src/SubPackages/react-dom/component/web.ts +126 -67
  80. package/src/SubPackages/react-test-renderer/jsx/index.ts +0 -1
  81. package/src/Web.ts +25 -69
  82. package/src/esbuildConfigs/web.ts +4 -2
  83. package/src/lib/abstractBase.ts +260 -65
  84. package/src/lib/basebuilder.ts +121 -100
  85. package/src/lib/classBuilder.ts +5 -4
  86. package/src/lib/core.ts +58 -59
  87. package/src/lib/index.ts +10 -9
  88. package/src/lib/types.ts +18 -27
  89. package/src/preload.ts +14 -14
  90. package/dist/common/NodeWriter.js +0 -54
  91. package/dist/common/electron.js +0 -266
  92. package/dist/module/NodeWriter.js +0 -48
  93. package/dist/module/electron.js +0 -261
  94. package/dist/types/NodeWriter.d.ts +0 -2
  95. package/src/NodeWriter.ts +0 -72
  96. package/src/electron.ts +0 -317
  97. package/yarn-error.log +0 -3144
  98. /package/dist/types/{electron.d.ts → Puppeteer.d.ts} +0 -0
@@ -1,7 +1,8 @@
1
1
  import { IBaseTest } from "../Types";
2
2
 
3
3
  import { ITTestResourceConfiguration, ITestArtifactory, ITLog } from ".";
4
- import { IUtils } from "./types";
4
+ import { PM } from "../PM/index.js";
5
+ // import { IUtils } from "./types";
5
6
 
6
7
  export type IGivens<ITestShape extends IBaseTest> = Record<
7
8
  string,
@@ -42,78 +43,153 @@ export abstract class BaseSuite<ITestShape extends IBaseTest> {
42
43
  s: ITestShape["iinput"],
43
44
  artifactory: ITestArtifactory,
44
45
  tr: ITTestResourceConfiguration,
45
- utils: IUtils
46
+ pm: PM
46
47
  ): Promise<ITestShape["isubject"]> {
47
48
  return new Promise((res) => res(s as unknown as ITestShape["isubject"]));
48
49
  }
49
50
 
50
51
  assertThat(t: ITestShape["then"]): unknown {
51
- // console.log("base assertThat")
52
52
  return t;
53
53
  }
54
54
 
55
+ afterAll(store: ITestShape["istore"], artifactory: ITestArtifactory, pm: PM) {
56
+ return store;
57
+ }
58
+
55
59
  async run(
56
60
  input: ITestShape["iinput"],
57
61
  testResourceConfiguration: ITTestResourceConfiguration,
58
62
  artifactory: (fPath: string, value: unknown) => void,
59
63
  tLog: (...string) => void,
60
- utils: IUtils
64
+ pm: PM
61
65
  ): Promise<BaseSuite<ITestShape>> {
62
66
  this.testResourceConfiguration = testResourceConfiguration;
63
- tLog("test resources: ", testResourceConfiguration);
67
+ tLog("test resources: ", JSON.stringify(testResourceConfiguration));
64
68
 
65
69
  const suiteArtifactory = (fPath: string, value: unknown) =>
66
70
  artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
67
- const subject = await this.setup(
68
- input,
69
- suiteArtifactory,
70
- testResourceConfiguration,
71
- utils
72
- );
73
71
 
72
+ console.log("\nSuite:", this.index, this.name);
74
73
  tLog("\nSuite:", this.index, this.name);
75
- for (const k of Object.keys(this.givens)) {
76
- const giver = this.givens[k];
74
+ const sNdx = this.index;
75
+ const sName = this.name;
76
+
77
+ for (const [gNdx, g] of Object.entries(this.givens)) {
78
+ const subject = await this.setup(
79
+ input,
80
+ suiteArtifactory,
81
+ testResourceConfiguration,
82
+ pm
83
+ );
84
+
85
+ const giver = this.givens[gNdx];
77
86
  try {
78
87
  this.store = await giver.give(
79
88
  subject,
80
- k,
89
+ gNdx,
81
90
  testResourceConfiguration,
82
91
  this.assertThat,
83
92
  suiteArtifactory,
84
93
  tLog,
85
- utils
94
+ pm,
95
+ sNdx
86
96
  );
87
97
  } catch (e) {
88
98
  console.error(e);
89
99
  this.fails.push(giver);
90
- return this;
100
+ // return this;
91
101
  }
92
102
  }
93
- for (const [ndx, thater] of this.checks.entries()) {
94
- await thater.check(
95
- subject,
96
- thater.name,
97
- testResourceConfiguration,
98
- this.assertThat,
99
- suiteArtifactory,
100
- tLog,
101
- utils
102
- );
103
+
104
+ const afterAllProxy = new Proxy(pm, {
105
+ get(target, prop, receiver) {
106
+ if (prop === "writeFileSync") {
107
+ return (fp, contents) =>
108
+ target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
109
+ }
110
+
111
+ if (prop === "browser") {
112
+ return new Proxy(target[prop], {
113
+ get(bTarget, bProp, bReceiver) {
114
+ if (bProp === "pages") {
115
+ return async () => {
116
+ return bTarget.pages().then((pages) => {
117
+ return pages.map((page) => {
118
+ return new Proxy(page, {
119
+ get(pTarget, pProp, pReciever) {
120
+ if (pProp === "screenshot") {
121
+ return async (x) => {
122
+ // console.log(
123
+ // "custom-screenshot-MARK-afterAllProxy",
124
+ // // arguments,
125
+ // // x,
126
+ // window["custom-screenshot"].toString()
127
+ // );
128
+ return await window["custom-screenshot"]({
129
+ ...x,
130
+ path:
131
+ `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
132
+ "/" +
133
+ x.path,
134
+ });
135
+ };
136
+ }
137
+ // else if (pProp === "mainFrame") {
138
+ // return () => target[pProp](...arguments);
139
+ // }
140
+ else {
141
+ return Reflect.get(...arguments);
142
+ }
143
+ },
144
+ });
145
+ });
146
+ });
147
+ // return (await target.pages()).map((page) => {
148
+ // return new Proxy(page, handler2);
149
+ // });
150
+ };
151
+ }
152
+ },
153
+ });
154
+ }
155
+
156
+ return Reflect.get(...arguments);
157
+ },
158
+ });
159
+
160
+ // pm.browser
161
+ try {
162
+ this.afterAll(this.store, artifactory, afterAllProxy);
163
+ } catch (e) {
164
+ console.error(e);
165
+ // this.fails.push(this);
166
+ // return this;
103
167
  }
104
168
 
105
- // @TODO fix me
106
- for (const k of Object.keys(this.givens)) {
107
- const giver = this.givens[k];
169
+ // for (const [ndx, thater] of this.checks.entries()) {
170
+ // await thater.check(
171
+ // subject,
172
+ // thater.name,
173
+ // testResourceConfiguration,
174
+ // this.assertThat,
175
+ // suiteArtifactory,
176
+ // tLog,
177
+ // pm
178
+ // );
179
+ // }
108
180
 
109
- try {
110
- giver.afterAll(this.store, artifactory, utils);
111
- } catch (e) {
112
- console.error(e);
113
- this.fails.push(giver);
114
- return this;
115
- }
116
- }
181
+ // @TODO fix me
182
+ // for (const k of Object.keys(this.givens)) {
183
+ // const giver = this.givens[k];
184
+
185
+ // try {
186
+ // giver.afterAll(this.store, artifactory, pm);
187
+ // } catch (e) {
188
+ // console.error(e);
189
+ // this.fails.push(giver);
190
+ // return this;
191
+ // }
192
+ // }
117
193
  ////////////////
118
194
 
119
195
  return this;
@@ -126,6 +202,7 @@ export abstract class BaseGiven<ITestShape extends IBaseTest> {
126
202
  whens: BaseWhen<ITestShape>[];
127
203
  thens: BaseThen<ITestShape>[];
128
204
  error: Error;
205
+ fail: any;
129
206
  store: ITestShape["istore"];
130
207
  recommendedFsPath: string;
131
208
  givenCB: ITestShape["given"];
@@ -151,20 +228,13 @@ export abstract class BaseGiven<ITestShape extends IBaseTest> {
151
228
  return store;
152
229
  }
153
230
 
154
- afterAll(
155
- store: ITestShape["istore"],
156
- artifactory: ITestArtifactory,
157
- utils: IUtils
158
- ) {
159
- return store;
160
- }
161
-
162
231
  toObj() {
163
232
  return {
164
233
  name: this.name,
165
234
  whens: this.whens.map((w) => w.toObj()),
166
235
  thens: this.thens.map((t) => t.toObj()),
167
236
  error: this.error ? [this.error, this.error.stack] : null,
237
+ // fail: this.fail ? [this.fail] : false,
168
238
  features: this.features,
169
239
  };
170
240
  }
@@ -173,14 +243,15 @@ export abstract class BaseGiven<ITestShape extends IBaseTest> {
173
243
  subject: ITestShape["isubject"],
174
244
  testResourceConfiguration,
175
245
  artifactory: ITestArtifactory,
176
- givenCB: ITestShape["given"]
246
+ givenCB: ITestShape["given"],
247
+ pm: PM
177
248
  ): Promise<ITestShape["istore"]>;
178
249
 
179
250
  async afterEach(
180
251
  store: ITestShape["istore"],
181
252
  key: string,
182
253
  artifactory: ITestArtifactory,
183
- utils: IUtils
254
+ pm: PM
184
255
  ): Promise<unknown> {
185
256
  return store;
186
257
  }
@@ -189,33 +260,58 @@ export abstract class BaseGiven<ITestShape extends IBaseTest> {
189
260
  subject: ITestShape["isubject"],
190
261
  key: string,
191
262
  testResourceConfiguration,
192
- tester,
263
+ tester: (t: Awaited<ITestShape["then"]> | undefined) => boolean,
193
264
  artifactory: ITestArtifactory,
194
265
  tLog: ITLog,
195
- utils: IUtils
266
+ pm: PM,
267
+ suiteNdx: number
196
268
  ) {
197
269
  tLog(`\n Given: ${this.name}`);
198
270
 
199
271
  const givenArtifactory = (fPath: string, value: unknown) =>
200
272
  artifactory(`given-${key}/${fPath}`, value);
201
273
  try {
274
+ // tLog(`\n Given this.store`, this.store);
275
+
276
+ const beforeEachProxy = new Proxy(pm, {
277
+ get(target, prop, receiver) {
278
+ if (prop === "writeFileSync") {
279
+ console.log("beforeEachProx", arguments, target[prop]);
280
+ return (fp, contents) =>
281
+ target[prop](
282
+ `suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`,
283
+ contents
284
+ );
285
+ }
286
+
287
+ return Reflect.get(...arguments);
288
+ },
289
+ });
290
+
202
291
  this.store = await this.givenThat(
203
292
  subject,
204
293
  testResourceConfiguration,
205
294
  givenArtifactory,
206
- this.givenCB
295
+ this.givenCB,
296
+ beforeEachProxy
207
297
  );
208
298
 
209
- // tLog(`\n Given this.store`, this.store);
210
- for (const whenStep of this.whens) {
211
- await whenStep.test(this.store, testResourceConfiguration, tLog, utils);
299
+ for (const [whenNdx, whenStep] of this.whens.entries()) {
300
+ await whenStep.test(
301
+ this.store,
302
+ testResourceConfiguration,
303
+ tLog,
304
+ pm,
305
+ `suite-${suiteNdx}/given-${key}/when/${whenNdx}`
306
+ );
212
307
  }
308
+
213
309
  for (const thenStep of this.thens) {
214
310
  const t = await thenStep.test(
215
311
  this.store,
216
312
  testResourceConfiguration,
217
313
  tLog,
218
- utils
314
+ pm
219
315
  );
220
316
  tester(t);
221
317
  }
@@ -226,7 +322,82 @@ export abstract class BaseGiven<ITestShape extends IBaseTest> {
226
322
  // throw e;
227
323
  } finally {
228
324
  try {
229
- await this.afterEach(this.store, key, givenArtifactory, utils);
325
+ // const afterEachProxy = new Proxy(pm, {
326
+ // get(target, prop, receiver) {
327
+ // if (prop === "writeFileSync") {
328
+ // console.log("afterEachProxy", arguments, target[prop]);
329
+ // return (fp, contents) =>
330
+ // // target[prop](`${key}/andWhen/${fp}`, contents);
331
+ // target[prop](`${key}/afterEach/${fp}`, contents);
332
+ // }
333
+
334
+ // return Reflect.get(...arguments);
335
+ // },
336
+ // });
337
+
338
+ // await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
339
+
340
+ // await this.afterEach(this.store, key, givenArtifactory, pm);
341
+
342
+ const afterEachProxy = new Proxy(pm, {
343
+ get(target, prop, receiver) {
344
+ if (prop === "writeFileSync") {
345
+ return (fp, contents) =>
346
+ target[prop](
347
+ `suite-${suiteNdx}/given-${key}/afterAll/${fp}`,
348
+ contents
349
+ );
350
+ }
351
+
352
+ if (prop === "browser") {
353
+ return new Proxy(target[prop], {
354
+ get(bTarget, bProp, bReceiver) {
355
+ if (bProp === "pages") {
356
+ return async () => {
357
+ return bTarget.pages().then((pages) => {
358
+ return pages.map((page) => {
359
+ return new Proxy(page, {
360
+ get(pTarget, pProp, pReciever) {
361
+ if (pProp === "screenshot") {
362
+ return async (x) => {
363
+ // console.log(
364
+ // "custom-screenshot-MARK-afterEachProxy",
365
+ // window["custom-screenshot"].toString()
366
+ // );
367
+
368
+ return await pTarget[pProp]({
369
+ ...x,
370
+ path:
371
+ `${testResourceConfiguration.fs}/suite-${suiteNdx}/given-${key}/afterEach` +
372
+ "/" +
373
+ x.path,
374
+ });
375
+ };
376
+ }
377
+ // else if (pProp === "mainFrame") {
378
+ // return () => target[pProp](...arguments);
379
+ // }
380
+ else {
381
+ return Reflect.get(...arguments);
382
+ }
383
+ },
384
+ });
385
+ });
386
+ });
387
+ // return (await target.pages()).map((page) => {
388
+ // return new Proxy(page, handler2);
389
+ // });
390
+ };
391
+ }
392
+ },
393
+ });
394
+ }
395
+
396
+ return Reflect.get(...arguments);
397
+ },
398
+ });
399
+
400
+ await this.afterEach(this.store, key, givenArtifactory, afterEachProxy);
230
401
  } catch (e) {
231
402
  console.error("afterEach failed! no error will be recorded!", e);
232
403
  }
@@ -251,7 +422,8 @@ export abstract class BaseWhen<ITestShape extends IBaseTest> {
251
422
  abstract andWhen(
252
423
  store: ITestShape["istore"],
253
424
  whenCB: (x: ITestShape["iselection"]) => ITestShape["then"],
254
- testResource
425
+ testResource,
426
+ pm: PM
255
427
  );
256
428
 
257
429
  toObj() {
@@ -265,11 +437,32 @@ export abstract class BaseWhen<ITestShape extends IBaseTest> {
265
437
  store: ITestShape["istore"],
266
438
  testResourceConfiguration,
267
439
  tLog: ITLog,
268
- utils: IUtils
440
+ pm: PM,
441
+ key: string
269
442
  ) {
270
443
  tLog(" When:", this.name);
444
+
445
+ const name = this.name;
446
+ const andWhenProxy = new Proxy(pm, {
447
+ get(target, prop, receiver) {
448
+ if (prop === "writeFileSync") {
449
+ console.log("andWhenProxy", arguments, target[prop]);
450
+ return (fp, contents) =>
451
+ // target[prop](`${key}/andWhen/${fp}`, contents);
452
+ target[prop](`${key}/andWhen/${fp}`, contents);
453
+ }
454
+
455
+ return Reflect.get(...arguments);
456
+ },
457
+ });
458
+
271
459
  try {
272
- return await this.andWhen(store, this.whenCB, testResourceConfiguration);
460
+ return await this.andWhen(
461
+ store,
462
+ this.whenCB,
463
+ testResourceConfiguration,
464
+ andWhenProxy
465
+ );
273
466
  } catch (e) {
274
467
  this.error = true;
275
468
  throw e;
@@ -288,6 +481,7 @@ export abstract class BaseThen<ITestShape extends IBaseTest> {
288
481
  ) {
289
482
  this.name = name;
290
483
  this.thenCB = thenCB;
484
+ this.error = false;
291
485
  }
292
486
 
293
487
  toObj() {
@@ -307,7 +501,7 @@ export abstract class BaseThen<ITestShape extends IBaseTest> {
307
501
  store: ITestShape["istore"],
308
502
  testResourceConfiguration,
309
503
  tLog: ITLog,
310
- utils: IUtils
504
+ pm: PM
311
505
  ): Promise<ITestShape["then"] | undefined> {
312
506
  tLog(" Then:", this.name);
313
507
  try {
@@ -319,7 +513,7 @@ export abstract class BaseThen<ITestShape extends IBaseTest> {
319
513
  return x;
320
514
  } catch (e) {
321
515
  console.log("test failed", e);
322
- this.error = true;
516
+ this.error = e.message;
323
517
  throw e;
324
518
  }
325
519
  }
@@ -360,7 +554,7 @@ export abstract class BaseCheck<ITestShape extends IBaseTest> {
360
554
  store: ITestShape["istore"],
361
555
  key: string,
362
556
  cb,
363
- utils: IUtils
557
+ pm: PM
364
558
  ): Promise<unknown> {
365
559
  return;
366
560
  }
@@ -372,7 +566,7 @@ export abstract class BaseCheck<ITestShape extends IBaseTest> {
372
566
  tester,
373
567
  artifactory: ITestArtifactory,
374
568
  tLog: ITLog,
375
- utils: IUtils
569
+ pm: PM
376
570
  ) {
377
571
  tLog(`\n Check: ${this.name}`);
378
572
  const store = await this.checkThat(
@@ -387,7 +581,8 @@ export abstract class BaseCheck<ITestShape extends IBaseTest> {
387
581
  store,
388
582
  testResourceConfiguration,
389
583
  tLog,
390
- utils
584
+ pm,
585
+ "x"
391
586
  );
392
587
  };
393
588
  return a;
@@ -398,7 +593,7 @@ export abstract class BaseCheck<ITestShape extends IBaseTest> {
398
593
  store,
399
594
  testResourceConfiguration,
400
595
  tLog,
401
- utils
596
+ pm
402
597
  );
403
598
  tester(t);
404
599
  };
@@ -406,7 +601,7 @@ export abstract class BaseCheck<ITestShape extends IBaseTest> {
406
601
  }, {})
407
602
  );
408
603
 
409
- await this.afterEach(store, key, () => {}, utils);
604
+ await this.afterEach(store, key, () => {}, pm);
410
605
  return;
411
606
  }
412
607
  }