testeranto.tiposkripto 0.3.2 → 0.4.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 (31) hide show
  1. package/dist/.DS_Store +0 -0
  2. package/dist/module/Node.js +1394 -824
  3. package/dist/module/Web.js +1405 -825
  4. package/dist/module/index.js +243 -841
  5. package/dist/types/Types.d.ts +55 -10
  6. package/dist/types/lib/tiposkripto/src/Adapters.d.ts +3 -0
  7. package/dist/types/lib/tiposkripto/src/BaseExpected.d.ts +1 -1
  8. package/dist/types/lib/tiposkripto/src/BaseTiposkripto.d.ts +22 -18
  9. package/dist/types/lib/tiposkripto/src/CoreTypes.d.ts +27 -28
  10. package/dist/types/lib/tiposkripto/src/Node.d.ts +4 -4
  11. package/dist/types/lib/tiposkripto/src/Web.d.ts +9 -3
  12. package/dist/types/lib/tiposkripto/src/index.d.ts +21 -29
  13. package/dist/types/lib/tiposkripto/src/interop/index.d.ts +0 -0
  14. package/dist/types/lib/tiposkripto/src/interop/jest.d.ts +0 -0
  15. package/dist/types/lib/tiposkripto/src/interop/mocha.d.ts +0 -0
  16. package/dist/types/lib/tiposkripto/src/interop/nodeNative.d.ts +0 -0
  17. package/dist/types/lib/tiposkripto/src/interop/vite.d.ts +0 -0
  18. package/dist/types/lib/tiposkripto/src/types.d.ts +18 -26
  19. package/dist/types/lib/tiposkripto/src/verbs/BaseSuite.d.ts +0 -0
  20. package/dist/types/lib/tiposkripto/src/verbs/aaa/BaseDescribe.d.ts +39 -0
  21. package/dist/types/lib/tiposkripto/src/verbs/aaa/BaseIt.d.ts +22 -0
  22. package/dist/types/lib/tiposkripto/src/verbs/bdd/BaseGiven.d.ts +48 -0
  23. package/dist/types/lib/tiposkripto/src/verbs/bdd/BaseThen.d.ts +38 -0
  24. package/dist/types/lib/tiposkripto/src/verbs/bdd/BaseWhen.d.ts +37 -0
  25. package/dist/types/lib/tiposkripto/src/verbs/internal/CommonUtils.d.ts +45 -0
  26. package/dist/types/lib/tiposkripto/src/verbs/tdt/BaseConfirm.d.ts +26 -0
  27. package/dist/types/lib/tiposkripto/src/verbs/tdt/BaseExpected.d.ts +27 -0
  28. package/dist/types/lib/tiposkripto/src/verbs/tdt/BaseShould.d.ts +24 -0
  29. package/dist/types/lib/tiposkripto/src/verbs/tdt/BaseValue.d.ts +38 -0
  30. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  31. package/package.json +2 -1
@@ -1,22 +1,9 @@
1
- // src/BaseSetup.ts
2
- var BaseSetup = class {
3
- constructor(features, actions, checks, setupCB, initialValues) {
4
- this.recommendedFsPath = "";
5
- this.artifacts = [];
6
- this.fails = 0;
7
- this.features = features;
8
- this.actions = actions;
9
- this.checks = checks;
10
- this.setupCB = setupCB;
11
- this.initialValues = initialValues;
12
- this.fails = 0;
13
- this.failed = false;
14
- this.error = null;
15
- this.store = null;
16
- this.key = "";
17
- this.status = void 0;
18
- }
19
- addArtifact(path) {
1
+ // src/verbs/internal/CommonUtils.ts
2
+ var CommonUtils = class {
3
+ /**
4
+ * Normalize a path string for consistent artifact storage
5
+ */
6
+ static normalizePath(path) {
20
7
  if (typeof path !== "string") {
21
8
  throw new Error(
22
9
  `[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(
@@ -24,617 +11,113 @@ var BaseSetup = class {
24
11
  )}`
25
12
  );
26
13
  }
27
- const normalizedPath = path.replace(/\\/g, "/");
28
- this.artifacts.push(normalizedPath);
29
- }
30
- toObj() {
31
- return {
32
- key: this.key,
33
- actions: (this.actions || []).map((a) => {
34
- if (a && a.toObj) return a.toObj();
35
- console.error("Action step is not as expected!", JSON.stringify(a));
36
- return {};
37
- }),
38
- checks: (this.checks || []).map((c) => c && c.toObj ? c.toObj() : {}),
39
- error: this.error ? [this.error, this.error.stack] : null,
40
- failed: this.failed,
41
- features: this.features || [],
42
- artifacts: this.artifacts,
43
- status: this.status
44
- };
45
- }
46
- async afterEach(store, key, artifactory) {
47
- return store;
48
- }
49
- async setup(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
50
- this.key = key;
51
- this.fails = 0;
52
- const actualArtifactory = artifactory || ((fPath, value) => {
53
- });
54
- const setupArtifactory = (fPath, value) => actualArtifactory(`setup-${key}/${fPath}`, value);
55
- try {
56
- this.store = await this.setupThat(
57
- subject,
58
- testResourceConfiguration,
59
- setupArtifactory,
60
- this.setupCB,
61
- this.initialValues
62
- );
63
- this.status = true;
64
- } catch (e) {
65
- this.status = false;
66
- this.failed = true;
67
- this.fails++;
68
- this.error = e;
69
- return this.store;
70
- }
71
- try {
72
- for (const [actionNdx, actionStep] of (this.actions || []).entries()) {
73
- try {
74
- const actionArtifactory = this.createArtifactoryForAction(
75
- key,
76
- actionNdx,
77
- suiteNdx
78
- );
79
- this.store = await actionStep.test(
80
- this.store,
81
- testResourceConfiguration,
82
- actionArtifactory
83
- );
84
- } catch (e) {
85
- this.failed = true;
86
- this.fails++;
87
- this.error = e;
88
- }
89
- }
90
- for (const [checkNdx, checkStep] of this.checks.entries()) {
91
- try {
92
- const filepath = suiteNdx !== void 0 ? `suite-${suiteNdx}/setup-${key}/check-${checkNdx}` : `setup-${key}/check-${checkNdx}`;
93
- const checkArtifactory = this.createArtifactoryForCheck(
94
- key,
95
- checkNdx,
96
- suiteNdx
97
- );
98
- const t = await checkStep.test(
99
- this.store,
100
- testResourceConfiguration,
101
- filepath,
102
- checkArtifactory
103
- );
104
- tester(t);
105
- } catch (e) {
106
- this.failed = true;
107
- this.fails++;
108
- this.error = e;
109
- }
110
- }
111
- } catch (e) {
112
- this.error = e;
113
- this.failed = true;
114
- this.fails++;
115
- } finally {
116
- try {
117
- await this.afterEach(this.store, this.key, setupArtifactory);
118
- } catch (e) {
119
- this.failed = true;
120
- this.fails++;
121
- this.error = e;
122
- }
123
- }
124
- return this.store;
125
- }
126
- createArtifactoryForAction(key, actionIndex, suiteNdx) {
127
- const self = this;
128
- if (self._parent && self._parent.createArtifactory) {
129
- return self._parent.createArtifactory({
130
- givenKey: key,
131
- whenIndex: actionIndex,
132
- suiteIndex: suiteNdx
133
- });
134
- }
14
+ return path.replace(/\\/g, "/");
15
+ }
16
+ /**
17
+ * Add an artifact with path normalization
18
+ */
19
+ static addArtifact(artifacts, path) {
20
+ artifacts.push(this.normalizePath(path));
21
+ }
22
+ /**
23
+ * Create a fallback artifactory for logging
24
+ */
25
+ static createFallbackArtifactory(context, basePath) {
26
+ const { suiteIndex, givenKey, whenIndex, thenIndex, valueKey, rowIndex } = context;
27
+ const actualBasePath = basePath || "testeranto";
135
28
  return {
136
29
  writeFileSync: (filename, payload) => {
137
30
  let path = "";
138
- if (suiteNdx !== void 0) {
139
- path += `suite-${suiteNdx}/`;
31
+ if (suiteIndex !== void 0) {
32
+ path += `suite-${suiteIndex}/`;
140
33
  }
141
- path += `setup-${key}/`;
142
- path += `action-${actionIndex} ${filename}`;
143
- console.log(`[Artifactory] Would write to: ${path}`);
144
- console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
145
- },
146
- screenshot: (filename, payload) => {
147
- console.log(`[Artifactory] Would take screenshot: ${filename}`);
148
- }
149
- };
150
- }
151
- createArtifactoryForCheck(key, checkIndex, suiteNdx) {
152
- const self = this;
153
- if (self._parent && self._parent.createArtifactory) {
154
- return self._parent.createArtifactory({
155
- givenKey: key,
156
- thenIndex: checkIndex,
157
- suiteIndex: suiteNdx
158
- });
159
- }
160
- return {
161
- writeFileSync: (filename, payload) => {
162
- let path = "";
163
- if (suiteNdx !== void 0) {
164
- path += `suite-${suiteNdx}/`;
34
+ if (givenKey !== void 0) {
35
+ path += `given-${givenKey}/`;
165
36
  }
166
- path += `setup-${key}/`;
167
- path += `check-${checkIndex} ${filename}`;
168
- console.log(`[Artifactory] Would write to: ${path}`);
169
- console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
170
- },
171
- screenshot: (filename, payload) => {
172
- console.log(`[Artifactory] Would take screenshot: ${filename}`);
173
- }
174
- };
175
- }
176
- };
177
-
178
- // src/BaseGiven.ts
179
- var BaseGiven = class extends BaseSetup {
180
- constructor(features, whens, thens, givenCB, initialValues) {
181
- super(features, whens, thens, givenCB, initialValues);
182
- this.artifacts = [];
183
- this.fails = 0;
184
- this._parent = null;
185
- this.whens = whens || [];
186
- this.thens = thens || [];
187
- console.log(`[BaseGiven.constructor] _parent initialized to null`);
188
- console.log(`[BaseGiven.constructor] whens:`, this.whens.length);
189
- console.log(`[BaseGiven.constructor] thens:`, this.thens.length);
190
- }
191
- addArtifact(path) {
192
- if (typeof path !== "string") {
193
- throw new Error(
194
- `[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(
195
- path
196
- )}`
197
- );
198
- }
199
- const normalizedPath = path.replace(/\\/g, "/");
200
- this.artifacts.push(normalizedPath);
201
- }
202
- // Set the parent explicitly
203
- setParent(parent) {
204
- this._parent = parent;
205
- console.log(`[BaseGiven.setParent] _parent set to:`, parent);
206
- }
207
- beforeAll(store) {
208
- return store;
209
- }
210
- toObj() {
211
- const whens = this.whens || [];
212
- const thens = this.thens || [];
213
- return {
214
- key: this.key,
215
- actions: whens.map((w) => {
216
- if (w && w.toObj) return w.toObj();
217
- console.error("When step is not as expected!", JSON.stringify(w));
218
- return {};
219
- }),
220
- checks: thens.map((t) => t && t.toObj ? t.toObj() : {}),
221
- error: this.error ? [this.error, this.error.stack] : null,
222
- failed: this.failed,
223
- features: this.features || [],
224
- artifacts: this.artifacts,
225
- status: this.status
226
- };
227
- }
228
- // Implement BaseSetup's abstract method
229
- async setupThat(subject, testResourceConfiguration, artifactory, setupCB, initialValues) {
230
- return this.givenThat(
231
- subject,
232
- testResourceConfiguration,
233
- artifactory,
234
- setupCB,
235
- initialValues
236
- );
237
- }
238
- async afterEach(store, key, artifactory) {
239
- return store;
240
- }
241
- async give(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
242
- this.key = key;
243
- this.fails = 0;
244
- this._suiteIndex = suiteNdx;
245
- const actualArtifactory = artifactory || this.createDefaultArtifactory(key, suiteNdx);
246
- try {
247
- this.store = await this.givenThat(
248
- subject,
249
- testResourceConfiguration,
250
- actualArtifactory,
251
- this.givenCB,
252
- this.initialValues
253
- );
254
- this.status = true;
255
- } catch (e) {
256
- this.status = false;
257
- this.failed = true;
258
- this.fails++;
259
- this.error = e;
260
- return this.store;
261
- }
262
- try {
263
- const whens = this.whens || [];
264
- if (whens && Array.isArray(whens)) {
265
- for (const [whenNdx, whenStep] of whens.entries()) {
266
- try {
267
- const whenArtifactory = this.createArtifactoryForWhen(
268
- key,
269
- whenNdx,
270
- suiteNdx
271
- );
272
- this.store = await whenStep.test(
273
- this.store,
274
- testResourceConfiguration,
275
- whenArtifactory
276
- );
277
- } catch (e) {
278
- this.failed = true;
279
- this.fails++;
280
- this.error = e;
281
- }
282
- }
283
- } else {
284
- console.warn(`[BaseGiven.give] whens is not an array:`, whens);
285
- }
286
- const thens = this.thens || [];
287
- if (thens && Array.isArray(thens)) {
288
- for (const [thenNdx, thenStep] of thens.entries()) {
289
- try {
290
- const filepath = suiteNdx !== void 0 ? `suite-${suiteNdx}/given-${key}/then-${thenNdx}` : `given-${key}/then-${thenNdx}`;
291
- const thenArtifactory = this.createArtifactoryForThen(
292
- key,
293
- thenNdx,
294
- suiteNdx
295
- );
296
- const t = await thenStep.test(
297
- this.store,
298
- testResourceConfiguration,
299
- filepath,
300
- thenArtifactory
301
- );
302
- tester(t);
303
- } catch (e) {
304
- this.failed = true;
305
- this.fails++;
306
- this.error = e;
307
- }
308
- }
309
- } else {
310
- console.warn(`[BaseGiven.give] thens is not an array:`, thens);
311
- }
312
- } catch (e) {
313
- this.error = e;
314
- this.failed = true;
315
- this.fails++;
316
- } finally {
317
- try {
318
- await this.afterEach(this.store, this.key, actualArtifactory);
319
- } catch (e) {
320
- this.failed = true;
321
- this.fails++;
322
- this.error = e;
323
- }
324
- }
325
- return this.store;
326
- }
327
- createDefaultArtifactory(givenKey, suiteNdx) {
328
- const self = this;
329
- console.log(`[BaseGiven.createDefaultArtifactory] self._parent:`, self._parent);
330
- console.log(`[BaseGiven.createDefaultArtifactory] self._parent.createArtifactory:`, self._parent?.createArtifactory);
331
- if (self._parent && self._parent.createArtifactory) {
332
- const artifactory = self._parent.createArtifactory({
333
- givenKey,
334
- suiteIndex: suiteNdx
335
- });
336
- console.log(`[BaseGiven.createDefaultArtifactory] Created artifactory from parent:`, artifactory);
337
- return artifactory;
338
- }
339
- let basePath = "testeranto";
340
- if (self._parent && self._parent.testResourceConfiguration?.fs) {
341
- basePath = self._parent.testResourceConfiguration.fs;
342
- console.log(`[BaseGiven.createDefaultArtifactory] Using base path from parent: ${basePath}`);
343
- } else {
344
- console.log(`[BaseGiven.createDefaultArtifactory] Using default base path: ${basePath}`);
345
- }
346
- return {
347
- writeFileSync: (filename, payload) => {
348
- let path = "";
349
- if (suiteNdx !== void 0) {
350
- path += `suite-${suiteNdx}/`;
37
+ if (whenIndex !== void 0) {
38
+ path += `when-${whenIndex}/`;
351
39
  }
352
- path += `given-${givenKey}/`;
353
- path += filename;
354
- if (!path.match(/\.[a-zA-Z0-9]+$/)) {
355
- path += ".txt";
40
+ if (thenIndex !== void 0) {
41
+ path += `then-${thenIndex}/`;
356
42
  }
357
- const fullPath = `${basePath}/${path}`;
358
- console.log(`[Artifactory] Writing to: ${fullPath}`);
359
- if (self._parent && typeof self._parent.writeFileSync === "function") {
360
- self._parent.writeFileSync(fullPath, payload);
361
- } else {
362
- console.log(`[Artifactory] Would write to: ${fullPath}`);
363
- console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
43
+ if (valueKey !== void 0) {
44
+ path += `value-${valueKey}/`;
364
45
  }
365
- },
366
- screenshot: (filename, payload) => {
367
- let path = "";
368
- if (suiteNdx !== void 0) {
369
- path += `suite-${suiteNdx}/`;
46
+ if (rowIndex !== void 0) {
47
+ path += `row-${rowIndex}/`;
370
48
  }
371
- path += `given-${givenKey}/`;
372
49
  path += filename;
373
- if (!path.match(/\.[a-zA-Z0-9]+$/)) {
374
- path += ".png";
375
- }
376
- const fullPath = `${basePath}/${path}`;
377
- console.log(`[Artifactory] Would take screenshot: ${fullPath}`);
378
- if (self._parent && typeof self._parent.screenshot === "function") {
379
- self._parent.screenshot(fullPath, payload || "");
380
- }
381
- }
382
- };
383
- }
384
- createArtifactoryForWhen(givenKey, whenIndex, suiteNdx) {
385
- const self = this;
386
- console.log(`[BaseGiven.createArtifactoryForWhen] self._parent:`, self._parent);
387
- console.log(`[BaseGiven.createArtifactoryForWhen] self._parent.createArtifactory:`, self._parent?.createArtifactory);
388
- if (self._parent && self._parent.createArtifactory) {
389
- const artifactory = self._parent.createArtifactory({
390
- givenKey,
391
- whenIndex,
392
- suiteIndex: suiteNdx
393
- });
394
- console.log(`[BaseGiven.createArtifactoryForWhen] Created artifactory:`, artifactory);
395
- return artifactory;
396
- }
397
- console.log(`[BaseGiven.createArtifactoryForWhen] Using fallback artifactory`);
398
- return {
399
- writeFileSync: (filename, payload) => {
400
- let path = "";
401
- if (suiteNdx !== void 0) {
402
- path += `suite-${suiteNdx}/`;
403
- }
404
- path += `given-${givenKey}/`;
405
- path += `when-${whenIndex} ${filename}`;
406
- console.log(`[Artifactory] Would write to: ${path}`);
407
- console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
50
+ const fullPath = `${actualBasePath}/${path}`;
51
+ console.log(`[Artifactory] Would write to ${fullPath}: ${payload.substring(0, 100)}...`);
408
52
  },
409
53
  screenshot: (filename, payload) => {
410
54
  console.log(`[Artifactory] Would take screenshot: ${filename}`);
411
55
  }
412
56
  };
413
57
  }
414
- createArtifactoryForThen(givenKey, thenIndex, suiteNdx) {
415
- const self = this;
416
- console.log(`[BaseGiven.createArtifactoryForThen] self._parent:`, self._parent);
417
- console.log(`[BaseGiven.createArtifactoryForThen] self._parent.createArtifactory:`, self._parent?.createArtifactory);
418
- if (self._parent && self._parent.createArtifactory) {
419
- const artifactory = self._parent.createArtifactory({
420
- givenKey,
421
- thenIndex,
422
- suiteIndex: suiteNdx
423
- });
424
- console.log(`[BaseGiven.createArtifactoryForThen] Created artifactory:`, artifactory);
425
- return artifactory;
426
- }
427
- console.log(`[BaseGiven.createArtifactoryForThen] Using fallback artifactory`);
428
- return {
429
- writeFileSync: (filename, payload) => {
430
- let path = "";
431
- if (suiteNdx !== void 0) {
432
- path += `suite-${suiteNdx}/`;
433
- }
434
- path += `given-${givenKey}/`;
435
- path += `then-${thenIndex} ${filename}`;
436
- console.log(`[Artifactory] Would write to: ${path}`);
437
- console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
438
- },
439
- screenshot: (filename, payload) => {
440
- console.log(`[Artifactory] Would take screenshot: ${filename}`);
441
- }
58
+ /**
59
+ * Standard error handling for test operations
60
+ */
61
+ static handleTestError(error, target) {
62
+ target.failed = true;
63
+ target.fails++;
64
+ target.error = error;
65
+ }
66
+ /**
67
+ * Standard method to create an object representation
68
+ */
69
+ static toObj(target, additionalProps = {}) {
70
+ const baseObj = {
71
+ key: target.key,
72
+ name: target.name,
73
+ error: target.error ? [target.error, target.error.stack] : null,
74
+ failed: target.failed,
75
+ features: target.features || [],
76
+ artifacts: target.artifacts,
77
+ status: target.status
442
78
  };
443
- }
444
- };
445
-
446
- // src/BaseAction.ts
447
- var BaseAction = class {
448
- constructor(name, actionCB) {
449
- this.error = null;
450
- this.artifacts = [];
451
- this.name = name;
452
- this.actionCB = actionCB;
453
- }
454
- addArtifact(path) {
455
- if (typeof path !== "string") {
456
- throw new Error(
457
- `[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(
458
- path
459
- )}`
460
- );
461
- }
462
- const normalizedPath = path.replace(/\\/g, "/");
463
- this.artifacts.push(normalizedPath);
464
- }
465
- toObj() {
466
- const obj = {
467
- name: this.name,
468
- status: this.status,
469
- error: this.error ? `${this.error.name}: ${this.error.message}
470
- ${this.error.stack}` : null,
471
- artifacts: this.artifacts
472
- };
473
- return obj;
474
- }
475
- async test(store, testResourceConfiguration, artifactory) {
476
- try {
477
- const result = await this.performAction(
478
- store,
479
- this.actionCB,
480
- testResourceConfiguration,
481
- artifactory
482
- );
483
- this.status = true;
484
- return result;
485
- } catch (e) {
486
- this.status = false;
487
- this.error = e;
488
- throw e;
489
- }
490
- }
491
- };
492
-
493
- // src/BaseWhen.ts
494
- var BaseWhen = class extends BaseAction {
495
- constructor(name, whenCB) {
496
- super(name, whenCB);
497
- this.whenCB = whenCB;
498
- }
499
- // Implement BaseAction's abstract method
500
- async performAction(store, actionCB, testResource) {
501
- return this.andWhen(store, actionCB, testResource);
502
- }
503
- async test(store, testResourceConfiguration, artifactory) {
504
- try {
505
- const result = await this.andWhen(
506
- store,
507
- this.whenCB,
508
- testResourceConfiguration,
509
- artifactory
510
- );
511
- this.status = true;
512
- return result;
513
- } catch (e) {
514
- this.status = false;
515
- this.error = e;
516
- throw e;
79
+ if (target.fails !== void 0) {
80
+ baseObj.fails = target.fails;
517
81
  }
82
+ return { ...baseObj, ...additionalProps };
518
83
  }
519
84
  };
520
85
 
521
- // src/BaseCheck.ts
522
- var BaseCheck = class {
523
- constructor(name, checkCB) {
524
- this.artifacts = [];
525
- this.name = name;
526
- this.checkCB = checkCB;
527
- this.error = false;
86
+ // src/verbs/tdt/BaseValue.ts
87
+ var BaseValue = class {
88
+ constructor(features, tableRows, confirmCB, initialValues) {
89
+ this.key = "";
90
+ this.failed = false;
528
91
  this.artifacts = [];
92
+ this.fails = 0;
93
+ this.error = null;
94
+ this.store = null;
95
+ this.testResourceConfiguration = null;
96
+ this.features = features;
97
+ this.tableRows = tableRows;
98
+ this.confirmCB = confirmCB;
99
+ this.initialValues = initialValues;
529
100
  }
530
- addArtifact(path) {
531
- if (typeof path !== "string") {
532
- throw new Error(
533
- `[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(
534
- path
535
- )}`
536
- );
537
- }
538
- const normalizedPath = path.replace(/\\/g, "/");
539
- this.artifacts.push(normalizedPath);
540
- }
541
- toObj() {
542
- const obj = {
543
- name: this.name,
544
- error: this.error,
545
- artifacts: this.artifacts,
546
- status: this.status
547
- };
548
- return obj;
549
- }
550
- async test(store, testResourceConfiguration, filepath, artifactory) {
551
- const addArtifact = this.addArtifact.bind(this);
552
- try {
553
- const x = await this.verifyCheck(
554
- store,
555
- async (s) => {
556
- try {
557
- if (typeof this.checkCB === "function") {
558
- const result = await this.checkCB(s);
559
- return result;
560
- } else {
561
- return this.checkCB;
562
- }
563
- } catch (e) {
564
- this.error = true;
565
- throw e;
566
- }
567
- },
568
- testResourceConfiguration,
569
- artifactory
570
- );
571
- this.status = true;
572
- return x;
573
- } catch (e) {
574
- this.status = false;
575
- this.error = true;
576
- throw e;
577
- }
578
- }
579
- };
580
-
581
- // src/BaseThen.ts
582
- var BaseThen = class extends BaseCheck {
583
- constructor(name, thenCB) {
584
- super(name, thenCB);
585
- this.thenCB = thenCB;
586
- }
587
- async test(store, testResourceConfiguration, filepath, artifactory) {
588
- try {
589
- const x = await this.butThen(
590
- store,
591
- async (s) => {
592
- try {
593
- if (typeof this.thenCB === "function") {
594
- const result = await this.thenCB(s);
595
- return result;
596
- } else {
597
- return this.thenCB;
598
- }
599
- } catch (e) {
600
- this.error = true;
601
- throw e;
602
- }
603
- },
604
- testResourceConfiguration,
605
- artifactory
606
- );
607
- this.status = true;
608
- return x;
609
- } catch (e) {
610
- this.status = false;
611
- this.error = true;
612
- throw e;
613
- }
101
+ setParent(parent) {
102
+ this._parent = parent;
614
103
  }
615
- };
616
-
617
- // src/BaseValue.ts
618
- var BaseValue = class extends BaseSetup {
619
- constructor(features, tableRows, confirmCB, initialValues) {
620
- super(features, [], [], confirmCB, initialValues);
621
- this.tableRows = tableRows;
104
+ addArtifact(path) {
105
+ CommonUtils.addArtifact(this.artifacts, path);
622
106
  }
623
- // Override setup to process table rows
624
- async setup(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
107
+ async value(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
625
108
  this.key = key;
626
109
  this.fails = 0;
110
+ this.testResourceConfiguration = testResourceConfiguration;
627
111
  const actualArtifactory = artifactory || ((fPath, value) => {
628
112
  });
629
113
  const valueArtifactory = (fPath, value) => actualArtifactory(`value-${key}/${fPath}`, value);
630
114
  try {
631
- this.store = await this.setupThat(
632
- subject,
633
- testResourceConfiguration,
634
- valueArtifactory,
635
- this.setupCB,
636
- this.initialValues
637
- );
115
+ const result = this.confirmCB();
116
+ if (typeof result === "function") {
117
+ this.store = await result();
118
+ } else {
119
+ this.store = await result;
120
+ }
638
121
  this.status = true;
639
122
  } catch (e) {
640
123
  this.status = false;
@@ -651,7 +134,12 @@ var BaseValue = class extends BaseSetup {
651
134
  rowIndex,
652
135
  suiteNdx
653
136
  );
654
- const rowResult = await this.processRow(row, rowIndex, rowArtifactory, testResourceConfiguration);
137
+ const rowResult = await this.processRow(
138
+ row,
139
+ rowIndex,
140
+ rowArtifactory,
141
+ testResourceConfiguration
142
+ );
655
143
  if (rowResult !== void 0) {
656
144
  tester(rowResult);
657
145
  }
@@ -704,15 +192,51 @@ var BaseValue = class extends BaseSetup {
704
192
  }
705
193
  };
706
194
  }
195
+ async afterEach(store, key, artifactory) {
196
+ return store;
197
+ }
198
+ toObj() {
199
+ const processedRows = (this.tableRows || []).map((row) => {
200
+ if (Array.isArray(row)) {
201
+ return row.map((item) => {
202
+ if (item && typeof item === "object") {
203
+ if (item.toObj) {
204
+ return item.toObj();
205
+ }
206
+ const result = {};
207
+ for (const [key, value] of Object.entries(item)) {
208
+ if (key !== "_parent" && key !== "testResourceConfiguration") {
209
+ result[key] = value;
210
+ }
211
+ }
212
+ return result;
213
+ }
214
+ return item;
215
+ });
216
+ }
217
+ return row;
218
+ });
219
+ return {
220
+ key: this.key,
221
+ values: processedRows,
222
+ tableRows: this.tableRows || [],
223
+ error: this.error ? [this.error, this.error.stack] : null,
224
+ failed: this.failed,
225
+ features: this.features || [],
226
+ artifacts: this.artifacts,
227
+ status: this.status
228
+ };
229
+ }
707
230
  };
708
231
 
709
- // src/BaseShould.ts
710
- var BaseShould = class extends BaseAction {
232
+ // src/verbs/tdt/BaseShould.ts
233
+ var BaseShould = class {
711
234
  constructor(name, shouldCB) {
712
- super(name, shouldCB);
713
- // Current row data
714
235
  this.currentRow = [];
715
236
  this.rowIndex = -1;
237
+ this.error = null;
238
+ this.name = name;
239
+ this.shouldCB = shouldCB;
716
240
  }
717
241
  // Set current row data
718
242
  setRowData(rowIndex, rowData) {
@@ -720,63 +244,89 @@ var BaseShould = class extends BaseAction {
720
244
  this.currentRow = rowData;
721
245
  }
722
246
  // Process the current row
723
- async processRow(store, testResourceConfiguration, artifactory) {
247
+ async processRow(actualResult, testResourceConfiguration, artifactory) {
724
248
  try {
725
- const result = await this.performAction(
726
- store,
727
- this.actionCB,
728
- testResourceConfiguration,
729
- artifactory
730
- );
731
- this.status = true;
732
- return result;
249
+ let success = false;
250
+ if (typeof this.shouldCB === "function") {
251
+ const result = await this.shouldCB(actualResult);
252
+ success = !!result;
253
+ } else {
254
+ success = actualResult === this.shouldCB;
255
+ }
256
+ this.status = success;
257
+ return success;
733
258
  } catch (e) {
734
259
  this.status = false;
735
260
  this.error = e;
736
261
  throw e;
737
262
  }
738
263
  }
264
+ toObj() {
265
+ return {
266
+ name: this.name,
267
+ status: this.status,
268
+ error: this.error ? `${this.error.name}: ${this.error.message}` : null,
269
+ rowIndex: this.rowIndex,
270
+ currentRow: this.currentRow
271
+ };
272
+ }
739
273
  };
740
274
 
741
- // src/BaseExpected.ts
742
- var BaseExpected = class extends BaseCheck {
275
+ // src/verbs/tdt/BaseExpected.ts
276
+ var BaseExpected = class {
743
277
  constructor(name, expectedCB) {
744
- super(name, expectedCB);
745
- // Expected value for current row
746
278
  this.expectedValue = null;
279
+ this.error = null;
280
+ this.name = name;
281
+ this.expectedCB = expectedCB;
747
282
  }
748
283
  // Set expected value for current row
749
284
  setExpectedValue(expected) {
750
285
  this.expectedValue = expected;
751
286
  }
752
- // Validate current row
753
- async validateRow(store, testResourceConfiguration, filepath, expectedValue, artifactory) {
754
- this.setExpectedValue(expectedValue);
755
- return this.test(store, testResourceConfiguration, filepath, artifactory);
287
+ async test(store, testResourceConfiguration, filepath, artifactory) {
288
+ try {
289
+ const result = await this.expectedCB(store);
290
+ this.status = true;
291
+ return result;
292
+ } catch (e) {
293
+ this.status = false;
294
+ this.error = e;
295
+ throw e;
296
+ }
297
+ }
298
+ toObj() {
299
+ return {
300
+ name: this.name,
301
+ status: this.status,
302
+ error: this.error ? `${this.error.name}: ${this.error.message}` : null,
303
+ expectedValue: this.expectedValue
304
+ };
756
305
  }
757
306
  };
758
307
 
759
- // src/BaseDescribe.ts
760
- var BaseDescribe = class _BaseDescribe extends BaseSetup {
308
+ // src/verbs/aaa/BaseDescribe.ts
309
+ var BaseDescribe = class {
761
310
  constructor(features, its, describeCB, initialValues) {
762
- super(features, its, [], describeCB, initialValues);
311
+ this.error = null;
312
+ this.store = null;
313
+ this.key = "";
314
+ this.failed = false;
315
+ this.artifacts = [];
316
+ this.fails = 0;
317
+ this.features = features;
763
318
  this.its = its;
319
+ this.describeCB = describeCB;
320
+ this.initialValues = initialValues;
321
+ }
322
+ addArtifact(path) {
323
+ CommonUtils.addArtifact(this.artifacts, path);
764
324
  }
765
- // Override setup to handle Its differently
766
- async setup(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
325
+ async describe(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
767
326
  this.key = key;
768
327
  this.fails = 0;
769
- const actualArtifactory = artifactory || ((fPath, value) => {
770
- });
771
- const describeArtifactory = (fPath, value) => actualArtifactory(`describe-${key}/${fPath}`, value);
772
328
  try {
773
- this.store = await this.setupThat(
774
- subject,
775
- testResourceConfiguration,
776
- describeArtifactory,
777
- this.setupCB,
778
- this.initialValues
779
- );
329
+ this.store = await this.describeCB("x");
780
330
  this.status = true;
781
331
  } catch (e) {
782
332
  this.status = false;
@@ -786,36 +336,15 @@ var BaseDescribe = class _BaseDescribe extends BaseSetup {
786
336
  return this.store;
787
337
  }
788
338
  try {
789
- for (const [itNdx, itStep] of (this.its || []).entries()) {
339
+ for (const [itNdx, it] of this.its.entries()) {
790
340
  try {
791
- const itArtifactory = this.createArtifactoryForIt(
792
- key,
793
- itNdx,
794
- suiteNdx
341
+ const result = await it.test(
342
+ this.store,
343
+ testResourceConfiguration,
344
+ artifactory
795
345
  );
796
- if (itStep && itStep instanceof _BaseDescribe) {
797
- const nestedResult = await itStep.setup(
798
- this.store,
799
- `${key}.nested${itNdx}`,
800
- testResourceConfiguration,
801
- tester,
802
- itArtifactory,
803
- suiteNdx
804
- );
805
- this.store = nestedResult;
806
- } else {
807
- const result = await itStep.test(
808
- this.store,
809
- testResourceConfiguration,
810
- itArtifactory
811
- );
812
- if (result !== void 0) {
813
- if (typeof result === "boolean" || result === null || result === void 0) {
814
- tester(result);
815
- } else {
816
- this.store = result;
817
- }
818
- }
346
+ if (result !== void 0) {
347
+ tester(result);
819
348
  }
820
349
  } catch (e) {
821
350
  this.failed = true;
@@ -827,59 +356,37 @@ var BaseDescribe = class _BaseDescribe extends BaseSetup {
827
356
  this.error = e;
828
357
  this.failed = true;
829
358
  this.fails++;
830
- } finally {
831
- try {
832
- await this.afterEach(this.store, this.key, describeArtifactory);
833
- } catch (e) {
834
- this.failed = true;
835
- this.fails++;
836
- this.error = e;
837
- }
838
359
  }
839
360
  return this.store;
840
361
  }
841
- createArtifactoryForIt(key, itIndex, suiteNdx) {
842
- const self = this;
843
- if (self._parent && self._parent.createArtifactory) {
844
- return self._parent.createArtifactory({
845
- describeKey: key,
846
- itIndex,
847
- suiteIndex: suiteNdx
848
- });
849
- }
362
+ toObj() {
850
363
  return {
851
- writeFileSync: (filename, payload) => {
852
- let path = "";
853
- if (suiteNdx !== void 0) {
854
- path += `suite-${suiteNdx}/`;
855
- }
856
- path += `describe-${key}/`;
857
- path += `it-${itIndex} ${filename}`;
858
- console.log(`[Artifactory] Would write to: ${path}`);
859
- console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
860
- },
861
- screenshot: (filename, payload) => {
862
- console.log(`[Artifactory] Would take screenshot: ${filename}`);
863
- }
364
+ key: this.key,
365
+ its: this.its.map((it) => it.toObj()),
366
+ error: this.error ? [this.error.message, this.error.stack] : null,
367
+ failed: this.failed,
368
+ features: this.features || [],
369
+ artifacts: this.artifacts,
370
+ status: this.status,
371
+ fails: this.fails
864
372
  };
865
373
  }
866
374
  };
867
375
 
868
- // src/BaseIt.ts
869
- var BaseIt = class extends BaseAction {
870
- // It can perform both actions and assertions
376
+ // src/verbs/aaa/BaseIt.ts
377
+ var BaseIt = class {
871
378
  constructor(name, itCB) {
872
- super(name, itCB);
379
+ this.error = null;
380
+ this.artifacts = [];
381
+ this.name = name;
382
+ this.itCB = itCB;
383
+ }
384
+ addArtifact(path) {
385
+ CommonUtils.addArtifact(this.artifacts, path);
873
386
  }
874
- // Override test to handle both mutations and assertions
875
387
  async test(store, testResourceConfiguration, artifactory) {
876
388
  try {
877
- const result = await this.performAction(
878
- store,
879
- this.actionCB,
880
- testResourceConfiguration,
881
- artifactory
882
- );
389
+ const result = await this.itCB(store);
883
390
  this.status = true;
884
391
  return result;
885
392
  } catch (e) {
@@ -888,119 +395,18 @@ var BaseIt = class extends BaseAction {
888
395
  throw e;
889
396
  }
890
397
  }
891
- // Alias performAction to performIt
892
- async performIt(store, itCB, testResource, artifactory) {
893
- return this.performAction(store, itCB, testResource, artifactory);
398
+ toObj() {
399
+ return {
400
+ name: this.name,
401
+ status: this.status,
402
+ error: this.error ? `${this.error.name}: ${this.error.message}
403
+ ${this.error.stack}` : null,
404
+ artifacts: this.artifacts
405
+ };
894
406
  }
895
407
  };
896
408
 
897
409
  // src/index.ts
898
- var BaseAdapter = () => ({
899
- prepareAll: async (input, testResource, artifactory) => {
900
- return input;
901
- },
902
- prepareEach: async function(subject, initializer, testResource, initialValues, artifactory) {
903
- return subject;
904
- },
905
- cleanupEach: async (store, key, artifactory) => Promise.resolve(store),
906
- cleanupAll: (store, artifactory) => void 0,
907
- verify: async (store, checkCb, testResource, artifactory) => {
908
- return checkCb(store);
909
- },
910
- execute: async (store, actionCB, testResource, artifactory) => {
911
- return actionCB(store);
912
- },
913
- assert: (x) => x
914
- });
915
- var DefaultAdapter = (p) => {
916
- const base = BaseAdapter();
917
- const mapped = { ...p };
918
- if (p.beforeAll && !p.prepareAll) {
919
- mapped.prepareAll = async (input, testResource, artifactory) => {
920
- if (p.beforeAll.length >= 3) {
921
- return await p.beforeAll(input, testResource, artifactory);
922
- } else if (p.beforeAll.length >= 2) {
923
- return await p.beforeAll(input, testResource);
924
- } else {
925
- return await p.beforeAll(input);
926
- }
927
- };
928
- }
929
- if (p.beforeEach && !p.prepareEach) {
930
- mapped.prepareEach = async (subject, initializer, testResource, initialValues, artifactory) => {
931
- if (p.beforeEach.length >= 5) {
932
- return await p.beforeEach(subject, initializer, testResource, initialValues, artifactory);
933
- } else if (p.beforeEach.length >= 4) {
934
- return await p.beforeEach(subject, initializer, testResource, initialValues);
935
- } else if (p.beforeEach.length >= 3) {
936
- return await p.beforeEach(subject, initializer, testResource);
937
- } else if (p.beforeEach.length >= 2) {
938
- return await p.beforeEach(subject, initializer);
939
- } else {
940
- return await p.beforeEach(subject);
941
- }
942
- };
943
- }
944
- if (p.afterEach && !p.cleanupEach) {
945
- mapped.cleanupEach = async (store, key, artifactory) => {
946
- if (p.afterEach.length >= 3) {
947
- return await p.afterEach(store, key, artifactory);
948
- } else if (p.afterEach.length >= 2) {
949
- return await p.afterEach(store, key);
950
- } else {
951
- return await p.afterEach(store);
952
- }
953
- };
954
- }
955
- if (p.afterAll && !p.cleanupAll) {
956
- mapped.cleanupAll = (store, artifactory) => {
957
- if (p.afterAll.length >= 2) {
958
- return p.afterAll(store, artifactory);
959
- } else {
960
- return p.afterAll(store);
961
- }
962
- };
963
- }
964
- if (p.andWhen && !p.execute) {
965
- mapped.execute = async (store, actionCB, testResource, artifactory) => {
966
- if (p.andWhen.length >= 4) {
967
- return await p.andWhen(store, actionCB, testResource, artifactory);
968
- } else if (p.andWhen.length >= 3) {
969
- return await p.andWhen(store, actionCB, testResource);
970
- } else if (p.andWhen.length >= 2) {
971
- return await p.andWhen(store, actionCB);
972
- } else {
973
- return await p.andWhen(store);
974
- }
975
- };
976
- }
977
- if (p.butThen && !p.verify) {
978
- mapped.verify = async (store, checkCB, testResource, artifactory) => {
979
- if (p.butThen.length >= 4) {
980
- return await p.butThen(store, checkCB, testResource, artifactory);
981
- } else if (p.butThen.length >= 3) {
982
- return await p.butThen(store, checkCB, testResource);
983
- } else if (p.butThen.length >= 2) {
984
- return await p.butThen(store, checkCB);
985
- } else {
986
- return await p.butThen(store);
987
- }
988
- };
989
- }
990
- if (p.assertThis && !p.assert) {
991
- mapped.assert = (x) => {
992
- if (p.assertThis.length >= 1) {
993
- return p.assertThis(x);
994
- } else {
995
- return p.assertThis();
996
- }
997
- };
998
- }
999
- return {
1000
- ...base,
1001
- ...mapped
1002
- };
1003
- };
1004
410
  function createDescribeItSpecification() {
1005
411
  return {
1006
412
  // Create a suite with Describe-It pattern
@@ -1022,12 +428,7 @@ function createDescribeItSpecification() {
1022
428
  // Describe maps to Setup
1023
429
  Describe: {
1024
430
  Default: (features, its, describeCB, initialValues) => {
1025
- return (Describe) => Describe.Default(
1026
- features,
1027
- its,
1028
- describeCB,
1029
- initialValues
1030
- );
431
+ return (Describe) => Describe.Default(features, its, describeCB, initialValues);
1031
432
  }
1032
433
  },
1033
434
  // It can mix mutations and assertions
@@ -1059,12 +460,7 @@ function createTDTSpecification() {
1059
460
  // Value maps to Setup (sets up table data)
1060
461
  Value: {
1061
462
  Default: (features, tableRows, confirmCB, initialValues) => {
1062
- return (Value) => Value.Default(
1063
- features,
1064
- tableRows,
1065
- confirmCB,
1066
- initialValues
1067
- );
463
+ return (Value) => Value.Default(features, tableRows, confirmCB, initialValues);
1068
464
  }
1069
465
  },
1070
466
  // Should processes each row (like Action)
@@ -1085,19 +481,25 @@ function DescribeIt() {
1085
481
  return {
1086
482
  Suite: {
1087
483
  Default: (name, descriptions) => {
1088
- console.warn("DescribeIt.Suite.Default: This helper function requires proper context from a test specification. Use createDescribeItSpecification() for full functionality.");
484
+ console.warn(
485
+ "DescribeIt.Suite.Default: This helper function requires proper context from a test specification. Use createDescribeItSpecification() for full functionality."
486
+ );
1089
487
  return { name, descriptions };
1090
488
  }
1091
489
  },
1092
490
  Describe: {
1093
491
  Default: (features, its, describeCB, initialValues) => {
1094
- console.warn("DescribeIt.Describe.Default: This helper function requires proper context. Use createDescribeItSpecification() for full functionality.");
492
+ console.warn(
493
+ "DescribeIt.Describe.Default: This helper function requires proper context. Use createDescribeItSpecification() for full functionality."
494
+ );
1095
495
  return { features, its, describeCB, initialValues };
1096
496
  }
1097
497
  },
1098
498
  It: {
1099
499
  Default: (name, itCB) => {
1100
- console.warn("DescribeIt.It.Default: This helper function requires proper context. Use createDescribeItSpecification() for full functionality.");
500
+ console.warn(
501
+ "DescribeIt.It.Default: This helper function requires proper context. Use createDescribeItSpecification() for full functionality."
502
+ );
1101
503
  return { name, itCB };
1102
504
  }
1103
505
  }
@@ -1107,45 +509,45 @@ function Confirm() {
1107
509
  return {
1108
510
  Suite: {
1109
511
  Default: (name, confirms) => {
1110
- console.warn("Confirm.Suite.Default: This helper function requires proper context from a test specification. Use createTDTSpecification() for full functionality.");
512
+ console.warn(
513
+ "Confirm.Suite.Default: This helper function requires proper context from a test specification. Use createTDTSpecification() for full functionality."
514
+ );
1111
515
  return { name, confirms };
1112
516
  }
1113
517
  },
1114
518
  Value: {
1115
519
  Default: (features, tableRows, confirmCB, initialValues) => {
1116
- console.warn("Confirm.Value.Default: This helper function requires proper context. Use createTDTSpecification() for full functionality.");
520
+ console.warn(
521
+ "Confirm.Value.Default: This helper function requires proper context. Use createTDTSpecification() for full functionality."
522
+ );
1117
523
  return { features, tableRows, confirmCB, initialValues };
1118
524
  }
1119
525
  },
1120
526
  Should: {
1121
527
  Default: (name, shouldCB) => {
1122
- console.warn("Confirm.Should.Default: This helper function requires proper context. Use createTDTSpecification() for full functionality.");
528
+ console.warn(
529
+ "Confirm.Should.Default: This helper function requires proper context. Use createTDTSpecification() for full functionality."
530
+ );
1123
531
  return { name, shouldCB };
1124
532
  }
1125
533
  },
1126
534
  Expected: {
1127
535
  Default: (name, expectedCB) => {
1128
- console.warn("Confirm.Expected.Default: This helper function requires proper context. Use createTDTSpecification() for full functionality.");
536
+ console.warn(
537
+ "Confirm.Expected.Default: This helper function requires proper context. Use createTDTSpecification() for full functionality."
538
+ );
1129
539
  return { name, expectedCB };
1130
540
  }
1131
541
  }
1132
542
  };
1133
543
  }
1134
544
  export {
1135
- BaseAction,
1136
- BaseAdapter,
1137
- BaseCheck,
1138
545
  BaseDescribe,
1139
546
  BaseExpected,
1140
- BaseGiven,
1141
547
  BaseIt,
1142
- BaseSetup,
1143
548
  BaseShould,
1144
- BaseThen,
1145
549
  BaseValue,
1146
- BaseWhen,
1147
550
  Confirm,
1148
- DefaultAdapter,
1149
551
  DescribeIt,
1150
552
  createDescribeItSpecification,
1151
553
  createTDTSpecification