testeranto 0.140.1 → 0.143.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 (132) hide show
  1. package/.aider.chat.history.md +9173 -0
  2. package/.aider.input.history +336 -0
  3. package/.aider.tags.cache.v3/{ad/3c/10f2ab1397f6d544e613d2a6acaf.val → 3d/81/8b6f0e9b98ec2952cdb8968ac386.val} +0 -0
  4. package/.aider.tags.cache.v3/63/f1/138061b0aadb868173d197c2a0e0.val +0 -0
  5. package/.aider.tags.cache.v3/be/72/19ee8e656d160afe9b31523245fe.val +0 -0
  6. package/.aider.tags.cache.v3/cache.db +0 -0
  7. package/.aider.tags.cache.v3/cache.db-shm +0 -0
  8. package/.aider.tags.cache.v3/cache.db-wal +0 -0
  9. package/.aider.tags.cache.v3/{a7/97/6d37fce350ad2d588f36729db0cd.val → d6/7d/1820c2d4b9330eab7017da4515e7.val} +0 -0
  10. package/README.md +1 -1
  11. package/docs/aiderTest.sh +1 -0
  12. package/docs/testing.ai.txt +98 -0
  13. package/docs/testing.prompt.txt +8 -0
  14. package/index.html +1 -1
  15. package/package.json +3 -3
  16. package/src/PM/PM_WithEslintAndTsc.ts +35 -21
  17. package/src/Pure.test.ts +299 -0
  18. package/src/lib/BaseSuite.test.ts +24 -5
  19. package/src/lib/abstractBase.test/MockGiven.ts +31 -0
  20. package/src/lib/abstractBase.test/MockThen.ts +20 -0
  21. package/src/lib/abstractBase.test/MockWhen.ts +17 -0
  22. package/src/lib/abstractBase.test/implementation.ts +51 -0
  23. package/src/lib/abstractBase.test/index.ts +19 -0
  24. package/src/lib/abstractBase.test/interface.ts +12 -0
  25. package/src/lib/abstractBase.test/specification.ts +49 -0
  26. package/src/lib/abstractBase.test/types.ts +19 -0
  27. package/src/lib/baseBuilder.test/TestBaseBuilder.ts +83 -0
  28. package/src/lib/baseBuilder.test/baseBuilder.test.implementation.ts +133 -0
  29. package/src/lib/baseBuilder.test/baseBuilder.test.interface.ts +18 -0
  30. package/src/lib/baseBuilder.test/baseBuilder.test.specification.ts +35 -0
  31. package/src/lib/baseBuilder.test/baseBuilder.test.ts +13 -0
  32. package/src/lib/baseBuilder.test/baseBuilder.test.types.ts +36 -0
  33. package/src/lib/classBuilder.test/TestClassBuilder.ts +88 -0
  34. package/src/lib/classBuilder.test/classBuilder.test.implementation.ts +200 -0
  35. package/src/lib/classBuilder.test/classBuilder.test.interface.ts +17 -0
  36. package/src/lib/classBuilder.test/classBuilder.test.specification.ts +112 -0
  37. package/src/lib/classBuilder.test/classBuilder.test.ts +14 -0
  38. package/src/lib/classBuilder.test/classBuilder.test.types.ts +72 -0
  39. package/src/lib/core.test/MockCore.ts +49 -0
  40. package/src/lib/core.test/core.test.implementation.ts +129 -0
  41. package/src/lib/core.test/core.test.interface.ts +18 -0
  42. package/src/lib/core.test/core.test.specification.ts +99 -0
  43. package/src/lib/core.test/core.test.ts +15 -0
  44. package/src/lib/core.test/core.test.types.ts +68 -0
  45. package/src/lib/core.ts +1 -1
  46. package/src/lib/pmProxy.test/implementation.ts +104 -0
  47. package/src/lib/pmProxy.test/index.ts +19 -0
  48. package/src/lib/pmProxy.test/interface.ts +47 -0
  49. package/src/lib/pmProxy.test/mockPM.ts +38 -0
  50. package/src/lib/pmProxy.test/mockPMBase.ts +136 -0
  51. package/src/lib/pmProxy.test/specification.ts +123 -0
  52. package/src/lib/pmProxy.test/types.ts +45 -0
  53. package/src/lib/pmProxy.ts +40 -193
  54. package/testeranto/bundles/node/allTests/chunk-2FXOXAKZ.mjs +800 -0
  55. package/testeranto/bundles/node/allTests/chunk-5MQGD4WC.mjs +251 -0
  56. package/testeranto/bundles/node/allTests/chunk-6CGAD2FD.mjs +800 -0
  57. package/testeranto/bundles/node/allTests/chunk-DWKHII32.mjs +800 -0
  58. package/testeranto/bundles/node/allTests/chunk-KYSOR62N.mjs +167 -0
  59. package/testeranto/bundles/node/allTests/chunk-PRPFVO6G.mjs +251 -0
  60. package/testeranto/bundles/node/allTests/chunk-RX4SUFXQ.mjs +251 -0
  61. package/testeranto/bundles/node/allTests/chunk-UED26IMH.mjs +802 -0
  62. package/testeranto/bundles/node/allTests/chunk-VAAIAWXC.mjs +117 -0
  63. package/testeranto/bundles/node/allTests/chunk-W44DUDBK.mjs +251 -0
  64. package/testeranto/bundles/node/allTests/chunk-YI3EGRMQ.mjs +167 -0
  65. package/testeranto/bundles/node/allTests/metafile.json +1072 -222
  66. package/testeranto/bundles/node/allTests/src/PM/__tests__/nodeSidecar.testeranto.mjs +2 -1
  67. package/testeranto/bundles/node/allTests/src/PM/__tests__/pureSidecar.testeranto.mjs +2 -1
  68. package/testeranto/bundles/node/allTests/src/PM/__tests__/webSidecar.testeranto.mjs +2 -1
  69. package/testeranto/bundles/node/allTests/src/Pure.test.mjs +261 -0
  70. package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test.mjs +22 -4
  71. package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.mjs +226 -0
  72. package/testeranto/bundles/node/allTests/src/lib/classBuilder.test/classBuilder.test.mjs +406 -0
  73. package/testeranto/bundles/node/allTests/src/lib/core.test/core.test.mjs +279 -0
  74. package/testeranto/bundles/node/allTests/src/lib/pmProxy.test/index.mjs +4479 -0
  75. package/testeranto/bundles/node/allTests/src/mothership/test.mjs +4 -2
  76. package/testeranto/reports/allTests/config.json +40 -1
  77. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/console_log.txt +0 -0
  78. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/log.txt +0 -0
  79. package/testeranto/reports/allTests/src/Pure.test/node/console_log.txt +17 -0
  80. package/testeranto/reports/allTests/src/Pure.test/node/dev.html +21 -0
  81. package/testeranto/reports/allTests/src/Pure.test/node/index.html +21 -0
  82. package/testeranto/reports/allTests/src/Pure.test/node/lint_errors.json +134 -0
  83. package/testeranto/reports/allTests/src/Pure.test/node/message +1 -0
  84. package/testeranto/reports/allTests/src/Pure.test/node/prompt.txt +7 -0
  85. package/testeranto/reports/allTests/src/Pure.test/node/type_errors.txt +26 -0
  86. package/testeranto/reports/allTests/src/lib/BaseGiven.test/node/dev.html +21 -0
  87. package/testeranto/reports/allTests/src/lib/BaseGiven.test/node/index.html +21 -0
  88. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/console_log.txt +27 -27
  89. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/lint_errors.json +104 -104
  90. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/type_errors.txt +47 -22
  91. package/testeranto/reports/allTests/src/lib/BaseThen.test/node/dev.html +21 -0
  92. package/testeranto/reports/allTests/src/lib/BaseThen.test/node/index.html +21 -0
  93. package/testeranto/reports/allTests/src/lib/BaseWhen.test/node/dev.html +21 -0
  94. package/testeranto/reports/allTests/src/lib/BaseWhen.test/node/index.html +21 -0
  95. package/testeranto/reports/allTests/src/lib/abstractBase/index/node/dev.html +21 -0
  96. package/testeranto/reports/allTests/src/lib/abstractBase/index/node/index.html +21 -0
  97. package/testeranto/reports/allTests/src/lib/baseBuilder/baseBuilder.test/node/dev.html +21 -0
  98. package/testeranto/reports/allTests/src/lib/baseBuilder/baseBuilder.test/node/index.html +21 -0
  99. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/console_log.txt +12 -0
  100. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/dev.html +21 -0
  101. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/index.html +21 -0
  102. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/lint_errors.json +966 -0
  103. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/message +1 -0
  104. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/prompt.txt +11 -0
  105. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/type_errors.txt +52 -0
  106. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/console_log.txt +17 -0
  107. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/dev.html +21 -0
  108. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/index.html +21 -0
  109. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/lint_errors.json +771 -0
  110. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/message +1 -0
  111. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/prompt.txt +11 -0
  112. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/type_errors.txt +67 -0
  113. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/console_log.txt +17 -0
  114. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/dev.html +21 -0
  115. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/index.html +21 -0
  116. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/lint_errors.json +416 -0
  117. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/message +1 -0
  118. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/prompt.txt +11 -0
  119. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/type_errors.txt +54 -0
  120. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/console_log.txt +43 -0
  121. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/dev.html +21 -0
  122. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/index.html +21 -0
  123. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/lint_errors.json +319 -0
  124. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/log.txt +0 -0
  125. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/message +1 -0
  126. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/prompt.txt +10 -0
  127. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/type_errors.txt +64 -0
  128. package/testeranto/reports/allTests/src/mothership/test/node/console_log.txt +44 -0
  129. package/testeranto/reports/allTests/src/mothership/test/node/log.txt +0 -0
  130. package/testeranto/reports/allTests/summary.json +76 -6
  131. package/testeranto/reportsnode_build_errors +12 -0
  132. package/testeranto.config.ts +19 -2
@@ -0,0 +1,800 @@
1
+ import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined")
12
+ return require.apply(this, arguments);
13
+ throw new Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __commonJS = (cb, mod) => function __require2() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+
35
+ // src/lib/pmProxy.ts
36
+ var baseProxy = function(pm, mappings) {
37
+ return new Proxy(pm, {
38
+ get: (target, prop, receiver) => {
39
+ for (const mapping of mappings) {
40
+ const method = mapping[0];
41
+ const arger = mapping[1];
42
+ if (prop === method) {
43
+ return (...x) => target[prop](arger(...x));
44
+ }
45
+ }
46
+ return (...x) => target[prop](...x);
47
+ }
48
+ });
49
+ };
50
+ var butThenProxy = (pm, filepath) => baseProxy(pm, [
51
+ [
52
+ "screencast",
53
+ (opts, p) => [
54
+ {
55
+ ...opts,
56
+ path: `${filepath}/butThen/${opts.path}`
57
+ },
58
+ p
59
+ ]
60
+ ],
61
+ ["createWriteStream", (fp) => [`${filepath}/butThen/${fp}`]],
62
+ [
63
+ "writeFileSync",
64
+ (fp, contents) => [`${filepath}/butThen/${fp}`, contents]
65
+ ],
66
+ [
67
+ "customScreenShot",
68
+ (opts, p) => [
69
+ {
70
+ ...opts,
71
+ path: `${filepath}/butThen/${opts.path}`
72
+ },
73
+ p
74
+ ]
75
+ ]
76
+ ]);
77
+ var andWhenProxy = (pm, filepath) => baseProxy(pm, [
78
+ [
79
+ "screencast",
80
+ (opts, p) => [
81
+ {
82
+ ...opts,
83
+ path: `${filepath}/andWhen/${opts.path}`
84
+ },
85
+ p
86
+ ]
87
+ ],
88
+ ["createWriteStream", (fp) => [`${filepath}/andWhen/${fp}`]],
89
+ ["writeFileSync", (fp, contents) => [`${filepath}/andWhen${fp}`, contents]],
90
+ [
91
+ "customScreenShot",
92
+ (opts, p) => [
93
+ {
94
+ ...opts,
95
+ path: `${filepath}/andWhen${opts.path}`
96
+ },
97
+ p
98
+ ]
99
+ ]
100
+ ]);
101
+ var afterEachProxy = (pm, suite, given) => baseProxy(pm, [
102
+ [
103
+ "screencast",
104
+ (opts, p) => [
105
+ {
106
+ ...opts,
107
+ path: `suite-${suite}/given-${given}/afterEach/${opts.path}`
108
+ },
109
+ p
110
+ ]
111
+ ],
112
+ ["createWriteStream", (fp) => [`suite-${suite}/afterEach/${fp}`]],
113
+ [
114
+ "writeFileSync",
115
+ (fp, contents) => [
116
+ `suite-${suite}/given-${given}/afterEach/${fp}`,
117
+ contents
118
+ ]
119
+ ],
120
+ [
121
+ "customScreenShot",
122
+ (opts, p) => [
123
+ {
124
+ ...opts,
125
+ path: `suite-${suite}/given-${given}/afterEach/${opts.path}`
126
+ },
127
+ p
128
+ ]
129
+ ]
130
+ ]);
131
+ var beforeEachProxy = (pm, suite) => baseProxy(pm, [
132
+ [
133
+ "screencast",
134
+ (opts, p) => [
135
+ {
136
+ ...opts,
137
+ path: `suite-${suite}/beforeEach/${opts.path}`
138
+ },
139
+ p
140
+ ]
141
+ ],
142
+ [
143
+ "writeFileSync",
144
+ (fp, contents) => [`suite-${suite}/beforeEach/${fp}`, contents]
145
+ ],
146
+ [
147
+ "customScreenShot",
148
+ (opts, p) => [
149
+ {
150
+ ...opts,
151
+ path: `suite-${suite}/beforeEach/${opts.path}`
152
+ },
153
+ p
154
+ ]
155
+ ],
156
+ ["createWriteStream", (fp) => [`suite-${suite}/beforeEach/${fp}`]]
157
+ ]);
158
+ var beforeAllProxy = (pm, suite) => baseProxy(pm, [
159
+ [
160
+ "writeFileSync",
161
+ (fp, contents) => [`suite-${suite}/beforeAll/${fp}`, contents]
162
+ ],
163
+ [
164
+ "customScreenShot",
165
+ (opts, p) => [
166
+ {
167
+ ...opts,
168
+ path: `suite-${suite}/beforeAll/${opts.path}`
169
+ },
170
+ p
171
+ ]
172
+ ],
173
+ ["createWriteStream", (fp) => [`suite-${suite}/beforeAll/${fp}`]]
174
+ ]);
175
+ var afterAllProxy = (pm, suite) => baseProxy(pm, [
176
+ ["createWriteStream", (fp) => [`suite-${suite}/afterAll/${fp}`]],
177
+ [
178
+ "writeFileSync",
179
+ (fp, contents) => [`suite-${suite}/afterAll/${fp}`, contents]
180
+ ],
181
+ [
182
+ "customScreenShot",
183
+ (opts, p) => [
184
+ {
185
+ ...opts,
186
+ path: `suite-${suite}/afterAll/${opts.path}`
187
+ },
188
+ p
189
+ ]
190
+ ]
191
+ ]);
192
+
193
+ // src/lib/abstractBase.ts
194
+ var BaseGiven = class {
195
+ constructor(name, features, whens, thens, givenCB, initialValues) {
196
+ this.name = name;
197
+ this.features = features;
198
+ this.whens = whens;
199
+ this.thens = thens;
200
+ this.givenCB = givenCB;
201
+ this.initialValues = initialValues;
202
+ }
203
+ beforeAll(store) {
204
+ return store;
205
+ }
206
+ toObj() {
207
+ return {
208
+ key: this.key,
209
+ name: this.name,
210
+ whens: this.whens.map((w) => {
211
+ if (w && w.toObj)
212
+ return w.toObj();
213
+ console.error("w is not as expected!", w);
214
+ return {};
215
+ }),
216
+ thens: this.thens.map((t) => t.toObj()),
217
+ error: this.error ? [this.error, this.error.stack] : null,
218
+ failed: this.failed,
219
+ features: this.features
220
+ };
221
+ }
222
+ async afterEach(store, key, artifactory, pm) {
223
+ return store;
224
+ }
225
+ async give(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm, suiteNdx) {
226
+ this.key = key;
227
+ tLog(`
228
+ ${this.key}`);
229
+ tLog(`
230
+ Given: ${this.name}`);
231
+ const givenArtifactory = (fPath, value) => artifactory(`given-${key}/${fPath}`, value);
232
+ this.uberCatcher((e) => {
233
+ console.error(e);
234
+ this.error = e.error;
235
+ tLog(e.stack);
236
+ });
237
+ try {
238
+ this.store = await this.givenThat(
239
+ subject,
240
+ testResourceConfiguration,
241
+ givenArtifactory,
242
+ this.givenCB,
243
+ this.initialValues,
244
+ beforeEachProxy(pm, suiteNdx.toString())
245
+ );
246
+ } catch (e) {
247
+ console.error("failure 4 ", e);
248
+ this.error = e;
249
+ throw e;
250
+ }
251
+ try {
252
+ for (const [whenNdx, whenStep] of this.whens.entries()) {
253
+ await whenStep.test(
254
+ this.store,
255
+ testResourceConfiguration,
256
+ tLog,
257
+ pm,
258
+ `suite-${suiteNdx}/given-${key}/when/${whenNdx}`
259
+ );
260
+ }
261
+ for (const [thenNdx, thenStep] of this.thens.entries()) {
262
+ const t = await thenStep.test(
263
+ this.store,
264
+ testResourceConfiguration,
265
+ tLog,
266
+ pm,
267
+ `suite-${suiteNdx}/given-${key}/then-${thenNdx}`
268
+ );
269
+ tester(t);
270
+ }
271
+ } catch (e) {
272
+ this.failed = true;
273
+ tLog(e.stack);
274
+ throw e;
275
+ } finally {
276
+ try {
277
+ await this.afterEach(
278
+ this.store,
279
+ this.key,
280
+ givenArtifactory,
281
+ afterEachProxy(pm, suiteNdx.toString(), key)
282
+ );
283
+ } catch (e) {
284
+ console.error("afterEach failed!", e);
285
+ this.failed = e;
286
+ throw e;
287
+ }
288
+ }
289
+ return this.store;
290
+ }
291
+ };
292
+ var BaseWhen = class {
293
+ constructor(name, whenCB) {
294
+ this.name = name;
295
+ this.whenCB = whenCB;
296
+ }
297
+ toObj() {
298
+ console.log("toObj error", this.error);
299
+ return {
300
+ name: this.name,
301
+ error: this.error && this.error.name + this.error.stack
302
+ };
303
+ }
304
+ async test(store, testResourceConfiguration, tLog, pm, filepath) {
305
+ tLog(" When:", this.name);
306
+ return await this.andWhen(
307
+ store,
308
+ this.whenCB,
309
+ testResourceConfiguration,
310
+ andWhenProxy(pm, filepath)
311
+ ).catch((e) => {
312
+ console.log("MARK9", e);
313
+ this.error = e;
314
+ throw e;
315
+ });
316
+ }
317
+ };
318
+ var BaseThen = class {
319
+ constructor(name, thenCB) {
320
+ this.name = name;
321
+ this.thenCB = thenCB;
322
+ this.error = false;
323
+ }
324
+ toObj() {
325
+ return {
326
+ name: this.name,
327
+ error: this.error
328
+ };
329
+ }
330
+ async test(store, testResourceConfiguration, tLog, pm, filepath) {
331
+ return this.butThen(
332
+ store,
333
+ async (s) => {
334
+ tLog(" Then!!!:", this.name);
335
+ if (typeof this.thenCB === "function") {
336
+ return await this.thenCB(s);
337
+ } else {
338
+ return this.thenCB;
339
+ }
340
+ },
341
+ testResourceConfiguration,
342
+ butThenProxy(pm, filepath)
343
+ ).catch((e) => {
344
+ console.log("test failed 3", e);
345
+ this.error = e;
346
+ throw e;
347
+ });
348
+ }
349
+ check() {
350
+ }
351
+ };
352
+ var BaseCheck = class {
353
+ constructor(name, features, checker, x, checkCB) {
354
+ this.name = name;
355
+ this.features = features;
356
+ this.checkCB = checkCB;
357
+ this.checker = checker;
358
+ }
359
+ toObj() {
360
+ return {
361
+ key: this.key,
362
+ name: this.name,
363
+ // functionAsString: this.checkCB.toString(),
364
+ features: this.features
365
+ };
366
+ }
367
+ async afterEach(store, key, artifactory, pm) {
368
+ return store;
369
+ }
370
+ beforeAll(store) {
371
+ return store;
372
+ }
373
+ async check(subject, key, testResourceConfiguration, tester, artifactory, tLog, pm) {
374
+ this.key = key;
375
+ tLog(`
376
+ Check: ${this.name}`);
377
+ this.store = await this.checkThat(
378
+ subject,
379
+ testResourceConfiguration,
380
+ artifactory,
381
+ this.checkCB,
382
+ this.initialValues,
383
+ pm
384
+ );
385
+ await this.checker(this.store, pm);
386
+ return;
387
+ }
388
+ };
389
+
390
+ // src/lib/basebuilder.ts
391
+ var BaseBuilder = class {
392
+ constructor(input, suitesOverrides, givenOverides, whenOverides, thenOverides, checkOverides, testResourceRequirement, testSpecification) {
393
+ this.artifacts = [];
394
+ this.artifacts = [];
395
+ this.testResourceRequirement = testResourceRequirement;
396
+ this.suitesOverrides = suitesOverrides;
397
+ this.givenOverides = givenOverides;
398
+ this.whenOverides = whenOverides;
399
+ this.thenOverides = thenOverides;
400
+ this.checkOverides = checkOverides;
401
+ this.testSpecification = testSpecification;
402
+ this.specs = testSpecification(
403
+ this.Suites(),
404
+ this.Given(),
405
+ this.When(),
406
+ this.Then(),
407
+ this.Check()
408
+ );
409
+ this.testJobs = this.specs.map((suite) => {
410
+ const suiteRunner = (suite2) => async (puppetMaster, tLog) => {
411
+ const x = await suite2.run(
412
+ input,
413
+ puppetMaster.testResourceConfiguration,
414
+ (fPath, value) => puppetMaster.testArtiFactoryfileWriter(
415
+ tLog,
416
+ (p) => {
417
+ this.artifacts.push(p);
418
+ }
419
+ )(puppetMaster.testResourceConfiguration.fs + "/" + fPath, value),
420
+ tLog,
421
+ puppetMaster
422
+ );
423
+ return x;
424
+ };
425
+ const runner = suiteRunner(suite);
426
+ return {
427
+ test: suite,
428
+ toObj: () => {
429
+ return suite.toObj();
430
+ },
431
+ runner,
432
+ receiveTestResourceConfig: async function(puppetMaster) {
433
+ const logFilePath = "log.txt";
434
+ const access = await puppetMaster.createWriteStream(
435
+ logFilePath
436
+ );
437
+ const tLog = async (...l) => {
438
+ };
439
+ const suiteDone = await runner(puppetMaster, tLog);
440
+ const logPromise = new Promise(async (res) => {
441
+ await puppetMaster.end(access);
442
+ res(true);
443
+ });
444
+ const fails = suiteDone.fails;
445
+ await puppetMaster.writeFileSync(`bdd_errors.txt`, fails.toString());
446
+ await puppetMaster.writeFileSync(
447
+ `tests.json`,
448
+ JSON.stringify(this.toObj(), null, 2)
449
+ );
450
+ return {
451
+ failed: fails > 0,
452
+ fails,
453
+ artifacts: this.artifacts || [],
454
+ logPromise,
455
+ features: suiteDone.features()
456
+ };
457
+ }
458
+ };
459
+ });
460
+ }
461
+ // testsJson() {
462
+ // puppetMaster.writeFileSync(
463
+ // `tests.json`,
464
+ // JSON.stringify({ features: suiteDone.features() }, null, 2)
465
+ // );
466
+ // }
467
+ Specs() {
468
+ return this.specs;
469
+ }
470
+ Suites() {
471
+ return this.suitesOverrides;
472
+ }
473
+ Given() {
474
+ return this.givenOverides;
475
+ }
476
+ When() {
477
+ return this.whenOverides;
478
+ }
479
+ Then() {
480
+ return this.thenOverides;
481
+ }
482
+ Check() {
483
+ return this.checkOverides;
484
+ }
485
+ };
486
+
487
+ // src/lib/classBuilder.ts
488
+ var ClassBuilder = class extends BaseBuilder {
489
+ constructor(testImplementation, testSpecification, input, suiteKlasser, givenKlasser, whenKlasser, thenKlasser, checkKlasser, testResourceRequirement) {
490
+ const classySuites = Object.entries(testImplementation.suites).reduce(
491
+ (a, [key], index) => {
492
+ a[key] = (somestring, givens, checks) => {
493
+ return new suiteKlasser.prototype.constructor(
494
+ somestring,
495
+ index,
496
+ givens,
497
+ checks
498
+ );
499
+ };
500
+ return a;
501
+ },
502
+ {}
503
+ );
504
+ const classyGivens = Object.entries(testImplementation.givens).reduce(
505
+ (a, [key, g]) => {
506
+ a[key] = (features, whens, thens, ...initialValues) => {
507
+ return new givenKlasser.prototype.constructor(
508
+ key,
509
+ features,
510
+ whens,
511
+ thens,
512
+ testImplementation.givens[key],
513
+ initialValues
514
+ );
515
+ };
516
+ return a;
517
+ },
518
+ {}
519
+ );
520
+ const classyWhens = Object.entries(testImplementation.whens).reduce(
521
+ (a, [key, whEn]) => {
522
+ a[key] = (...payload) => {
523
+ return new whenKlasser.prototype.constructor(
524
+ `${whEn.name}: ${payload && payload.toString()}`,
525
+ whEn(...payload)
526
+ );
527
+ };
528
+ return a;
529
+ },
530
+ {}
531
+ );
532
+ const classyThens = Object.entries(
533
+ testImplementation.thens
534
+ ).reduce(
535
+ (a, [key, thEn]) => {
536
+ a[key] = (expected, ...x) => {
537
+ return new thenKlasser.prototype.constructor(
538
+ `${thEn.name}: ${expected && expected.toString()}`,
539
+ thEn(expected, ...x)
540
+ );
541
+ };
542
+ return a;
543
+ },
544
+ {}
545
+ );
546
+ const classyChecks = Object.entries(testImplementation.checks).reduce(
547
+ (a, [key, chEck]) => {
548
+ a[key] = (name, features, checker) => {
549
+ return new checkKlasser.prototype.constructor(
550
+ key,
551
+ features,
552
+ chEck,
553
+ checker
554
+ );
555
+ };
556
+ return a;
557
+ },
558
+ {}
559
+ );
560
+ super(
561
+ input,
562
+ classySuites,
563
+ classyGivens,
564
+ classyWhens,
565
+ classyThens,
566
+ classyChecks,
567
+ testResourceRequirement,
568
+ testSpecification
569
+ );
570
+ }
571
+ };
572
+
573
+ // src/lib/BaseSuite.ts
574
+ var BaseSuite = class {
575
+ constructor(name, index, givens = {}, checks = []) {
576
+ this.name = name;
577
+ this.index = index;
578
+ this.givens = givens;
579
+ this.checks = checks;
580
+ this.fails = 0;
581
+ }
582
+ features() {
583
+ const features = Object.keys(this.givens).map((k) => this.givens[k].features).flat().filter((value, index, array) => {
584
+ return array.indexOf(value) === index;
585
+ });
586
+ return features || [];
587
+ }
588
+ toObj() {
589
+ const givens = Object.keys(this.givens).map((k) => this.givens[k].toObj());
590
+ const checks = Object.keys(this.checks).map((k) => this.checks[k].toObj());
591
+ return {
592
+ name: this.name,
593
+ givens,
594
+ checks,
595
+ fails: this.fails,
596
+ failed: this.failed,
597
+ features: this.features()
598
+ };
599
+ }
600
+ setup(s, artifactory, tr, pm) {
601
+ return new Promise((res) => res(s));
602
+ }
603
+ assertThat(t) {
604
+ return !!t;
605
+ }
606
+ afterAll(store, artifactory, pm) {
607
+ return store;
608
+ }
609
+ async run(input, testResourceConfiguration, artifactory, tLog, pm) {
610
+ this.testResourceConfiguration = testResourceConfiguration;
611
+ const suiteArtifactory = (fPath, value) => artifactory(`suite-${this.index}-${this.name}/${fPath}`, value);
612
+ tLog("\nSuite:", this.index, this.name);
613
+ const sNdx = this.index;
614
+ const subject = await this.setup(
615
+ input,
616
+ suiteArtifactory,
617
+ testResourceConfiguration,
618
+ beforeAllProxy(pm, sNdx.toString())
619
+ );
620
+ for (const [gKey, g] of Object.entries(this.givens)) {
621
+ const giver = this.givens[gKey];
622
+ this.store = await giver.give(
623
+ subject,
624
+ gKey,
625
+ testResourceConfiguration,
626
+ this.assertThat,
627
+ suiteArtifactory,
628
+ tLog,
629
+ pm,
630
+ sNdx
631
+ ).catch((e) => {
632
+ this.failed = true;
633
+ this.fails = this.fails + 1;
634
+ console.error("Given error:", e);
635
+ throw e;
636
+ });
637
+ }
638
+ for (const [ndx, thater] of this.checks.entries()) {
639
+ await thater.check(
640
+ subject,
641
+ thater.name,
642
+ testResourceConfiguration,
643
+ this.assertThat,
644
+ suiteArtifactory,
645
+ tLog,
646
+ pm
647
+ );
648
+ }
649
+ try {
650
+ this.afterAll(
651
+ this.store,
652
+ artifactory,
653
+ afterAllProxy(pm, sNdx.toString())
654
+ );
655
+ } catch (e) {
656
+ console.error(e);
657
+ }
658
+ return this;
659
+ }
660
+ };
661
+
662
+ // src/lib/index.ts
663
+ var BaseTestInterface = () => ({
664
+ beforeAll: async (s) => s,
665
+ beforeEach: async function(subject, initialValues, x, testResource, pm) {
666
+ return subject;
667
+ },
668
+ afterEach: async (s) => s,
669
+ afterAll: (store) => void 0,
670
+ butThen: async (store, thenCb) => {
671
+ return thenCb(store);
672
+ },
673
+ andWhen: async (store, whenCB, testResource, pm) => {
674
+ try {
675
+ await whenCB(store, testResource, pm);
676
+ } catch (error) {
677
+ console.error("Error in andWhen:", error);
678
+ throw error;
679
+ }
680
+ },
681
+ assertThis: (x) => x
682
+ });
683
+ var DefaultTestInterface = (p) => {
684
+ return {
685
+ ...BaseTestInterface,
686
+ ...p
687
+ };
688
+ };
689
+ var defaultTestResourceRequirement = {
690
+ ports: 0
691
+ };
692
+
693
+ // src/lib/core.ts
694
+ var TesterantoCore = class extends ClassBuilder {
695
+ constructor(input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testInterface, uberCatcher) {
696
+ const fullTestInterface = DefaultTestInterface(testInterface);
697
+ super(
698
+ testImplementation,
699
+ testSpecification,
700
+ input,
701
+ class extends BaseSuite {
702
+ afterAll(store, artifactory, pm) {
703
+ return fullTestInterface.afterAll(store, pm);
704
+ }
705
+ assertThat(t) {
706
+ return fullTestInterface.assertThis(t);
707
+ }
708
+ async setup(s, artifactory, tr, pm) {
709
+ return (fullTestInterface.beforeAll || (async (input2, artifactory2, tr2, pm2) => input2))(
710
+ s,
711
+ this.testResourceConfiguration,
712
+ // artifactory,
713
+ pm
714
+ );
715
+ }
716
+ },
717
+ class Given extends BaseGiven {
718
+ constructor() {
719
+ super(...arguments);
720
+ this.uberCatcher = uberCatcher;
721
+ }
722
+ async givenThat(subject, testResource, artifactory, initializer, initialValues, pm) {
723
+ return fullTestInterface.beforeEach(
724
+ subject,
725
+ initializer,
726
+ testResource,
727
+ initialValues,
728
+ pm
729
+ );
730
+ }
731
+ afterEach(store, key, artifactory, pm) {
732
+ return new Promise(
733
+ (res) => res(fullTestInterface.afterEach(store, key, pm))
734
+ );
735
+ }
736
+ },
737
+ class When extends BaseWhen {
738
+ async andWhen(store, whenCB, testResource, pm) {
739
+ return await fullTestInterface.andWhen(
740
+ store,
741
+ whenCB,
742
+ testResource,
743
+ pm
744
+ );
745
+ }
746
+ },
747
+ class Then extends BaseThen {
748
+ async butThen(store, thenCB, testResource, pm) {
749
+ return await fullTestInterface.butThen(
750
+ store,
751
+ thenCB,
752
+ testResource,
753
+ pm
754
+ );
755
+ }
756
+ },
757
+ class Check extends BaseCheck {
758
+ constructor(name, features, checkCallback, x, i, c) {
759
+ super(name, features, checkCallback, x, c);
760
+ this.initialValues = i;
761
+ }
762
+ async checkThat(subject, testResourceConfiguration, artifactory, initializer, initialValues, pm) {
763
+ return fullTestInterface.beforeEach(
764
+ subject,
765
+ initializer,
766
+ testResourceConfiguration,
767
+ initialValues,
768
+ pm
769
+ );
770
+ }
771
+ afterEach(store, key, artifactory, pm) {
772
+ return new Promise(
773
+ (res) => res(fullTestInterface.afterEach(store, key, pm))
774
+ );
775
+ }
776
+ },
777
+ testResourceRequirement
778
+ );
779
+ }
780
+ };
781
+
782
+ // src/PM/index.ts
783
+ var PM = class {
784
+ };
785
+
786
+ export {
787
+ __require,
788
+ __commonJS,
789
+ __toESM,
790
+ defaultTestResourceRequirement,
791
+ BaseGiven,
792
+ BaseWhen,
793
+ BaseThen,
794
+ BaseCheck,
795
+ BaseBuilder,
796
+ ClassBuilder,
797
+ BaseSuite,
798
+ TesterantoCore,
799
+ PM
800
+ };