testeranto 0.90.0 → 0.94.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 (60) hide show
  1. package/dist/common/src/Node.js +5 -3
  2. package/dist/common/src/PM/main.js +102 -92
  3. package/dist/common/src/Project.js +5 -3
  4. package/dist/common/src/Puppeteer.js +1 -3
  5. package/dist/common/src/SubPackages/puppeteer.js +1 -1
  6. package/dist/common/src/SubPackages/react/jsx/index.js +14 -6
  7. package/dist/common/src/SubPackages/react/jsx/node.js +7 -2
  8. package/dist/common/src/SubPackages/react-dom/component/web.js +13 -39
  9. package/dist/common/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  10. package/dist/common/src/Web.js +25 -21
  11. package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +0 -2
  12. package/dist/common/src/lib/abstractBase.js +29 -184
  13. package/dist/common/src/lib/basebuilder.js +1 -11
  14. package/dist/common/src/lib/classBuilder.js +1 -1
  15. package/dist/common/src/lib/core.js +8 -28
  16. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  17. package/dist/module/src/Node.js +5 -3
  18. package/dist/module/src/PM/main.js +102 -92
  19. package/dist/module/src/Project.js +5 -3
  20. package/dist/module/src/Puppeteer.js +1 -3
  21. package/dist/module/src/SubPackages/puppeteer.js +1 -1
  22. package/dist/module/src/SubPackages/react/jsx/index.js +14 -6
  23. package/dist/module/src/SubPackages/react/jsx/node.js +7 -2
  24. package/dist/module/src/SubPackages/react-dom/component/web.js +13 -39
  25. package/dist/module/src/SubPackages/react-test-renderer/component/interface.js +2 -10
  26. package/dist/module/src/Web.js +25 -21
  27. package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +0 -2
  28. package/dist/module/src/lib/abstractBase.js +29 -184
  29. package/dist/module/src/lib/basebuilder.js +1 -11
  30. package/dist/module/src/lib/classBuilder.js +1 -1
  31. package/dist/module/src/lib/core.js +8 -28
  32. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  33. package/dist/prebuild/build-tests.mjs +4 -3
  34. package/dist/prebuild/run-tests.mjs +30 -66
  35. package/dist/types/src/Node.d.ts +4 -1
  36. package/dist/types/src/PM/main.d.ts +2 -1
  37. package/dist/types/src/SubPackages/react/jsx/node.d.ts +1 -1
  38. package/dist/types/src/SubPackages/react-test-renderer/component/interface.d.ts +1 -1
  39. package/dist/types/src/Web.d.ts +2 -2
  40. package/dist/types/src/lib/abstractBase.d.ts +6 -2
  41. package/dist/types/src/lib/core.d.ts +3 -3
  42. package/dist/types/src/lib/types.d.ts +5 -1
  43. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  44. package/package.json +13 -13
  45. package/src/Node.ts +6 -3
  46. package/src/PM/main.ts +121 -111
  47. package/src/Project.ts +6 -5
  48. package/src/Puppeteer.ts +1 -3
  49. package/src/SubPackages/puppeteer.ts +1 -1
  50. package/src/SubPackages/react/jsx/index.ts +15 -7
  51. package/src/SubPackages/react/jsx/node.ts +6 -5
  52. package/src/SubPackages/react-dom/component/web.ts +28 -51
  53. package/src/SubPackages/react-test-renderer/component/interface.ts +4 -11
  54. package/src/Web.ts +45 -23
  55. package/src/esbuildConfigs/inputFilesPlugin.ts +0 -3
  56. package/src/lib/abstractBase.ts +38 -188
  57. package/src/lib/basebuilder.ts +1 -12
  58. package/src/lib/classBuilder.ts +2 -1
  59. package/src/lib/core.ts +17 -29
  60. package/src/lib/types.ts +3 -1
@@ -41,11 +41,12 @@ export class BaseSuite {
41
41
  this.testResourceConfiguration = testResourceConfiguration;
42
42
  tLog("test resources: ", JSON.stringify(testResourceConfiguration));
43
43
  const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
44
- console.log("\nSuite:", this.index, this.name);
44
+ // console.log("\nSuite:", this.index, this.name);
45
45
  tLog("\nSuite:", this.index, this.name);
46
46
  const sNdx = this.index;
47
47
  const sName = this.name;
48
- for (const [gNdx, g] of Object.entries(this.givens)) {
48
+ for (const [gKey, g] of Object.entries(this.givens)) {
49
+ // console.log("gKey", gKey);
49
50
  const beforeAllProxy = new Proxy(pm, {
50
51
  get(target, prop, receiver) {
51
52
  if (prop === "customScreenShot") {
@@ -56,65 +57,13 @@ export class BaseSuite {
56
57
  if (prop === "writeFileSync") {
57
58
  return (fp, contents) => target[prop](`suite-${sNdx}/beforeAll/${fp}`, contents);
58
59
  }
59
- // if (prop === "browser") {
60
- // return new Proxy(target[prop], {
61
- // get(bTarget, bProp, bReceiver) {
62
- // if (bProp === "pages") {
63
- // return async () => {
64
- // return bTarget.pages().then((pages) => {
65
- // return pages.map((page) => {
66
- // return new Proxy(page, {
67
- // get(pTarget, pProp, pReciever) {
68
- // if (pProp === "screenshot") {
69
- // return async (x) => {
70
- // return pm.customScreenShot(
71
- // {
72
- // ...x,
73
- // path:
74
- // `${testResourceConfiguration.fs}/suite-${sNdx}/beforeAll` +
75
- // "/" +
76
- // x.path,
77
- // },
78
- // page
79
- // );
80
- // // return await window["custom-screenshot"]({
81
- // // ...x,
82
- // // path:
83
- // // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
84
- // // "/" +
85
- // // x.path,
86
- // // });
87
- // };
88
- // } else if (pProp === "mainFrame") {
89
- // return () => pTarget[pProp]();
90
- // } else if (pProp === "close") {
91
- // return () => pTarget[pProp]();
92
- // }
93
- // // else if (pProp === "mainFrame") {
94
- // // return () => target[pProp](...arguments);
95
- // // }
96
- // else {
97
- // return Reflect.get(...arguments);
98
- // }
99
- // },
100
- // });
101
- // });
102
- // });
103
- // // return (await target.pages()).map((page) => {
104
- // // return new Proxy(page, handler2);
105
- // // });
106
- // };
107
- // }
108
- // },
109
- // });
110
- // }
111
60
  return Reflect.get(...arguments);
112
61
  },
113
62
  });
114
63
  const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration, beforeAllProxy);
115
- const giver = this.givens[gNdx];
64
+ const giver = this.givens[gKey];
116
65
  try {
117
- this.store = await giver.give(subject, gNdx, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
66
+ this.store = await giver.give(subject, gKey, testResourceConfiguration, this.assertThat, suiteArtifactory, tLog, pm, sNdx);
118
67
  }
119
68
  catch (e) {
120
69
  console.error(e);
@@ -122,64 +71,6 @@ export class BaseSuite {
122
71
  // return this;
123
72
  }
124
73
  }
125
- // const afterAllProxy = new Proxy(pm, {
126
- // get(target, prop, receiver) {
127
- // if (prop === "writeFileSync") {
128
- // return (fp, contents) =>
129
- // target[prop](`suite-${sNdx}/afterAll/${fp}`, contents);
130
- // }
131
- // if (prop === "browser") {
132
- // return new Proxy(target[prop], {
133
- // get(bTarget, bProp, bReceiver) {
134
- // if (bProp === "pages") {
135
- // return async () => {
136
- // return bTarget.pages().then((pages) => {
137
- // return pages.map((page) => {
138
- // return new Proxy(page, {
139
- // get(pTarget, pProp, pReciever) {
140
- // if (pProp === "screenshot") {
141
- // return async (x) => {
142
- // return pm.customScreenShot({
143
- // ...x,
144
- // path:
145
- // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
146
- // "/" +
147
- // x.path,
148
- // });
149
- // // return await window["custom-screenshot"]({
150
- // // ...x,
151
- // // path:
152
- // // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
153
- // // "/" +
154
- // // x.path,
155
- // // });
156
- // };
157
- // } else if (pProp === "mainFrame") {
158
- // return () => pTarget[pProp]();
159
- // } else if (pProp === "close") {
160
- // return () => pTarget[pProp]();
161
- // }
162
- // // else if (pProp === "mainFrame") {
163
- // // return () => target[pProp](...arguments);
164
- // // }
165
- // else {
166
- // return Reflect.get(...arguments);
167
- // }
168
- // },
169
- // });
170
- // });
171
- // });
172
- // // return (await target.pages()).map((page) => {
173
- // // return new Proxy(page, handler2);
174
- // // });
175
- // };
176
- // }
177
- // },
178
- // });
179
- // }
180
- // return Reflect.get(...arguments);
181
- // },
182
- // });
183
74
  try {
184
75
  this.afterAll(this.store, artifactory,
185
76
  // afterAllProxy
@@ -217,7 +108,9 @@ export class BaseSuite {
217
108
  }
218
109
  }
219
110
  export class BaseGiven {
220
- constructor(name, features, whens, thens, givenCB, initialValues) {
111
+ constructor(name, features, whens, thens, givenCB, initialValues
112
+ // key: string
113
+ ) {
221
114
  this.name = name;
222
115
  this.features = features;
223
116
  this.whens = whens;
@@ -225,11 +118,15 @@ export class BaseGiven {
225
118
  this.givenCB = givenCB;
226
119
  this.initialValues = initialValues;
227
120
  }
228
- beforeAll(store, artifactory) {
121
+ beforeAll(store,
122
+ // artifactory: ITestArtifactory
123
+ // subject,
124
+ initializer, artifactory, testResource, initialValues, pm) {
229
125
  return store;
230
126
  }
231
127
  toObj() {
232
128
  return {
129
+ key: this.key,
233
130
  name: this.name,
234
131
  whens: this.whens.map((w) => w.toObj()),
235
132
  thens: this.thens.map((t) => t.toObj()),
@@ -242,30 +139,34 @@ export class BaseGiven {
242
139
  return store;
243
140
  }
244
141
  async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
142
+ this.key = key;
143
+ tLog(`\n ${this.key}`);
245
144
  tLog(`\n Given: ${this.name}`);
246
- const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
145
+ const givenArtifactory = (fPath, value) => artifactory(`given-${this.key}/${fPath}`, value);
247
146
  try {
248
147
  // tLog(`\n Given this.store`, this.store);
249
148
  const beforeEachProxy = new Proxy(pm, {
250
149
  get(target, prop, receiver) {
251
150
  if (prop === "writeFileSync") {
252
- return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/when/beforeEach/${fp}`, contents);
151
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${this.key}/when/beforeEach/${fp}`, contents);
253
152
  }
254
153
  if (prop === "customScreenShot") {
255
- return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), {
256
- // path: `${filepath}/${opts.path}`,
257
- path: `suite-${suiteNdx}/given-${key}/when/beforeEach/${opts.path}` }));
154
+ return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${this.key}/when/beforeEach/${opts.path}` }));
258
155
  }
259
156
  return Reflect.get(...arguments);
260
157
  },
261
158
  });
262
- this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, beforeEachProxy);
263
- // console.log("mark6", this.store);
159
+ this.uberCatcher((e) => {
160
+ console.error(e);
161
+ this.error = e.error;
162
+ tLog(e.stack);
163
+ });
164
+ this.store = await this.givenThat(subject, testResourceConfiguration, givenArtifactory, this.givenCB, this.initialValues, beforeEachProxy);
264
165
  for (const [whenNdx, whenStep] of this.whens.entries()) {
265
- await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/when/${whenNdx}`);
166
+ await whenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${this.key}/when/${whenNdx}`);
266
167
  }
267
168
  for (const [thenNdx, thenStep] of this.thens.entries()) {
268
- const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${key}/then-${thenNdx}`);
169
+ const t = await thenStep.test(this.store, testResourceConfiguration, tLog, pm, `suite-${suiteNdx}/given-${this.key}/then-${thenNdx}`);
269
170
  tester(t);
270
171
  }
271
172
  }
@@ -281,15 +182,15 @@ export class BaseGiven {
281
182
  const afterEachProxy = new Proxy(pm, {
282
183
  get(target, prop, receiver) {
283
184
  if (prop === "customScreenShot") {
284
- return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${key}/afterEach/${opts.path}` }));
185
+ return (opts) => target.customScreenShot(Object.assign(Object.assign({}, opts), { path: `suite-${suiteNdx}/given-${this.key}/afterEach/${opts.path}` }));
285
186
  }
286
187
  if (prop === "writeFileSync") {
287
- return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${key}/afterEach/${fp}`, contents);
188
+ return (fp, contents) => target[prop](`suite-${suiteNdx}/given-${this.key}/afterEach/${fp}`, contents);
288
189
  }
289
190
  return Reflect.get(...arguments);
290
191
  },
291
192
  });
292
- await this.afterEach(this.store, key, givenArtifactory,
193
+ await this.afterEach(this.store, this.key, givenArtifactory,
293
194
  // pm
294
195
  afterEachProxy);
295
196
  }
@@ -445,62 +346,6 @@ export class BaseThen {
445
346
  if (prop === "writeFileSync") {
446
347
  return (fp, contents) => target[prop](`${filepath}/${fp}`, contents);
447
348
  }
448
- // if (prop === "browser") {
449
- // return new Proxy(target[prop], {
450
- // get(bTarget, bProp, bReceiver) {
451
- // if (bProp === "pages") {
452
- // return async () => {
453
- // return bTarget.pages().then((pages) => {
454
- // return pages.map((page) => {
455
- // return new Proxy(page, {
456
- // get(pTarget, pProp, pReciever) {
457
- // if (pProp === "screenshot") {
458
- // return async (x) => {
459
- // return pm.customScreenShot(
460
- // {
461
- // ...x,
462
- // path:
463
- // `${testResourceConfiguration.fs}/${filepath}/butThen` +
464
- // "/" +
465
- // x.path,
466
- // },
467
- // page
468
- // );
469
- // // return await window["custom-screenshot"]({
470
- // // ...x,
471
- // // path:
472
- // // `${testResourceConfiguration.fs}/suite-${sNdx}/afterAll` +
473
- // // "/" +
474
- // // x.path,
475
- // // });
476
- // };
477
- // } else if (pProp === "close") {
478
- // return () => pTarget[pProp]();
479
- // } else if (pProp === "mainFrame") {
480
- // return () => pTarget[pProp]();
481
- // } else if (pProp === "exposeFunction") {
482
- // // return Reflect.get(target, prop, receiver);
483
- // return (...a) => pTarget[pProp](...a);
484
- // // return target[pProp];
485
- // } else if (pProp === "removeExposedFunction") {
486
- // // return Reflect.get(target, prop, receiver);
487
- // return pTarget[pProp].bind(pTarget);
488
- // // return target[pProp];
489
- // } else {
490
- // return Reflect.get(...arguments);
491
- // }
492
- // },
493
- // });
494
- // });
495
- // });
496
- // // return (await target.pages()).map((page) => {
497
- // // return new Proxy(page, handler2);
498
- // // });
499
- // };
500
- // }
501
- // },
502
- // });
503
- // }
504
349
  return Reflect.get(...arguments);
505
350
  },
506
351
  });
@@ -11,21 +11,11 @@ export class BaseBuilder {
11
11
  this.checkOverides = checkOverides;
12
12
  this.testSpecification = testSpecification;
13
13
  this.specs = testSpecification(this.Suites(), this.Given(), this.When(), this.Then(), this.Check());
14
- // const f = this.specs[0].features;
15
14
  this.testJobs = this.specs.map((suite) => {
16
15
  const suiteRunner = (suite) => async (puppetMaster, tLog) => {
17
- // const puppeteerBrowser = await puppetMaster.startPuppeteer(
18
- // {
19
- // browserWSEndpoint:
20
- // puppetMaster.testResourceConfiguration.browserWSEndpoint,
21
- // },
22
- // puppetMaster.testResourceConfiguration.fs
23
- // );
24
16
  const x = await suite.run(input, puppetMaster.testResourceConfiguration, (fPath, value) => puppetMaster.testArtiFactoryfileWriter(tLog, (p) => {
25
17
  this.artifacts.push(p);
26
18
  })(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value), tLog, puppetMaster);
27
- // await puppetMaster.browser.disconnect();
28
- // puppeteerBrowser.close();
29
19
  return x;
30
20
  };
31
21
  const runner = suiteRunner(suite);
@@ -59,7 +49,7 @@ export class BaseBuilder {
59
49
  // );
60
50
  // }
61
51
  puppetMaster.writeFileSync(`tests.json`, JSON.stringify(this.toObj(), null, 2));
62
- console.log(`exiting gracefully with ${numberOfFailures} failures.`);
52
+ // console.log(`exiting gracefully with ${numberOfFailures} failures.`);
63
53
  return {
64
54
  failed: numberOfFailures,
65
55
  artifacts: this.artifacts || [],
@@ -7,7 +7,7 @@ export class ClassBuilder extends BaseBuilder {
7
7
  };
8
8
  return a;
9
9
  }, {});
10
- const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, givEn]) => {
10
+ const classyGivens = Object.entries(testImplementation.givens).reduce((a, [key, g]) => {
11
11
  a[key] = (features, whens, thens, givEn) => {
12
12
  return new givenKlasser.prototype.constructor(key, features, whens, thens, testImplementation.givens[key], givEn);
13
13
  };
@@ -2,28 +2,10 @@ import { DefaultTestInterface, defaultTestResourceRequirement, } from "./index.j
2
2
  import { BaseSuite, BaseGiven, BaseWhen, BaseThen, BaseCheck, } from "./abstractBase.js";
3
3
  import { ClassBuilder } from "./classBuilder.js";
4
4
  export default class Testeranto extends ClassBuilder {
5
- constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testInterface) {
5
+ constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testInterface, uberCatcher) {
6
6
  const fullTestInterface = DefaultTestInterface(testInterface);
7
7
  super(testImplementation, testSpecification, input, class extends BaseSuite {
8
8
  afterAll(store, artifactory, pm) {
9
- // const pagesHandler = {
10
- // get(target, prop) {
11
- // console.log(`Getting pages property ${prop}`);
12
- // return target[prop];
13
- // },
14
- // };
15
- // const browserHandler = {
16
- // get(target, prop) {
17
- // console.log(`Getting browser property ${prop}`);
18
- // if (prop === "pages") {
19
- // // return target[prop];
20
- // return new Proxy(target[prop], pagesHandler);
21
- // } else {
22
- // return target[prop];
23
- // }
24
- // },
25
- // };
26
- // const proxy = new Proxy(utils.browser, browserHandler);
27
9
  return fullTestInterface.afterAll(store, (fPath, value) => {
28
10
  artifactory(`afterAll4-${this.name}/${fPath}`, value);
29
11
  }, pm);
@@ -36,12 +18,12 @@ export default class Testeranto extends ClassBuilder {
36
18
  (async (input, artifactory, tr, pm) => input))(s, this.testResourceConfiguration, artifactory, pm);
37
19
  }
38
20
  }, class Given extends BaseGiven {
39
- async givenThat(subject, testResource, artifactory, initializer, pm) {
40
- return fullTestInterface.beforeEach(subject, initializer,
41
- // (fPath: string, value: unknown) =>
42
- // // TODO does not work?
43
- // artifactory(`beforeEach/${fPath}`, value),
44
- testResource, this.initialValues, pm);
21
+ constructor() {
22
+ super(...arguments);
23
+ this.uberCatcher = uberCatcher;
24
+ }
25
+ async givenThat(subject, testResource, artifactory, initializer, initialValues, pm) {
26
+ return fullTestInterface.beforeEach(subject, initializer, artifactory, testResource, initialValues, pm);
45
27
  }
46
28
  afterEach(store, key, artifactory, pm) {
47
29
  return new Promise((res) => res(fullTestInterface.afterEach(store, key, (fPath, value) => artifactory(`after/${fPath}`, value), pm)));
@@ -111,8 +93,6 @@ export default class Testeranto extends ClassBuilder {
111
93
  // TODO does not work?
112
94
  artifactory(`afterEach2-${this.name}/${fPath}`, value), pm)));
113
95
  }
114
- }, testResourceRequirement
115
- // puppetMaster
116
- );
96
+ }, testResourceRequirement);
117
97
  }
118
98
  }