testeranto 0.134.0 → 0.140.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 (221) hide show
  1. package/.aider.chat.history.md +14577 -0
  2. package/.aider.input.history +566 -0
  3. package/.aider.tags.cache.v3/{8d/fa/12860238755bcfab9af8a93c52ab.val → bd/91/b71f967fd074cf4b757081b429b7.val} +0 -0
  4. package/.aider.tags.cache.v3/cache.db +0 -0
  5. package/.aider.tags.cache.v3/{18/8b/7dfca822129dad10b5cacadf7728.val → fb/96/b0f91c7e75e08fc5a6907633cf99.val} +0 -0
  6. package/README.md +29 -423
  7. package/bundle.js +1 -1
  8. package/dist/common/src/CoreTypes.js +2 -0
  9. package/dist/common/src/Init.js +4 -1
  10. package/dist/common/src/Node.js +1 -1
  11. package/dist/common/src/PM/PM_WithEslintAndTsc.js +10 -8
  12. package/dist/common/src/PM/__tests__/nodeSidecar.testeranto.js +2 -2
  13. package/dist/common/src/PM/main.js +12 -7
  14. package/dist/common/src/PM/node.js +10 -3
  15. package/dist/common/src/Web.js +2 -2
  16. package/dist/common/src/build.js +7 -72
  17. package/dist/common/src/defaultConfig.js +0 -1
  18. package/dist/common/src/esbuildConfigs/eslint-formatter-testeranto.js +16 -1
  19. package/dist/common/src/esbuildConfigs/node.js +2 -16
  20. package/dist/common/src/esbuildConfigs/pure.js +2 -16
  21. package/dist/common/src/esbuildConfigs/rebuildPlugin.js +22 -0
  22. package/dist/common/src/esbuildConfigs/web.js +2 -16
  23. package/dist/common/src/lib/abstractBase.js +8 -1
  24. package/dist/common/src/lib/basebuilder.js +4 -0
  25. package/dist/common/src/lib/classBuilder.js +2 -3
  26. package/dist/common/src/lib/core.js +2 -0
  27. package/dist/common/src/run.js +1 -1
  28. package/dist/common/src/utils/buildTemplates.js +88 -0
  29. package/dist/common/tsconfig.common.tsbuildinfo +1 -1
  30. package/dist/module/src/Init.js +4 -1
  31. package/dist/module/src/Node.js +1 -1
  32. package/dist/module/src/PM/PM_WithEslintAndTsc.js +10 -8
  33. package/dist/module/src/PM/__tests__/nodeSidecar.testeranto.js +2 -2
  34. package/dist/module/src/PM/main.js +12 -7
  35. package/dist/module/src/PM/node.js +10 -3
  36. package/dist/module/src/Project.js +41 -47
  37. package/dist/module/src/TestReport.js +34 -31
  38. package/dist/module/src/Web.js +2 -2
  39. package/dist/module/src/build.js +7 -72
  40. package/dist/module/src/defaultConfig.js +0 -1
  41. package/dist/module/src/esbuildConfigs/eslint-formatter-testeranto.js +16 -1
  42. package/dist/module/src/esbuildConfigs/node.js +2 -16
  43. package/dist/module/src/esbuildConfigs/pure.js +2 -16
  44. package/dist/module/src/esbuildConfigs/rebuildPlugin.js +17 -0
  45. package/dist/module/src/esbuildConfigs/web.js +2 -16
  46. package/dist/module/src/lib/abstractBase.js +8 -1
  47. package/dist/module/src/lib/basebuilder.js +4 -0
  48. package/dist/module/src/lib/classBuilder.js +2 -3
  49. package/dist/module/src/lib/core.js +2 -0
  50. package/dist/module/src/run.js +1 -1
  51. package/dist/module/src/utils/buildTemplates.js +82 -0
  52. package/dist/module/tsconfig.module.tsbuildinfo +1 -1
  53. package/dist/prebuild/Project.js +77 -29
  54. package/dist/prebuild/TestReport.js +51 -32
  55. package/dist/prebuild/build.mjs +132 -131
  56. package/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs +14 -1
  57. package/dist/prebuild/init-docs.mjs +0 -4
  58. package/dist/prebuild/run.mjs +50 -31
  59. package/dist/tsconfig.tsbuildinfo +1 -0
  60. package/dist/types/src/CoreTypes.d.ts +53 -0
  61. package/dist/types/src/Node.d.ts +3 -3
  62. package/dist/types/src/PM/__tests__/nodeSidecar.testeranto.d.ts +2 -4
  63. package/dist/types/src/PM/__tests__/pureSidecar.testeranto.d.ts +2 -4
  64. package/dist/types/src/PM/__tests__/webSidecar.testeranto.d.ts +2 -4
  65. package/dist/types/src/PM/index.d.ts +1 -1
  66. package/dist/types/src/PM/nodeSidecar.d.ts +2 -2
  67. package/dist/types/src/Pure.d.ts +3 -3
  68. package/dist/types/src/Types.d.ts +21 -61
  69. package/dist/types/src/Web.d.ts +3 -3
  70. package/dist/types/src/esbuildConfigs/rebuildPlugin.d.ts +6 -0
  71. package/dist/types/src/lib/abstractBase.d.ts +10 -16
  72. package/dist/types/src/lib/basebuilder.d.ts +3 -3
  73. package/dist/types/src/lib/classBuilder.d.ts +2 -2
  74. package/dist/types/src/lib/core.d.ts +2 -2
  75. package/dist/types/src/lib/index.d.ts +7 -6
  76. package/dist/types/src/lib/types.d.ts +8 -8
  77. package/dist/types/src/mothership/test.d.ts +2 -2
  78. package/dist/types/src/utils/buildTemplates.d.ts +3 -0
  79. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  80. package/docs/index.md +567 -0
  81. package/docs/style.md +116 -0
  82. package/docs.html +537 -0
  83. package/example.css +351 -0
  84. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Black.ttf +0 -0
  85. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Bold.ttf +0 -0
  86. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-ExtraBold.ttf +0 -0
  87. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Light.ttf +0 -0
  88. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Medium.ttf +0 -0
  89. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Regular.ttf +0 -0
  90. package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Thin.ttf +0 -0
  91. package/fonts/M_PLUS_Rounded_1c/OFL.txt +91 -0
  92. package/index.html +245 -24
  93. package/logo.svg +72 -0
  94. package/package.json +11 -2
  95. package/scripts/compile-docs.js +89 -0
  96. package/src/CoreTypes.ts +152 -0
  97. package/src/Init.ts +4 -4
  98. package/src/Node.ts +13 -13
  99. package/src/PM/PM_WithEslintAndTsc.ts +46 -15
  100. package/src/PM/__tests__/nodeSidecar.testeranto.ts +13 -20
  101. package/src/PM/__tests__/pureSidecar.testeranto.ts +8 -15
  102. package/src/PM/__tests__/webSidecar.testeranto.ts +8 -15
  103. package/src/PM/index.ts +1 -1
  104. package/src/PM/main.ts +17 -16
  105. package/src/PM/node.ts +10 -10
  106. package/src/PM/nodeSidecar.ts +2 -2
  107. package/src/PM/pure.ts +0 -4
  108. package/src/Project.tsx +289 -292
  109. package/src/Pure.ts +13 -14
  110. package/src/PureSidecar.ts +1 -0
  111. package/src/TestReport.tsx +179 -165
  112. package/src/Types.ts +52 -151
  113. package/src/Web.ts +15 -14
  114. package/src/build.ts +22 -72
  115. package/src/defaultConfig.ts +2 -1
  116. package/src/esbuildConfigs/eslint-formatter-testeranto.ts +17 -1
  117. package/src/esbuildConfigs/node.ts +2 -18
  118. package/src/esbuildConfigs/pure.ts +2 -18
  119. package/src/esbuildConfigs/rebuildPlugin.ts +23 -0
  120. package/src/esbuildConfigs/web.ts +2 -18
  121. package/src/lib/BaseSuite.test.ts +457 -0
  122. package/src/lib/BaseSuite.ts +155 -0
  123. package/src/lib/abstractBase.ts +13 -163
  124. package/src/lib/basebuilder.ts +11 -11
  125. package/src/lib/classBuilder.ts +13 -7
  126. package/src/lib/core.ts +13 -17
  127. package/src/lib/index.ts +21 -24
  128. package/src/lib/types.ts +23 -9
  129. package/src/mothership/test.ts +13 -10
  130. package/src/run.ts +1 -1
  131. package/src/style.css +1 -1
  132. package/src/utils/buildTemplates.ts +88 -0
  133. package/style.css +496 -0
  134. package/testeranto/bundles/node/{mothership/chunk-V2EQEXU2.mjs → allTests/chunk-4PJCC2XT.mjs} +66 -59
  135. package/testeranto/bundles/node/allTests/metafile.json +4151 -0
  136. package/testeranto/bundles/node/allTests/src/PM/__tests__/nodeSidecar.testeranto.mjs +187 -0
  137. package/testeranto/bundles/node/{mothership → allTests}/src/PM/__tests__/pureSidecar.testeranto.mjs +1 -1
  138. package/testeranto/bundles/node/{mothership → allTests}/src/PM/__tests__/webSidecar.testeranto.mjs +1 -1
  139. package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test.mjs +305 -0
  140. package/testeranto/bundles/node/{mothership → allTests}/src/mothership/test.mjs +1 -1
  141. package/testeranto/dev.html +29 -0
  142. package/testeranto/index.html +28 -27
  143. package/testeranto/reports/allTests/config.json +57 -0
  144. package/testeranto/reports/{mothership/index.html → allTests/dev.html} +2 -0
  145. package/testeranto/reports/allTests/index.html +26 -0
  146. package/testeranto/reports/{mothership/src/PM/__tests__/sidecar.testeranto/node/index.html → allTests/src/PM/__tests__/nodeSidecar.testeranto/node/dev.html} +4 -3
  147. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/index.html +21 -0
  148. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/lint_errors.json +80 -0
  149. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/message +1 -0
  150. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/prompt.txt +8 -0
  151. package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/type_errors.txt +28 -0
  152. package/testeranto/reports/{mothership/src/PM/__tests__/webSidecar.testeranto/node/index.html → allTests/src/PM/__tests__/pureSidecar.testeranto/node/dev.html} +4 -3
  153. package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/index.html +21 -0
  154. package/testeranto/reports/{mothership → allTests}/src/PM/__tests__/pureSidecar.testeranto/node/lint_errors.json +12 -12
  155. package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/message +1 -0
  156. package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/prompt.txt +8 -0
  157. package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/type_errors.txt +32 -0
  158. package/testeranto/reports/{mothership/src/PM/__tests__/nodeSidecar.testeranto/node/index.html → allTests/src/PM/__tests__/webSidecar.testeranto/node/dev.html} +4 -3
  159. package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/index.html +21 -0
  160. package/testeranto/reports/{mothership → allTests}/src/PM/__tests__/webSidecar.testeranto/node/lint_errors.json +12 -12
  161. package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/message +1 -0
  162. package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/prompt.txt +8 -0
  163. package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/type_errors.txt +32 -0
  164. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/console_log.txt +35 -0
  165. package/testeranto/reports/{mothership/src/PM/__tests__/pureSidecar.testeranto/node/index.html → allTests/src/lib/BaseSuite.test/node/dev.html} +4 -3
  166. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/index.html +21 -0
  167. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/lint_errors.json +608 -0
  168. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/message +1 -0
  169. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/prompt.txt +7 -0
  170. package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/type_errors.txt +68 -0
  171. package/testeranto/reports/allTests/src/mothership/test/node/dev.html +21 -0
  172. package/testeranto/reports/allTests/src/mothership/test/node/index.html +21 -0
  173. package/testeranto/reports/allTests/src/mothership/test/node/message +1 -0
  174. package/testeranto/reports/allTests/src/mothership/test/node/prompt.txt +8 -0
  175. package/testeranto/reports/allTests/src/mothership/test/node/type_errors.txt +24 -0
  176. package/testeranto/reports/allTests/summary.json +37 -0
  177. package/testeranto.config.ts +16 -26
  178. package/tsc.log +66 -69
  179. package/.aider.tags.cache.v3/cache.db-shm +0 -0
  180. package/.aider.tags.cache.v3/cache.db-wal +0 -0
  181. package/dist/common/src/SP__Polygon.test.js +0 -10
  182. package/dist/module/src/ReportClient.js +0 -132
  183. package/dist/module/src/SP__Polygon.test.js +0 -8
  184. package/dist/prebuild/ReportClient.js +0 -3
  185. package/src/ReportClient.tsx +0 -164
  186. package/src/SP__Polygon.test.ts +0 -13
  187. package/testeranto/ReportClient.css +0 -11367
  188. package/testeranto/ReportClient.js +0 -24641
  189. package/testeranto/bundles/node/mothership/metafile.json +0 -389
  190. package/testeranto/bundles/node/mothership/src/PM/__tests__/nodeSidecar.testeranto.mjs +0 -1219
  191. package/testeranto/bundles/node/mothership/src/PM/__tests__/sidecar.testeranto.mjs +0 -1199
  192. package/testeranto/reports/mothership/config.json +0 -25
  193. package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/console_log.txt +0 -0
  194. package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/lint_errors.json +0 -1564
  195. package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/prompt.txt +0 -22
  196. package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/type_errors.txt +0 -35
  197. package/testeranto/reports/mothership/src/PM/__tests__/pureSidecar.testeranto/node/prompt.txt +0 -12
  198. package/testeranto/reports/mothership/src/PM/__tests__/pureSidecar.testeranto/node/type_errors.txt +0 -26
  199. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/bdd_errors.txt +0 -1
  200. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/console_log.txt +0 -0
  201. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/lint_errors.json +0 -1564
  202. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/log.txt +0 -0
  203. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/prompt.txt +0 -22
  204. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/tests.json +0 -56
  205. package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/type_errors.txt +0 -29
  206. package/testeranto/reports/mothership/src/PM/__tests__/webSidecar.testeranto/node/prompt.txt +0 -12
  207. package/testeranto/reports/mothership/src/PM/__tests__/webSidecar.testeranto/node/type_errors.txt +0 -26
  208. package/testeranto/reports/mothership/src/mothership/test/node/bdd_errors.txt +0 -1
  209. package/testeranto/reports/mothership/src/mothership/test/node/console_log.txt +0 -4
  210. package/testeranto/reports/mothership/src/mothership/test/node/index.html +0 -20
  211. package/testeranto/reports/mothership/src/mothership/test/node/log.txt +0 -0
  212. package/testeranto/reports/mothership/src/mothership/test/node/prompt.txt +0 -12
  213. package/testeranto/reports/mothership/src/mothership/test/node/tests.json +0 -24
  214. package/testeranto/reports/mothership/src/mothership/test/node/type_errors.txt +0 -18
  215. package/testeranto/reports/mothership/summary.json +0 -9
  216. /package/dist/{types/src/SP__Polygon.test.d.ts → module/src/CoreTypes.js} +0 -0
  217. /package/testeranto/bundles/node/{mothership → allTests}/chunk-PG6KUKNP.mjs +0 -0
  218. /package/testeranto/bundles/pure/{mothership → allTests}/metafile.json +0 -0
  219. /package/testeranto/bundles/web/{mothership → allTests}/metafile.json +0 -0
  220. /package/testeranto/reports/{mothership/src/PM/__tests__/nodeSidecar.testeranto → allTests/src/lib/BaseSuite.test}/node/log.txt +0 -0
  221. /package/testeranto/reports/{mothership → allTests}/src/mothership/test/node/lint_errors.json +0 -0
package/docs/index.md ADDED
@@ -0,0 +1,567 @@
1
+ # Testeranto docs and core concepts
2
+
3
+ Testeranto's type system provides a rigorous framework for Behavior-Driven Development (BDD) testing. While powerful, the API can initially seem complex but everything you need to know can be summed up in **3 core functions and 5 essential types**. Follow these patterns, and TypeScript's type checker will guide you through the rest.
4
+
5
+ ### ⚠️ this doc is a work in progress. It is 99% accurate but needs some attention to be complete. ⚠️
6
+
7
+ Let's break down the key components using a Rectangle class example.
8
+
9
+ ### The Test Subject
10
+
11
+ This is the thing-to-be-tested, for this example, a very simple implementation of a Rectangle
12
+
13
+ ```typescript
14
+ class Rectangle {
15
+ constructor(public width: number, public height: number) {}
16
+
17
+ setWidth(w: number) {
18
+ this.width = w;
19
+ }
20
+ setHeight(h: number) {
21
+ this.height = h;
22
+ }
23
+ getArea() {
24
+ return this.width * this.height;
25
+ }
26
+ }
27
+ ```
28
+
29
+ ### Testeranto's 3 functions
30
+
31
+ For each of testeranto's runtime, there is a specific Testeranto main function. Each is it's own import but all 3 are called in the same way.
32
+
33
+ #### Node
34
+
35
+ ```ts
36
+ import Testeranto from "testeranto/src/Node"; // <- import the Node main function
37
+ // below this point, all runtimes are identical!
38
+
39
+ // Note the type parameters I, O, and M: these will be important later
40
+ export default Testeranto<
41
+ I extends Ibdd_in,
42
+ O extends Ibdd_out,
43
+ M
44
+ >(
45
+ Rectangle.prototype, // <- the subject of the test.
46
+ specification,
47
+ implementation,
48
+ interface
49
+ );
50
+ ```
51
+
52
+ #### Web
53
+
54
+ ```ts
55
+ import Testeranto from "testeranto/src/Web"; // <- import the Web main function
56
+ // below this point, all runtimes are identical!
57
+
58
+ import { implementation } from "./Rectangle.test.implementation";
59
+ import { specification } from "./Rectangle.test.specification";
60
+ import { interface } from "./Rectangle.test.interface";
61
+
62
+ // Note the type parameters I, O, and M: these will be important later
63
+ export default Testeranto<
64
+ I extends Ibdd_in,
65
+ O extends Ibdd_out,
66
+ M
67
+ >(
68
+ Rectangle.prototype, // <- the subject of the test.
69
+ specification,
70
+ implementation,
71
+ interface
72
+ );
73
+ ```
74
+
75
+ #### Pure
76
+
77
+ ```ts
78
+ import Testeranto from "testeranto/src/Pure"; // <- import the Pure main function
79
+ // below this point, all runtimes are identical!
80
+
81
+ import { implementation } from "./Rectangle.test.implementation";
82
+ import { specification } from "./Rectangle.test.specification";
83
+ import { interface } from "./Rectangle.test.interface";
84
+
85
+ // Note the type parameters I, O, and M: these will be important later
86
+ export default Testeranto<
87
+ I extends Ibdd_in,
88
+ O extends Ibdd_out,
89
+ M
90
+ >(
91
+ Rectangle.prototype, // <- the subject of the test.
92
+ specification,
93
+ implementation,
94
+ interface
95
+ );
96
+ ```
97
+
98
+ ### Testeranto's 5 Essential Types
99
+
100
+ Every testeranto test is built around these 5 types that form a complete testing pipeline:
101
+
102
+ 1. **ITestSpecification** - The "what" of your tests (business requirements)
103
+ 2. **ITestImplementation** - The "how" of your tests (concrete operations)
104
+ 3. **ITestInterface** - The "glue" between specs and implementation
105
+ 4. **Ibdd_in** - Defines the internal test flow shape
106
+ 5. **Ibdd_out** - Defines the external test interface
107
+
108
+ ```mermaid
109
+ flowchart LR
110
+ S[ITestSpecification] -->|defines| O[Ibdd_out]
111
+ I[ITestImplementation] -->|uses| O
112
+ I -->|uses| M[Modifier]
113
+ T[ITestInterface] -->|connects| N[Ibdd_in]
114
+ S -->|flows through| N
115
+ I -->|flows through| N
116
+
117
+ style S fill:#2aa198,stroke:#073642
118
+ style I fill:#859900,stroke:#073642
119
+ style T fill:#b58900,stroke:#073642
120
+ style O fill:#d33682,stroke:#073642
121
+ style N fill:#cb4b16,stroke:#073642
122
+ style M fill:#6c71c4,stroke:#073642
123
+ ```
124
+
125
+ #### The Specification (ITestSpecification)
126
+
127
+ The Specification defines the business requirements in plain language, completely separate from implementation details. This is where you describe **what** should be tested without worrying about **how**.
128
+
129
+ - Pure business logic
130
+ - Human-readable test descriptions
131
+ - Defines test suites, scenarios (Given/When/Then)
132
+ - Maps directly to BDD concepts
133
+ - Uses Ibdd_out for type safety
134
+
135
+ ```typescript
136
+ import {
137
+ Ibdd_in,
138
+ Ibdd_out,
139
+ ITestSpecification,
140
+ } from "testeranto/src/CoreTypes";
141
+
142
+ // Note the type parameters I and O. These are important!
143
+ export const specification: ITestSpecification<
144
+ I extends Ibdd_in,
145
+ O extends Ibdd_out,
146
+ > = (
147
+ Suite,
148
+ Given,
149
+ When,
150
+ Then,
151
+ Check
152
+ ) => {
153
+ return [
154
+ Suite.Default(
155
+ "Testing the Rectangle class",
156
+ {
157
+ test0: Given.Default(
158
+ ["https://api.github.com/repos/adamwong246/testeranto/issues/8"],
159
+ [],
160
+ [Then.getWidth(2)]
161
+ ),
162
+ test1: Given.Default(
163
+ [`Rectangles have width and height.`],
164
+ [When.setWidth(4), When.setHeight(5)],
165
+ [Then.getWidth(4), Then.getHeight(5), Then.area(20)]
166
+ ),
167
+ },
168
+
169
+ // Ignore this for now
170
+ []
171
+ ),
172
+ ];
173
+ };
174
+ ```
175
+
176
+ #### The Implementation (ITestImplementation)
177
+
178
+ The Implementation provides the concrete operations that bring specifications to life. This is where you define **how** each test step actually works.
179
+
180
+ - `suites`: Test grouping and organization
181
+ - `givens`: Initial test states/setup
182
+ - `whens`: Actions that change state
183
+ - `thens`: Assertions and validations
184
+ - `checks`: Additional verification points
185
+
186
+ ```ts
187
+ import {
188
+ Ibdd_in,
189
+ Ibdd_out,
190
+ ITestImplementation,
191
+ } from "testeranto/src/CoreTypes";
192
+
193
+ // Note the type parameters I and O. These are important!
194
+ export const implementation: ITestImplementation<
195
+ I extends Ibdd_in,
196
+ O extends Ibdd_out,
197
+ M
198
+ > = {
199
+ suites: {
200
+ Default: "a default suite",
201
+ },
202
+
203
+ givens: {
204
+ Default: () => new Rectangle(2, 2),
205
+ WidthAndHeightOf: (width, height) => new Rectangle(width, height),
206
+ },
207
+
208
+ whens: {
209
+ setWidth: (width: number) => (rectangle) => {
210
+ rectangle.setWidth(width);
211
+ return rectangle;
212
+ },
213
+ setHeight: (height: number) => (rectangle) => {
214
+ rectangle.setHeight(height);
215
+ return rectangle;
216
+ },
217
+ },
218
+
219
+ thens: {
220
+ getWidth: (expectedWidth) => (rectangle) => {
221
+ assert.equal(rectangle.getWidth(), expectedWidth);
222
+ return rectangle;
223
+ },
224
+ getHeight: (expectedHeight) => (rectangle) => {
225
+ assert.equal(rectangle.getHeight(), expectedHeight);
226
+ return rectangle;
227
+ },
228
+ area: (area) => (rectangle) => {
229
+ assert.equal(rectangle.area(), area);
230
+ return rectangle;
231
+ },
232
+ circumference: (circumference: number) => (rectangle: Rectangle) => {
233
+ assert.equal(rectangle.circumference(), circumference);
234
+ return rectangle;
235
+ },
236
+ },
237
+
238
+ checks: {
239
+ Default: () => new Rectangle(2, 2),
240
+ },
241
+ };
242
+ ```
243
+
244
+ #### The Interface aka ITestInterface
245
+
246
+ The test interface is code which is NOT BDD . The interface adapts your test subject so that the BDD hooks can be applied. The interface implements the traditional BDD steps "before all", "after all", "before each", "after each", etc
247
+
248
+ ```ts
249
+
250
+ import {
251
+ Ibdd_in,
252
+ ITestInterface,
253
+ } from "testeranto/src/CoreTypes";
254
+
255
+ // Note the type parameter. This is important!
256
+ export const testInterface: ITestInterface<
257
+ I extends Ibdd_in,
258
+ > = {
259
+ beforeEach: async (subject, i) => {
260
+ return i();
261
+ },
262
+ andWhen: async function (s, whenCB, tr, utils) {
263
+ return whenCB(s, utils);
264
+ },
265
+ butThen: async (s, t, tr, pm) => {
266
+ return t(s, pm);
267
+ },
268
+ afterEach: (z) => {
269
+ return z;
270
+ },
271
+ afterAll: () => {},
272
+ assertThis: (x: any, y) => {},
273
+ };
274
+ ```
275
+
276
+ #### type I aka Ibdd_in
277
+
278
+ this type describes the "inner" shape of your BDD tests.
279
+
280
+ ```ts
281
+ import { Ibdd_in } from "testeranto/src/CoreTypes";
282
+
283
+ // TODO this is inaccurate
284
+ export type I = Ibdd_in<
285
+ null,
286
+ null,
287
+ Rectangle,
288
+ Rectangle,
289
+ Rectangle,
290
+ (...x) => (rectangle: Rectangle, utils: IPM) => Rectangle,
291
+ (rectangle: Rectangle, utils: IPM) => Rectangle
292
+ >;
293
+ ```
294
+
295
+ #### type O aka Ibdd_out
296
+
297
+ this type describes the "outer" shape of your BDD tests.
298
+
299
+ ```ts
300
+ import { Ibdd_out } from "testeranto/src/CoreTypes";
301
+
302
+ export type O = Ibdd_out<
303
+ // Suite
304
+ {
305
+ Default: [string];
306
+ },
307
+ // "Given" are initial states
308
+ {
309
+ Default;
310
+ WidthOfOneAndHeightOfOne;
311
+ WidthAndHeightOf: [number, number];
312
+ },
313
+ // "Whens" are steps which change the state of the test subject
314
+ {
315
+ HeightIsPubliclySetTo: [number];
316
+ WidthIsPubliclySetTo: [number];
317
+ setWidth: [number];
318
+ setHeight: [number];
319
+ },
320
+ // "Thens" are steps which make assertions of the test subject
321
+ {
322
+ AreaPlusCircumference: [number];
323
+ circumference: [number];
324
+ getWidth: [number];
325
+ getHeight: [number];
326
+ area: [number];
327
+ prototype: [];
328
+ },
329
+ // "Checks" are similar to "Givens"
330
+ {
331
+ Default;
332
+ WidthOfOneAndHeightOfOne;
333
+ WidthAndHeightOf: [number, number];
334
+ }
335
+ >;
336
+ ```
337
+
338
+ #### type M (optional)
339
+
340
+ this type describes the modifications to the shape of the "specification". It can be used to make your BDD tests DRYer but is not necessary
341
+
342
+ ```ts
343
+ export type M = {
344
+ givens: {
345
+ [K in keyof O["givens"]]: (...Iw: O["givens"][K]) => Rectangle;
346
+ };
347
+ whens: {
348
+ [K in keyof O["whens"]]: (
349
+ ...Iw: O["whens"][K]
350
+ ) => (rectangle: Rectangle, utils: PM) => Rectangle;
351
+ };
352
+ thens: {
353
+ [K in keyof O["thens"]]: (
354
+ ...Iw: O["thens"][K]
355
+ ) => (rectangle: Rectangle, utils: PM) => Rectangle;
356
+ };
357
+ };
358
+ ```
359
+
360
+ ## Putting it all together
361
+
362
+ ```ts
363
+ // Make sure you import the right runtime
364
+ import Testeranto from "testeranto/src/Pure";
365
+
366
+ import {
367
+ Ibdd_in,
368
+ Ibdd_out,
369
+ ITestImplementation,
370
+ ITestSpecification,
371
+ ITestInterface,
372
+ } from "testeranto/src/CoreTypes";
373
+
374
+ // The test subject
375
+ class Rectangle {
376
+ constructor(public width: number, public height: number) {}
377
+
378
+ setWidth(w: number) {
379
+ this.width = w;
380
+ }
381
+ setHeight(h: number) {
382
+ this.height = h;
383
+ }
384
+ getArea() {
385
+ return this.width * this.height;
386
+ }
387
+ }
388
+
389
+ ////////////////////////////////////////////////////////
390
+
391
+ // TODO this is inaccurate
392
+ type I = Ibdd_in<
393
+ null,
394
+ null,
395
+ Rectangle,
396
+ Rectangle,
397
+ Rectangle,
398
+ (...x) => (rectangle: Rectangle, utils: IPM) => Rectangle,
399
+ (rectangle: Rectangle, utils: IPM) => Rectangle
400
+ >;
401
+
402
+ type O = Ibdd_out<
403
+ // Suites
404
+ {
405
+ Default: [string];
406
+ },
407
+ // Givens
408
+ {
409
+ Default;
410
+ WidthOfOneAndHeightOfOne;
411
+ WidthAndHeightOf: [number, number];
412
+ },
413
+ // Whens
414
+ {
415
+ HeightIsPubliclySetTo: [number];
416
+ WidthIsPubliclySetTo: [number];
417
+ setWidth: [number];
418
+ setHeight: [number];
419
+ },
420
+ // Thens
421
+ {
422
+ AreaPlusCircumference: [number];
423
+ circumference: [number];
424
+ getWidth: [number];
425
+ getHeight: [number];
426
+ area: [number];
427
+ prototype: [];
428
+ },
429
+ // Checks are broken right now, ignore them
430
+ {
431
+ Default;
432
+ WidthOfOneAndHeightOfOne;
433
+ WidthAndHeightOf: [number, number];
434
+ }
435
+ >;
436
+
437
+ type M = {
438
+ givens: {
439
+ [K in keyof O["givens"]]: (...Iw: O["givens"][K]) => Rectangle;
440
+ };
441
+ whens: {
442
+ [K in keyof O["whens"]]: (
443
+ ...Iw: O["whens"][K]
444
+ ) => (rectangle: Rectangle, utils: PM) => Rectangle;
445
+ };
446
+ thens: {
447
+ [K in keyof O["thens"]]: (
448
+ ...Iw: O["thens"][K]
449
+ ) => (rectangle: Rectangle, utils: PM) => Rectangle;
450
+ };
451
+ };
452
+
453
+ const testInterface: ITestInterface<
454
+ I extends Ibdd_in,
455
+ > = {
456
+ beforeEach: async (subject, i) => {
457
+ return i();
458
+ },
459
+ andWhen: async function (s, whenCB, tr, utils) {
460
+ return whenCB(s, utils);
461
+ },
462
+ butThen: async (s, t, tr, pm) => {
463
+ return t(s, pm);
464
+ },
465
+ afterEach: (z) => {
466
+ return z;
467
+ },
468
+ afterAll: () => {},
469
+ assertThis: (x: any, y) => {},
470
+ };
471
+
472
+ const testImplementation: ITestImplementation<
473
+ I extends Ibdd_in,
474
+ O extends Ibdd_out,
475
+ M
476
+ > = {
477
+ suites: {
478
+ Default: "a default suite",
479
+ },
480
+
481
+ givens: {
482
+ Default: () => new Rectangle(2, 2),
483
+ WidthAndHeightOf: (width, height) => new Rectangle(width, height),
484
+ },
485
+
486
+ whens: {
487
+ setWidth: (width: number) => (rectangle) => {
488
+ rectangle.setWidth(width);
489
+ return rectangle;
490
+ },
491
+ setHeight: (height: number) => (rectangle) => {
492
+ rectangle.setHeight(height);
493
+ return rectangle;
494
+ },
495
+ },
496
+
497
+ thens: {
498
+ getWidth: (expectedWidth) => (rectangle) => {
499
+ assert.equal(rectangle.getWidth(), expectedWidth);
500
+ return rectangle;
501
+ },
502
+ getHeight: (expectedHeight) => (rectangle) => {
503
+ assert.equal(rectangle.getHeight(), expectedHeight);
504
+ return rectangle;
505
+ },
506
+ area: (area) => (rectangle) => {
507
+ assert.equal(rectangle.area(), area);
508
+ return rectangle;
509
+ },
510
+ circumference: (circumference: number) => (rectangle: Rectangle) => {
511
+ assert.equal(rectangle.circumference(), circumference);
512
+ return rectangle;
513
+ },
514
+ },
515
+
516
+ checks: {
517
+ Default: () => new Rectangle(2, 2),
518
+ },
519
+ };
520
+
521
+ const testSpecification: ITestSpecification<
522
+ I extends Ibdd_in,
523
+ O extends Ibdd_out,
524
+ > = (
525
+ Suite,
526
+ Given,
527
+ When,
528
+ Then,
529
+ Check
530
+ ) => {
531
+ return [
532
+ Suite.Default(
533
+ "Testing the Rectangle class",
534
+ {
535
+ test0: Given.Default(
536
+ ["https://api.github.com/repos/adamwong246/testeranto/issues/8"],
537
+ [],
538
+ [Then.getWidth(2)]
539
+ ),
540
+ test1: Given.Default(
541
+ [`Rectangles have width and height.`],
542
+ [When.setWidth(4), When.setHeight(5)],
543
+ [Then.getWidth(4), Then.getHeight(5), Then.area(20)]
544
+ ),
545
+ },
546
+
547
+ // Ignore this for now
548
+ []
549
+ ),
550
+ ];
551
+ };
552
+
553
+ // 1 function will launch the test
554
+ export default Testeranto<
555
+ I extends Ibdd_in,
556
+ O extends Ibdd_out,
557
+ M
558
+ >(
559
+ Rectangle.prototype,
560
+ testSpecification,
561
+ testSmplementation,
562
+ testSnterface
563
+ );
564
+
565
+
566
+
567
+ ```
package/docs/style.md ADDED
@@ -0,0 +1,116 @@
1
+ # Official Color Palette
2
+
3
+ <div class="color-sampler">
4
+ <div class="color-group">
5
+ <h2>Primary Colors</h2>
6
+ <div class="color-row">
7
+ <div class="color-swatch" style="background-color: #ff6b6b; color: white;">
8
+ <span class="hex">#ff6b6b</span>
9
+ <span class="name">Coral Blush</span>
10
+ </div>
11
+ <div class="color-swatch" style="background-color: #4ecdc4; color: white;">
12
+ <span class="hex">#4ecdc4</span>
13
+ <span class="name">Mint Teal</span>
14
+ </div>
15
+ <div class="color-swatch" style="background-color: #E6B422; color: #292f36;">
16
+ <span class="hex">#E6B422</span>
17
+ <span class="name">Muted Gold</span>
18
+ </div>
19
+ <div class="color-swatch" style="background-color: #00B4A0; color: white;">
20
+ <span class="hex">#00B4A0</span>
21
+ <span class="name">Deep Teal</span>
22
+ </div>
23
+ </div>
24
+ </div>
25
+
26
+ <div class="color-group">
27
+ <h2>Text & Background</h2>
28
+ <div class="color-row">
29
+ <div class="color-swatch" style="background-color: #292f36; color: white;">
30
+ <span class="hex">#292f36</span>
31
+ <span class="name">Midnight Ink</span>
32
+ </div>
33
+ <div class="color-swatch" style="background-color: #f1faee; color: #292f36;">
34
+ <span class="hex">#f1faee</span>
35
+ <span class="name">Pearl Mist</span>
36
+ </div>
37
+ </div>
38
+ </div>
39
+
40
+ <div class="color-group">
41
+ <h2>Gradient Colors</h2>
42
+ <div class="color-row">
43
+ <div class="color-swatch" style="background-color: #0a0f1f; color: white;">
44
+ <span class="hex">#0a0f1f</span>
45
+ <span class="name">Deep Cosmos</span>
46
+ </div>
47
+ <div class="color-swatch" style="background-color: #1a2b50; color: white;">
48
+ <span class="hex">#1a2b50</span>
49
+ <span class="name">Twilight Navy</span>
50
+ </div>
51
+ <div class="color-swatch" style="background-color: #B07D85; color: white;">
52
+ <span class="hex">#B07D85</span>
53
+ <span class="name">Muted Rose</span>
54
+ </div>
55
+ <div class="color-swatch" style="background-color: #7fb3d5; color: white;">
56
+ <span class="hex">#7fb3d5</span>
57
+ <span class="name">Sky Whisper</span>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ </div>
62
+
63
+ <style>
64
+ .color-sampler {
65
+ margin: 2rem 0;
66
+ max-width: 800px;
67
+ }
68
+
69
+ .color-group {
70
+ margin-bottom: 2rem;
71
+ }
72
+
73
+ .color-row {
74
+ display: flex;
75
+ flex-wrap: wrap;
76
+ gap: 1rem;
77
+ margin-top: 1rem;
78
+ }
79
+
80
+ .color-swatch {
81
+ flex: 1;
82
+ min-width: 150px;
83
+ padding: 1rem;
84
+ border-radius: 8px;
85
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
86
+ display: flex;
87
+ flex-direction: column;
88
+ align-items: center;
89
+ justify-content: center;
90
+ height: 100px;
91
+ transition: transform 0.2s ease;
92
+ }
93
+
94
+ .color-swatch:hover {
95
+ transform: translateY(-5px);
96
+ }
97
+
98
+ .hex {
99
+ font-family: monospace;
100
+ font-weight: bold;
101
+ font-size: 1.1rem;
102
+ }
103
+
104
+ .name {
105
+ font-style: italic;
106
+ margin-top: 0.5rem;
107
+ }
108
+ </style>
109
+
110
+ ## Usage Guidelines
111
+
112
+ - Use "Coral Blush" for primary actions and important elements
113
+ - "Mint Teal" works well for secondary actions and accents
114
+ - The gradient colors create the sunrise effect from dark to light
115
+ - "Muted Gold" and "Deep Teal" provide sophisticated accents
116
+ - "Midnight Ink" and "Pearl Mist" ensure good text contrast