testeranto 0.37.2 → 0.38.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testeranto",
3
3
  "description": "teeny tiny tightly-typed typescript tests",
4
- "version": "0.37.2",
4
+ "version": "0.38.0",
5
5
  "type": "module",
6
6
  "types": "./src/index.d.mts",
7
7
  "main": "./src/index.mts",
@@ -9,8 +9,7 @@
9
9
  ".": "./src/index.mjs",
10
10
  "./src/Project": "./src/Project.js",
11
11
  "./src/Features": "./src/Features.js",
12
- "./src/Report": "./src/Report.tsx",
13
- "./src/kokomoFeatures": "./src/kokomoFeatures.ts"
12
+ "./src/Report": "./src/Report.tsx"
14
13
  },
15
14
  "repository": "git@github.com:adamwong246/testeranto.git",
16
15
  "homepage": "https://github.com/adamwong246/testeranto",
@@ -66,4 +65,4 @@
66
65
  "why-is-node-running": "^2.2.2",
67
66
  "why-is-node-still-running": "^1.0.0"
68
67
  }
69
- }
68
+ }
package/src/index.mts CHANGED
@@ -24,8 +24,8 @@ type IRunner = (x: ITTestResourceConfiguration, t: ITLog) => Promise<boolean>;
24
24
  export type IT = {
25
25
  toObj(): object;
26
26
  name: string;
27
- givens: BaseGiven<unknown, unknown, unknown, unknown>[];
28
- checks: BaseCheck<unknown, unknown, unknown, unknown, ITTestShape>[];
27
+ givens: BaseGiven<unknown, unknown, unknown, unknown, Record<string, BaseFeature>>[];
28
+ checks: BaseCheck<unknown, unknown, unknown, unknown, ITTestShape, unknown>[];
29
29
  testResourceConfiguration: ITTestResourceConfiguration
30
30
  };
31
31
 
@@ -47,21 +47,21 @@ export type ITTestShape = {
47
47
  checks;
48
48
  };
49
49
 
50
- export type ITestSpecification<ITestShape extends ITTestShape> = (
50
+ export type ITestSpecification<ITestShape extends ITTestShape, IFeatureShape> = (
51
51
  Suite: {
52
52
  [K in keyof ITestShape["suites"]]: (
53
53
  name: string,
54
- givens: BaseGiven<unknown, unknown, unknown, unknown>[],
55
- checks: BaseCheck<unknown, unknown, unknown, unknown, ITestShape>[]
56
- ) => BaseSuite<unknown, unknown, unknown, unknown, unknown, ITestShape>;
54
+ givens: BaseGiven<unknown, unknown, unknown, unknown, Record<string, BaseFeature>>[],
55
+ checks: BaseCheck<unknown, unknown, unknown, unknown, ITestShape, IFeatureShape>[]
56
+ ) => BaseSuite<unknown, unknown, unknown, unknown, unknown, ITestShape, IFeatureShape>;
57
57
  },
58
58
  Given: {
59
59
  [K in keyof ITestShape["givens"]]: (
60
- features: string[],
60
+ features: (keyof IFeatureShape)[],
61
61
  whens: BaseWhen<unknown, unknown, unknown>[],
62
62
  thens: BaseThen<unknown, unknown, unknown>[],
63
63
  ...xtras: ITestShape["givens"][K]
64
- ) => BaseGiven<unknown, unknown, unknown, unknown>;
64
+ ) => BaseGiven<unknown, unknown, unknown, unknown, unknown>;
65
65
  },
66
66
  When: {
67
67
  [K in keyof ITestShape["whens"]]: (
@@ -77,7 +77,7 @@ export type ITestSpecification<ITestShape extends ITTestShape> = (
77
77
  [K in keyof ITestShape["checks"]]: (
78
78
 
79
79
  name: string,
80
- features: string[],
80
+ features: (keyof IFeatureShape)[],
81
81
  callbackA: (
82
82
  whens: {
83
83
  [K in keyof ITestShape["whens"]]: (...unknown) => BaseWhen<unknown, unknown, unknown>
@@ -88,7 +88,7 @@ export type ITestSpecification<ITestShape extends ITTestShape> = (
88
88
 
89
89
  ) => unknown,
90
90
  ...xtras: ITestShape["checks"][K]
91
- ) => BaseCheck<unknown, unknown, unknown, unknown, ITestShape>;
91
+ ) => BaseCheck<unknown, unknown, unknown, unknown, ITestShape, IFeatureShape>;
92
92
  }
93
93
  ) => any[];
94
94
 
@@ -177,18 +177,19 @@ export abstract class BaseSuite<
177
177
  ISelection,
178
178
  IThenShape,
179
179
  ITestShape extends ITTestShape,
180
+ IFeatureShape,
180
181
  > {
181
182
  name: string;
182
- givens: BaseGiven<ISubject, IStore, ISelection, IThenShape>[];
183
- checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape>[];
183
+ givens: BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>[];
184
+ checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape>[];
184
185
  store: IStore;
185
- fails: BaseGiven<ISubject, IStore, ISelection, IThenShape>[];
186
+ fails: BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>[];
186
187
  testResourceConfiguration: ITTestResourceConfiguration;
187
188
 
188
189
  constructor(
189
190
  name: string,
190
- givens: BaseGiven<ISubject, IStore, ISelection, IThenShape>[] = [],
191
- checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape>[] = []
191
+ givens: BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>[] = [],
192
+ checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape>[] = []
192
193
  ) {
193
194
  this.name = name;
194
195
  this.givens = givens;
@@ -222,7 +223,8 @@ export abstract class BaseSuite<
222
223
  IStore,
223
224
  ISelection,
224
225
  IThenShape,
225
- ITestShape
226
+ ITestShape,
227
+ IFeatureShape
226
228
  >> {
227
229
 
228
230
  this.testResourceConfiguration = testResourceConfiguration;
@@ -269,9 +271,10 @@ export abstract class BaseGiven<
269
271
  IStore,
270
272
  ISelection,
271
273
  IThenShape,
274
+ IFeatureShape
272
275
  > {
273
276
  name: string;
274
- features: string[];
277
+ features: (keyof IFeatureShape)[];
275
278
  whens: BaseWhen<IStore, ISelection, IThenShape>[];
276
279
  thens: BaseThen<ISelection, IStore, IThenShape>[];
277
280
  error: Error;
@@ -280,7 +283,7 @@ export abstract class BaseGiven<
280
283
 
281
284
  constructor(
282
285
  name: string,
283
- features: string[],
286
+ features: (keyof IFeatureShape)[],
284
287
  whens: BaseWhen<IStore, ISelection, IThenShape>[],
285
288
  thens: BaseThen<ISelection, IStore, IThenShape>[],
286
289
  ) {
@@ -447,10 +450,11 @@ export abstract class BaseCheck<
447
450
  IStore,
448
451
  ISelection,
449
452
  IThenShape,
450
- ITestShape extends ITTestShape
453
+ ITestShape extends ITTestShape,
454
+ IFeatureShape
451
455
  > {
452
456
  name: string;
453
- features: string[];
457
+ features: (keyof IFeatureShape)[];
454
458
  checkCB: (whens, thens) => any;
455
459
  whens: {
456
460
  [K in keyof ITestShape["whens"]]: (p, tc) =>
@@ -463,7 +467,7 @@ export abstract class BaseCheck<
463
467
 
464
468
  constructor(
465
469
  name: string,
466
- features: string[],
470
+ features: (keyof IFeatureShape)[],
467
471
  checkCB: (
468
472
  whens,
469
473
  thens
@@ -550,7 +554,8 @@ export abstract class TesterantoLevelZero<
550
554
  WhenExtensions,
551
555
  ThenExtensions,
552
556
  CheckExtensions,
553
- IThenShape
557
+ IThenShape,
558
+ IFeatureShape,
554
559
 
555
560
  > {
556
561
  constructorator: IStore;
@@ -559,20 +564,20 @@ export abstract class TesterantoLevelZero<
559
564
  keyof SuiteExtensions,
560
565
  (
561
566
  name: string,
562
- givens: BaseGiven<ISubject, IStore, ISelection, IThenShape>[],
563
- checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape>[]
564
- ) => BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITTestShape>
567
+ givens: BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>[],
568
+ checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape, IFeatureShape>[]
569
+ ) => BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITTestShape, IFeatureShape>
565
570
  >;
566
571
 
567
572
  givenOverides: Record<
568
573
  keyof GivenExtensions,
569
574
  (
570
575
  name: string,
571
- features: string[],
576
+ features: (keyof IFeatureShape)[],
572
577
  whens: BaseWhen<IStore, ISelection, IThenShape>[],
573
578
  thens: BaseThen<ISelection, IStore, IThenShape>[],
574
579
  ...xtraArgs
575
- ) => BaseGiven<ISubject, IStore, ISelection, IThenShape>
580
+ ) => BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>
576
581
  >;
577
582
 
578
583
  whenOverides: Record<
@@ -594,7 +599,7 @@ export abstract class TesterantoLevelZero<
594
599
  feature: string,
595
600
  callback: (whens, thens) => any,
596
601
  ...xtraArgs
597
- ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape>
602
+ ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape, IFeatureShape>
598
603
  >;
599
604
 
600
605
  constructor(
@@ -603,20 +608,20 @@ export abstract class TesterantoLevelZero<
603
608
  keyof SuiteExtensions,
604
609
  (
605
610
  name: string,
606
- givens: BaseGiven<ISubject, IStore, ISelection, IThenShape>[],
607
- checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape>[]
608
- ) => BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITTestShape>
611
+ givens: BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>[],
612
+ checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape, IFeatureShape>[]
613
+ ) => BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITTestShape, IFeatureShape>
609
614
  >,
610
615
 
611
616
  givenOverides: Record<
612
617
  keyof GivenExtensions,
613
618
  (
614
619
  name: string,
615
- features: string[],
620
+ features: (keyof IFeatureShape)[],
616
621
  whens: BaseWhen<IStore, ISelection, IThenShape>[],
617
622
  thens: BaseThen<ISelection, IStore, IThenShape>[],
618
623
  ...xtraArgs
619
- ) => BaseGiven<ISubject, IStore, ISelection, IThenShape>
624
+ ) => BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>
620
625
  >,
621
626
 
622
627
  whenOverides: Record<
@@ -638,7 +643,7 @@ export abstract class TesterantoLevelZero<
638
643
  feature: string,
639
644
  callback: (whens, thens) => any,
640
645
  ...xtraArgs
641
- ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape>
646
+ ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape, IFeatureShape>
642
647
  >
643
648
  ) {
644
649
  this.constructorator = cc;
@@ -657,11 +662,11 @@ export abstract class TesterantoLevelZero<
657
662
  keyof GivenExtensions,
658
663
  (
659
664
  name: string,
660
- features: string[],
665
+ features: (keyof IFeatureShape)[],
661
666
  whens: BaseWhen<IStore, ISelection, IThenShape>[],
662
667
  thens: BaseThen<ISelection, IStore, IThenShape>[],
663
668
  ...xtraArgs
664
- ) => BaseGiven<ISubject, IStore, ISelection, IThenShape>
669
+ ) => BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>
665
670
  > {
666
671
  return this.givenOverides;
667
672
  }
@@ -690,7 +695,7 @@ export abstract class TesterantoLevelZero<
690
695
  callback: (whens, thens) => any,
691
696
  whens,
692
697
  thens
693
- ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape>
698
+ ) => BaseCheck<ISubject, IStore, ISelection, IThenShape, ITTestShape, IFeatureShape>
694
699
  > {
695
700
  return this.checkOverides;
696
701
  }
@@ -704,7 +709,8 @@ export abstract class TesterantoLevelOne<
704
709
  ISubject,
705
710
  IWhenShape,
706
711
  IThenShape,
707
- IInput
712
+ IInput,
713
+ IFeatureShape extends Record<string, BaseFeature>
708
714
  > {
709
715
  constructor(
710
716
  testImplementation: ITestImplementation<
@@ -719,18 +725,18 @@ export abstract class TesterantoLevelOne<
719
725
  Suite: {
720
726
  [K in keyof ITestShape["suites"]]: (
721
727
  feature: string,
722
- givens: BaseGiven<ISubject, IStore, ISelection, IThenShape>[],
723
- checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape>[]
724
- ) => BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITestShape>;
728
+ givens: BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>[],
729
+ checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape>[]
730
+ ) => BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape>;
725
731
  },
726
732
  Given: {
727
733
  [K in keyof ITestShape["givens"]]: (
728
734
  name: string,
729
- features: string[],
735
+ features: (keyof IFeatureShape)[],
730
736
  whens: BaseWhen<IStore, ISelection, IThenShape>[],
731
737
  thens: BaseThen<ISelection, IStore, IThenShape>[],
732
- ...a: ITestShape["givens"]
733
- ) => BaseGiven<ISubject, IStore, ISelection, IThenShape>;
738
+ ...a: ITestShape["givens"][K]
739
+ ) => BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>;
734
740
  },
735
741
  When: {
736
742
  [K in keyof ITestShape["whens"]]: (
@@ -745,28 +751,28 @@ export abstract class TesterantoLevelOne<
745
751
  Check: {
746
752
  [K in keyof ITestShape["checks"]]: (
747
753
  name: string,
748
- features: string[],
754
+ features: (keyof IFeatureShape)[],
749
755
  cbz: (...any) => Promise<void>
750
756
  ) => any;
751
757
  }
752
- ) => BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITestShape>[],
758
+ ) => BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape>[],
753
759
 
754
760
  input: IInput,
755
761
 
756
762
  suiteKlasser: (
757
763
  name: string,
758
- givens: BaseGiven<ISubject, IStore, ISelection, IThenShape>[],
759
- checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape>[]
764
+ givens: BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>[],
765
+ checks: BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape>[]
760
766
  ) =>
761
- BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITestShape>,
767
+ BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape>,
762
768
  givenKlasser: (n, f, w, t, z?) =>
763
- BaseGiven<ISubject, IStore, ISelection, IThenShape>,
769
+ BaseGiven<ISubject, IStore, ISelection, IThenShape, IFeatureShape>,
764
770
  whenKlasser: (s, o) =>
765
771
  BaseWhen<IStore, ISelection, IThenShape>,
766
772
  thenKlasser: (s, o) =>
767
773
  BaseThen<IStore, ISelection, IThenShape>,
768
774
  checkKlasser: (n, f, cb, w, t) =>
769
- BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape>,
775
+ BaseCheck<ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape>,
770
776
 
771
777
  testResourceRequirement,
772
778
  nameKey: string
@@ -834,7 +840,8 @@ export abstract class TesterantoLevelOne<
834
840
  WhenExtensions,
835
841
  ThenExtensions,
836
842
  ICheckExtensions,
837
- IThenShape
843
+ IThenShape,
844
+ IFeatureShape,
838
845
  > extends TesterantoLevelZero<
839
846
  IInput,
840
847
  ISubject,
@@ -845,7 +852,8 @@ export abstract class TesterantoLevelOne<
845
852
  WhenExtensions,
846
853
  ThenExtensions,
847
854
  ICheckExtensions,
848
- IThenShape
855
+ IThenShape,
856
+ IFeatureShape
849
857
  > { })(
850
858
  input,
851
859
  classySuites,
@@ -868,7 +876,7 @@ export abstract class TesterantoLevelOne<
868
876
  const suiteRunner = (suite) => (
869
877
  testResourceConfiguration: ITTestResourceConfiguration,
870
878
  tLog: ITLog,
871
- ): BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITestShape> => {
879
+ ): BaseSuite<IInput, ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape> => {
872
880
  return suite.run(
873
881
  input,
874
882
  testResourceConfiguration,
@@ -904,7 +912,7 @@ export abstract class TesterantoLevelOne<
904
912
  access.write(`${l.toString()}\n`);
905
913
  }
906
914
  const suiteDone: BaseSuite<
907
- IInput, ISubject, IStore, ISelection, IThenShape, ITestShape
915
+ IInput, ISubject, IStore, ISelection, IThenShape, ITestShape, IFeatureShape
908
916
  > = await runner(testResourceConfiguration, tLog);
909
917
  const resultsFilePath = path.resolve(`${testResourceConfiguration.fs}/results.json`)
910
918
 
@@ -937,10 +945,12 @@ export default async <
937
945
  WhenShape,
938
946
  ThenShape,
939
947
  InitialStateShape,
948
+ IFeatureShape extends Record<string, BaseFeature>,
940
949
  >(
941
950
  input: Input,
942
951
  testSpecification: ITestSpecification<
943
- TestShape
952
+ TestShape,
953
+ IFeatureShape
944
954
  >,
945
955
  testImplementation,
946
956
  testInterface: {
@@ -973,6 +983,8 @@ export default async <
973
983
  testResourceRequirement: ITTestResourceRequirement = defaultTestResourceRequirement
974
984
 
975
985
  ) => {
986
+
987
+
976
988
  const butThen = testInterface.butThen || (async (a) => a as any);
977
989
  const { andWhen } = testInterface;
978
990
  const actionHandler = testInterface.actionHandler || function (b: (...any: any[]) => any) {
@@ -994,7 +1006,8 @@ export default async <
994
1006
  Subject,
995
1007
  WhenShape,
996
1008
  ThenShape,
997
- Input
1009
+ Input,
1010
+ IFeatureShape
998
1011
  > {
999
1012
  constructor() {
1000
1013
  super(
@@ -1002,7 +1015,7 @@ export default async <
1002
1015
  /* @ts-ignore:next-line */
1003
1016
  testSpecification,
1004
1017
  input,
1005
- (class extends BaseSuite<Input, Subject, Store, Selection, ThenShape, TestShape> {
1018
+ (class extends BaseSuite<Input, Subject, Store, Selection, ThenShape, TestShape, IFeatureShape> {
1006
1019
  async setup(s: Input, artifactory): Promise<Subject> {
1007
1020
  return beforeAll(s, artifactory);
1008
1021
  }
@@ -1015,12 +1028,13 @@ export default async <
1015
1028
  Subject,
1016
1029
  Store,
1017
1030
  Selection,
1018
- ThenShape
1031
+ ThenShape,
1032
+ IFeatureShape
1019
1033
  > {
1020
1034
  initialValues: any;
1021
1035
  constructor(
1022
1036
  name: string,
1023
- features: string[],
1037
+ features: (keyof IFeatureShape)[],
1024
1038
  whens: BaseWhen<Store, Selection, ThenShape>[],
1025
1039
  thens: BaseThen<Selection, Store, ThenShape>[],
1026
1040
  initialValues: any
@@ -1068,12 +1082,12 @@ export default async <
1068
1082
  }
1069
1083
  },
1070
1084
 
1071
- class Check extends BaseCheck<Subject, Store, Selection, ThenShape, TestShape> {
1085
+ class Check extends BaseCheck<Subject, Store, Selection, ThenShape, TestShape, IFeatureShape> {
1072
1086
  initialValues: any;
1073
1087
 
1074
1088
  constructor(
1075
1089
  name: string,
1076
- features: string[],
1090
+ features: (keyof IFeatureShape)[],
1077
1091
  checkCallback: (a, b) => any,
1078
1092
  whens,
1079
1093
  thens,