testeranto 0.135.0 → 0.140.1
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/.aider.chat.history.md +13976 -0
- package/.aider.input.history +530 -0
- package/.aider.tags.cache.v3/{d8/b0/a8966fcd65890fd9f70d7afe8141.val → bd/91/b71f967fd074cf4b757081b429b7.val} +0 -0
- package/.aider.tags.cache.v3/cache.db +0 -0
- package/.aider.tags.cache.v3/{8e/ec/2d4659a1589a0187a757ab1cbefa.val → fb/96/b0f91c7e75e08fc5a6907633cf99.val} +0 -0
- package/README.md +29 -135
- package/bundle.js +1 -1
- package/dist/common/src/Init.js +4 -1
- package/dist/common/src/Node.js +1 -1
- package/dist/common/src/PM/__tests__/nodeSidecar.testeranto.js +2 -2
- package/dist/common/src/Web.js +2 -2
- package/dist/common/src/build.js +7 -73
- package/dist/common/src/defaultConfig.js +0 -1
- package/dist/common/src/lib/abstractBase.js +2 -0
- package/dist/common/src/lib/basebuilder.js +4 -0
- package/dist/common/src/lib/core.js +2 -0
- package/dist/common/src/run.js +1 -1
- package/dist/common/src/utils/buildTemplates.js +88 -0
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/Init.js +4 -1
- package/dist/module/src/Node.js +1 -1
- package/dist/module/src/PM/__tests__/nodeSidecar.testeranto.js +2 -2
- package/dist/module/src/Project.js +41 -47
- package/dist/module/src/TestReport.js +34 -31
- package/dist/module/src/Web.js +2 -2
- package/dist/module/src/build.js +7 -73
- package/dist/module/src/defaultConfig.js +0 -1
- package/dist/module/src/lib/abstractBase.js +2 -0
- package/dist/module/src/lib/basebuilder.js +4 -0
- package/dist/module/src/lib/core.js +2 -0
- package/dist/module/src/run.js +1 -1
- package/dist/module/src/utils/buildTemplates.js +82 -0
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Project.js +62 -13
- package/dist/prebuild/TestReport.js +39 -18
- package/dist/prebuild/build.mjs +96 -73
- package/dist/prebuild/init-docs.mjs +0 -4
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/src/CoreTypes.d.ts +5 -3
- package/dist/types/src/Node.d.ts +3 -3
- package/dist/types/src/PM/__tests__/nodeSidecar.testeranto.d.ts +17 -1
- package/dist/types/src/PM/__tests__/pureSidecar.testeranto.d.ts +17 -1
- package/dist/types/src/PM/__tests__/webSidecar.testeranto.d.ts +17 -1
- package/dist/types/src/PM/nodeSidecar.d.ts +2 -2
- package/dist/types/src/Pure.d.ts +3 -3
- package/dist/types/src/Types.d.ts +18 -14
- package/dist/types/src/Web.d.ts +3 -3
- package/dist/types/src/lib/abstractBase.d.ts +8 -8
- package/dist/types/src/lib/basebuilder.d.ts +3 -3
- package/dist/types/src/lib/classBuilder.d.ts +2 -2
- package/dist/types/src/lib/core.d.ts +2 -2
- package/dist/types/src/lib/index.d.ts +7 -6
- package/dist/types/src/lib/types.d.ts +8 -8
- package/dist/types/src/mothership/test.d.ts +20 -1
- package/dist/types/src/utils/buildTemplates.d.ts +3 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/docs/index.md +344 -54
- package/docs/style.md +116 -0
- package/docs.html +537 -0
- package/example.css +351 -0
- package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Black.ttf +0 -0
- package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Bold.ttf +0 -0
- package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-ExtraBold.ttf +0 -0
- package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Light.ttf +0 -0
- package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Medium.ttf +0 -0
- package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Regular.ttf +0 -0
- package/fonts/M_PLUS_Rounded_1c/MPLUSRounded1c-Thin.ttf +0 -0
- package/fonts/M_PLUS_Rounded_1c/OFL.txt +91 -0
- package/index.html +246 -24
- package/logo.svg +72 -0
- package/package.json +6 -2
- package/scripts/compile-docs.js +89 -0
- package/src/CoreTypes.ts +24 -43
- package/src/Init.ts +4 -4
- package/src/Node.ts +6 -20
- package/src/PM/__tests__/nodeSidecar.testeranto.ts +13 -20
- package/src/PM/__tests__/pureSidecar.testeranto.ts +8 -15
- package/src/PM/__tests__/webSidecar.testeranto.ts +8 -15
- package/src/PM/nodeSidecar.ts +2 -2
- package/src/PM/pure.ts +0 -4
- package/src/Project.tsx +289 -292
- package/src/Pure.ts +13 -14
- package/src/PureSidecar.ts +1 -0
- package/src/TestReport.tsx +179 -165
- package/src/Types.ts +29 -144
- package/src/Web.ts +15 -11
- package/src/build.ts +22 -73
- package/src/defaultConfig.ts +2 -1
- package/src/lib/BaseSuite.test.ts +457 -0
- package/src/lib/BaseSuite.ts +155 -0
- package/src/lib/abstractBase.ts +7 -162
- package/src/lib/basebuilder.ts +11 -11
- package/src/lib/classBuilder.ts +8 -3
- package/src/lib/core.ts +12 -12
- package/src/lib/index.ts +21 -24
- package/src/lib/types.ts +23 -9
- package/src/mothership/test.ts +13 -10
- package/src/run.ts +1 -1
- package/src/style.css +1 -1
- package/src/utils/buildTemplates.ts +88 -0
- package/style.css +496 -0
- package/testeranto/bundles/node/{mothership/chunk-V2EQEXU2.mjs → allTests/chunk-4PJCC2XT.mjs} +66 -59
- package/testeranto/bundles/node/allTests/metafile.json +4151 -0
- package/testeranto/bundles/node/allTests/src/PM/__tests__/nodeSidecar.testeranto.mjs +187 -0
- package/testeranto/bundles/node/{mothership → allTests}/src/PM/__tests__/pureSidecar.testeranto.mjs +1 -1
- package/testeranto/bundles/node/{mothership → allTests}/src/PM/__tests__/webSidecar.testeranto.mjs +1 -1
- package/testeranto/bundles/node/allTests/src/lib/BaseSuite.test.mjs +305 -0
- package/testeranto/bundles/node/{mothership → allTests}/src/mothership/test.mjs +1 -1
- package/testeranto/dev.html +29 -0
- package/testeranto/index.html +28 -27
- package/testeranto/reports/allTests/config.json +57 -0
- package/testeranto/reports/{mothership/index.html → allTests/dev.html} +2 -0
- package/testeranto/reports/allTests/index.html +26 -0
- package/testeranto/reports/{mothership/src/PM/__tests__/sidecar.testeranto/node/index.html → allTests/src/PM/__tests__/nodeSidecar.testeranto/node/dev.html} +4 -3
- package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/index.html +21 -0
- package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/lint_errors.json +80 -0
- package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/message +1 -0
- package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/prompt.txt +8 -0
- package/testeranto/reports/allTests/src/PM/__tests__/nodeSidecar.testeranto/node/type_errors.txt +28 -0
- package/testeranto/reports/{mothership/src/PM/__tests__/webSidecar.testeranto/node/index.html → allTests/src/PM/__tests__/pureSidecar.testeranto/node/dev.html} +4 -3
- package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/index.html +21 -0
- package/testeranto/reports/{mothership → allTests}/src/PM/__tests__/pureSidecar.testeranto/node/lint_errors.json +12 -12
- package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/message +1 -0
- package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/prompt.txt +8 -0
- package/testeranto/reports/allTests/src/PM/__tests__/pureSidecar.testeranto/node/type_errors.txt +32 -0
- package/testeranto/reports/{mothership/src/PM/__tests__/nodeSidecar.testeranto/node/index.html → allTests/src/PM/__tests__/webSidecar.testeranto/node/dev.html} +4 -3
- package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/index.html +21 -0
- package/testeranto/reports/{mothership → allTests}/src/PM/__tests__/webSidecar.testeranto/node/lint_errors.json +12 -12
- package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/message +1 -0
- package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/prompt.txt +8 -0
- package/testeranto/reports/allTests/src/PM/__tests__/webSidecar.testeranto/node/type_errors.txt +32 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/console_log.txt +35 -0
- package/testeranto/reports/{mothership/src/PM/__tests__/pureSidecar.testeranto/node/index.html → allTests/src/lib/BaseSuite.test/node/dev.html} +4 -3
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/lint_errors.json +608 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/message +1 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/prompt.txt +7 -0
- package/testeranto/reports/allTests/src/lib/BaseSuite.test/node/type_errors.txt +68 -0
- package/testeranto/reports/allTests/src/mothership/test/node/dev.html +21 -0
- package/testeranto/reports/allTests/src/mothership/test/node/index.html +21 -0
- package/testeranto/reports/allTests/src/mothership/test/node/message +1 -0
- package/testeranto/reports/allTests/src/mothership/test/node/prompt.txt +8 -0
- package/testeranto/reports/allTests/src/mothership/test/node/type_errors.txt +24 -0
- package/testeranto/reports/allTests/summary.json +37 -0
- package/testeranto.config.ts +16 -26
- package/tsc.log +66 -69
- package/dist/common/src/SP__Polygon.test.js +0 -10
- package/dist/module/src/ReportClient.js +0 -132
- package/dist/module/src/SP__Polygon.test.js +0 -8
- package/dist/prebuild/ReportClient.js +0 -3
- package/dist/types/src/SP__Polygon.test.d.ts +0 -1
- package/src/ReportClient.tsx +0 -164
- package/src/SP__Polygon.test.ts +0 -13
- package/testeranto/ReportClient.css +0 -11367
- package/testeranto/ReportClient.js +0 -24641
- package/testeranto/bundles/node/mothership/metafile.json +0 -389
- package/testeranto/bundles/node/mothership/src/PM/__tests__/nodeSidecar.testeranto.mjs +0 -1219
- package/testeranto/bundles/node/mothership/src/PM/__tests__/sidecar.testeranto.mjs +0 -1199
- package/testeranto/reports/mothership/config.json +0 -25
- package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/console_log.txt +0 -0
- package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/lint_errors.json +0 -1564
- package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/prompt.txt +0 -22
- package/testeranto/reports/mothership/src/PM/__tests__/nodeSidecar.testeranto/node/type_errors.txt +0 -35
- package/testeranto/reports/mothership/src/PM/__tests__/pureSidecar.testeranto/node/prompt.txt +0 -12
- package/testeranto/reports/mothership/src/PM/__tests__/pureSidecar.testeranto/node/type_errors.txt +0 -26
- package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/bdd_errors.txt +0 -1
- package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/console_log.txt +0 -0
- package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/lint_errors.json +0 -1564
- package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/log.txt +0 -0
- package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/prompt.txt +0 -22
- package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/tests.json +0 -56
- package/testeranto/reports/mothership/src/PM/__tests__/sidecar.testeranto/node/type_errors.txt +0 -29
- package/testeranto/reports/mothership/src/PM/__tests__/webSidecar.testeranto/node/prompt.txt +0 -12
- package/testeranto/reports/mothership/src/PM/__tests__/webSidecar.testeranto/node/type_errors.txt +0 -26
- package/testeranto/reports/mothership/src/mothership/test/node/bdd_errors.txt +0 -1
- package/testeranto/reports/mothership/src/mothership/test/node/console_log.txt +0 -4
- package/testeranto/reports/mothership/src/mothership/test/node/index.html +0 -20
- package/testeranto/reports/mothership/src/mothership/test/node/log.txt +0 -0
- package/testeranto/reports/mothership/src/mothership/test/node/prompt.txt +0 -12
- package/testeranto/reports/mothership/src/mothership/test/node/tests.json +0 -24
- package/testeranto/reports/mothership/src/mothership/test/node/type_errors.txt +0 -18
- package/testeranto/reports/mothership/summary.json +0 -9
- /package/testeranto/bundles/node/{mothership → allTests}/chunk-PG6KUKNP.mjs +0 -0
- /package/testeranto/bundles/pure/{mothership → allTests}/metafile.json +0 -0
- /package/testeranto/bundles/web/{mothership → allTests}/metafile.json +0 -0
- /package/testeranto/reports/{mothership/src/PM/__tests__/nodeSidecar.testeranto → allTests/src/lib/BaseSuite.test}/node/log.txt +0 -0
- /package/testeranto/reports/{mothership → allTests}/src/mothership/test/node/lint_errors.json +0 -0
package/docs/index.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
# Testeranto docs and core concepts
|
|
2
2
|
|
|
3
|
-
Testeranto's type system provides a rigorous framework for Behavior-Driven Development (BDD) testing.
|
|
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.
|
|
4
8
|
|
|
5
9
|
### The Test Subject
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
This is the thing-to-be-tested, for this example, a very simple implementation of a Rectangle
|
|
8
12
|
|
|
9
13
|
```typescript
|
|
10
14
|
class Rectangle {
|
|
@@ -22,81 +26,130 @@ class Rectangle {
|
|
|
22
26
|
}
|
|
23
27
|
```
|
|
24
28
|
|
|
25
|
-
###
|
|
29
|
+
### Testeranto's 3 functions
|
|
26
30
|
|
|
27
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.
|
|
28
32
|
|
|
29
33
|
#### Node
|
|
30
34
|
|
|
31
35
|
```ts
|
|
32
|
-
import Testeranto from "testeranto/src/Node";
|
|
33
|
-
|
|
34
|
-
import { RectangleTesterantoBaseTestImplementation } from "./Rectangle.test.implementation";
|
|
35
|
-
import { RectangleTesterantoBaseTestSpecification } from "./Rectangle.test.specification";
|
|
36
|
-
import { RectangleTesterantoBaseInterface } from "./Rectangle.test.interface";
|
|
36
|
+
import Testeranto from "testeranto/src/Node"; // <- import the Node main function
|
|
37
|
+
// below this point, all runtimes are identical!
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
43
49
|
);
|
|
44
50
|
```
|
|
45
51
|
|
|
46
52
|
#### Web
|
|
47
53
|
|
|
48
54
|
```ts
|
|
49
|
-
import Testeranto from "testeranto/src/Web";
|
|
55
|
+
import Testeranto from "testeranto/src/Web"; // <- import the Web main function
|
|
56
|
+
// below this point, all runtimes are identical!
|
|
50
57
|
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
58
|
+
import { implementation } from "./Rectangle.test.implementation";
|
|
59
|
+
import { specification } from "./Rectangle.test.specification";
|
|
60
|
+
import { interface } from "./Rectangle.test.interface";
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
60
72
|
);
|
|
61
73
|
```
|
|
62
74
|
|
|
63
75
|
#### Pure
|
|
64
76
|
|
|
65
77
|
```ts
|
|
66
|
-
import Testeranto from "testeranto/src/Pure";
|
|
78
|
+
import Testeranto from "testeranto/src/Pure"; // <- import the Pure main function
|
|
79
|
+
// below this point, all runtimes are identical!
|
|
67
80
|
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
81
|
+
import { implementation } from "./Rectangle.test.implementation";
|
|
82
|
+
import { specification } from "./Rectangle.test.specification";
|
|
83
|
+
import { interface } from "./Rectangle.test.interface";
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
77
95
|
);
|
|
78
96
|
```
|
|
79
97
|
|
|
80
|
-
### Testeranto
|
|
81
|
-
|
|
82
|
-
Every testeranto test
|
|
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
|
+
```
|
|
83
124
|
|
|
84
|
-
|
|
85
|
-
2. ITestImplementation
|
|
86
|
-
3. ITestInterface
|
|
87
|
-
4. Ibdd_in
|
|
88
|
-
5. Ibdd_out
|
|
89
|
-
6. the "modifier" type
|
|
125
|
+
#### The Specification (ITestSpecification)
|
|
90
126
|
|
|
91
|
-
|
|
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**.
|
|
92
128
|
|
|
93
|
-
|
|
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
|
|
94
134
|
|
|
95
135
|
```typescript
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
+
) => {
|
|
100
153
|
return [
|
|
101
154
|
Suite.Default(
|
|
102
155
|
"Testing the Rectangle class",
|
|
@@ -113,20 +166,34 @@ export const RectangleTesterantoBaseTestSpecification: ITestSpecification<
|
|
|
113
166
|
),
|
|
114
167
|
},
|
|
115
168
|
|
|
169
|
+
// Ignore this for now
|
|
116
170
|
[]
|
|
117
171
|
),
|
|
118
172
|
];
|
|
119
173
|
};
|
|
120
174
|
```
|
|
121
175
|
|
|
122
|
-
#### The Implementation
|
|
176
|
+
#### The Implementation (ITestImplementation)
|
|
123
177
|
|
|
124
|
-
The Implementation
|
|
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
|
|
125
185
|
|
|
126
186
|
```ts
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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,
|
|
130
197
|
M
|
|
131
198
|
> = {
|
|
132
199
|
suites: {
|
|
@@ -176,10 +243,19 @@ export const RectangleTesterantoBaseTestImplementation: ITestImplementation<
|
|
|
176
243
|
|
|
177
244
|
#### The Interface aka ITestInterface
|
|
178
245
|
|
|
179
|
-
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 "before all", "after all", "before each",
|
|
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
|
|
180
247
|
|
|
181
248
|
```ts
|
|
182
|
-
|
|
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
|
+
> = {
|
|
183
259
|
beforeEach: async (subject, i) => {
|
|
184
260
|
return i();
|
|
185
261
|
},
|
|
@@ -202,6 +278,9 @@ export const RectangleTesterantoBaseInterface: ITestInterface<I> = {
|
|
|
202
278
|
this type describes the "inner" shape of your BDD tests.
|
|
203
279
|
|
|
204
280
|
```ts
|
|
281
|
+
import { Ibdd_in } from "testeranto/src/CoreTypes";
|
|
282
|
+
|
|
283
|
+
// TODO this is inaccurate
|
|
205
284
|
export type I = Ibdd_in<
|
|
206
285
|
null,
|
|
207
286
|
null,
|
|
@@ -218,6 +297,8 @@ export type I = Ibdd_in<
|
|
|
218
297
|
this type describes the "outer" shape of your BDD tests.
|
|
219
298
|
|
|
220
299
|
```ts
|
|
300
|
+
import { Ibdd_out } from "testeranto/src/CoreTypes";
|
|
301
|
+
|
|
221
302
|
export type O = Ibdd_out<
|
|
222
303
|
// Suite
|
|
223
304
|
{
|
|
@@ -274,4 +355,213 @@ export type M = {
|
|
|
274
355
|
) => (rectangle: Rectangle, utils: PM) => Rectangle;
|
|
275
356
|
};
|
|
276
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
|
+
|
|
277
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
|