testeranto.tiposkripto 0.2.22 → 0.3.2
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.
- package/README.md +13 -0
- package/dist/module/Node.js +230 -229
- package/dist/module/Web.js +317 -229
- package/dist/module/index.js +467 -349
- package/dist/types/lib/tiposkripto/src/BaseAction.d.ts +2 -2
- package/dist/types/lib/tiposkripto/src/BaseCheck.d.ts +2 -2
- package/dist/types/lib/tiposkripto/src/BaseDescribe.d.ts +26 -0
- package/dist/types/lib/tiposkripto/src/BaseExpected.d.ts +25 -0
- package/dist/types/lib/tiposkripto/src/BaseGiven.d.ts +11 -2
- package/dist/types/lib/tiposkripto/src/BaseIt.d.ts +23 -0
- package/dist/types/lib/tiposkripto/src/BaseSetup.d.ts +2 -2
- package/dist/types/lib/tiposkripto/src/BaseShould.d.ts +25 -0
- package/dist/types/lib/tiposkripto/src/BaseThen.d.ts +10 -2
- package/dist/types/lib/tiposkripto/src/BaseTiposkripto.d.ts +14 -6
- package/dist/types/lib/tiposkripto/src/BaseValue.d.ts +27 -0
- package/dist/types/lib/tiposkripto/src/BaseWhen.d.ts +10 -2
- package/dist/types/lib/tiposkripto/src/CoreTypes.d.ts +1 -1
- package/dist/types/lib/tiposkripto/src/Web.d.ts +11 -0
- package/dist/types/lib/tiposkripto/src/index.d.ts +44 -57
- package/dist/types/lib/tiposkripto/src/types.d.ts +5 -6
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/module/index.js
CHANGED
|
@@ -175,248 +175,6 @@ var BaseSetup = class {
|
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
// src/BaseAction.ts
|
|
179
|
-
var BaseAction = class {
|
|
180
|
-
constructor(name, actionCB) {
|
|
181
|
-
this.error = null;
|
|
182
|
-
this.artifacts = [];
|
|
183
|
-
this.name = name;
|
|
184
|
-
this.actionCB = actionCB;
|
|
185
|
-
}
|
|
186
|
-
addArtifact(path) {
|
|
187
|
-
if (typeof path !== "string") {
|
|
188
|
-
throw new Error(
|
|
189
|
-
`[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(
|
|
190
|
-
path
|
|
191
|
-
)}`
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
const normalizedPath = path.replace(/\\/g, "/");
|
|
195
|
-
this.artifacts.push(normalizedPath);
|
|
196
|
-
}
|
|
197
|
-
toObj() {
|
|
198
|
-
const obj = {
|
|
199
|
-
name: this.name,
|
|
200
|
-
status: this.status,
|
|
201
|
-
error: this.error ? `${this.error.name}: ${this.error.message}
|
|
202
|
-
${this.error.stack}` : null,
|
|
203
|
-
artifacts: this.artifacts
|
|
204
|
-
};
|
|
205
|
-
return obj;
|
|
206
|
-
}
|
|
207
|
-
async test(store, testResourceConfiguration, artifactory) {
|
|
208
|
-
try {
|
|
209
|
-
const result = await this.performAction(
|
|
210
|
-
store,
|
|
211
|
-
this.actionCB,
|
|
212
|
-
testResourceConfiguration,
|
|
213
|
-
artifactory
|
|
214
|
-
);
|
|
215
|
-
this.status = true;
|
|
216
|
-
return result;
|
|
217
|
-
} catch (e) {
|
|
218
|
-
this.status = false;
|
|
219
|
-
this.error = e;
|
|
220
|
-
throw e;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
// src/BaseCheck.ts
|
|
226
|
-
var BaseCheck = class {
|
|
227
|
-
constructor(name, checkCB) {
|
|
228
|
-
this.artifacts = [];
|
|
229
|
-
this.name = name;
|
|
230
|
-
this.checkCB = checkCB;
|
|
231
|
-
this.error = false;
|
|
232
|
-
this.artifacts = [];
|
|
233
|
-
}
|
|
234
|
-
addArtifact(path) {
|
|
235
|
-
if (typeof path !== "string") {
|
|
236
|
-
throw new Error(
|
|
237
|
-
`[ARTIFACT ERROR] Expected string, got ${typeof path}: ${JSON.stringify(
|
|
238
|
-
path
|
|
239
|
-
)}`
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
const normalizedPath = path.replace(/\\/g, "/");
|
|
243
|
-
this.artifacts.push(normalizedPath);
|
|
244
|
-
}
|
|
245
|
-
toObj() {
|
|
246
|
-
const obj = {
|
|
247
|
-
name: this.name,
|
|
248
|
-
error: this.error,
|
|
249
|
-
artifacts: this.artifacts,
|
|
250
|
-
status: this.status
|
|
251
|
-
};
|
|
252
|
-
return obj;
|
|
253
|
-
}
|
|
254
|
-
async test(store, testResourceConfiguration, filepath, artifactory) {
|
|
255
|
-
const addArtifact = this.addArtifact.bind(this);
|
|
256
|
-
try {
|
|
257
|
-
const x = await this.verifyCheck(
|
|
258
|
-
store,
|
|
259
|
-
async (s) => {
|
|
260
|
-
try {
|
|
261
|
-
if (typeof this.checkCB === "function") {
|
|
262
|
-
const result = await this.checkCB(s);
|
|
263
|
-
return result;
|
|
264
|
-
} else {
|
|
265
|
-
return this.checkCB;
|
|
266
|
-
}
|
|
267
|
-
} catch (e) {
|
|
268
|
-
this.error = true;
|
|
269
|
-
throw e;
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
testResourceConfiguration,
|
|
273
|
-
artifactory
|
|
274
|
-
);
|
|
275
|
-
this.status = true;
|
|
276
|
-
return x;
|
|
277
|
-
} catch (e) {
|
|
278
|
-
this.status = false;
|
|
279
|
-
this.error = true;
|
|
280
|
-
throw e;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
// src/BaseArrange.ts
|
|
286
|
-
var BaseArrange = class extends BaseSetup {
|
|
287
|
-
setupThat(subject, testResourceConfiguration, artifactory, setupCB, initialValues) {
|
|
288
|
-
throw new Error("Method not implemented.");
|
|
289
|
-
}
|
|
290
|
-
constructor(features, acts, asserts, arrangeCB, initialValues) {
|
|
291
|
-
super(features, acts, asserts, arrangeCB, initialValues);
|
|
292
|
-
}
|
|
293
|
-
// Alias setup to arrange for AAA pattern
|
|
294
|
-
async arrange(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
|
|
295
|
-
return super.setup(
|
|
296
|
-
subject,
|
|
297
|
-
key,
|
|
298
|
-
testResourceConfiguration,
|
|
299
|
-
tester,
|
|
300
|
-
artifactory,
|
|
301
|
-
suiteNdx
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
// src/BaseAct.ts
|
|
307
|
-
var BaseAct = class extends BaseAction {
|
|
308
|
-
performAction(store, actionCB, testResource, artifactory) {
|
|
309
|
-
throw new Error("Method not implemented.");
|
|
310
|
-
}
|
|
311
|
-
constructor(name, actCB) {
|
|
312
|
-
super(name, actCB);
|
|
313
|
-
}
|
|
314
|
-
// Alias performAction to performAct for AAA pattern
|
|
315
|
-
async performAct(store, actCB, testResource) {
|
|
316
|
-
return this.performAction(store, actCB, testResource);
|
|
317
|
-
}
|
|
318
|
-
// Alias test to act for AAA pattern
|
|
319
|
-
async act(store, testResourceConfiguration) {
|
|
320
|
-
return super.test(store, testResourceConfiguration);
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
// src/BaseAssert.ts
|
|
325
|
-
var BaseAssert = class extends BaseCheck {
|
|
326
|
-
verifyCheck(store, checkCB, testResourceConfiguration, artifactory) {
|
|
327
|
-
throw new Error("Method not implemented.");
|
|
328
|
-
}
|
|
329
|
-
constructor(name, assertCB) {
|
|
330
|
-
super(name, assertCB);
|
|
331
|
-
}
|
|
332
|
-
// Alias verifyCheck to verifyAssert for AAA pattern
|
|
333
|
-
async verifyAssert(store, assertCB, testResourceConfiguration) {
|
|
334
|
-
return this.verifyCheck(store, assertCB, testResourceConfiguration);
|
|
335
|
-
}
|
|
336
|
-
// Alias test to verify for AAA pattern
|
|
337
|
-
async verify(store, testResourceConfiguration, filepath) {
|
|
338
|
-
return super.test(store, testResourceConfiguration, filepath);
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
// src/BaseMap.ts
|
|
343
|
-
var BaseMap = class extends BaseSetup {
|
|
344
|
-
setupThat(subject, testResourceConfiguration, artifactory, setupCB, initialValues) {
|
|
345
|
-
throw new Error("Method not implemented.");
|
|
346
|
-
}
|
|
347
|
-
constructor(features, feeds, validates, mapCB, initialValues, tableData = []) {
|
|
348
|
-
super(features, feeds, validates, mapCB, initialValues);
|
|
349
|
-
this.tableData = tableData;
|
|
350
|
-
}
|
|
351
|
-
// Alias setup to map for TDT pattern
|
|
352
|
-
async map(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
|
|
353
|
-
return super.setup(
|
|
354
|
-
subject,
|
|
355
|
-
key,
|
|
356
|
-
testResourceConfiguration,
|
|
357
|
-
tester,
|
|
358
|
-
artifactory,
|
|
359
|
-
suiteNdx
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
// Method to get table data
|
|
363
|
-
getTableData() {
|
|
364
|
-
return this.tableData || [];
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
// src/BaseFeed.ts
|
|
369
|
-
var BaseFeed = class extends BaseAction {
|
|
370
|
-
constructor(name, feedCB) {
|
|
371
|
-
super(name, feedCB);
|
|
372
|
-
// Row index being processed
|
|
373
|
-
this.rowIndex = -1;
|
|
374
|
-
this.rowData = null;
|
|
375
|
-
}
|
|
376
|
-
performAction(store, actionCB, testResource, artifactory) {
|
|
377
|
-
throw new Error("Method not implemented.");
|
|
378
|
-
}
|
|
379
|
-
// Set the current row data before processing
|
|
380
|
-
setRowData(index, data) {
|
|
381
|
-
this.rowIndex = index;
|
|
382
|
-
this.rowData = data;
|
|
383
|
-
}
|
|
384
|
-
// Alias performAction to feed for TDT pattern
|
|
385
|
-
async feed(store, feedCB, testResource) {
|
|
386
|
-
return this.performAction(store, feedCB, testResource);
|
|
387
|
-
}
|
|
388
|
-
// Alias test to processRow for TDT pattern
|
|
389
|
-
async processRow(store, testResourceConfiguration, rowIndex, rowData) {
|
|
390
|
-
this.setRowData(rowIndex, rowData);
|
|
391
|
-
return super.test(store, testResourceConfiguration);
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
// src/BaseValidate.ts
|
|
396
|
-
var BaseValidate = class extends BaseCheck {
|
|
397
|
-
constructor(name, validateCB) {
|
|
398
|
-
super(name, validateCB);
|
|
399
|
-
// Expected result for the current row
|
|
400
|
-
this.expectedResult = null;
|
|
401
|
-
}
|
|
402
|
-
verifyCheck(store, checkCB, testResourceConfiguration, artifactory) {
|
|
403
|
-
throw new Error("Method not implemented.");
|
|
404
|
-
}
|
|
405
|
-
// Set expected result before validation
|
|
406
|
-
setExpectedResult(expected) {
|
|
407
|
-
this.expectedResult = expected;
|
|
408
|
-
}
|
|
409
|
-
// Alias verifyCheck to validate for TDT pattern
|
|
410
|
-
async validate(store, validateCB, testResourceConfiguration) {
|
|
411
|
-
return this.verifyCheck(store, validateCB, testResourceConfiguration);
|
|
412
|
-
}
|
|
413
|
-
// Alias test to check for TDT pattern
|
|
414
|
-
async check(store, testResourceConfiguration, filepath, expectedResult) {
|
|
415
|
-
this.setExpectedResult(expectedResult);
|
|
416
|
-
return super.test(store, testResourceConfiguration, filepath);
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
|
|
420
178
|
// src/BaseGiven.ts
|
|
421
179
|
var BaseGiven = class extends BaseSetup {
|
|
422
180
|
constructor(features, whens, thens, givenCB, initialValues) {
|
|
@@ -685,6 +443,53 @@ var BaseGiven = class extends BaseSetup {
|
|
|
685
443
|
}
|
|
686
444
|
};
|
|
687
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
|
+
|
|
688
493
|
// src/BaseWhen.ts
|
|
689
494
|
var BaseWhen = class extends BaseAction {
|
|
690
495
|
constructor(name, whenCB) {
|
|
@@ -713,6 +518,66 @@ var BaseWhen = class extends BaseAction {
|
|
|
713
518
|
}
|
|
714
519
|
};
|
|
715
520
|
|
|
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;
|
|
528
|
+
this.artifacts = [];
|
|
529
|
+
}
|
|
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
|
+
|
|
716
581
|
// src/BaseThen.ts
|
|
717
582
|
var BaseThen = class extends BaseCheck {
|
|
718
583
|
constructor(name, thenCB) {
|
|
@@ -749,6 +614,286 @@ var BaseThen = class extends BaseCheck {
|
|
|
749
614
|
}
|
|
750
615
|
};
|
|
751
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;
|
|
622
|
+
}
|
|
623
|
+
// Override setup to process table rows
|
|
624
|
+
async setup(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
|
|
625
|
+
this.key = key;
|
|
626
|
+
this.fails = 0;
|
|
627
|
+
const actualArtifactory = artifactory || ((fPath, value) => {
|
|
628
|
+
});
|
|
629
|
+
const valueArtifactory = (fPath, value) => actualArtifactory(`value-${key}/${fPath}`, value);
|
|
630
|
+
try {
|
|
631
|
+
this.store = await this.setupThat(
|
|
632
|
+
subject,
|
|
633
|
+
testResourceConfiguration,
|
|
634
|
+
valueArtifactory,
|
|
635
|
+
this.setupCB,
|
|
636
|
+
this.initialValues
|
|
637
|
+
);
|
|
638
|
+
this.status = true;
|
|
639
|
+
} catch (e) {
|
|
640
|
+
this.status = false;
|
|
641
|
+
this.failed = true;
|
|
642
|
+
this.fails++;
|
|
643
|
+
this.error = e;
|
|
644
|
+
return this.store;
|
|
645
|
+
}
|
|
646
|
+
try {
|
|
647
|
+
for (const [rowIndex, row] of (this.tableRows || []).entries()) {
|
|
648
|
+
try {
|
|
649
|
+
const rowArtifactory = this.createArtifactoryForRow(
|
|
650
|
+
key,
|
|
651
|
+
rowIndex,
|
|
652
|
+
suiteNdx
|
|
653
|
+
);
|
|
654
|
+
const rowResult = await this.processRow(row, rowIndex, rowArtifactory, testResourceConfiguration);
|
|
655
|
+
if (rowResult !== void 0) {
|
|
656
|
+
tester(rowResult);
|
|
657
|
+
}
|
|
658
|
+
} catch (e) {
|
|
659
|
+
this.failed = true;
|
|
660
|
+
this.fails++;
|
|
661
|
+
this.error = e;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
} catch (e) {
|
|
665
|
+
this.error = e;
|
|
666
|
+
this.failed = true;
|
|
667
|
+
this.fails++;
|
|
668
|
+
} finally {
|
|
669
|
+
try {
|
|
670
|
+
await this.afterEach(this.store, this.key, valueArtifactory);
|
|
671
|
+
} catch (e) {
|
|
672
|
+
this.failed = true;
|
|
673
|
+
this.fails++;
|
|
674
|
+
this.error = e;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return this.store;
|
|
678
|
+
}
|
|
679
|
+
async processRow(row, rowIndex, artifactory, testResourceConfiguration) {
|
|
680
|
+
return row;
|
|
681
|
+
}
|
|
682
|
+
createArtifactoryForRow(key, rowIndex, suiteNdx) {
|
|
683
|
+
const self = this;
|
|
684
|
+
if (self._parent && self._parent.createArtifactory) {
|
|
685
|
+
return self._parent.createArtifactory({
|
|
686
|
+
valueKey: key,
|
|
687
|
+
rowIndex,
|
|
688
|
+
suiteIndex: suiteNdx
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
return {
|
|
692
|
+
writeFileSync: (filename, payload) => {
|
|
693
|
+
let path = "";
|
|
694
|
+
if (suiteNdx !== void 0) {
|
|
695
|
+
path += `suite-${suiteNdx}/`;
|
|
696
|
+
}
|
|
697
|
+
path += `value-${key}/`;
|
|
698
|
+
path += `row-${rowIndex} ${filename}`;
|
|
699
|
+
console.log(`[Artifactory] Would write to: ${path}`);
|
|
700
|
+
console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
|
|
701
|
+
},
|
|
702
|
+
screenshot: (filename, payload) => {
|
|
703
|
+
console.log(`[Artifactory] Would take screenshot: ${filename}`);
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
// src/BaseShould.ts
|
|
710
|
+
var BaseShould = class extends BaseAction {
|
|
711
|
+
constructor(name, shouldCB) {
|
|
712
|
+
super(name, shouldCB);
|
|
713
|
+
// Current row data
|
|
714
|
+
this.currentRow = [];
|
|
715
|
+
this.rowIndex = -1;
|
|
716
|
+
}
|
|
717
|
+
// Set current row data
|
|
718
|
+
setRowData(rowIndex, rowData) {
|
|
719
|
+
this.rowIndex = rowIndex;
|
|
720
|
+
this.currentRow = rowData;
|
|
721
|
+
}
|
|
722
|
+
// Process the current row
|
|
723
|
+
async processRow(store, testResourceConfiguration, artifactory) {
|
|
724
|
+
try {
|
|
725
|
+
const result = await this.performAction(
|
|
726
|
+
store,
|
|
727
|
+
this.actionCB,
|
|
728
|
+
testResourceConfiguration,
|
|
729
|
+
artifactory
|
|
730
|
+
);
|
|
731
|
+
this.status = true;
|
|
732
|
+
return result;
|
|
733
|
+
} catch (e) {
|
|
734
|
+
this.status = false;
|
|
735
|
+
this.error = e;
|
|
736
|
+
throw e;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
// src/BaseExpected.ts
|
|
742
|
+
var BaseExpected = class extends BaseCheck {
|
|
743
|
+
constructor(name, expectedCB) {
|
|
744
|
+
super(name, expectedCB);
|
|
745
|
+
// Expected value for current row
|
|
746
|
+
this.expectedValue = null;
|
|
747
|
+
}
|
|
748
|
+
// Set expected value for current row
|
|
749
|
+
setExpectedValue(expected) {
|
|
750
|
+
this.expectedValue = expected;
|
|
751
|
+
}
|
|
752
|
+
// Validate current row
|
|
753
|
+
async validateRow(store, testResourceConfiguration, filepath, expectedValue, artifactory) {
|
|
754
|
+
this.setExpectedValue(expectedValue);
|
|
755
|
+
return this.test(store, testResourceConfiguration, filepath, artifactory);
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
// src/BaseDescribe.ts
|
|
760
|
+
var BaseDescribe = class _BaseDescribe extends BaseSetup {
|
|
761
|
+
constructor(features, its, describeCB, initialValues) {
|
|
762
|
+
super(features, its, [], describeCB, initialValues);
|
|
763
|
+
this.its = its;
|
|
764
|
+
}
|
|
765
|
+
// Override setup to handle Its differently
|
|
766
|
+
async setup(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
|
|
767
|
+
this.key = key;
|
|
768
|
+
this.fails = 0;
|
|
769
|
+
const actualArtifactory = artifactory || ((fPath, value) => {
|
|
770
|
+
});
|
|
771
|
+
const describeArtifactory = (fPath, value) => actualArtifactory(`describe-${key}/${fPath}`, value);
|
|
772
|
+
try {
|
|
773
|
+
this.store = await this.setupThat(
|
|
774
|
+
subject,
|
|
775
|
+
testResourceConfiguration,
|
|
776
|
+
describeArtifactory,
|
|
777
|
+
this.setupCB,
|
|
778
|
+
this.initialValues
|
|
779
|
+
);
|
|
780
|
+
this.status = true;
|
|
781
|
+
} catch (e) {
|
|
782
|
+
this.status = false;
|
|
783
|
+
this.failed = true;
|
|
784
|
+
this.fails++;
|
|
785
|
+
this.error = e;
|
|
786
|
+
return this.store;
|
|
787
|
+
}
|
|
788
|
+
try {
|
|
789
|
+
for (const [itNdx, itStep] of (this.its || []).entries()) {
|
|
790
|
+
try {
|
|
791
|
+
const itArtifactory = this.createArtifactoryForIt(
|
|
792
|
+
key,
|
|
793
|
+
itNdx,
|
|
794
|
+
suiteNdx
|
|
795
|
+
);
|
|
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
|
+
}
|
|
819
|
+
}
|
|
820
|
+
} catch (e) {
|
|
821
|
+
this.failed = true;
|
|
822
|
+
this.fails++;
|
|
823
|
+
this.error = e;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
} catch (e) {
|
|
827
|
+
this.error = e;
|
|
828
|
+
this.failed = true;
|
|
829
|
+
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
|
+
}
|
|
839
|
+
return this.store;
|
|
840
|
+
}
|
|
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
|
+
}
|
|
850
|
+
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
|
+
}
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
// src/BaseIt.ts
|
|
869
|
+
var BaseIt = class extends BaseAction {
|
|
870
|
+
// It can perform both actions and assertions
|
|
871
|
+
constructor(name, itCB) {
|
|
872
|
+
super(name, itCB);
|
|
873
|
+
}
|
|
874
|
+
// Override test to handle both mutations and assertions
|
|
875
|
+
async test(store, testResourceConfiguration, artifactory) {
|
|
876
|
+
try {
|
|
877
|
+
const result = await this.performAction(
|
|
878
|
+
store,
|
|
879
|
+
this.actionCB,
|
|
880
|
+
testResourceConfiguration,
|
|
881
|
+
artifactory
|
|
882
|
+
);
|
|
883
|
+
this.status = true;
|
|
884
|
+
return result;
|
|
885
|
+
} catch (e) {
|
|
886
|
+
this.status = false;
|
|
887
|
+
this.error = e;
|
|
888
|
+
throw e;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
// Alias performAction to performIt
|
|
892
|
+
async performIt(store, itCB, testResource, artifactory) {
|
|
893
|
+
return this.performAction(store, itCB, testResource, artifactory);
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
|
|
752
897
|
// src/index.ts
|
|
753
898
|
var BaseAdapter = () => ({
|
|
754
899
|
prepareAll: async (input, testResource, artifactory) => {
|
|
@@ -856,47 +1001,39 @@ var DefaultAdapter = (p) => {
|
|
|
856
1001
|
...mapped
|
|
857
1002
|
};
|
|
858
1003
|
};
|
|
859
|
-
function
|
|
1004
|
+
function createDescribeItSpecification() {
|
|
860
1005
|
return {
|
|
861
|
-
// Create a suite with
|
|
1006
|
+
// Create a suite with Describe-It pattern
|
|
862
1007
|
Suite: {
|
|
863
|
-
Default: (Suite,
|
|
864
|
-
const
|
|
865
|
-
for (const [key,
|
|
866
|
-
const { features,
|
|
867
|
-
|
|
1008
|
+
Default: (Suite, Describe, It) => (name, descriptions) => {
|
|
1009
|
+
const setups = {};
|
|
1010
|
+
for (const [key, description] of Object.entries(descriptions)) {
|
|
1011
|
+
const { features, its, describeCB, initialValues } = description;
|
|
1012
|
+
setups[key] = Describe.Default(
|
|
868
1013
|
features,
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
arrangeCB,
|
|
1014
|
+
its,
|
|
1015
|
+
describeCB,
|
|
872
1016
|
initialValues
|
|
873
1017
|
);
|
|
874
1018
|
}
|
|
875
|
-
return Suite.Default(name,
|
|
1019
|
+
return Suite.Default(name, setups);
|
|
876
1020
|
}
|
|
877
1021
|
},
|
|
878
|
-
//
|
|
879
|
-
|
|
880
|
-
Default: (features,
|
|
881
|
-
return (
|
|
1022
|
+
// Describe maps to Setup
|
|
1023
|
+
Describe: {
|
|
1024
|
+
Default: (features, its, describeCB, initialValues) => {
|
|
1025
|
+
return (Describe) => Describe.Default(
|
|
882
1026
|
features,
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
arrangeCB,
|
|
1027
|
+
its,
|
|
1028
|
+
describeCB,
|
|
886
1029
|
initialValues
|
|
887
1030
|
);
|
|
888
1031
|
}
|
|
889
1032
|
},
|
|
890
|
-
//
|
|
891
|
-
|
|
892
|
-
Default: (name,
|
|
893
|
-
return (
|
|
894
|
-
}
|
|
895
|
-
},
|
|
896
|
-
// Assert maps to Then
|
|
897
|
-
Assert: {
|
|
898
|
-
Default: (name, assertCB) => {
|
|
899
|
-
return (Assert) => Assert.Default(name, assertCB);
|
|
1033
|
+
// It can mix mutations and assertions
|
|
1034
|
+
It: {
|
|
1035
|
+
Default: (name, itCB) => {
|
|
1036
|
+
return (It) => It.Default(name, itCB);
|
|
900
1037
|
}
|
|
901
1038
|
}
|
|
902
1039
|
};
|
|
@@ -905,130 +1042,111 @@ function createTDTSpecification() {
|
|
|
905
1042
|
return {
|
|
906
1043
|
// Create a suite with TDT pattern
|
|
907
1044
|
Suite: {
|
|
908
|
-
Default: (Suite,
|
|
909
|
-
const
|
|
910
|
-
for (const [key,
|
|
911
|
-
const {
|
|
1045
|
+
Default: (Suite, Value, Should, Expected) => (name, confirms) => {
|
|
1046
|
+
const setups = {};
|
|
1047
|
+
for (const [key, confirm] of Object.entries(confirms)) {
|
|
1048
|
+
const { features, tableRows, confirmCB, initialValues } = confirm;
|
|
1049
|
+
setups[key] = Value.Default(
|
|
912
1050
|
features,
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
initialValues,
|
|
917
|
-
tableData
|
|
918
|
-
} = map;
|
|
919
|
-
givens[key] = Map.Default(
|
|
920
|
-
features,
|
|
921
|
-
feeds,
|
|
922
|
-
validates,
|
|
923
|
-
mapCB,
|
|
924
|
-
initialValues,
|
|
925
|
-
tableData
|
|
1051
|
+
tableRows,
|
|
1052
|
+
confirmCB,
|
|
1053
|
+
initialValues
|
|
926
1054
|
);
|
|
927
1055
|
}
|
|
928
|
-
return Suite.Default(name,
|
|
1056
|
+
return Suite.Default(name, setups);
|
|
929
1057
|
}
|
|
930
1058
|
},
|
|
931
|
-
//
|
|
932
|
-
|
|
933
|
-
Default: (features,
|
|
934
|
-
return (
|
|
1059
|
+
// Value maps to Setup (sets up table data)
|
|
1060
|
+
Value: {
|
|
1061
|
+
Default: (features, tableRows, confirmCB, initialValues) => {
|
|
1062
|
+
return (Value) => Value.Default(
|
|
935
1063
|
features,
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
initialValues,
|
|
940
|
-
tableData
|
|
1064
|
+
tableRows,
|
|
1065
|
+
confirmCB,
|
|
1066
|
+
initialValues
|
|
941
1067
|
);
|
|
942
1068
|
}
|
|
943
1069
|
},
|
|
944
|
-
//
|
|
945
|
-
|
|
946
|
-
Default: (name,
|
|
947
|
-
return (
|
|
1070
|
+
// Should processes each row (like Action)
|
|
1071
|
+
Should: {
|
|
1072
|
+
Default: (name, shouldCB) => {
|
|
1073
|
+
return (Should) => Should.Default(name, shouldCB);
|
|
948
1074
|
}
|
|
949
1075
|
},
|
|
950
|
-
//
|
|
951
|
-
|
|
952
|
-
Default: (name,
|
|
953
|
-
return (
|
|
1076
|
+
// Expected validates each row (like Check)
|
|
1077
|
+
Expected: {
|
|
1078
|
+
Default: (name, expectedCB) => {
|
|
1079
|
+
return (Expected) => Expected.Default(name, expectedCB);
|
|
954
1080
|
}
|
|
955
1081
|
}
|
|
956
1082
|
};
|
|
957
1083
|
}
|
|
958
|
-
function
|
|
959
|
-
const spec = createAAASpecification();
|
|
1084
|
+
function DescribeIt() {
|
|
960
1085
|
return {
|
|
961
1086
|
Suite: {
|
|
962
|
-
Default: (name,
|
|
963
|
-
console.warn("
|
|
964
|
-
return { name,
|
|
965
|
-
}
|
|
966
|
-
},
|
|
967
|
-
Arrange: {
|
|
968
|
-
Default: (features, acts, asserts, arrangeCB, initialValues) => {
|
|
969
|
-
console.warn("AAA.Arrange.Default called without proper context");
|
|
970
|
-
return { features, acts, asserts, arrangeCB, initialValues };
|
|
1087
|
+
Default: (name, descriptions) => {
|
|
1088
|
+
console.warn("DescribeIt.Suite.Default: This helper function requires proper context from a test specification. Use createDescribeItSpecification() for full functionality.");
|
|
1089
|
+
return { name, descriptions };
|
|
971
1090
|
}
|
|
972
1091
|
},
|
|
973
|
-
|
|
974
|
-
Default: (
|
|
975
|
-
console.warn("
|
|
976
|
-
return {
|
|
1092
|
+
Describe: {
|
|
1093
|
+
Default: (features, its, describeCB, initialValues) => {
|
|
1094
|
+
console.warn("DescribeIt.Describe.Default: This helper function requires proper context. Use createDescribeItSpecification() for full functionality.");
|
|
1095
|
+
return { features, its, describeCB, initialValues };
|
|
977
1096
|
}
|
|
978
1097
|
},
|
|
979
|
-
|
|
980
|
-
Default: (name,
|
|
981
|
-
console.warn("
|
|
982
|
-
return { name,
|
|
1098
|
+
It: {
|
|
1099
|
+
Default: (name, itCB) => {
|
|
1100
|
+
console.warn("DescribeIt.It.Default: This helper function requires proper context. Use createDescribeItSpecification() for full functionality.");
|
|
1101
|
+
return { name, itCB };
|
|
983
1102
|
}
|
|
984
1103
|
}
|
|
985
1104
|
};
|
|
986
1105
|
}
|
|
987
|
-
function
|
|
1106
|
+
function Confirm() {
|
|
988
1107
|
return {
|
|
989
1108
|
Suite: {
|
|
990
|
-
Default: (name,
|
|
991
|
-
console.warn("
|
|
992
|
-
return { name,
|
|
1109
|
+
Default: (name, confirms) => {
|
|
1110
|
+
console.warn("Confirm.Suite.Default: This helper function requires proper context from a test specification. Use createTDTSpecification() for full functionality.");
|
|
1111
|
+
return { name, confirms };
|
|
993
1112
|
}
|
|
994
1113
|
},
|
|
995
|
-
|
|
996
|
-
Default: (features,
|
|
997
|
-
console.warn("
|
|
998
|
-
return { features,
|
|
1114
|
+
Value: {
|
|
1115
|
+
Default: (features, tableRows, confirmCB, initialValues) => {
|
|
1116
|
+
console.warn("Confirm.Value.Default: This helper function requires proper context. Use createTDTSpecification() for full functionality.");
|
|
1117
|
+
return { features, tableRows, confirmCB, initialValues };
|
|
999
1118
|
}
|
|
1000
1119
|
},
|
|
1001
|
-
|
|
1002
|
-
Default: (name,
|
|
1003
|
-
console.warn("
|
|
1004
|
-
return { name,
|
|
1120
|
+
Should: {
|
|
1121
|
+
Default: (name, shouldCB) => {
|
|
1122
|
+
console.warn("Confirm.Should.Default: This helper function requires proper context. Use createTDTSpecification() for full functionality.");
|
|
1123
|
+
return { name, shouldCB };
|
|
1005
1124
|
}
|
|
1006
1125
|
},
|
|
1007
|
-
|
|
1008
|
-
Default: (name,
|
|
1009
|
-
console.warn("
|
|
1010
|
-
return { name,
|
|
1126
|
+
Expected: {
|
|
1127
|
+
Default: (name, expectedCB) => {
|
|
1128
|
+
console.warn("Confirm.Expected.Default: This helper function requires proper context. Use createTDTSpecification() for full functionality.");
|
|
1129
|
+
return { name, expectedCB };
|
|
1011
1130
|
}
|
|
1012
1131
|
}
|
|
1013
1132
|
};
|
|
1014
1133
|
}
|
|
1015
1134
|
export {
|
|
1016
|
-
AAA,
|
|
1017
|
-
BaseAct,
|
|
1018
1135
|
BaseAction,
|
|
1019
1136
|
BaseAdapter,
|
|
1020
|
-
BaseArrange,
|
|
1021
|
-
BaseAssert,
|
|
1022
1137
|
BaseCheck,
|
|
1023
|
-
|
|
1138
|
+
BaseDescribe,
|
|
1139
|
+
BaseExpected,
|
|
1024
1140
|
BaseGiven,
|
|
1025
|
-
|
|
1141
|
+
BaseIt,
|
|
1026
1142
|
BaseSetup,
|
|
1143
|
+
BaseShould,
|
|
1027
1144
|
BaseThen,
|
|
1028
|
-
|
|
1145
|
+
BaseValue,
|
|
1029
1146
|
BaseWhen,
|
|
1147
|
+
Confirm,
|
|
1030
1148
|
DefaultAdapter,
|
|
1031
|
-
|
|
1032
|
-
|
|
1149
|
+
DescribeIt,
|
|
1150
|
+
createDescribeItSpecification,
|
|
1033
1151
|
createTDTSpecification
|
|
1034
1152
|
};
|