testeranto 0.140.1 → 0.143.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/.aider.chat.history.md +9173 -0
  2. package/.aider.input.history +336 -0
  3. package/.aider.tags.cache.v3/{ad/3c/10f2ab1397f6d544e613d2a6acaf.val → 3d/81/8b6f0e9b98ec2952cdb8968ac386.val} +0 -0
  4. package/.aider.tags.cache.v3/63/f1/138061b0aadb868173d197c2a0e0.val +0 -0
  5. package/.aider.tags.cache.v3/be/72/19ee8e656d160afe9b31523245fe.val +0 -0
  6. package/.aider.tags.cache.v3/cache.db +0 -0
  7. package/.aider.tags.cache.v3/cache.db-shm +0 -0
  8. package/.aider.tags.cache.v3/cache.db-wal +0 -0
  9. package/.aider.tags.cache.v3/{a7/97/6d37fce350ad2d588f36729db0cd.val → d6/7d/1820c2d4b9330eab7017da4515e7.val} +0 -0
  10. package/README.md +1 -1
  11. package/docs/aiderTest.sh +1 -0
  12. package/docs/testing.ai.txt +98 -0
  13. package/docs/testing.prompt.txt +8 -0
  14. package/index.html +1 -1
  15. package/package.json +3 -3
  16. package/src/PM/PM_WithEslintAndTsc.ts +35 -21
  17. package/src/Pure.test.ts +299 -0
  18. package/src/lib/BaseSuite.test.ts +24 -5
  19. package/src/lib/abstractBase.test/MockGiven.ts +31 -0
  20. package/src/lib/abstractBase.test/MockThen.ts +20 -0
  21. package/src/lib/abstractBase.test/MockWhen.ts +17 -0
  22. package/src/lib/abstractBase.test/implementation.ts +51 -0
  23. package/src/lib/abstractBase.test/index.ts +19 -0
  24. package/src/lib/abstractBase.test/interface.ts +12 -0
  25. package/src/lib/abstractBase.test/specification.ts +49 -0
  26. package/src/lib/abstractBase.test/types.ts +19 -0
  27. package/src/lib/baseBuilder.test/TestBaseBuilder.ts +83 -0
  28. package/src/lib/baseBuilder.test/baseBuilder.test.implementation.ts +133 -0
  29. package/src/lib/baseBuilder.test/baseBuilder.test.interface.ts +18 -0
  30. package/src/lib/baseBuilder.test/baseBuilder.test.specification.ts +35 -0
  31. package/src/lib/baseBuilder.test/baseBuilder.test.ts +13 -0
  32. package/src/lib/baseBuilder.test/baseBuilder.test.types.ts +36 -0
  33. package/src/lib/classBuilder.test/TestClassBuilder.ts +88 -0
  34. package/src/lib/classBuilder.test/classBuilder.test.implementation.ts +200 -0
  35. package/src/lib/classBuilder.test/classBuilder.test.interface.ts +17 -0
  36. package/src/lib/classBuilder.test/classBuilder.test.specification.ts +112 -0
  37. package/src/lib/classBuilder.test/classBuilder.test.ts +14 -0
  38. package/src/lib/classBuilder.test/classBuilder.test.types.ts +72 -0
  39. package/src/lib/core.test/MockCore.ts +49 -0
  40. package/src/lib/core.test/core.test.implementation.ts +129 -0
  41. package/src/lib/core.test/core.test.interface.ts +18 -0
  42. package/src/lib/core.test/core.test.specification.ts +99 -0
  43. package/src/lib/core.test/core.test.ts +15 -0
  44. package/src/lib/core.test/core.test.types.ts +68 -0
  45. package/src/lib/core.ts +1 -1
  46. package/src/lib/pmProxy.test/implementation.ts +104 -0
  47. package/src/lib/pmProxy.test/index.ts +19 -0
  48. package/src/lib/pmProxy.test/interface.ts +47 -0
  49. package/src/lib/pmProxy.test/mockPM.ts +38 -0
  50. package/src/lib/pmProxy.test/mockPMBase.ts +136 -0
  51. package/src/lib/pmProxy.test/specification.ts +123 -0
  52. package/src/lib/pmProxy.test/types.ts +45 -0
  53. package/src/lib/pmProxy.ts +40 -193
  54. package/testeranto/bundles/node/allTests/chunk-2FXOXAKZ.mjs +800 -0
  55. package/testeranto/bundles/node/allTests/chunk-5MQGD4WC.mjs +251 -0
  56. package/testeranto/bundles/node/allTests/chunk-6CGAD2FD.mjs +800 -0
  57. package/testeranto/bundles/node/allTests/chunk-DWKHII32.mjs +800 -0
  58. package/testeranto/bundles/node/allTests/chunk-KYSOR62N.mjs +167 -0
  59. package/testeranto/bundles/node/allTests/chunk-PRPFVO6G.mjs +251 -0
  60. package/testeranto/bundles/node/allTests/chunk-RX4SUFXQ.mjs +251 -0
  61. package/testeranto/bundles/node/allTests/chunk-UED26IMH.mjs +802 -0
  62. package/testeranto/bundles/node/allTests/chunk-VAAIAWXC.mjs +117 -0
  63. package/testeranto/bundles/node/allTests/chunk-W44DUDBK.mjs +251 -0
  64. package/testeranto/bundles/node/allTests/chunk-YI3EGRMQ.mjs +167 -0
  65. package/testeranto/bundles/node/allTests/metafile.json +1072 -222
  66. package/testeranto/bundles/node/allTests/src/PM/__tests__/nodeSidecar.testeranto.mjs +2 -1
  67. package/testeranto/bundles/node/allTests/src/PM/__tests__/pureSidecar.testeranto.mjs +2 -1
  68. package/testeranto/bundles/node/allTests/src/PM/__tests__/webSidecar.testeranto.mjs +2 -1
  69. package/testeranto/bundles/node/allTests/src/Pure.test.mjs +261 -0
  70. package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test.mjs +22 -4
  71. package/testeranto/bundles/node/allTests/src/lib/baseBuilder.test/baseBuilder.test.mjs +226 -0
  72. package/testeranto/bundles/node/allTests/src/lib/classBuilder.test/classBuilder.test.mjs +406 -0
  73. package/testeranto/bundles/node/allTests/src/lib/core.test/core.test.mjs +279 -0
  74. package/testeranto/bundles/node/allTests/src/lib/pmProxy.test/index.mjs +4479 -0
  75. package/testeranto/bundles/node/allTests/src/mothership/test.mjs +4 -2
  76. package/testeranto/reports/allTests/config.json +40 -1
  77. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/console_log.txt +0 -0
  78. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/log.txt +0 -0
  79. package/testeranto/reports/allTests/src/Pure.test/node/console_log.txt +17 -0
  80. package/testeranto/reports/allTests/src/Pure.test/node/dev.html +21 -0
  81. package/testeranto/reports/allTests/src/Pure.test/node/index.html +21 -0
  82. package/testeranto/reports/allTests/src/Pure.test/node/lint_errors.json +134 -0
  83. package/testeranto/reports/allTests/src/Pure.test/node/message +1 -0
  84. package/testeranto/reports/allTests/src/Pure.test/node/prompt.txt +7 -0
  85. package/testeranto/reports/allTests/src/Pure.test/node/type_errors.txt +26 -0
  86. package/testeranto/reports/allTests/src/lib/BaseGiven.test/node/dev.html +21 -0
  87. package/testeranto/reports/allTests/src/lib/BaseGiven.test/node/index.html +21 -0
  88. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/console_log.txt +27 -27
  89. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/lint_errors.json +104 -104
  90. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/type_errors.txt +47 -22
  91. package/testeranto/reports/allTests/src/lib/BaseThen.test/node/dev.html +21 -0
  92. package/testeranto/reports/allTests/src/lib/BaseThen.test/node/index.html +21 -0
  93. package/testeranto/reports/allTests/src/lib/BaseWhen.test/node/dev.html +21 -0
  94. package/testeranto/reports/allTests/src/lib/BaseWhen.test/node/index.html +21 -0
  95. package/testeranto/reports/allTests/src/lib/abstractBase/index/node/dev.html +21 -0
  96. package/testeranto/reports/allTests/src/lib/abstractBase/index/node/index.html +21 -0
  97. package/testeranto/reports/allTests/src/lib/baseBuilder/baseBuilder.test/node/dev.html +21 -0
  98. package/testeranto/reports/allTests/src/lib/baseBuilder/baseBuilder.test/node/index.html +21 -0
  99. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/console_log.txt +12 -0
  100. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/dev.html +21 -0
  101. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/index.html +21 -0
  102. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/lint_errors.json +966 -0
  103. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/message +1 -0
  104. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/prompt.txt +11 -0
  105. package/testeranto/reports/allTests/src/lib/baseBuilder.test/baseBuilder.test/node/type_errors.txt +52 -0
  106. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/console_log.txt +17 -0
  107. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/dev.html +21 -0
  108. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/index.html +21 -0
  109. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/lint_errors.json +771 -0
  110. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/message +1 -0
  111. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/prompt.txt +11 -0
  112. package/testeranto/reports/allTests/src/lib/classBuilder.test/classBuilder.test/node/type_errors.txt +67 -0
  113. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/console_log.txt +17 -0
  114. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/dev.html +21 -0
  115. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/index.html +21 -0
  116. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/lint_errors.json +416 -0
  117. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/message +1 -0
  118. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/prompt.txt +11 -0
  119. package/testeranto/reports/allTests/src/lib/core.test/core.test/node/type_errors.txt +54 -0
  120. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/console_log.txt +43 -0
  121. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/dev.html +21 -0
  122. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/index.html +21 -0
  123. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/lint_errors.json +319 -0
  124. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/log.txt +0 -0
  125. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/message +1 -0
  126. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/prompt.txt +10 -0
  127. package/testeranto/reports/allTests/src/lib/pmProxy.test/index/node/type_errors.txt +64 -0
  128. package/testeranto/reports/allTests/src/mothership/test/node/console_log.txt +44 -0
  129. package/testeranto/reports/allTests/src/mothership/test/node/log.txt +0 -0
  130. package/testeranto/reports/allTests/summary.json +76 -6
  131. package/testeranto/reportsnode_build_errors +12 -0
  132. package/testeranto.config.ts +19 -2
@@ -0,0 +1,72 @@
1
+ import { Ibdd_in, Ibdd_out } from "../../CoreTypes";
2
+ import { ClassBuilder } from "../classBuilder";
3
+ import { ITTestResourceRequest } from "..";
4
+
5
+ export type I = Ibdd_in<
6
+ {}, // iinput
7
+ ClassBuilder<any, any, any>, // isubject
8
+ ClassBuilder<any, any, any>, // istore
9
+ ClassBuilder<any, any, any>, // iselection
10
+ () => ClassBuilder<any, any, any>, // given
11
+ (store: any) => any, // when
12
+ (store: any) => any // then
13
+ >;
14
+
15
+ export type O = Ibdd_out<
16
+ // Suites
17
+ {
18
+ Default: [string];
19
+ ExtendedSuite: [description: string];
20
+ },
21
+ // Givens
22
+ {
23
+ Default: [];
24
+ WithCustomInput: [input: any];
25
+ WithResourceRequirements: [requirements: ITTestResourceRequest];
26
+ WithCustomImplementation: [impl: ITestImplementation<any, any>];
27
+ WithCustomSpecification: [spec: ITestSpecification<any, any>];
28
+ },
29
+ // Whens
30
+ {
31
+ addArtifact: [artifact: Promise<any>];
32
+ setTestJobs: [jobs: ITestJob[]];
33
+ modifySpecs: [modifier: (specs: any[]) => any[]];
34
+ modifyJobs: [modifier: (jobs: ITestJob[]) => ITestJob[]];
35
+ triggerError: [message: string];
36
+ },
37
+ // Thens
38
+ {
39
+ initializedProperly: [];
40
+ specsGenerated: [];
41
+ jobsCreated: [];
42
+ artifactsTracked: [];
43
+ resourceRequirementsSet: [];
44
+ suitesOverridesConfigured: [];
45
+ givensOverridesConfigured: [];
46
+ whensOverridesConfigured: [];
47
+ thensOverridesConfigured: [];
48
+ checksOverridesConfigured: [];
49
+ specsModified: [expectedCount: number];
50
+ jobsModified: [expectedCount: number];
51
+ errorThrown: [expectedMessage: string];
52
+ testRunSuccessful: [];
53
+ },
54
+ // Checks
55
+ {
56
+ Default: [];
57
+ ImplementationCheck: [validator: (impl: any) => boolean];
58
+ SpecificationCheck: [validator: (spec: any) => boolean];
59
+ }
60
+ >;
61
+
62
+ export type M = {
63
+ givens: {
64
+ [K in keyof O["givens"]]: (...args: O["givens"][K]) => ClassBuilder<any, any, any>;
65
+ };
66
+ whens: {
67
+ [K in keyof O["whens"]]: (...args: O["whens"][K]) => (builder: ClassBuilder<any, any, any>) => ClassBuilder<any, any, any>;
68
+ };
69
+ thens: {
70
+ [K in keyof O["thens"]]: (...args: O["thens"][K]) => (builder: ClassBuilder<any, any, any>) => ClassBuilder<any, any, any>;
71
+ };
72
+ };
@@ -0,0 +1,49 @@
1
+ import TesterantoCore from "../core";
2
+
3
+ import {
4
+ Ibdd_in_any,
5
+ Ibdd_out_any,
6
+ ITestImplementation,
7
+ ITestSpecification,
8
+ ITestInterface,
9
+ } from "../../CoreTypes";
10
+ import { ITTestResourceRequest, IFinalResults } from "..";
11
+
12
+ /**
13
+ * Concrete implementation of Testeranto for testing purposes
14
+ */
15
+ export class MockCore<
16
+ I extends Ibdd_in_any,
17
+ O extends Ibdd_out_any,
18
+ M = unknown
19
+ > extends TesterantoCore<I, O, M> {
20
+ constructor(
21
+ input: I["iinput"],
22
+ testSpecification: ITestSpecification<I, O>,
23
+ testImplementation: ITestImplementation<I, O, M>,
24
+ testResourceRequirement: ITTestResourceRequest = { ports: [] },
25
+ testInterface: Partial<ITestInterface<I>> = {},
26
+ uberCatcher: (cb: () => void) => void = (cb) => cb()
27
+ ) {
28
+ super(
29
+ input,
30
+ testSpecification,
31
+ testImplementation,
32
+ testResourceRequirement,
33
+ testInterface,
34
+ uberCatcher
35
+ );
36
+ }
37
+
38
+ async receiveTestResourceConfig(
39
+ partialTestResource: string
40
+ ): Promise<IFinalResults> {
41
+ return {
42
+ failed: false,
43
+ fails: 0,
44
+ artifacts: [],
45
+ logPromise: Promise.resolve(),
46
+ features: [],
47
+ };
48
+ }
49
+ }
@@ -0,0 +1,129 @@
1
+ import { ITestImplementation } from "../../CoreTypes";
2
+ import { MockCore } from "./MockCore";
3
+ import { I, O, M } from "./core.test.types";
4
+ import { PassThrough } from "stream";
5
+ import { ITTestResourceRequest } from "..";
6
+ import { ITestInterface } from "../../CoreTypes";
7
+
8
+ export const implementation: ITestImplementation<I, O, M> = {
9
+ suites: {
10
+ Default: "Testeranto test suite",
11
+ ExtendedSuite: "Extended Testeranto test suite",
12
+ },
13
+
14
+ givens: {
15
+ Default: () => {
16
+ return new MockCore(
17
+ {}, // input
18
+ specification, // testSpecification
19
+ implementation, // testImplementation
20
+ { ports: [] }, // testResourceRequirement
21
+ testInterface, // testInterface
22
+ (cb) => cb() // uberCatcher
23
+ );
24
+ },
25
+ WithCustomInput: (input: any) => {
26
+ return new MockCore(
27
+ input,
28
+ specification,
29
+ implementation,
30
+ { ports: [] },
31
+ testInterface,
32
+ (cb) => cb()
33
+ );
34
+ },
35
+ WithResourceRequirements: (requirements: ITTestResourceRequest) => {
36
+ return new MockCore(
37
+ {},
38
+ specification,
39
+ implementation,
40
+ requirements,
41
+ testInterface,
42
+ (cb) => cb()
43
+ );
44
+ },
45
+ WithCustomInterface: (customInterface: Partial<ITestInterface<any>>) => {
46
+ return new MockCore(
47
+ {},
48
+ specification,
49
+ implementation,
50
+ { ports: [] },
51
+ {...testInterface, ...customInterface},
52
+ (cb) => cb()
53
+ );
54
+ }
55
+ },
56
+
57
+ whens: {
58
+ addArtifact: (artifact: Promise<any>) => (builder) => {
59
+ builder.artifacts.push(artifact);
60
+ return builder;
61
+ },
62
+ setTestJobs: (jobs: any[]) => (builder) => {
63
+ builder.testJobs = jobs;
64
+ return builder;
65
+ },
66
+ modifySpecs: (modifier: (specs: any[]) => any[]) => (builder) => {
67
+ builder.specs = modifier(builder.specs || []);
68
+ return builder;
69
+ },
70
+ triggerError: (message: string) => (builder) => {
71
+ throw new Error(message);
72
+ },
73
+ },
74
+
75
+ thens: {
76
+ initializedProperly: () => (builder) => {
77
+ if (!(builder instanceof MockCore)) {
78
+ throw new Error("Builder was not properly initialized");
79
+ }
80
+ return builder;
81
+ },
82
+ specsGenerated: () => (builder) => {
83
+ if (!Array.isArray(builder.specs)) {
84
+ throw new Error("Specs were not generated");
85
+ }
86
+ return builder;
87
+ },
88
+ jobsCreated: () => (builder) => {
89
+ if (!Array.isArray(builder.testJobs)) {
90
+ throw new Error("Test jobs were not created");
91
+ }
92
+ return builder;
93
+ },
94
+ artifactsTracked: () => (builder) => {
95
+ if (!Array.isArray(builder.artifacts)) {
96
+ throw new Error("Artifacts array not initialized");
97
+ }
98
+ return builder;
99
+ },
100
+ resourceRequirementsSet: () => (builder) => {
101
+ if (!builder.testResourceRequirement) {
102
+ throw new Error("Resource requirements not set");
103
+ }
104
+ return builder;
105
+ },
106
+ interfaceConfigured: () => (builder) => {
107
+ if (!builder.testInterface) {
108
+ throw new Error("Test interface not configured");
109
+ }
110
+ return builder;
111
+ },
112
+ errorThrown: (expectedMessage: string) => (builder) => {
113
+ // Handled by test runner
114
+ return builder;
115
+ },
116
+ testRunSuccessful: () => async (builder) => {
117
+ try {
118
+ await builder.receiveTestResourceConfig("");
119
+ return builder;
120
+ } catch (e) {
121
+ throw new Error(`Test run failed: ${e.message}`);
122
+ }
123
+ },
124
+ },
125
+
126
+ checks: {
127
+ Default: () => new PassThrough(),
128
+ },
129
+ };
@@ -0,0 +1,18 @@
1
+ import { ITestInterface } from "../../CoreTypes";
2
+ import { I } from "./core.test.types";
3
+
4
+ export const testInterface: ITestInterface<I> = {
5
+ beforeEach: async (subject, initializer, testResource, initialValues, pm) => {
6
+ return initializer();
7
+ },
8
+ andWhen: async (store, whenCB, testResource, pm) => {
9
+ return whenCB(store, pm);
10
+ },
11
+ butThen: async (store, thenCB, testResource, pm) => {
12
+ return thenCB(store, pm);
13
+ },
14
+ afterEach: (store) => store,
15
+ afterAll: (store, pm) => {},
16
+ assertThis: (result) => !!result,
17
+ beforeAll: async (input, testResource, pm) => input as any
18
+ };
@@ -0,0 +1,99 @@
1
+ import { ITestSpecification } from "../../CoreTypes";
2
+ import { I, O } from "./core.test.types";
3
+
4
+ export const specification: ITestSpecification<I, O> = (
5
+ Suite,
6
+ Given,
7
+ When,
8
+ Then,
9
+ Check
10
+ ) => {
11
+ return [
12
+ Suite.Default(
13
+ "Testeranto Core Functionality",
14
+ {
15
+ // Initialization tests
16
+ defaultInitialization: Given.Default(
17
+ ["Should initialize with default values"],
18
+ [],
19
+ [Then.initializedProperly()]
20
+ ),
21
+ customInputInitialization: Given.WithCustomInput(
22
+ { test: "input" },
23
+ [],
24
+ [Then.initializedProperly()]
25
+ ),
26
+
27
+ // Configuration tests
28
+ resourceConfig: Given.WithResourceRequirements(
29
+ { ports: [3000, 3001] },
30
+ [],
31
+ [Then.resourceRequirementsSet()]
32
+ ),
33
+ interfaceConfig: Given.WithCustomInterface(
34
+ {
35
+ assertThis: (x) => !!x,
36
+ beforeEach: async (s, i) => i()
37
+ },
38
+ [],
39
+ [Then.interfaceConfigured()]
40
+ ),
41
+
42
+ // Core operations
43
+ specGeneration: Given.Default(
44
+ ["Should generate test specs"],
45
+ [],
46
+ [Then.specsGenerated()]
47
+ ),
48
+ jobCreation: Given.Default(
49
+ ["Should create test jobs"],
50
+ [],
51
+ [Then.jobsCreated()]
52
+ ),
53
+ artifactHandling: Given.Default(
54
+ ["Should track artifacts"],
55
+ [When.addArtifact(Promise.resolve("test"))],
56
+ [Then.artifactsTracked()]
57
+ )
58
+ },
59
+ []
60
+ ),
61
+
62
+ Suite.ExtendedSuite(
63
+ "Testeranto Advanced Features",
64
+ {
65
+ // Error handling
66
+ errorPropagation: Given.Default(
67
+ ["Should propagate errors properly"],
68
+ [When.triggerError("test error")],
69
+ [Then.errorThrown("test error")]
70
+ ),
71
+
72
+ // Dynamic behavior
73
+ specModification: Given.Default(
74
+ ["Should allow spec modification"],
75
+ [When.modifySpecs((specs) => [...specs, {name: "extra"}])],
76
+ [Then.specsModified(1)]
77
+ ),
78
+
79
+ // Full lifecycle
80
+ testExecution: Given.Default(
81
+ ["Should execute full test lifecycle"],
82
+ [],
83
+ [Then.testRunSuccessful()]
84
+ ),
85
+
86
+ // Custom implementations
87
+ customImpl: Given.WithCustomImplementation(
88
+ {
89
+ ...implementation,
90
+ suites: {Default: "Custom suite"}
91
+ },
92
+ [],
93
+ [Then.specsGenerated()]
94
+ )
95
+ },
96
+ []
97
+ )
98
+ ];
99
+ };
@@ -0,0 +1,15 @@
1
+ import Testeranto from "../../Pure";
2
+ import { specification } from "./core.test.specification";
3
+ import { implementation } from "./core.test.implementation";
4
+ import { testInterface } from "./core.test.interface";
5
+ import { I, O, M } from "./core.test.types";
6
+ import { MockCore } from "./MockCore";
7
+
8
+ export default Testeranto<I, O, M>(
9
+ MockCore.prototype, // test subject
10
+ specification, // test scenarios
11
+ implementation, // test operations
12
+ testInterface, // test lifecycle hooks
13
+ { ports: [] }, // resource requirements
14
+ (cb) => cb() // error handler
15
+ );
@@ -0,0 +1,68 @@
1
+ import { Ibdd_in, Ibdd_out, ITestInterface } from "../../CoreTypes";
2
+ import { MockCore } from "./MockCore";
3
+ import { ITTestResourceRequest } from "..";
4
+
5
+ export type I = Ibdd_in<
6
+ {}, // iinput
7
+ MockCore<any, any, any>, // isubject
8
+ MockCore<any, any, any>, // istore
9
+ MockCore<any, any, any>, // iselection
10
+ () => MockCore<any, any, any>, // given
11
+ (store: any) => any, // when
12
+ (store: any) => any // then
13
+ >;
14
+
15
+ export type O = Ibdd_out<
16
+ // Suites
17
+ {
18
+ Default: [string];
19
+ ExtendedSuite: [description: string];
20
+ },
21
+ // Givens
22
+ {
23
+ Default: [];
24
+ WithCustomInput: [input: any];
25
+ WithResourceRequirements: [requirements: ITTestResourceRequest];
26
+ WithCustomInterface: [interface: Partial<ITestInterface<any>>];
27
+ },
28
+ // Whens
29
+ {
30
+ addArtifact: [artifact: Promise<any>];
31
+ setTestJobs: [jobs: any[]];
32
+ modifySpecs: [modifier: (specs: any[]) => any[]];
33
+ triggerError: [message: string];
34
+ },
35
+ // Thens
36
+ {
37
+ initializedProperly: [];
38
+ specsGenerated: [];
39
+ jobsCreated: [];
40
+ artifactsTracked: [];
41
+ resourceRequirementsSet: [];
42
+ interfaceConfigured: [];
43
+ errorThrown: [expectedMessage: string];
44
+ testRunSuccessful: [];
45
+ },
46
+ // Checks
47
+ {
48
+ Default: [];
49
+ }
50
+ >;
51
+
52
+ export type M = {
53
+ givens: {
54
+ [K in keyof O["givens"]]: (
55
+ ...args: O["givens"][K]
56
+ ) => MockCore<any, any, any>;
57
+ };
58
+ whens: {
59
+ [K in keyof O["whens"]]: (
60
+ ...args: O["whens"][K]
61
+ ) => (builder: MockCore<any, any, any>) => MockCore<any, any, any>;
62
+ };
63
+ thens: {
64
+ [K in keyof O["thens"]]: (
65
+ ...args: O["thens"][K]
66
+ ) => (builder: MockCore<any, any, any>) => MockCore<any, any, any>;
67
+ };
68
+ };
package/src/lib/core.ts CHANGED
@@ -21,7 +21,7 @@ import type {
21
21
  } from "../CoreTypes";
22
22
  import { BaseSuite } from "./BaseSuite.js";
23
23
 
24
- export default abstract class Testeranto<
24
+ export default abstract class TesterantoCore<
25
25
  I extends Ibdd_in_any,
26
26
  O extends Ibdd_out_any,
27
27
  M
@@ -0,0 +1,104 @@
1
+ import { I, M, O } from "./types";
2
+ import { ITestImplementation } from "../../CoreTypes";
3
+ // import { ITestProxies } from ".";
4
+ import { IPM } from "../types";
5
+ import { IProxiedFunctions, IProxy } from "../pmProxy";
6
+ import { MockPMBase } from "./mockPMBase";
7
+
8
+ export const implementation: ITestImplementation<I, O, M> = {
9
+ suites: {
10
+ Default: "PM Proxy Tests",
11
+ },
12
+
13
+ givens: {
14
+ SomeBaseString: (s: string) => s,
15
+ },
16
+
17
+ whens: {
18
+ // functions have no mutations
19
+ },
20
+ thens: {
21
+ theButTheProxyReturns:
22
+ (method: IProxiedFunctions, expectedPath: string) =>
23
+ (store: { butThenProxy: IProxy }) => {
24
+ const mockPm = new MockPMBase() as unknown as IPM;
25
+ const filepath = "test/path";
26
+ const proxiedPm = store.butThenProxy(mockPm, filepath);
27
+
28
+ let actualPath: string;
29
+ let actualContent: any;
30
+
31
+ try {
32
+ switch (method) {
33
+ case "writeFileSync":
34
+ const content = expectedPath.includes('content') ?
35
+ "test content" : "default content";
36
+ proxiedPm.writeFileSync(
37
+ expectedPath.includes('empty') ? "" :
38
+ expectedPath.includes('nested') ? "nested/folder/test.txt" :
39
+ expectedPath.includes('spaces') ? "file with spaces.txt" :
40
+ expectedPath.includes('invalid') ? "../invalid.txt" :
41
+ "test.txt",
42
+ content
43
+ );
44
+ actualPath = mockPm.getLastCall("writeFileSync")?.path;
45
+ actualContent = mockPm.getLastCall("writeFileSync")?.content;
46
+ break;
47
+
48
+ case "createWriteStream":
49
+ proxiedPm.createWriteStream(
50
+ expectedPath.includes('empty') ? "" : "stream.txt"
51
+ );
52
+ actualPath = mockPm.getLastCall("createWriteStream")?.path;
53
+ break;
54
+
55
+ case "screencast":
56
+ proxiedPm.screencast(
57
+ {
58
+ path: "screen.png",
59
+ quality: 80,
60
+ fullPage: true
61
+ },
62
+ "test"
63
+ );
64
+ actualPath = mockPm.getLastCall("screencast")?.opts?.path;
65
+ actualContent = mockPm.getLastCall("screencast")?.opts;
66
+ break;
67
+
68
+ case "customScreenShot":
69
+ proxiedPm.customScreenShot(
70
+ { path: "shot.png" },
71
+ "test"
72
+ );
73
+ actualPath = mockPm.getLastCall("customScreenShot")?.opts?.path;
74
+ break;
75
+
76
+ default:
77
+ throw new Error(`Unknown method: ${method}`);
78
+ }
79
+
80
+ if (expectedPath === undefined) {
81
+ return [undefined, undefined];
82
+ }
83
+
84
+ return [actualPath, expectedPath, actualContent];
85
+ } catch (error) {
86
+ return [error.message, expectedPath];
87
+ }
88
+ },
89
+
90
+ verifyContent: (expectedContent: any) => (result: any[]) => {
91
+ const actualContent = result[2];
92
+ if (JSON.stringify(actualContent) !== JSON.stringify(expectedContent)) {
93
+ throw new Error(
94
+ `Content mismatch. Expected: ${JSON.stringify(expectedContent)}, Got: ${JSON.stringify(actualContent)}`
95
+ );
96
+ }
97
+ return result;
98
+ },
99
+ },
100
+
101
+ checks: {
102
+ Default: (s: string) => s,
103
+ },
104
+ };
@@ -0,0 +1,19 @@
1
+ import Testeranto from "../../Node";
2
+ import { implementation } from "./implementation";
3
+ import { specification } from "./specification";
4
+ import { testInterface } from "./interface";
5
+ import { I, O } from "./types";
6
+
7
+ import { butThenProxy, IProxy } from "../pmProxy";
8
+
9
+ export type ITestProxies = { butThenProxy: IProxy };
10
+
11
+ export default Testeranto<I, O, {}>(
12
+ // because of the nature of testeranto, we must add all the testable items here
13
+ {
14
+ butThenProxy,
15
+ },
16
+ specification,
17
+ implementation,
18
+ testInterface
19
+ );
@@ -0,0 +1,47 @@
1
+ import { assert } from "chai";
2
+
3
+ import { I } from "./types";
4
+ import { ITestInterface } from "../../CoreTypes";
5
+ import { andWhenProxy, butThenProxy } from "../pmProxy";
6
+ import { IPM } from "../types";
7
+ import { MockPMBase } from "./mockPMBase";
8
+ // import { butThenProxy, andWhenProxy, beforeEachProxy } from "../pmProxy";
9
+
10
+ export const testInterface: ITestInterface<I> = {
11
+ beforeEach: async (subject, initializer, testResource, initialValues, pm) => {
12
+ return subject;
13
+ // const mockPM = MockPMBase();
14
+ // return {
15
+ // beforeEachProxy: subject.butThenProxy(
16
+ // new MockPMBase() as unknown as IPM,
17
+ // initializer
18
+ // ),
19
+ // };
20
+ },
21
+
22
+ andWhen: async (store, whenCB, testResource, pm) => {
23
+ const proxiedPM = andWhenProxy(pm, "some/path");
24
+ return whenCB(store, proxiedPM);
25
+ },
26
+
27
+ butThen: async (store, thenCB, testResource, pm) => {
28
+ console.log("mark2 butThen", store, thenCB.toString());
29
+ const proxiedPM = butThenProxy(pm, "some/path");
30
+ return thenCB(store, proxiedPM);
31
+ },
32
+
33
+ afterEach: async (store, key, pm) => store,
34
+ afterAll: async (store, pm) => {},
35
+ beforeAll: async (input, testResource, pm, theGivenString) => {
36
+ return {
37
+ beforeEachProxy: input.butThenProxy(
38
+ new MockPMBase() as unknown as IPM,
39
+ theGivenString
40
+ ),
41
+ };
42
+ },
43
+
44
+ assertThis: (returnedFilePath, expectation) => {
45
+ assert.equal(returnedFilePath, expectation);
46
+ },
47
+ };
@@ -0,0 +1,38 @@
1
+ import { MockPMBase } from "./mockPMBase";
2
+
3
+ export class MockPM extends MockPMBase {
4
+ server: any;
5
+
6
+ constructor(configs?: any) {
7
+ super(configs);
8
+ this.server = {};
9
+ this.testResourceConfiguration = {};
10
+ }
11
+
12
+ // PM-specific methods
13
+ start(): Promise<void> {
14
+ this.trackCall("start", {});
15
+ return Promise.resolve();
16
+ }
17
+
18
+ stop(): Promise<void> {
19
+ this.trackCall("stop", {});
20
+ return Promise.resolve();
21
+ }
22
+
23
+ launchSideCar(n: number): Promise<[number, any]> {
24
+ this.trackCall("launchSideCar", { n });
25
+ return Promise.resolve([n, this.testResourceConfiguration]);
26
+ }
27
+
28
+ stopSideCar(n: number): Promise<any> {
29
+ this.trackCall("stopSideCar", { n });
30
+ return Promise.resolve();
31
+ }
32
+
33
+ // Override any methods that need different behavior from MockPMBase
34
+ // For example:
35
+ writeFileSync(path: string, content: string): Promise<boolean> {
36
+ return super.writeFileSync(path, content, "default-test-name");
37
+ }
38
+ }