testeranto.tiposkripto 0.2.11 → 0.2.13
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/dist/module/Node.js +125 -23
- package/dist/module/Web.js +164 -33
- package/dist/module/index.js +192 -21
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/lib/tiposkripto/src/BaseAct.d.ts +2 -1
- package/dist/types/lib/tiposkripto/src/BaseAction.d.ts +1 -1
- package/dist/types/lib/tiposkripto/src/BaseArrange.d.ts +3 -2
- package/dist/types/lib/tiposkripto/src/BaseAssert.d.ts +3 -2
- package/dist/types/lib/tiposkripto/src/BaseCheck.d.ts +2 -2
- package/dist/types/lib/tiposkripto/src/BaseFeed.d.ts +2 -1
- package/dist/types/lib/tiposkripto/src/BaseGiven.d.ts +5 -5
- package/dist/types/lib/tiposkripto/src/BaseMap.d.ts +3 -2
- package/dist/types/lib/tiposkripto/src/BaseSetup.d.ts +2 -2
- package/dist/types/lib/tiposkripto/src/BaseSuite.d.ts +5 -5
- package/dist/types/lib/tiposkripto/src/BaseThen.d.ts +4 -4
- package/dist/types/lib/tiposkripto/src/BaseTiposkripto.d.ts +2 -2
- package/dist/types/lib/tiposkripto/src/BaseValidate.d.ts +3 -2
- package/dist/types/lib/tiposkripto/src/BaseWhen.d.ts +2 -2
- package/dist/types/lib/tiposkripto/src/CoreTypes.d.ts +14 -6
- package/dist/types/lib/tiposkripto/src/Node.d.ts +2 -2
- package/dist/types/lib/tiposkripto/src/Web.d.ts +9 -2
- package/dist/types/lib/tiposkripto/src/index.d.ts +71 -14
- package/dist/types/lib/tiposkripto/src/types.d.ts +9 -9
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/module/Node.js
CHANGED
|
@@ -5,6 +5,7 @@ import path from "path";
|
|
|
5
5
|
// src/BaseSetup.ts
|
|
6
6
|
var BaseSetup = class {
|
|
7
7
|
constructor(features, actions, checks, setupCB, initialValues) {
|
|
8
|
+
this.recommendedFsPath = "";
|
|
8
9
|
this.artifacts = [];
|
|
9
10
|
this.fails = 0;
|
|
10
11
|
this.features = features;
|
|
@@ -119,6 +120,7 @@ var BaseSetup = class {
|
|
|
119
120
|
// src/BaseAction.ts
|
|
120
121
|
var BaseAction = class {
|
|
121
122
|
constructor(name, actionCB) {
|
|
123
|
+
this.error = null;
|
|
122
124
|
this.artifacts = [];
|
|
123
125
|
this.name = name;
|
|
124
126
|
this.actionCB = actionCB;
|
|
@@ -245,12 +247,12 @@ var BaseGiven = class extends BaseSetup {
|
|
|
245
247
|
toObj() {
|
|
246
248
|
return {
|
|
247
249
|
key: this.key,
|
|
248
|
-
|
|
250
|
+
actions: (this.whens || []).map((w) => {
|
|
249
251
|
if (w && w.toObj) return w.toObj();
|
|
250
252
|
console.error("When step is not as expected!", JSON.stringify(w));
|
|
251
253
|
return {};
|
|
252
254
|
}),
|
|
253
|
-
|
|
255
|
+
checks: (this.thens || []).map((t) => t && t.toObj ? t.toObj() : {}),
|
|
254
256
|
error: this.error ? [this.error, this.error.stack] : null,
|
|
255
257
|
failed: this.failed,
|
|
256
258
|
features: this.features || [],
|
|
@@ -508,15 +510,103 @@ var BaseAdapter = () => ({
|
|
|
508
510
|
});
|
|
509
511
|
var DefaultAdapter = (p) => {
|
|
510
512
|
const base = BaseAdapter();
|
|
513
|
+
const mapped = { ...p };
|
|
514
|
+
if (p.beforeAll && !p.prepareAll) {
|
|
515
|
+
mapped.prepareAll = async (input, testResource, artifactory) => {
|
|
516
|
+
if (p.beforeAll.length >= 3) {
|
|
517
|
+
return await p.beforeAll(input, testResource, artifactory);
|
|
518
|
+
} else if (p.beforeAll.length >= 2) {
|
|
519
|
+
return await p.beforeAll(input, testResource);
|
|
520
|
+
} else {
|
|
521
|
+
return await p.beforeAll(input);
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
if (p.beforeEach && !p.prepareEach) {
|
|
526
|
+
mapped.prepareEach = async (subject, initializer, testResource, initialValues, artifactory) => {
|
|
527
|
+
if (p.beforeEach.length >= 5) {
|
|
528
|
+
return await p.beforeEach(subject, initializer, testResource, initialValues, artifactory);
|
|
529
|
+
} else if (p.beforeEach.length >= 4) {
|
|
530
|
+
return await p.beforeEach(subject, initializer, testResource, initialValues);
|
|
531
|
+
} else if (p.beforeEach.length >= 3) {
|
|
532
|
+
return await p.beforeEach(subject, initializer, testResource);
|
|
533
|
+
} else if (p.beforeEach.length >= 2) {
|
|
534
|
+
return await p.beforeEach(subject, initializer);
|
|
535
|
+
} else {
|
|
536
|
+
return await p.beforeEach(subject);
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
if (p.afterEach && !p.cleanupEach) {
|
|
541
|
+
mapped.cleanupEach = async (store, key, artifactory) => {
|
|
542
|
+
if (p.afterEach.length >= 3) {
|
|
543
|
+
return await p.afterEach(store, key, artifactory);
|
|
544
|
+
} else if (p.afterEach.length >= 2) {
|
|
545
|
+
return await p.afterEach(store, key);
|
|
546
|
+
} else {
|
|
547
|
+
return await p.afterEach(store);
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
if (p.afterAll && !p.cleanupAll) {
|
|
552
|
+
mapped.cleanupAll = (store, artifactory) => {
|
|
553
|
+
if (p.afterAll.length >= 2) {
|
|
554
|
+
return p.afterAll(store, artifactory);
|
|
555
|
+
} else {
|
|
556
|
+
return p.afterAll(store);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
if (p.andWhen && !p.execute) {
|
|
561
|
+
mapped.execute = async (store, actionCB, testResource, artifactory) => {
|
|
562
|
+
if (p.andWhen.length >= 4) {
|
|
563
|
+
return await p.andWhen(store, actionCB, testResource, artifactory);
|
|
564
|
+
} else if (p.andWhen.length >= 3) {
|
|
565
|
+
return await p.andWhen(store, actionCB, testResource);
|
|
566
|
+
} else if (p.andWhen.length >= 2) {
|
|
567
|
+
return await p.andWhen(store, actionCB);
|
|
568
|
+
} else {
|
|
569
|
+
return await p.andWhen(store);
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
if (p.butThen && !p.verify) {
|
|
574
|
+
mapped.verify = async (store, checkCB, testResource, artifactory) => {
|
|
575
|
+
if (p.butThen.length >= 4) {
|
|
576
|
+
return await p.butThen(store, checkCB, testResource, artifactory);
|
|
577
|
+
} else if (p.butThen.length >= 3) {
|
|
578
|
+
return await p.butThen(store, checkCB, testResource);
|
|
579
|
+
} else if (p.butThen.length >= 2) {
|
|
580
|
+
return await p.butThen(store, checkCB);
|
|
581
|
+
} else {
|
|
582
|
+
return await p.butThen(store);
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
if (p.assertThis && !p.assert) {
|
|
587
|
+
mapped.assert = (x) => {
|
|
588
|
+
if (p.assertThis.length >= 1) {
|
|
589
|
+
return p.assertThis(x);
|
|
590
|
+
} else {
|
|
591
|
+
return p.assertThis();
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
}
|
|
511
595
|
return {
|
|
512
596
|
...base,
|
|
513
|
-
...
|
|
597
|
+
...mapped
|
|
514
598
|
};
|
|
515
599
|
};
|
|
516
600
|
|
|
517
601
|
// src/BaseSuite.ts
|
|
518
602
|
var BaseSuite = class {
|
|
519
603
|
constructor(name, index, givens = {}, parent) {
|
|
604
|
+
this.store = null;
|
|
605
|
+
this.testResourceConfiguration = null;
|
|
606
|
+
this.index = 0;
|
|
607
|
+
this.failed = false;
|
|
608
|
+
this.fails = 0;
|
|
609
|
+
this.parent = null;
|
|
520
610
|
// Reference to parent BaseTiposkripto instance
|
|
521
611
|
this.artifacts = [];
|
|
522
612
|
const suiteName = name || "testSuite";
|
|
@@ -587,10 +677,7 @@ var BaseSuite = class {
|
|
|
587
677
|
async run(input, testResourceConfiguration) {
|
|
588
678
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
589
679
|
const sNdx = this.index;
|
|
590
|
-
const subject = await this.setup(
|
|
591
|
-
input,
|
|
592
|
-
testResourceConfiguration
|
|
593
|
-
);
|
|
680
|
+
const subject = await this.setup(input, null, testResourceConfiguration);
|
|
594
681
|
for (const [gKey, g] of Object.entries(this.givens)) {
|
|
595
682
|
const giver = this.givens[gKey];
|
|
596
683
|
try {
|
|
@@ -626,7 +713,9 @@ var BaseSuite = class {
|
|
|
626
713
|
const basePath = this.testResourceConfiguration?.fs || "testeranto";
|
|
627
714
|
suiteArtifactory = {
|
|
628
715
|
writeFileSync: (filename, payload) => {
|
|
629
|
-
console.log(
|
|
716
|
+
console.log(
|
|
717
|
+
`[BaseSuite] Would write to ${basePath}/suite-${this.index}/${filename}: ${payload.substring(0, 100)}...`
|
|
718
|
+
);
|
|
630
719
|
},
|
|
631
720
|
screenshot: (filename, payload) => {
|
|
632
721
|
console.log(`[BaseSuite] Would take screenshot: ${filename}`);
|
|
@@ -651,8 +740,11 @@ var BaseTiposkripto = class {
|
|
|
651
740
|
constructor(webOrNode, input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testAdapter = {}, testResourceConfiguration, wsPort = "3456", wsHost = "localhost") {
|
|
652
741
|
this.totalTests = 0;
|
|
653
742
|
this.artifacts = [];
|
|
743
|
+
this.assertThis = () => {
|
|
744
|
+
};
|
|
654
745
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
655
746
|
const fullAdapter = DefaultAdapter(testAdapter);
|
|
747
|
+
const instance = this;
|
|
656
748
|
if (!testImplementation.suites || typeof testImplementation.suites !== "object") {
|
|
657
749
|
throw new Error(
|
|
658
750
|
`testImplementation.suites must be an object, got ${typeof testImplementation.suites}: ${JSON.stringify(
|
|
@@ -663,7 +755,6 @@ var BaseTiposkripto = class {
|
|
|
663
755
|
const classySuites = Object.entries(testImplementation.suites).reduce(
|
|
664
756
|
(a, [key], index) => {
|
|
665
757
|
a[key] = (somestring, givens) => {
|
|
666
|
-
const capturedOuterThis = outerThis;
|
|
667
758
|
const capturedFullAdapter = fullAdapter;
|
|
668
759
|
return new class extends BaseSuite {
|
|
669
760
|
afterAll(store, artifactory) {
|
|
@@ -674,7 +765,7 @@ var BaseTiposkripto = class {
|
|
|
674
765
|
suiteIndex: this.index
|
|
675
766
|
});
|
|
676
767
|
} else {
|
|
677
|
-
suiteArtifactory =
|
|
768
|
+
suiteArtifactory = instance.createArtifactory({
|
|
678
769
|
suiteIndex: this.index
|
|
679
770
|
});
|
|
680
771
|
}
|
|
@@ -684,10 +775,10 @@ var BaseTiposkripto = class {
|
|
|
684
775
|
assertThat(t) {
|
|
685
776
|
return capturedFullAdapter.assert(t);
|
|
686
777
|
}
|
|
687
|
-
async setup(s, tr) {
|
|
688
|
-
return capturedFullAdapter.prepareAll?.(s, tr) ?? s;
|
|
778
|
+
async setup(s, artifactory, tr) {
|
|
779
|
+
return capturedFullAdapter.prepareAll?.(s, tr, artifactory) ?? s;
|
|
689
780
|
}
|
|
690
|
-
}(somestring, index, givens,
|
|
781
|
+
}(somestring, index, givens, instance);
|
|
691
782
|
};
|
|
692
783
|
return a;
|
|
693
784
|
},
|
|
@@ -699,11 +790,10 @@ var BaseTiposkripto = class {
|
|
|
699
790
|
const safeFeatures = Array.isArray(features) ? [...features] : [];
|
|
700
791
|
const safeWhens = Array.isArray(whens) ? [...whens] : [];
|
|
701
792
|
const safeThens = Array.isArray(thens) ? [...thens] : [];
|
|
702
|
-
const capturedOuterThis = outerThis;
|
|
703
793
|
const capturedFullAdapter = fullAdapter;
|
|
704
794
|
const givenInstance = new class extends BaseGiven {
|
|
705
795
|
async givenThat(subject, testResource, artifactory, initializer, initialValues2) {
|
|
706
|
-
const givenArtifactory =
|
|
796
|
+
const givenArtifactory = instance.createArtifactory({
|
|
707
797
|
givenKey: key,
|
|
708
798
|
suiteIndex: this._suiteIndex
|
|
709
799
|
});
|
|
@@ -716,7 +806,9 @@ var BaseTiposkripto = class {
|
|
|
716
806
|
);
|
|
717
807
|
}
|
|
718
808
|
afterEach(store, key2, artifactory) {
|
|
719
|
-
return Promise.resolve(
|
|
809
|
+
return Promise.resolve(
|
|
810
|
+
capturedFullAdapter.cleanupEach(store, key2, artifactory)
|
|
811
|
+
);
|
|
720
812
|
}
|
|
721
813
|
}(
|
|
722
814
|
safeFeatures,
|
|
@@ -725,7 +817,7 @@ var BaseTiposkripto = class {
|
|
|
725
817
|
testImplementation.givens[key],
|
|
726
818
|
initialValues
|
|
727
819
|
);
|
|
728
|
-
givenInstance._parent =
|
|
820
|
+
givenInstance._parent = instance;
|
|
729
821
|
return givenInstance;
|
|
730
822
|
};
|
|
731
823
|
return a;
|
|
@@ -738,7 +830,12 @@ var BaseTiposkripto = class {
|
|
|
738
830
|
const capturedFullAdapter = fullAdapter;
|
|
739
831
|
const whenInstance = new class extends BaseWhen {
|
|
740
832
|
async andWhen(store, whenCB, testResource, artifactory) {
|
|
741
|
-
return await capturedFullAdapter.execute(
|
|
833
|
+
return await capturedFullAdapter.execute(
|
|
834
|
+
store,
|
|
835
|
+
whenCB,
|
|
836
|
+
testResource,
|
|
837
|
+
artifactory
|
|
838
|
+
);
|
|
742
839
|
}
|
|
743
840
|
}(`${key}: ${payload && payload.toString()}`, whEn(...payload));
|
|
744
841
|
return whenInstance;
|
|
@@ -752,8 +849,16 @@ var BaseTiposkripto = class {
|
|
|
752
849
|
a[key] = (...args) => {
|
|
753
850
|
const capturedFullAdapter = fullAdapter;
|
|
754
851
|
const thenInstance = new class extends BaseThen {
|
|
852
|
+
verifyCheck(store, checkCB, testResourceConfiguration2) {
|
|
853
|
+
throw new Error("Method not implemented.");
|
|
854
|
+
}
|
|
755
855
|
async butThen(store, thenCB, testResource, artifactory) {
|
|
756
|
-
return await capturedFullAdapter.verify(
|
|
856
|
+
return await capturedFullAdapter.verify(
|
|
857
|
+
store,
|
|
858
|
+
thenCB,
|
|
859
|
+
testResource,
|
|
860
|
+
artifactory
|
|
861
|
+
);
|
|
757
862
|
}
|
|
758
863
|
}(`${key}: ${args && args.toString()}`, thEn(...args));
|
|
759
864
|
return thenInstance;
|
|
@@ -778,10 +883,7 @@ var BaseTiposkripto = class {
|
|
|
778
883
|
this.testJobs = this.specs.map((suite) => {
|
|
779
884
|
const suiteRunner = (suite2) => async (testResourceConfiguration2) => {
|
|
780
885
|
try {
|
|
781
|
-
const x = await suite2.run(
|
|
782
|
-
input,
|
|
783
|
-
testResourceConfiguration2
|
|
784
|
-
);
|
|
886
|
+
const x = await suite2.run(input, testResourceConfiguration2);
|
|
785
887
|
return x;
|
|
786
888
|
} catch (e) {
|
|
787
889
|
console.error(e.stack);
|
package/dist/module/Web.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/BaseSetup.ts
|
|
2
2
|
var BaseSetup = class {
|
|
3
3
|
constructor(features, actions, checks, setupCB, initialValues) {
|
|
4
|
+
this.recommendedFsPath = "";
|
|
4
5
|
this.artifacts = [];
|
|
5
6
|
this.fails = 0;
|
|
6
7
|
this.features = features;
|
|
@@ -115,6 +116,7 @@ var BaseSetup = class {
|
|
|
115
116
|
// src/BaseAction.ts
|
|
116
117
|
var BaseAction = class {
|
|
117
118
|
constructor(name, actionCB) {
|
|
119
|
+
this.error = null;
|
|
118
120
|
this.artifacts = [];
|
|
119
121
|
this.name = name;
|
|
120
122
|
this.actionCB = actionCB;
|
|
@@ -241,12 +243,12 @@ var BaseGiven = class extends BaseSetup {
|
|
|
241
243
|
toObj() {
|
|
242
244
|
return {
|
|
243
245
|
key: this.key,
|
|
244
|
-
|
|
246
|
+
actions: (this.whens || []).map((w) => {
|
|
245
247
|
if (w && w.toObj) return w.toObj();
|
|
246
248
|
console.error("When step is not as expected!", JSON.stringify(w));
|
|
247
249
|
return {};
|
|
248
250
|
}),
|
|
249
|
-
|
|
251
|
+
checks: (this.thens || []).map((t) => t && t.toObj ? t.toObj() : {}),
|
|
250
252
|
error: this.error ? [this.error, this.error.stack] : null,
|
|
251
253
|
failed: this.failed,
|
|
252
254
|
features: this.features || [],
|
|
@@ -504,15 +506,103 @@ var BaseAdapter = () => ({
|
|
|
504
506
|
});
|
|
505
507
|
var DefaultAdapter = (p) => {
|
|
506
508
|
const base = BaseAdapter();
|
|
509
|
+
const mapped = { ...p };
|
|
510
|
+
if (p.beforeAll && !p.prepareAll) {
|
|
511
|
+
mapped.prepareAll = async (input, testResource, artifactory) => {
|
|
512
|
+
if (p.beforeAll.length >= 3) {
|
|
513
|
+
return await p.beforeAll(input, testResource, artifactory);
|
|
514
|
+
} else if (p.beforeAll.length >= 2) {
|
|
515
|
+
return await p.beforeAll(input, testResource);
|
|
516
|
+
} else {
|
|
517
|
+
return await p.beforeAll(input);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
if (p.beforeEach && !p.prepareEach) {
|
|
522
|
+
mapped.prepareEach = async (subject, initializer, testResource, initialValues, artifactory) => {
|
|
523
|
+
if (p.beforeEach.length >= 5) {
|
|
524
|
+
return await p.beforeEach(subject, initializer, testResource, initialValues, artifactory);
|
|
525
|
+
} else if (p.beforeEach.length >= 4) {
|
|
526
|
+
return await p.beforeEach(subject, initializer, testResource, initialValues);
|
|
527
|
+
} else if (p.beforeEach.length >= 3) {
|
|
528
|
+
return await p.beforeEach(subject, initializer, testResource);
|
|
529
|
+
} else if (p.beforeEach.length >= 2) {
|
|
530
|
+
return await p.beforeEach(subject, initializer);
|
|
531
|
+
} else {
|
|
532
|
+
return await p.beforeEach(subject);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
if (p.afterEach && !p.cleanupEach) {
|
|
537
|
+
mapped.cleanupEach = async (store, key, artifactory) => {
|
|
538
|
+
if (p.afterEach.length >= 3) {
|
|
539
|
+
return await p.afterEach(store, key, artifactory);
|
|
540
|
+
} else if (p.afterEach.length >= 2) {
|
|
541
|
+
return await p.afterEach(store, key);
|
|
542
|
+
} else {
|
|
543
|
+
return await p.afterEach(store);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
if (p.afterAll && !p.cleanupAll) {
|
|
548
|
+
mapped.cleanupAll = (store, artifactory) => {
|
|
549
|
+
if (p.afterAll.length >= 2) {
|
|
550
|
+
return p.afterAll(store, artifactory);
|
|
551
|
+
} else {
|
|
552
|
+
return p.afterAll(store);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
if (p.andWhen && !p.execute) {
|
|
557
|
+
mapped.execute = async (store, actionCB, testResource, artifactory) => {
|
|
558
|
+
if (p.andWhen.length >= 4) {
|
|
559
|
+
return await p.andWhen(store, actionCB, testResource, artifactory);
|
|
560
|
+
} else if (p.andWhen.length >= 3) {
|
|
561
|
+
return await p.andWhen(store, actionCB, testResource);
|
|
562
|
+
} else if (p.andWhen.length >= 2) {
|
|
563
|
+
return await p.andWhen(store, actionCB);
|
|
564
|
+
} else {
|
|
565
|
+
return await p.andWhen(store);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
if (p.butThen && !p.verify) {
|
|
570
|
+
mapped.verify = async (store, checkCB, testResource, artifactory) => {
|
|
571
|
+
if (p.butThen.length >= 4) {
|
|
572
|
+
return await p.butThen(store, checkCB, testResource, artifactory);
|
|
573
|
+
} else if (p.butThen.length >= 3) {
|
|
574
|
+
return await p.butThen(store, checkCB, testResource);
|
|
575
|
+
} else if (p.butThen.length >= 2) {
|
|
576
|
+
return await p.butThen(store, checkCB);
|
|
577
|
+
} else {
|
|
578
|
+
return await p.butThen(store);
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
if (p.assertThis && !p.assert) {
|
|
583
|
+
mapped.assert = (x) => {
|
|
584
|
+
if (p.assertThis.length >= 1) {
|
|
585
|
+
return p.assertThis(x);
|
|
586
|
+
} else {
|
|
587
|
+
return p.assertThis();
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
}
|
|
507
591
|
return {
|
|
508
592
|
...base,
|
|
509
|
-
...
|
|
593
|
+
...mapped
|
|
510
594
|
};
|
|
511
595
|
};
|
|
512
596
|
|
|
513
597
|
// src/BaseSuite.ts
|
|
514
598
|
var BaseSuite = class {
|
|
515
599
|
constructor(name, index, givens = {}, parent) {
|
|
600
|
+
this.store = null;
|
|
601
|
+
this.testResourceConfiguration = null;
|
|
602
|
+
this.index = 0;
|
|
603
|
+
this.failed = false;
|
|
604
|
+
this.fails = 0;
|
|
605
|
+
this.parent = null;
|
|
516
606
|
// Reference to parent BaseTiposkripto instance
|
|
517
607
|
this.artifacts = [];
|
|
518
608
|
const suiteName = name || "testSuite";
|
|
@@ -583,10 +673,7 @@ var BaseSuite = class {
|
|
|
583
673
|
async run(input, testResourceConfiguration) {
|
|
584
674
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
585
675
|
const sNdx = this.index;
|
|
586
|
-
const subject = await this.setup(
|
|
587
|
-
input,
|
|
588
|
-
testResourceConfiguration
|
|
589
|
-
);
|
|
676
|
+
const subject = await this.setup(input, null, testResourceConfiguration);
|
|
590
677
|
for (const [gKey, g] of Object.entries(this.givens)) {
|
|
591
678
|
const giver = this.givens[gKey];
|
|
592
679
|
try {
|
|
@@ -622,7 +709,9 @@ var BaseSuite = class {
|
|
|
622
709
|
const basePath = this.testResourceConfiguration?.fs || "testeranto";
|
|
623
710
|
suiteArtifactory = {
|
|
624
711
|
writeFileSync: (filename, payload) => {
|
|
625
|
-
console.log(
|
|
712
|
+
console.log(
|
|
713
|
+
`[BaseSuite] Would write to ${basePath}/suite-${this.index}/${filename}: ${payload.substring(0, 100)}...`
|
|
714
|
+
);
|
|
626
715
|
},
|
|
627
716
|
screenshot: (filename, payload) => {
|
|
628
717
|
console.log(`[BaseSuite] Would take screenshot: ${filename}`);
|
|
@@ -647,8 +736,11 @@ var BaseTiposkripto = class {
|
|
|
647
736
|
constructor(webOrNode, input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testAdapter = {}, testResourceConfiguration, wsPort = "3456", wsHost = "localhost") {
|
|
648
737
|
this.totalTests = 0;
|
|
649
738
|
this.artifacts = [];
|
|
739
|
+
this.assertThis = () => {
|
|
740
|
+
};
|
|
650
741
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
651
742
|
const fullAdapter = DefaultAdapter(testAdapter);
|
|
743
|
+
const instance = this;
|
|
652
744
|
if (!testImplementation.suites || typeof testImplementation.suites !== "object") {
|
|
653
745
|
throw new Error(
|
|
654
746
|
`testImplementation.suites must be an object, got ${typeof testImplementation.suites}: ${JSON.stringify(
|
|
@@ -659,7 +751,6 @@ var BaseTiposkripto = class {
|
|
|
659
751
|
const classySuites = Object.entries(testImplementation.suites).reduce(
|
|
660
752
|
(a, [key], index) => {
|
|
661
753
|
a[key] = (somestring, givens) => {
|
|
662
|
-
const capturedOuterThis = outerThis;
|
|
663
754
|
const capturedFullAdapter = fullAdapter;
|
|
664
755
|
return new class extends BaseSuite {
|
|
665
756
|
afterAll(store, artifactory) {
|
|
@@ -670,7 +761,7 @@ var BaseTiposkripto = class {
|
|
|
670
761
|
suiteIndex: this.index
|
|
671
762
|
});
|
|
672
763
|
} else {
|
|
673
|
-
suiteArtifactory =
|
|
764
|
+
suiteArtifactory = instance.createArtifactory({
|
|
674
765
|
suiteIndex: this.index
|
|
675
766
|
});
|
|
676
767
|
}
|
|
@@ -680,10 +771,10 @@ var BaseTiposkripto = class {
|
|
|
680
771
|
assertThat(t) {
|
|
681
772
|
return capturedFullAdapter.assert(t);
|
|
682
773
|
}
|
|
683
|
-
async setup(s, tr) {
|
|
684
|
-
return capturedFullAdapter.prepareAll?.(s, tr) ?? s;
|
|
774
|
+
async setup(s, artifactory, tr) {
|
|
775
|
+
return capturedFullAdapter.prepareAll?.(s, tr, artifactory) ?? s;
|
|
685
776
|
}
|
|
686
|
-
}(somestring, index, givens,
|
|
777
|
+
}(somestring, index, givens, instance);
|
|
687
778
|
};
|
|
688
779
|
return a;
|
|
689
780
|
},
|
|
@@ -695,11 +786,10 @@ var BaseTiposkripto = class {
|
|
|
695
786
|
const safeFeatures = Array.isArray(features) ? [...features] : [];
|
|
696
787
|
const safeWhens = Array.isArray(whens) ? [...whens] : [];
|
|
697
788
|
const safeThens = Array.isArray(thens) ? [...thens] : [];
|
|
698
|
-
const capturedOuterThis = outerThis;
|
|
699
789
|
const capturedFullAdapter = fullAdapter;
|
|
700
790
|
const givenInstance = new class extends BaseGiven {
|
|
701
791
|
async givenThat(subject, testResource, artifactory, initializer, initialValues2) {
|
|
702
|
-
const givenArtifactory =
|
|
792
|
+
const givenArtifactory = instance.createArtifactory({
|
|
703
793
|
givenKey: key,
|
|
704
794
|
suiteIndex: this._suiteIndex
|
|
705
795
|
});
|
|
@@ -712,7 +802,9 @@ var BaseTiposkripto = class {
|
|
|
712
802
|
);
|
|
713
803
|
}
|
|
714
804
|
afterEach(store, key2, artifactory) {
|
|
715
|
-
return Promise.resolve(
|
|
805
|
+
return Promise.resolve(
|
|
806
|
+
capturedFullAdapter.cleanupEach(store, key2, artifactory)
|
|
807
|
+
);
|
|
716
808
|
}
|
|
717
809
|
}(
|
|
718
810
|
safeFeatures,
|
|
@@ -721,7 +813,7 @@ var BaseTiposkripto = class {
|
|
|
721
813
|
testImplementation.givens[key],
|
|
722
814
|
initialValues
|
|
723
815
|
);
|
|
724
|
-
givenInstance._parent =
|
|
816
|
+
givenInstance._parent = instance;
|
|
725
817
|
return givenInstance;
|
|
726
818
|
};
|
|
727
819
|
return a;
|
|
@@ -734,7 +826,12 @@ var BaseTiposkripto = class {
|
|
|
734
826
|
const capturedFullAdapter = fullAdapter;
|
|
735
827
|
const whenInstance = new class extends BaseWhen {
|
|
736
828
|
async andWhen(store, whenCB, testResource, artifactory) {
|
|
737
|
-
return await capturedFullAdapter.execute(
|
|
829
|
+
return await capturedFullAdapter.execute(
|
|
830
|
+
store,
|
|
831
|
+
whenCB,
|
|
832
|
+
testResource,
|
|
833
|
+
artifactory
|
|
834
|
+
);
|
|
738
835
|
}
|
|
739
836
|
}(`${key}: ${payload && payload.toString()}`, whEn(...payload));
|
|
740
837
|
return whenInstance;
|
|
@@ -748,8 +845,16 @@ var BaseTiposkripto = class {
|
|
|
748
845
|
a[key] = (...args) => {
|
|
749
846
|
const capturedFullAdapter = fullAdapter;
|
|
750
847
|
const thenInstance = new class extends BaseThen {
|
|
848
|
+
verifyCheck(store, checkCB, testResourceConfiguration2) {
|
|
849
|
+
throw new Error("Method not implemented.");
|
|
850
|
+
}
|
|
751
851
|
async butThen(store, thenCB, testResource, artifactory) {
|
|
752
|
-
return await capturedFullAdapter.verify(
|
|
852
|
+
return await capturedFullAdapter.verify(
|
|
853
|
+
store,
|
|
854
|
+
thenCB,
|
|
855
|
+
testResource,
|
|
856
|
+
artifactory
|
|
857
|
+
);
|
|
753
858
|
}
|
|
754
859
|
}(`${key}: ${args && args.toString()}`, thEn(...args));
|
|
755
860
|
return thenInstance;
|
|
@@ -774,10 +879,7 @@ var BaseTiposkripto = class {
|
|
|
774
879
|
this.testJobs = this.specs.map((suite) => {
|
|
775
880
|
const suiteRunner = (suite2) => async (testResourceConfiguration2) => {
|
|
776
881
|
try {
|
|
777
|
-
const x = await suite2.run(
|
|
778
|
-
input,
|
|
779
|
-
testResourceConfiguration2
|
|
780
|
-
);
|
|
882
|
+
const x = await suite2.run(input, testResourceConfiguration2);
|
|
781
883
|
return x;
|
|
782
884
|
} catch (e) {
|
|
783
885
|
console.error(e.stack);
|
|
@@ -933,12 +1035,19 @@ var BaseTiposkripto = class {
|
|
|
933
1035
|
};
|
|
934
1036
|
|
|
935
1037
|
// src/Web.ts
|
|
936
|
-
var
|
|
1038
|
+
var isBrowser = typeof globalThis !== "undefined" && globalThis.window !== void 0;
|
|
1039
|
+
var config = isBrowser ? globalThis.window?.testResourceConfig : {};
|
|
937
1040
|
var WebTiposkripto = class extends BaseTiposkripto {
|
|
938
1041
|
constructor(input, testSpecification, testImplementation, testResourceRequirement, testAdapter) {
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1042
|
+
let testResourceConfig = config;
|
|
1043
|
+
if (isBrowser) {
|
|
1044
|
+
const win = globalThis.window;
|
|
1045
|
+
if (win) {
|
|
1046
|
+
const urlParams = new URLSearchParams(win.location.search);
|
|
1047
|
+
const encodedConfig = urlParams.get("config");
|
|
1048
|
+
testResourceConfig = encodedConfig ? decodeURIComponent(encodedConfig) : "{}";
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
942
1051
|
super(
|
|
943
1052
|
"web",
|
|
944
1053
|
input,
|
|
@@ -946,15 +1055,32 @@ var WebTiposkripto = class extends BaseTiposkripto {
|
|
|
946
1055
|
testImplementation,
|
|
947
1056
|
testResourceRequirement,
|
|
948
1057
|
testAdapter,
|
|
949
|
-
|
|
950
|
-
config
|
|
1058
|
+
testResourceConfig
|
|
951
1059
|
);
|
|
952
1060
|
}
|
|
953
1061
|
writeFileSync(filename, payload) {
|
|
954
|
-
|
|
1062
|
+
if (isBrowser) {
|
|
1063
|
+
const win = globalThis.window;
|
|
1064
|
+
if (win && win.__writeFile) {
|
|
1065
|
+
win.__writeFile(filename, payload);
|
|
1066
|
+
} else {
|
|
1067
|
+
console.error("__writeFile not available");
|
|
1068
|
+
}
|
|
1069
|
+
} else {
|
|
1070
|
+
console.error("Not in browser environment");
|
|
1071
|
+
}
|
|
955
1072
|
}
|
|
956
1073
|
screenshot(filename, payload) {
|
|
957
|
-
|
|
1074
|
+
if (isBrowser) {
|
|
1075
|
+
const win = globalThis.window;
|
|
1076
|
+
if (win && win.__screenshot) {
|
|
1077
|
+
win.__screenshot(filename, payload || "");
|
|
1078
|
+
} else {
|
|
1079
|
+
console.error("__screenshot not available");
|
|
1080
|
+
}
|
|
1081
|
+
} else {
|
|
1082
|
+
console.error("Not in browser environment");
|
|
1083
|
+
}
|
|
958
1084
|
}
|
|
959
1085
|
};
|
|
960
1086
|
var tiposkripto = async (input, testSpecification, testImplementation, testAdapter, testResourceRequirement = defaultTestResourceRequirement) => {
|
|
@@ -969,8 +1095,13 @@ var tiposkripto = async (input, testSpecification, testImplementation, testAdapt
|
|
|
969
1095
|
return t;
|
|
970
1096
|
} catch (e) {
|
|
971
1097
|
console.error(e);
|
|
972
|
-
|
|
973
|
-
|
|
1098
|
+
if (isBrowser) {
|
|
1099
|
+
const win = globalThis.window;
|
|
1100
|
+
if (win) {
|
|
1101
|
+
const errorEvent = new CustomEvent("test-error", { detail: e });
|
|
1102
|
+
win.dispatchEvent(errorEvent);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
974
1105
|
throw e;
|
|
975
1106
|
}
|
|
976
1107
|
};
|