testeranto.tiposkripto 0.2.11 → 0.2.12
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 +42 -22
- package/dist/module/Web.js +81 -32
- package/dist/module/index.js +42 -8
- 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 +5 -5
- 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 +1 -1
- 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 || [],
|
|
@@ -517,6 +519,12 @@ var DefaultAdapter = (p) => {
|
|
|
517
519
|
// src/BaseSuite.ts
|
|
518
520
|
var BaseSuite = class {
|
|
519
521
|
constructor(name, index, givens = {}, parent) {
|
|
522
|
+
this.store = null;
|
|
523
|
+
this.testResourceConfiguration = null;
|
|
524
|
+
this.index = 0;
|
|
525
|
+
this.failed = false;
|
|
526
|
+
this.fails = 0;
|
|
527
|
+
this.parent = null;
|
|
520
528
|
// Reference to parent BaseTiposkripto instance
|
|
521
529
|
this.artifacts = [];
|
|
522
530
|
const suiteName = name || "testSuite";
|
|
@@ -587,10 +595,7 @@ var BaseSuite = class {
|
|
|
587
595
|
async run(input, testResourceConfiguration) {
|
|
588
596
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
589
597
|
const sNdx = this.index;
|
|
590
|
-
const subject = await this.setup(
|
|
591
|
-
input,
|
|
592
|
-
testResourceConfiguration
|
|
593
|
-
);
|
|
598
|
+
const subject = await this.setup(input, null, testResourceConfiguration);
|
|
594
599
|
for (const [gKey, g] of Object.entries(this.givens)) {
|
|
595
600
|
const giver = this.givens[gKey];
|
|
596
601
|
try {
|
|
@@ -626,7 +631,9 @@ var BaseSuite = class {
|
|
|
626
631
|
const basePath = this.testResourceConfiguration?.fs || "testeranto";
|
|
627
632
|
suiteArtifactory = {
|
|
628
633
|
writeFileSync: (filename, payload) => {
|
|
629
|
-
console.log(
|
|
634
|
+
console.log(
|
|
635
|
+
`[BaseSuite] Would write to ${basePath}/suite-${this.index}/${filename}: ${payload.substring(0, 100)}...`
|
|
636
|
+
);
|
|
630
637
|
},
|
|
631
638
|
screenshot: (filename, payload) => {
|
|
632
639
|
console.log(`[BaseSuite] Would take screenshot: ${filename}`);
|
|
@@ -651,8 +658,11 @@ var BaseTiposkripto = class {
|
|
|
651
658
|
constructor(webOrNode, input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testAdapter = {}, testResourceConfiguration, wsPort = "3456", wsHost = "localhost") {
|
|
652
659
|
this.totalTests = 0;
|
|
653
660
|
this.artifacts = [];
|
|
661
|
+
this.assertThis = () => {
|
|
662
|
+
};
|
|
654
663
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
655
664
|
const fullAdapter = DefaultAdapter(testAdapter);
|
|
665
|
+
const instance = this;
|
|
656
666
|
if (!testImplementation.suites || typeof testImplementation.suites !== "object") {
|
|
657
667
|
throw new Error(
|
|
658
668
|
`testImplementation.suites must be an object, got ${typeof testImplementation.suites}: ${JSON.stringify(
|
|
@@ -663,7 +673,6 @@ var BaseTiposkripto = class {
|
|
|
663
673
|
const classySuites = Object.entries(testImplementation.suites).reduce(
|
|
664
674
|
(a, [key], index) => {
|
|
665
675
|
a[key] = (somestring, givens) => {
|
|
666
|
-
const capturedOuterThis = outerThis;
|
|
667
676
|
const capturedFullAdapter = fullAdapter;
|
|
668
677
|
return new class extends BaseSuite {
|
|
669
678
|
afterAll(store, artifactory) {
|
|
@@ -674,7 +683,7 @@ var BaseTiposkripto = class {
|
|
|
674
683
|
suiteIndex: this.index
|
|
675
684
|
});
|
|
676
685
|
} else {
|
|
677
|
-
suiteArtifactory =
|
|
686
|
+
suiteArtifactory = instance.createArtifactory({
|
|
678
687
|
suiteIndex: this.index
|
|
679
688
|
});
|
|
680
689
|
}
|
|
@@ -684,10 +693,10 @@ var BaseTiposkripto = class {
|
|
|
684
693
|
assertThat(t) {
|
|
685
694
|
return capturedFullAdapter.assert(t);
|
|
686
695
|
}
|
|
687
|
-
async setup(s, tr) {
|
|
688
|
-
return capturedFullAdapter.prepareAll?.(s, tr) ?? s;
|
|
696
|
+
async setup(s, artifactory, tr) {
|
|
697
|
+
return capturedFullAdapter.prepareAll?.(s, tr, artifactory) ?? s;
|
|
689
698
|
}
|
|
690
|
-
}(somestring, index, givens,
|
|
699
|
+
}(somestring, index, givens, instance);
|
|
691
700
|
};
|
|
692
701
|
return a;
|
|
693
702
|
},
|
|
@@ -699,11 +708,10 @@ var BaseTiposkripto = class {
|
|
|
699
708
|
const safeFeatures = Array.isArray(features) ? [...features] : [];
|
|
700
709
|
const safeWhens = Array.isArray(whens) ? [...whens] : [];
|
|
701
710
|
const safeThens = Array.isArray(thens) ? [...thens] : [];
|
|
702
|
-
const capturedOuterThis = outerThis;
|
|
703
711
|
const capturedFullAdapter = fullAdapter;
|
|
704
712
|
const givenInstance = new class extends BaseGiven {
|
|
705
713
|
async givenThat(subject, testResource, artifactory, initializer, initialValues2) {
|
|
706
|
-
const givenArtifactory =
|
|
714
|
+
const givenArtifactory = instance.createArtifactory({
|
|
707
715
|
givenKey: key,
|
|
708
716
|
suiteIndex: this._suiteIndex
|
|
709
717
|
});
|
|
@@ -716,7 +724,9 @@ var BaseTiposkripto = class {
|
|
|
716
724
|
);
|
|
717
725
|
}
|
|
718
726
|
afterEach(store, key2, artifactory) {
|
|
719
|
-
return Promise.resolve(
|
|
727
|
+
return Promise.resolve(
|
|
728
|
+
capturedFullAdapter.cleanupEach(store, key2, artifactory)
|
|
729
|
+
);
|
|
720
730
|
}
|
|
721
731
|
}(
|
|
722
732
|
safeFeatures,
|
|
@@ -725,7 +735,7 @@ var BaseTiposkripto = class {
|
|
|
725
735
|
testImplementation.givens[key],
|
|
726
736
|
initialValues
|
|
727
737
|
);
|
|
728
|
-
givenInstance._parent =
|
|
738
|
+
givenInstance._parent = instance;
|
|
729
739
|
return givenInstance;
|
|
730
740
|
};
|
|
731
741
|
return a;
|
|
@@ -738,7 +748,12 @@ var BaseTiposkripto = class {
|
|
|
738
748
|
const capturedFullAdapter = fullAdapter;
|
|
739
749
|
const whenInstance = new class extends BaseWhen {
|
|
740
750
|
async andWhen(store, whenCB, testResource, artifactory) {
|
|
741
|
-
return await capturedFullAdapter.execute(
|
|
751
|
+
return await capturedFullAdapter.execute(
|
|
752
|
+
store,
|
|
753
|
+
whenCB,
|
|
754
|
+
testResource,
|
|
755
|
+
artifactory
|
|
756
|
+
);
|
|
742
757
|
}
|
|
743
758
|
}(`${key}: ${payload && payload.toString()}`, whEn(...payload));
|
|
744
759
|
return whenInstance;
|
|
@@ -752,8 +767,16 @@ var BaseTiposkripto = class {
|
|
|
752
767
|
a[key] = (...args) => {
|
|
753
768
|
const capturedFullAdapter = fullAdapter;
|
|
754
769
|
const thenInstance = new class extends BaseThen {
|
|
770
|
+
verifyCheck(store, checkCB, testResourceConfiguration2) {
|
|
771
|
+
throw new Error("Method not implemented.");
|
|
772
|
+
}
|
|
755
773
|
async butThen(store, thenCB, testResource, artifactory) {
|
|
756
|
-
return await capturedFullAdapter.verify(
|
|
774
|
+
return await capturedFullAdapter.verify(
|
|
775
|
+
store,
|
|
776
|
+
thenCB,
|
|
777
|
+
testResource,
|
|
778
|
+
artifactory
|
|
779
|
+
);
|
|
757
780
|
}
|
|
758
781
|
}(`${key}: ${args && args.toString()}`, thEn(...args));
|
|
759
782
|
return thenInstance;
|
|
@@ -778,10 +801,7 @@ var BaseTiposkripto = class {
|
|
|
778
801
|
this.testJobs = this.specs.map((suite) => {
|
|
779
802
|
const suiteRunner = (suite2) => async (testResourceConfiguration2) => {
|
|
780
803
|
try {
|
|
781
|
-
const x = await suite2.run(
|
|
782
|
-
input,
|
|
783
|
-
testResourceConfiguration2
|
|
784
|
-
);
|
|
804
|
+
const x = await suite2.run(input, testResourceConfiguration2);
|
|
785
805
|
return x;
|
|
786
806
|
} catch (e) {
|
|
787
807
|
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 || [],
|
|
@@ -513,6 +515,12 @@ var DefaultAdapter = (p) => {
|
|
|
513
515
|
// src/BaseSuite.ts
|
|
514
516
|
var BaseSuite = class {
|
|
515
517
|
constructor(name, index, givens = {}, parent) {
|
|
518
|
+
this.store = null;
|
|
519
|
+
this.testResourceConfiguration = null;
|
|
520
|
+
this.index = 0;
|
|
521
|
+
this.failed = false;
|
|
522
|
+
this.fails = 0;
|
|
523
|
+
this.parent = null;
|
|
516
524
|
// Reference to parent BaseTiposkripto instance
|
|
517
525
|
this.artifacts = [];
|
|
518
526
|
const suiteName = name || "testSuite";
|
|
@@ -583,10 +591,7 @@ var BaseSuite = class {
|
|
|
583
591
|
async run(input, testResourceConfiguration) {
|
|
584
592
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
585
593
|
const sNdx = this.index;
|
|
586
|
-
const subject = await this.setup(
|
|
587
|
-
input,
|
|
588
|
-
testResourceConfiguration
|
|
589
|
-
);
|
|
594
|
+
const subject = await this.setup(input, null, testResourceConfiguration);
|
|
590
595
|
for (const [gKey, g] of Object.entries(this.givens)) {
|
|
591
596
|
const giver = this.givens[gKey];
|
|
592
597
|
try {
|
|
@@ -622,7 +627,9 @@ var BaseSuite = class {
|
|
|
622
627
|
const basePath = this.testResourceConfiguration?.fs || "testeranto";
|
|
623
628
|
suiteArtifactory = {
|
|
624
629
|
writeFileSync: (filename, payload) => {
|
|
625
|
-
console.log(
|
|
630
|
+
console.log(
|
|
631
|
+
`[BaseSuite] Would write to ${basePath}/suite-${this.index}/${filename}: ${payload.substring(0, 100)}...`
|
|
632
|
+
);
|
|
626
633
|
},
|
|
627
634
|
screenshot: (filename, payload) => {
|
|
628
635
|
console.log(`[BaseSuite] Would take screenshot: ${filename}`);
|
|
@@ -647,8 +654,11 @@ var BaseTiposkripto = class {
|
|
|
647
654
|
constructor(webOrNode, input, testSpecification, testImplementation, testResourceRequirement = defaultTestResourceRequirement, testAdapter = {}, testResourceConfiguration, wsPort = "3456", wsHost = "localhost") {
|
|
648
655
|
this.totalTests = 0;
|
|
649
656
|
this.artifacts = [];
|
|
657
|
+
this.assertThis = () => {
|
|
658
|
+
};
|
|
650
659
|
this.testResourceConfiguration = testResourceConfiguration;
|
|
651
660
|
const fullAdapter = DefaultAdapter(testAdapter);
|
|
661
|
+
const instance = this;
|
|
652
662
|
if (!testImplementation.suites || typeof testImplementation.suites !== "object") {
|
|
653
663
|
throw new Error(
|
|
654
664
|
`testImplementation.suites must be an object, got ${typeof testImplementation.suites}: ${JSON.stringify(
|
|
@@ -659,7 +669,6 @@ var BaseTiposkripto = class {
|
|
|
659
669
|
const classySuites = Object.entries(testImplementation.suites).reduce(
|
|
660
670
|
(a, [key], index) => {
|
|
661
671
|
a[key] = (somestring, givens) => {
|
|
662
|
-
const capturedOuterThis = outerThis;
|
|
663
672
|
const capturedFullAdapter = fullAdapter;
|
|
664
673
|
return new class extends BaseSuite {
|
|
665
674
|
afterAll(store, artifactory) {
|
|
@@ -670,7 +679,7 @@ var BaseTiposkripto = class {
|
|
|
670
679
|
suiteIndex: this.index
|
|
671
680
|
});
|
|
672
681
|
} else {
|
|
673
|
-
suiteArtifactory =
|
|
682
|
+
suiteArtifactory = instance.createArtifactory({
|
|
674
683
|
suiteIndex: this.index
|
|
675
684
|
});
|
|
676
685
|
}
|
|
@@ -680,10 +689,10 @@ var BaseTiposkripto = class {
|
|
|
680
689
|
assertThat(t) {
|
|
681
690
|
return capturedFullAdapter.assert(t);
|
|
682
691
|
}
|
|
683
|
-
async setup(s, tr) {
|
|
684
|
-
return capturedFullAdapter.prepareAll?.(s, tr) ?? s;
|
|
692
|
+
async setup(s, artifactory, tr) {
|
|
693
|
+
return capturedFullAdapter.prepareAll?.(s, tr, artifactory) ?? s;
|
|
685
694
|
}
|
|
686
|
-
}(somestring, index, givens,
|
|
695
|
+
}(somestring, index, givens, instance);
|
|
687
696
|
};
|
|
688
697
|
return a;
|
|
689
698
|
},
|
|
@@ -695,11 +704,10 @@ var BaseTiposkripto = class {
|
|
|
695
704
|
const safeFeatures = Array.isArray(features) ? [...features] : [];
|
|
696
705
|
const safeWhens = Array.isArray(whens) ? [...whens] : [];
|
|
697
706
|
const safeThens = Array.isArray(thens) ? [...thens] : [];
|
|
698
|
-
const capturedOuterThis = outerThis;
|
|
699
707
|
const capturedFullAdapter = fullAdapter;
|
|
700
708
|
const givenInstance = new class extends BaseGiven {
|
|
701
709
|
async givenThat(subject, testResource, artifactory, initializer, initialValues2) {
|
|
702
|
-
const givenArtifactory =
|
|
710
|
+
const givenArtifactory = instance.createArtifactory({
|
|
703
711
|
givenKey: key,
|
|
704
712
|
suiteIndex: this._suiteIndex
|
|
705
713
|
});
|
|
@@ -712,7 +720,9 @@ var BaseTiposkripto = class {
|
|
|
712
720
|
);
|
|
713
721
|
}
|
|
714
722
|
afterEach(store, key2, artifactory) {
|
|
715
|
-
return Promise.resolve(
|
|
723
|
+
return Promise.resolve(
|
|
724
|
+
capturedFullAdapter.cleanupEach(store, key2, artifactory)
|
|
725
|
+
);
|
|
716
726
|
}
|
|
717
727
|
}(
|
|
718
728
|
safeFeatures,
|
|
@@ -721,7 +731,7 @@ var BaseTiposkripto = class {
|
|
|
721
731
|
testImplementation.givens[key],
|
|
722
732
|
initialValues
|
|
723
733
|
);
|
|
724
|
-
givenInstance._parent =
|
|
734
|
+
givenInstance._parent = instance;
|
|
725
735
|
return givenInstance;
|
|
726
736
|
};
|
|
727
737
|
return a;
|
|
@@ -734,7 +744,12 @@ var BaseTiposkripto = class {
|
|
|
734
744
|
const capturedFullAdapter = fullAdapter;
|
|
735
745
|
const whenInstance = new class extends BaseWhen {
|
|
736
746
|
async andWhen(store, whenCB, testResource, artifactory) {
|
|
737
|
-
return await capturedFullAdapter.execute(
|
|
747
|
+
return await capturedFullAdapter.execute(
|
|
748
|
+
store,
|
|
749
|
+
whenCB,
|
|
750
|
+
testResource,
|
|
751
|
+
artifactory
|
|
752
|
+
);
|
|
738
753
|
}
|
|
739
754
|
}(`${key}: ${payload && payload.toString()}`, whEn(...payload));
|
|
740
755
|
return whenInstance;
|
|
@@ -748,8 +763,16 @@ var BaseTiposkripto = class {
|
|
|
748
763
|
a[key] = (...args) => {
|
|
749
764
|
const capturedFullAdapter = fullAdapter;
|
|
750
765
|
const thenInstance = new class extends BaseThen {
|
|
766
|
+
verifyCheck(store, checkCB, testResourceConfiguration2) {
|
|
767
|
+
throw new Error("Method not implemented.");
|
|
768
|
+
}
|
|
751
769
|
async butThen(store, thenCB, testResource, artifactory) {
|
|
752
|
-
return await capturedFullAdapter.verify(
|
|
770
|
+
return await capturedFullAdapter.verify(
|
|
771
|
+
store,
|
|
772
|
+
thenCB,
|
|
773
|
+
testResource,
|
|
774
|
+
artifactory
|
|
775
|
+
);
|
|
753
776
|
}
|
|
754
777
|
}(`${key}: ${args && args.toString()}`, thEn(...args));
|
|
755
778
|
return thenInstance;
|
|
@@ -774,10 +797,7 @@ var BaseTiposkripto = class {
|
|
|
774
797
|
this.testJobs = this.specs.map((suite) => {
|
|
775
798
|
const suiteRunner = (suite2) => async (testResourceConfiguration2) => {
|
|
776
799
|
try {
|
|
777
|
-
const x = await suite2.run(
|
|
778
|
-
input,
|
|
779
|
-
testResourceConfiguration2
|
|
780
|
-
);
|
|
800
|
+
const x = await suite2.run(input, testResourceConfiguration2);
|
|
781
801
|
return x;
|
|
782
802
|
} catch (e) {
|
|
783
803
|
console.error(e.stack);
|
|
@@ -933,12 +953,19 @@ var BaseTiposkripto = class {
|
|
|
933
953
|
};
|
|
934
954
|
|
|
935
955
|
// src/Web.ts
|
|
936
|
-
var
|
|
956
|
+
var isBrowser = typeof globalThis !== "undefined" && globalThis.window !== void 0;
|
|
957
|
+
var config = isBrowser ? globalThis.window?.testResourceConfig : {};
|
|
937
958
|
var WebTiposkripto = class extends BaseTiposkripto {
|
|
938
959
|
constructor(input, testSpecification, testImplementation, testResourceRequirement, testAdapter) {
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
960
|
+
let testResourceConfig = config;
|
|
961
|
+
if (isBrowser) {
|
|
962
|
+
const win = globalThis.window;
|
|
963
|
+
if (win) {
|
|
964
|
+
const urlParams = new URLSearchParams(win.location.search);
|
|
965
|
+
const encodedConfig = urlParams.get("config");
|
|
966
|
+
testResourceConfig = encodedConfig ? decodeURIComponent(encodedConfig) : "{}";
|
|
967
|
+
}
|
|
968
|
+
}
|
|
942
969
|
super(
|
|
943
970
|
"web",
|
|
944
971
|
input,
|
|
@@ -946,15 +973,32 @@ var WebTiposkripto = class extends BaseTiposkripto {
|
|
|
946
973
|
testImplementation,
|
|
947
974
|
testResourceRequirement,
|
|
948
975
|
testAdapter,
|
|
949
|
-
|
|
950
|
-
config
|
|
976
|
+
testResourceConfig
|
|
951
977
|
);
|
|
952
978
|
}
|
|
953
979
|
writeFileSync(filename, payload) {
|
|
954
|
-
|
|
980
|
+
if (isBrowser) {
|
|
981
|
+
const win = globalThis.window;
|
|
982
|
+
if (win && win.__writeFile) {
|
|
983
|
+
win.__writeFile(filename, payload);
|
|
984
|
+
} else {
|
|
985
|
+
console.error("__writeFile not available");
|
|
986
|
+
}
|
|
987
|
+
} else {
|
|
988
|
+
console.error("Not in browser environment");
|
|
989
|
+
}
|
|
955
990
|
}
|
|
956
991
|
screenshot(filename, payload) {
|
|
957
|
-
|
|
992
|
+
if (isBrowser) {
|
|
993
|
+
const win = globalThis.window;
|
|
994
|
+
if (win && win.__screenshot) {
|
|
995
|
+
win.__screenshot(filename, payload || "");
|
|
996
|
+
} else {
|
|
997
|
+
console.error("__screenshot not available");
|
|
998
|
+
}
|
|
999
|
+
} else {
|
|
1000
|
+
console.error("Not in browser environment");
|
|
1001
|
+
}
|
|
958
1002
|
}
|
|
959
1003
|
};
|
|
960
1004
|
var tiposkripto = async (input, testSpecification, testImplementation, testAdapter, testResourceRequirement = defaultTestResourceRequirement) => {
|
|
@@ -969,8 +1013,13 @@ var tiposkripto = async (input, testSpecification, testImplementation, testAdapt
|
|
|
969
1013
|
return t;
|
|
970
1014
|
} catch (e) {
|
|
971
1015
|
console.error(e);
|
|
972
|
-
|
|
973
|
-
|
|
1016
|
+
if (isBrowser) {
|
|
1017
|
+
const win = globalThis.window;
|
|
1018
|
+
if (win) {
|
|
1019
|
+
const errorEvent = new CustomEvent("test-error", { detail: e });
|
|
1020
|
+
win.dispatchEvent(errorEvent);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
974
1023
|
throw e;
|
|
975
1024
|
}
|
|
976
1025
|
};
|
package/dist/module/index.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;
|
|
@@ -218,23 +220,36 @@ var BaseCheck = class {
|
|
|
218
220
|
|
|
219
221
|
// src/BaseArrange.ts
|
|
220
222
|
var BaseArrange = class extends BaseSetup {
|
|
223
|
+
setupThat(subject, testResourceConfiguration, artifactory, setupCB, initialValues) {
|
|
224
|
+
throw new Error("Method not implemented.");
|
|
225
|
+
}
|
|
221
226
|
constructor(features, acts, asserts, arrangeCB, initialValues) {
|
|
222
227
|
super(features, acts, asserts, arrangeCB, initialValues);
|
|
223
228
|
}
|
|
224
229
|
// Alias setup to arrange for AAA pattern
|
|
225
230
|
async arrange(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
|
|
226
|
-
return super.setup(
|
|
231
|
+
return super.setup(
|
|
232
|
+
subject,
|
|
233
|
+
key,
|
|
234
|
+
testResourceConfiguration,
|
|
235
|
+
tester,
|
|
236
|
+
artifactory,
|
|
237
|
+
suiteNdx
|
|
238
|
+
);
|
|
227
239
|
}
|
|
228
240
|
};
|
|
229
241
|
|
|
230
242
|
// src/BaseAct.ts
|
|
231
243
|
var BaseAct = class extends BaseAction {
|
|
244
|
+
performAction(store, actionCB, testResource) {
|
|
245
|
+
throw new Error("Method not implemented.");
|
|
246
|
+
}
|
|
232
247
|
constructor(name, actCB) {
|
|
233
248
|
super(name, actCB);
|
|
234
249
|
}
|
|
235
250
|
// Alias performAction to performAct for AAA pattern
|
|
236
251
|
async performAct(store, actCB, testResource) {
|
|
237
|
-
return
|
|
252
|
+
return this.performAction(store, actCB, testResource);
|
|
238
253
|
}
|
|
239
254
|
// Alias test to act for AAA pattern
|
|
240
255
|
async act(store, testResourceConfiguration) {
|
|
@@ -244,12 +259,15 @@ var BaseAct = class extends BaseAction {
|
|
|
244
259
|
|
|
245
260
|
// src/BaseAssert.ts
|
|
246
261
|
var BaseAssert = class extends BaseCheck {
|
|
262
|
+
verifyCheck(store, checkCB, testResourceConfiguration) {
|
|
263
|
+
throw new Error("Method not implemented.");
|
|
264
|
+
}
|
|
247
265
|
constructor(name, assertCB) {
|
|
248
266
|
super(name, assertCB);
|
|
249
267
|
}
|
|
250
268
|
// Alias verifyCheck to verifyAssert for AAA pattern
|
|
251
269
|
async verifyAssert(store, assertCB, testResourceConfiguration) {
|
|
252
|
-
return
|
|
270
|
+
return this.verifyCheck(store, assertCB, testResourceConfiguration);
|
|
253
271
|
}
|
|
254
272
|
// Alias test to verify for AAA pattern
|
|
255
273
|
async verify(store, testResourceConfiguration, filepath) {
|
|
@@ -259,13 +277,23 @@ var BaseAssert = class extends BaseCheck {
|
|
|
259
277
|
|
|
260
278
|
// src/BaseMap.ts
|
|
261
279
|
var BaseMap = class extends BaseSetup {
|
|
280
|
+
setupThat(subject, testResourceConfiguration, artifactory, setupCB, initialValues) {
|
|
281
|
+
throw new Error("Method not implemented.");
|
|
282
|
+
}
|
|
262
283
|
constructor(features, feeds, validates, mapCB, initialValues, tableData = []) {
|
|
263
284
|
super(features, feeds, validates, mapCB, initialValues);
|
|
264
285
|
this.tableData = tableData;
|
|
265
286
|
}
|
|
266
287
|
// Alias setup to map for TDT pattern
|
|
267
288
|
async map(subject, key, testResourceConfiguration, tester, artifactory, suiteNdx) {
|
|
268
|
-
return super.setup(
|
|
289
|
+
return super.setup(
|
|
290
|
+
subject,
|
|
291
|
+
key,
|
|
292
|
+
testResourceConfiguration,
|
|
293
|
+
tester,
|
|
294
|
+
artifactory,
|
|
295
|
+
suiteNdx
|
|
296
|
+
);
|
|
269
297
|
}
|
|
270
298
|
// Method to get table data
|
|
271
299
|
getTableData() {
|
|
@@ -281,6 +309,9 @@ var BaseFeed = class extends BaseAction {
|
|
|
281
309
|
this.rowIndex = -1;
|
|
282
310
|
this.rowData = null;
|
|
283
311
|
}
|
|
312
|
+
performAction(store, actionCB, testResource) {
|
|
313
|
+
throw new Error("Method not implemented.");
|
|
314
|
+
}
|
|
284
315
|
// Set the current row data before processing
|
|
285
316
|
setRowData(index, data) {
|
|
286
317
|
this.rowIndex = index;
|
|
@@ -288,7 +319,7 @@ var BaseFeed = class extends BaseAction {
|
|
|
288
319
|
}
|
|
289
320
|
// Alias performAction to feed for TDT pattern
|
|
290
321
|
async feed(store, feedCB, testResource) {
|
|
291
|
-
return
|
|
322
|
+
return this.performAction(store, feedCB, testResource);
|
|
292
323
|
}
|
|
293
324
|
// Alias test to processRow for TDT pattern
|
|
294
325
|
async processRow(store, testResourceConfiguration, rowIndex, rowData) {
|
|
@@ -304,13 +335,16 @@ var BaseValidate = class extends BaseCheck {
|
|
|
304
335
|
// Expected result for the current row
|
|
305
336
|
this.expectedResult = null;
|
|
306
337
|
}
|
|
338
|
+
verifyCheck(store, checkCB, testResourceConfiguration) {
|
|
339
|
+
throw new Error("Method not implemented.");
|
|
340
|
+
}
|
|
307
341
|
// Set expected result before validation
|
|
308
342
|
setExpectedResult(expected) {
|
|
309
343
|
this.expectedResult = expected;
|
|
310
344
|
}
|
|
311
345
|
// Alias verifyCheck to validate for TDT pattern
|
|
312
346
|
async validate(store, validateCB, testResourceConfiguration) {
|
|
313
|
-
return
|
|
347
|
+
return this.verifyCheck(store, validateCB, testResourceConfiguration);
|
|
314
348
|
}
|
|
315
349
|
// Alias test to check for TDT pattern
|
|
316
350
|
async check(store, testResourceConfiguration, filepath, expectedResult) {
|
|
@@ -344,12 +378,12 @@ var BaseGiven = class extends BaseSetup {
|
|
|
344
378
|
toObj() {
|
|
345
379
|
return {
|
|
346
380
|
key: this.key,
|
|
347
|
-
|
|
381
|
+
actions: (this.whens || []).map((w) => {
|
|
348
382
|
if (w && w.toObj) return w.toObj();
|
|
349
383
|
console.error("When step is not as expected!", JSON.stringify(w));
|
|
350
384
|
return {};
|
|
351
385
|
}),
|
|
352
|
-
|
|
386
|
+
checks: (this.thens || []).map((t) => t && t.toObj ? t.toObj() : {}),
|
|
353
387
|
error: this.error ? [this.error, this.error.stack] : null,
|
|
354
388
|
failed: this.failed,
|
|
355
389
|
features: this.features || [],
|