testeranto 0.166.0 → 0.167.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 (48) hide show
  1. package/dist/common/src/Pure.js +2 -2
  2. package/dist/common/src/lib/baseBuilder.test/baseBuilder.test.mock.js +1 -1
  3. package/dist/common/src/lib/basebuilder.js +9 -7
  4. package/dist/common/src/lib/core.test/MockCore.js +17 -15
  5. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  6. package/dist/module/src/Pure.js +2 -2
  7. package/dist/module/src/lib/baseBuilder.test/baseBuilder.test.mock.js +1 -1
  8. package/dist/module/src/lib/basebuilder.js +9 -7
  9. package/dist/module/src/lib/core.test/MockCore.js +17 -15
  10. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  11. package/dist/tsconfig.tsbuildinfo +1 -0
  12. package/dist/types/src/lib/index.d.ts +0 -1
  13. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  14. package/package.json +1 -1
  15. package/src/Pure.ts +2 -2
  16. package/src/lib/baseBuilder.test/baseBuilder.test.mock.ts +1 -1
  17. package/src/lib/basebuilder.ts +9 -9
  18. package/src/lib/core.test/MockCore.ts +26 -19
  19. package/src/lib/index.ts +1 -1
  20. package/testeranto/bundles/node/allTests/chunk-H2IBV7SY.mjs +113 -0
  21. package/testeranto/bundles/node/allTests/chunk-IDCUSTSM.mjs +669 -0
  22. package/testeranto/bundles/node/allTests/chunk-ZHOULXPN.mjs +252 -0
  23. package/testeranto/bundles/node/allTests/metafile.json +28 -28
  24. package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test/node.test.mjs +3 -3
  25. package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.node.mjs +3 -3
  26. package/testeranto/bundles/node/allTests/src/lib/classBuilder.test/classBuilder.test.mjs +3 -3
  27. package/testeranto/bundles/node/allTests/src/lib/core.test/core.test.mjs +11 -8
  28. package/testeranto/bundles/node/allTests/src/lib/pmProxy.test/index.mjs +2 -2
  29. package/testeranto/bundles/pure/allTests/chunk-4ULDTZFU.mjs +666 -0
  30. package/testeranto/bundles/pure/allTests/chunk-5SBJWHSZ.mjs +200 -0
  31. package/testeranto/bundles/pure/allTests/metafile.json +33 -33
  32. package/testeranto/bundles/pure/allTests/src/Pure.test.mjs +2 -2
  33. package/testeranto/bundles/pure/allTests/src/lib/BaseSuite.test/pure.test.mjs +2 -2
  34. package/testeranto/bundles/pure/allTests/src/lib/baseBuilder.test/baseBuilder.test.pure.mjs +2 -2
  35. package/testeranto/bundles/web/allTests/chunk-46E6YGGN.mjs +847 -0
  36. package/testeranto/bundles/web/allTests/metafile.json +10 -10
  37. package/testeranto/bundles/web/allTests/src/lib/BaseSuite.test/web.test.mjs +1 -1
  38. package/testeranto/bundles/web/allTests/src/lib/baseBuilder.test/baseBuilder.test.web.mjs +2 -2
  39. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node.test/node/logs.txt +0 -0
  40. package/testeranto/reports/allTests/src/lib/BaseSuite.test/web.test/web/logs.txt +0 -0
  41. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.node/node/logs.txt +0 -0
  42. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test.web/web/logs.txt +0 -0
  43. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/logs.txt +0 -0
  44. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/lint_errors.txt +0 -12
  45. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/type_errors.txt +2 -5
  46. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/logs.txt +0 -0
  47. package/testeranto/reports/allTests/summary.json +2 -2
  48. package/tsc.log +236 -234
@@ -0,0 +1,847 @@
1
+ // src/lib/pmProxy.ts
2
+ var baseProxy = function(pm, mappings) {
3
+ return new Proxy(pm, {
4
+ get: (target, prop, receiver) => {
5
+ for (const mapping of mappings) {
6
+ const method = mapping[0];
7
+ const arger = mapping[1];
8
+ if (prop === method) {
9
+ return (...x) => target[prop](arger(...x));
10
+ }
11
+ }
12
+ return (...x) => target[prop](...x);
13
+ }
14
+ });
15
+ };
16
+ var butThenProxy = (pm, filepath) => baseProxy(pm, [
17
+ [
18
+ "screencast",
19
+ (opts2, p) => [
20
+ {
21
+ ...opts2,
22
+ path: `${filepath}/butThen/${opts2.path}`
23
+ },
24
+ p
25
+ ]
26
+ ],
27
+ ["createWriteStream", (fp) => [`${filepath}/butThen/${fp}`]],
28
+ [
29
+ "writeFileSync",
30
+ (fp, contents) => [`${filepath}/butThen/${fp}`, contents]
31
+ ],
32
+ [
33
+ "customScreenShot",
34
+ (opts2, p) => [
35
+ {
36
+ ...opts2,
37
+ path: `${filepath}/butThen/${opts2.path}`
38
+ },
39
+ p
40
+ ]
41
+ ]
42
+ ]);
43
+ var andWhenProxy = (pm, filepath) => baseProxy(pm, [
44
+ [
45
+ "screencast",
46
+ (opts2, p) => [
47
+ {
48
+ ...opts2,
49
+ path: `${filepath}/andWhen/${opts2.path}`
50
+ },
51
+ p
52
+ ]
53
+ ],
54
+ ["createWriteStream", (fp) => [`${filepath}/andWhen/${fp}`]],
55
+ ["writeFileSync", (fp, contents) => [`${filepath}/andWhen${fp}`, contents]],
56
+ [
57
+ "customScreenShot",
58
+ (opts2, p) => [
59
+ {
60
+ ...opts2,
61
+ path: `${filepath}/andWhen${opts2.path}`
62
+ },
63
+ p
64
+ ]
65
+ ]
66
+ ]);
67
+ var afterEachProxy = (pm, suite, given) => baseProxy(pm, [
68
+ [
69
+ "screencast",
70
+ (opts2, p) => [
71
+ {
72
+ ...opts2,
73
+ path: `suite-${suite}/given-${given}/afterEach/${opts2.path}`
74
+ },
75
+ p
76
+ ]
77
+ ],
78
+ ["createWriteStream", (fp) => [`suite-${suite}/afterEach/${fp}`]],
79
+ [
80
+ "writeFileSync",
81
+ (fp, contents) => [
82
+ `suite-${suite}/given-${given}/afterEach/${fp}`,
83
+ contents
84
+ ]
85
+ ],
86
+ [
87
+ "customScreenShot",
88
+ (opts2, p) => [
89
+ {
90
+ ...opts2,
91
+ path: `suite-${suite}/given-${given}/afterEach/${opts2.path}`
92
+ },
93
+ p
94
+ ]
95
+ ]
96
+ ]);
97
+ var beforeEachProxy = (pm, suite) => baseProxy(pm, [
98
+ [
99
+ "screencast",
100
+ (opts2, p) => [
101
+ {
102
+ ...opts2,
103
+ path: `suite-${suite}/beforeEach/${opts2.path}`
104
+ },
105
+ p
106
+ ]
107
+ ],
108
+ [
109
+ "writeFileSync",
110
+ (fp, contents) => [`suite-${suite}/beforeEach/${fp}`, contents]
111
+ ],
112
+ [
113
+ "customScreenShot",
114
+ (opts2, p) => [
115
+ {
116
+ ...opts2,
117
+ path: `suite-${suite}/beforeEach/${opts2.path}`
118
+ },
119
+ p
120
+ ]
121
+ ],
122
+ ["createWriteStream", (fp) => [`suite-${suite}/beforeEach/${fp}`]]
123
+ ]);
124
+ var beforeAllProxy = (pm, suite) => baseProxy(pm, [
125
+ [
126
+ "writeFileSync",
127
+ (fp, contents) => [`suite-${suite}/beforeAll/${fp}`, contents]
128
+ ],
129
+ [
130
+ "customScreenShot",
131
+ (opts2, p) => [
132
+ {
133
+ ...opts2,
134
+ path: `suite-${suite}/beforeAll/${opts2.path}`
135
+ },
136
+ p
137
+ ]
138
+ ],
139
+ ["createWriteStream", (fp) => [`suite-${suite}/beforeAll/${fp}`]]
140
+ ]);
141
+ var afterAllProxy = (pm, suite) => baseProxy(pm, [
142
+ ["createWriteStream", (fp) => [`suite-${suite}/afterAll/${fp}`]],
143
+ [
144
+ "writeFileSync",
145
+ (fp, contents) => [`suite-${suite}/afterAll/${fp}`, contents]
146
+ ],
147
+ [
148
+ "customScreenShot",
149
+ (opts2, p) => [
150
+ {
151
+ ...opts2,
152
+ path: `suite-${suite}/afterAll/${opts2.path}`
153
+ },
154
+ p
155
+ ]
156
+ ]
157
+ ]);
158
+
159
+ // src/lib/BaseSuite.ts
160
+ var BaseSuite = class {
161
+ constructor(name, index, givens = {}) {
162
+ const suiteName = name || "testSuite";
163
+ if (!suiteName) {
164
+ throw new Error("BaseSuite requires a non-empty name");
165
+ }
166
+ console.log("[DEBUG] BaseSuite constructor - name:", suiteName, "index:", index);
167
+ this.name = suiteName;
168
+ this.index = index;
169
+ this.givens = givens;
170
+ this.fails = 0;
171
+ console.log("[DEBUG] BaseSuite initialized:", this.name, this.index);
172
+ console.log("[DEBUG] BaseSuite givens:", Object.keys(givens));
173
+ }
174
+ features() {
175
+ try {
176
+ const features = Object.keys(this.givens).map((k) => this.givens[k].features).flat().filter((value, index, array) => {
177
+ return array.indexOf(value) === index;
178
+ });
179
+ console.debug("[DEBUG] Features extracted:", features);
180
+ return features || [];
181
+ } catch (e) {
182
+ console.error("[ERROR] Failed to extract features:", e);
183
+ return [];
184
+ }
185
+ }
186
+ toObj() {
187
+ const givens = Object.keys(this.givens).map((k) => this.givens[k].toObj());
188
+ return {
189
+ name: this.name,
190
+ givens,
191
+ fails: this.fails,
192
+ failed: this.failed,
193
+ features: this.features()
194
+ };
195
+ }
196
+ setup(s, artifactory, tr, pm) {
197
+ return new Promise((res) => res(s));
198
+ }
199
+ assertThat(t) {
200
+ return !!t;
201
+ }
202
+ afterAll(store, artifactory, pm) {
203
+ return store;
204
+ }
205
+ async run(input, testResourceConfiguration, artifactory, tLog, pm) {
206
+ this.testResourceConfiguration = testResourceConfiguration;
207
+ const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
208
+ tLog("\nSuite:", this.index, this.name);
209
+ const sNdx = this.index;
210
+ const subject = await this.setup(
211
+ input,
212
+ suiteArtifactory,
213
+ testResourceConfiguration,
214
+ beforeAllProxy(pm, sNdx.toString())
215
+ );
216
+ for (const [gKey, g] of Object.entries(this.givens)) {
217
+ const giver = this.givens[gKey];
218
+ this.store = await giver.give(
219
+ subject,
220
+ gKey,
221
+ testResourceConfiguration,
222
+ this.assertThat,
223
+ suiteArtifactory,
224
+ tLog,
225
+ pm,
226
+ sNdx
227
+ ).catch((e) => {
228
+ this.failed = true;
229
+ this.fails = this.fails + 1;
230
+ console.error("Given error 1:", e);
231
+ throw e;
232
+ });
233
+ }
234
+ try {
235
+ this.afterAll(
236
+ this.store,
237
+ artifactory,
238
+ afterAllProxy(pm, sNdx.toString())
239
+ );
240
+ } catch (e) {
241
+ console.error(e);
242
+ }
243
+ return this;
244
+ }
245
+ };
246
+
247
+ // src/PM/index.ts
248
+ var PM = class {
249
+ };
250
+
251
+ // src/PM/web.ts
252
+ var PM_Web = class extends PM {
253
+ constructor(t) {
254
+ super();
255
+ this.testResourceConfiguration = t;
256
+ }
257
+ start() {
258
+ return new Promise((r) => r());
259
+ }
260
+ stop() {
261
+ return new Promise((r) => r());
262
+ }
263
+ getInnerHtml(selector, page2) {
264
+ throw new Error("web.ts getInnHtml not implemented");
265
+ }
266
+ pages() {
267
+ throw new Error("Method not implemented.");
268
+ }
269
+ stopSideCar(n) {
270
+ return window["stopSideCar"](n, this.testResourceConfiguration.name);
271
+ }
272
+ launchSideCar(n) {
273
+ return window["launchSideCar"](n, this.testResourceConfiguration.name);
274
+ }
275
+ waitForSelector(p, s) {
276
+ return window["waitForSelector"](p, s);
277
+ }
278
+ screencast(o, p) {
279
+ return window["screencast"](
280
+ {
281
+ ...opts,
282
+ path: this.testResourceConfiguration.fs + "/" + opts.path
283
+ },
284
+ page.mainFrame()._id,
285
+ this.testResourceConfiguration.name
286
+ );
287
+ }
288
+ screencastStop(recorder) {
289
+ return window["screencastStop"](recorder);
290
+ }
291
+ closePage(p) {
292
+ return window["closePage"](p);
293
+ }
294
+ goto(p, url) {
295
+ return window["goto"](p, url);
296
+ }
297
+ newPage() {
298
+ return window["newPage"]();
299
+ }
300
+ $(selector) {
301
+ return window["$"](selector);
302
+ }
303
+ isDisabled(selector) {
304
+ return window["isDisabled"](selector);
305
+ }
306
+ getAttribute(selector, attribute) {
307
+ return window["getAttribute"](selector, attribute);
308
+ }
309
+ getValue(selector) {
310
+ return window["getValue"](selector);
311
+ }
312
+ focusOn(selector) {
313
+ return window["focusOn"](selector);
314
+ }
315
+ typeInto(value) {
316
+ return window["typeInto"](value);
317
+ }
318
+ async page(x) {
319
+ return window["page"](x);
320
+ }
321
+ click(selector) {
322
+ return window["click"](selector);
323
+ }
324
+ customScreenShot(x, y) {
325
+ const opts2 = x[0];
326
+ const page2 = x[1];
327
+ console.log("customScreenShot 2 opts", opts2);
328
+ console.log("customScreenShot 2 page", page2);
329
+ return window["customScreenShot"](
330
+ {
331
+ ...opts2,
332
+ path: this.testResourceConfiguration.fs + "/" + opts2.path
333
+ },
334
+ this.testResourceConfiguration.name,
335
+ page2
336
+ );
337
+ }
338
+ existsSync(destFolder) {
339
+ return window["existsSync"](destFolder);
340
+ }
341
+ mkdirSync(x) {
342
+ return window["mkdirSync"](this.testResourceConfiguration.fs + "/");
343
+ }
344
+ write(uid, contents) {
345
+ return window["write"](uid, contents);
346
+ }
347
+ writeFileSync(filepath, contents) {
348
+ return window["writeFileSync"](
349
+ this.testResourceConfiguration.fs + "/" + filepath,
350
+ contents,
351
+ this.testResourceConfiguration.name
352
+ );
353
+ }
354
+ createWriteStream(filepath) {
355
+ return window["createWriteStream"](
356
+ this.testResourceConfiguration.fs + "/" + filepath,
357
+ this.testResourceConfiguration.name
358
+ );
359
+ }
360
+ end(uid) {
361
+ return window["end"](uid);
362
+ }
363
+ customclose() {
364
+ window["customclose"](
365
+ this.testResourceConfiguration.fs,
366
+ this.testResourceConfiguration.name
367
+ );
368
+ }
369
+ testArtiFactoryfileWriter(tLog, callback) {
370
+ return (fPath, value) => {
371
+ callback(
372
+ new Promise((res, rej) => {
373
+ tLog("testArtiFactory =>", fPath);
374
+ })
375
+ );
376
+ };
377
+ }
378
+ };
379
+
380
+ // src/lib/index.ts
381
+ var BaseAdapter = () => ({
382
+ beforeAll: async (s) => s,
383
+ beforeEach: async function(subject, initialValues, x, testResource, pm) {
384
+ return subject;
385
+ },
386
+ afterEach: async (s) => s,
387
+ afterAll: (store) => void 0,
388
+ butThen: async (store, thenCb) => {
389
+ return thenCb(store);
390
+ },
391
+ andWhen: async (store, whenCB, testResource, pm) => {
392
+ try {
393
+ await whenCB(store, testResource, pm);
394
+ } catch (error) {
395
+ console.error("Error in andWhen:", error);
396
+ throw error;
397
+ }
398
+ },
399
+ assertThis: (x) => x
400
+ });
401
+ var DefaultAdapter = (p) => {
402
+ return {
403
+ ...BaseAdapter,
404
+ ...p
405
+ };
406
+ };
407
+ var defaultTestResourceRequirement = {
408
+ ports: 0
409
+ };
410
+
411
+ // src/lib/abstractBase.ts
412
+ var BaseGiven = class {
413
+ constructor(name, features, whens, thens, givenCB, initialValues) {
414
+ this.name = name;
415
+ this.features = features;
416
+ this.whens = whens;
417
+ this.thens = thens;
418
+ this.givenCB = givenCB;
419
+ this.initialValues = initialValues;
420
+ }
421
+ beforeAll(store) {
422
+ return store;
423
+ }
424
+ toObj() {
425
+ return {
426
+ key: this.key,
427
+ name: this.name,
428
+ whens: this.whens.map((w) => {
429
+ if (w && w.toObj)
430
+ return w.toObj();
431
+ console.error("w is not as expected!", w);
432
+ return {};
433
+ }),
434
+ thens: this.thens.map((t) => t.toObj()),
435
+ error: this.error ? [this.error, this.error.stack] : null,
436
+ failed: this.failed,
437
+ features: this.features
438
+ };
439
+ }
440
+ async afterEach(store, key, artifactory, pm) {
441
+ return store;
442
+ }
443
+ async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
444
+ this.key = key;
445
+ tLog(`
446
+ ${this.key}`);
447
+ tLog(`
448
+ Given: ${this.name}`);
449
+ const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
450
+ this.uberCatcher((e) => {
451
+ console.error(e);
452
+ this.error = e.error;
453
+ tLog(e.stack);
454
+ });
455
+ try {
456
+ this.store = await this.givenThat(
457
+ subject,
458
+ testResourceConfiguration,
459
+ givenArtifactory,
460
+ this.givenCB,
461
+ this.initialValues,
462
+ beforeEachProxy(pm, suiteNdx.toString())
463
+ );
464
+ } catch (e) {
465
+ console.error("failure 4 ", e);
466
+ this.error = e;
467
+ throw e;
468
+ }
469
+ try {
470
+ for (const [whenNdx, whenStep] of this.whens.entries()) {
471
+ await whenStep.test(
472
+ this.store,
473
+ testResourceConfiguration,
474
+ tLog,
475
+ pm,
476
+ `suite-${suiteNdx}/given-${key}/when/${whenNdx}`
477
+ );
478
+ }
479
+ for (const [thenNdx, thenStep] of this.thens.entries()) {
480
+ const t = await thenStep.test(
481
+ this.store,
482
+ testResourceConfiguration,
483
+ tLog,
484
+ pm,
485
+ `suite-${suiteNdx}/given-${key}/then-${thenNdx}`
486
+ );
487
+ tester(t);
488
+ }
489
+ } catch (e) {
490
+ this.failed = true;
491
+ tLog(e.stack);
492
+ throw e;
493
+ } finally {
494
+ try {
495
+ await this.afterEach(
496
+ this.store,
497
+ this.key,
498
+ givenArtifactory,
499
+ afterEachProxy(pm, suiteNdx.toString(), key)
500
+ );
501
+ } catch (e) {
502
+ console.error("afterEach failed!", e);
503
+ this.failed = e;
504
+ throw e;
505
+ }
506
+ }
507
+ return this.store;
508
+ }
509
+ };
510
+ var BaseWhen = class {
511
+ constructor(name, whenCB) {
512
+ this.name = name;
513
+ this.whenCB = whenCB;
514
+ }
515
+ toObj() {
516
+ console.log("toObj error", this.error);
517
+ return {
518
+ name: this.name,
519
+ error: this.error && this.error.name + this.error.stack
520
+ };
521
+ }
522
+ async test(store, testResourceConfiguration, tLog, pm, filepath) {
523
+ try {
524
+ tLog(" When:", this.name);
525
+ console.debug("[DEBUG] Executing When step:", this.name);
526
+ const result = await this.andWhen(
527
+ store,
528
+ this.whenCB,
529
+ testResourceConfiguration,
530
+ andWhenProxy(pm, filepath)
531
+ );
532
+ console.debug("[DEBUG] When step completed:", this.name);
533
+ return result;
534
+ } catch (e) {
535
+ console.error("[ERROR] When step failed:", this.name, e);
536
+ this.error = e;
537
+ throw e;
538
+ }
539
+ }
540
+ };
541
+ var BaseThen = class {
542
+ constructor(name, thenCB) {
543
+ this.name = name;
544
+ this.thenCB = thenCB;
545
+ this.error = false;
546
+ }
547
+ toObj() {
548
+ return {
549
+ name: this.name,
550
+ error: this.error
551
+ };
552
+ }
553
+ async test(store, testResourceConfiguration, tLog, pm, filepath) {
554
+ return this.butThen(
555
+ store,
556
+ async (s) => {
557
+ if (typeof this.thenCB === "function") {
558
+ return await this.thenCB(s);
559
+ } else {
560
+ return this.thenCB;
561
+ }
562
+ },
563
+ testResourceConfiguration,
564
+ butThenProxy(pm, filepath)
565
+ ).catch((e) => {
566
+ this.error = e.toString();
567
+ });
568
+ }
569
+ };
570
+
571
+ // src/lib/basebuilder.ts
572
+ var BaseBuilder = class {
573
+ constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, testResourceRequirement, testSpecification) {
574
+ this.artifacts = [];
575
+ this.artifacts = [];
576
+ this.testResourceRequirement = testResourceRequirement;
577
+ this.suitesOverrides = suitesOverrides;
578
+ this.givenOverides = givenOverides;
579
+ this.whenOverides = whenOverides;
580
+ this.thenOverides = thenOverides;
581
+ this.testSpecification = testSpecification;
582
+ this.specs = testSpecification(
583
+ this.Suites(),
584
+ this.Given(),
585
+ this.When(),
586
+ this.Then()
587
+ );
588
+ this.testJobs = this.specs.map((suite) => {
589
+ const suiteRunner = (suite2) => async (puppetMaster, tLog) => {
590
+ const x = await suite2.run(
591
+ input,
592
+ puppetMaster.testResourceConfiguration,
593
+ (fPath, value) => puppetMaster.testArtiFactoryfileWriter(
594
+ tLog,
595
+ (p) => {
596
+ this.artifacts.push(p);
597
+ }
598
+ )(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value),
599
+ tLog,
600
+ puppetMaster
601
+ );
602
+ return x;
603
+ };
604
+ const runner = suiteRunner(suite);
605
+ return {
606
+ test: suite,
607
+ toObj: () => {
608
+ return suite.toObj();
609
+ },
610
+ runner,
611
+ receiveTestResourceConfig: async function(puppetMaster) {
612
+ const tLog = async (...l) => {
613
+ };
614
+ const suiteDone = await runner(puppetMaster, tLog);
615
+ const fails = suiteDone.fails;
616
+ await puppetMaster.writeFileSync(`bdd_errors.txt`, fails.toString());
617
+ await puppetMaster.writeFileSync(
618
+ `tests.json`,
619
+ JSON.stringify(this.toObj(), null, 2)
620
+ );
621
+ return {
622
+ failed: fails > 0,
623
+ fails,
624
+ artifacts: this.artifacts || [],
625
+ // logPromise,
626
+ features: suiteDone.features()
627
+ };
628
+ }
629
+ };
630
+ });
631
+ }
632
+ // testsJson() {
633
+ // puppetMaster.writeFileSync(
634
+ // `tests.json`,
635
+ // JSON.stringify({ features: suiteDone.features() }, null, 2)
636
+ // );
637
+ // }
638
+ Specs() {
639
+ return this.specs;
640
+ }
641
+ Suites() {
642
+ return this.suitesOverrides;
643
+ }
644
+ Given() {
645
+ return this.givenOverides;
646
+ }
647
+ When() {
648
+ return this.whenOverides;
649
+ }
650
+ Then() {
651
+ return this.thenOverides;
652
+ }
653
+ };
654
+
655
+ // src/lib/classBuilder.ts
656
+ var ClassBuilder = class extends BaseBuilder {
657
+ constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, testResourceRequirement) {
658
+ const classySuites = Object.entries(testImplementation.suites).reduce(
659
+ (a, [key], index) => {
660
+ a[key] = (somestring, givens) => {
661
+ return new suiteKlasser.prototype.constructor(
662
+ somestring,
663
+ index,
664
+ givens
665
+ );
666
+ };
667
+ return a;
668
+ },
669
+ {}
670
+ );
671
+ const classyGivens = Object.entries(testImplementation.givens).reduce(
672
+ (a, [key, g]) => {
673
+ a[key] = (features, whens, thens, ...initialValues) => {
674
+ return new givenKlasser.prototype.constructor(
675
+ key,
676
+ features,
677
+ whens,
678
+ thens,
679
+ testImplementation.givens[key],
680
+ initialValues
681
+ );
682
+ };
683
+ return a;
684
+ },
685
+ {}
686
+ );
687
+ const classyWhens = Object.entries(testImplementation.whens).reduce(
688
+ (a, [key, whEn]) => {
689
+ a[key] = (...payload) => {
690
+ return new whenKlasser.prototype.constructor(
691
+ `${whEn.name}: ${payload && payload.toString()}`,
692
+ whEn(...payload)
693
+ );
694
+ };
695
+ return a;
696
+ },
697
+ {}
698
+ );
699
+ const classyThens = Object.entries(
700
+ testImplementation.thens
701
+ ).reduce(
702
+ (a, [key, thEn]) => {
703
+ a[key] = (expected, ...x) => {
704
+ return new thenKlasser.prototype.constructor(
705
+ `${thEn.name}: ${expected && expected.toString()}`,
706
+ thEn(expected, ...x)
707
+ );
708
+ };
709
+ return a;
710
+ },
711
+ {}
712
+ );
713
+ super(
714
+ input,
715
+ classySuites,
716
+ classyGivens,
717
+ classyWhens,
718
+ classyThens,
719
+ testResourceRequirement,
720
+ testSpecification
721
+ );
722
+ }
723
+ };
724
+
725
+ // src/lib/core.ts
726
+ var TesterantoCore = class extends ClassBuilder {
727
+ constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testAdapter, uberCatcher) {
728
+ const fullAdapter = DefaultAdapter(testAdapter);
729
+ super(
730
+ testImplementation,
731
+ testSpecification,
732
+ input,
733
+ class extends BaseSuite {
734
+ afterAll(store, artifactory, pm) {
735
+ return fullAdapter.afterAll(store, pm);
736
+ }
737
+ assertThat(t) {
738
+ return fullAdapter.assertThis(t);
739
+ }
740
+ async setup(s, artifactory, tr, pm) {
741
+ return (fullAdapter.beforeAll || (async (input2, artifactory2, tr2, pm2) => input2))(
742
+ s,
743
+ this.testResourceConfiguration,
744
+ // artifactory,
745
+ pm
746
+ );
747
+ }
748
+ },
749
+ class Given extends BaseGiven {
750
+ constructor() {
751
+ super(...arguments);
752
+ this.uberCatcher = uberCatcher;
753
+ }
754
+ async givenThat(subject, testResource, artifactory, initializer, initialValues, pm) {
755
+ return fullAdapter.beforeEach(
756
+ subject,
757
+ initializer,
758
+ testResource,
759
+ initialValues,
760
+ pm
761
+ );
762
+ }
763
+ afterEach(store, key, artifactory, pm) {
764
+ return new Promise(
765
+ (res) => res(fullAdapter.afterEach(store, key, pm))
766
+ );
767
+ }
768
+ },
769
+ class When extends BaseWhen {
770
+ async andWhen(store, whenCB, testResource, pm) {
771
+ return await fullAdapter.andWhen(store, whenCB, testResource, pm);
772
+ }
773
+ },
774
+ class Then extends BaseThen {
775
+ async butThen(store, thenCB, testResource, pm) {
776
+ return await fullAdapter.butThen(store, thenCB, testResource, pm);
777
+ }
778
+ },
779
+ testResourceRequirement
780
+ );
781
+ }
782
+ };
783
+
784
+ // src/Web.ts
785
+ var errorCallback = (e) => {
786
+ };
787
+ var unhandledrejectionCallback = (event) => {
788
+ console.log("window.addEventListener unhandledrejection", event);
789
+ };
790
+ var WebTesteranto = class extends TesterantoCore {
791
+ constructor(input, testSpecification, testImplementation, testResourceRequirement, testAdapter) {
792
+ super(
793
+ input,
794
+ testSpecification,
795
+ testImplementation,
796
+ testResourceRequirement,
797
+ testAdapter,
798
+ (cb) => {
799
+ window.removeEventListener("error", errorCallback);
800
+ errorCallback = (e) => {
801
+ console.log("window.addEventListener error", e);
802
+ cb(e);
803
+ };
804
+ window.addEventListener("error", errorCallback);
805
+ window.removeEventListener(
806
+ "unhandledrejection",
807
+ unhandledrejectionCallback
808
+ );
809
+ window.removeEventListener(
810
+ "unhandledrejection",
811
+ unhandledrejectionCallback
812
+ );
813
+ unhandledrejectionCallback = (event) => {
814
+ console.log("window.addEventListener unhandledrejection", event);
815
+ cb({ error: event.reason.message });
816
+ };
817
+ window.addEventListener(
818
+ "unhandledrejection",
819
+ unhandledrejectionCallback
820
+ );
821
+ }
822
+ );
823
+ }
824
+ async receiveTestResourceConfig(partialTestResource) {
825
+ const t = partialTestResource;
826
+ const pm = new PM_Web(t);
827
+ return await this.testJobs[0].receiveTestResourceConfig(pm);
828
+ }
829
+ };
830
+ var Web_default = async (input, testSpecification, testImplementation, testAdapter, testResourceRequirement = defaultTestResourceRequirement) => {
831
+ return new WebTesteranto(
832
+ input,
833
+ testSpecification,
834
+ testImplementation,
835
+ testResourceRequirement,
836
+ testAdapter
837
+ );
838
+ };
839
+
840
+ export {
841
+ BaseGiven,
842
+ BaseWhen,
843
+ BaseThen,
844
+ BaseBuilder,
845
+ BaseSuite,
846
+ Web_default
847
+ };