testeranto 0.134.0 → 0.135.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.aider.chat.history.md +601 -0
- package/.aider.input.history +36 -0
- package/.aider.tags.cache.v3/{18/8b/7dfca822129dad10b5cacadf7728.val → 8e/ec/2d4659a1589a0187a757ab1cbefa.val} +0 -0
- package/.aider.tags.cache.v3/cache.db +0 -0
- package/.aider.tags.cache.v3/{8d/fa/12860238755bcfab9af8a93c52ab.val → d8/b0/a8966fcd65890fd9f70d7afe8141.val} +0 -0
- package/README.md +60 -347
- package/dist/common/src/CoreTypes.js +2 -0
- package/dist/common/src/PM/PM_WithEslintAndTsc.js +10 -8
- package/dist/common/src/PM/main.js +12 -7
- package/dist/common/src/PM/node.js +10 -3
- package/dist/common/src/build.js +3 -2
- package/dist/common/src/esbuildConfigs/eslint-formatter-testeranto.js +16 -1
- package/dist/common/src/esbuildConfigs/node.js +2 -16
- package/dist/common/src/esbuildConfigs/pure.js +2 -16
- package/dist/common/src/esbuildConfigs/rebuildPlugin.js +22 -0
- package/dist/common/src/esbuildConfigs/web.js +2 -16
- package/dist/common/src/lib/abstractBase.js +6 -1
- package/dist/common/src/lib/classBuilder.js +2 -3
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/src/CoreTypes.js +1 -0
- package/dist/module/src/PM/PM_WithEslintAndTsc.js +10 -8
- package/dist/module/src/PM/main.js +12 -7
- package/dist/module/src/PM/node.js +10 -3
- package/dist/module/src/build.js +3 -2
- package/dist/module/src/esbuildConfigs/eslint-formatter-testeranto.js +16 -1
- package/dist/module/src/esbuildConfigs/node.js +2 -16
- package/dist/module/src/esbuildConfigs/pure.js +2 -16
- package/dist/module/src/esbuildConfigs/rebuildPlugin.js +17 -0
- package/dist/module/src/esbuildConfigs/web.js +2 -16
- package/dist/module/src/lib/abstractBase.js +6 -1
- package/dist/module/src/lib/classBuilder.js +2 -3
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Project.js +15 -16
- package/dist/prebuild/TestReport.js +12 -14
- package/dist/prebuild/build.mjs +39 -61
- package/dist/prebuild/esbuildConfigs/eslint-formatter-testeranto.mjs +14 -1
- package/dist/prebuild/run.mjs +50 -31
- package/dist/types/src/CoreTypes.d.ts +51 -0
- package/dist/types/src/Node.d.ts +2 -2
- package/dist/types/src/PM/__tests__/nodeSidecar.testeranto.d.ts +1 -19
- package/dist/types/src/PM/__tests__/pureSidecar.testeranto.d.ts +1 -19
- package/dist/types/src/PM/__tests__/webSidecar.testeranto.d.ts +1 -19
- package/dist/types/src/PM/index.d.ts +1 -1
- package/dist/types/src/Types.d.ts +13 -57
- package/dist/types/src/Web.d.ts +1 -1
- package/dist/types/src/esbuildConfigs/rebuildPlugin.d.ts +6 -0
- package/dist/types/src/lib/abstractBase.d.ts +2 -8
- package/dist/types/src/lib/core.d.ts +1 -1
- package/dist/types/src/mothership/test.d.ts +1 -20
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/docs/index.md +277 -0
- package/package.json +6 -1
- package/src/CoreTypes.ts +171 -0
- package/src/Node.ts +25 -11
- package/src/PM/PM_WithEslintAndTsc.ts +46 -15
- package/src/PM/index.ts +1 -1
- package/src/PM/main.ts +17 -16
- package/src/PM/node.ts +10 -10
- package/src/Types.ts +166 -150
- package/src/Web.ts +0 -3
- package/src/build.ts +3 -2
- package/src/esbuildConfigs/eslint-formatter-testeranto.ts +17 -1
- package/src/esbuildConfigs/node.ts +2 -18
- package/src/esbuildConfigs/pure.ts +2 -18
- package/src/esbuildConfigs/rebuildPlugin.ts +23 -0
- package/src/esbuildConfigs/web.ts +2 -18
- package/src/lib/abstractBase.ts +6 -1
- package/src/lib/classBuilder.ts +5 -4
- package/src/lib/core.ts +5 -9
- package/.aider.tags.cache.v3/cache.db-shm +0 -0
- package/.aider.tags.cache.v3/cache.db-wal +0 -0
package/docs/index.md
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
## Core Concepts
|
|
2
|
+
|
|
3
|
+
Testeranto's type system provides a rigorous framework for Behavior-Driven Development (BDD) testing. Let's break down the key components using a Rectangle class example.
|
|
4
|
+
|
|
5
|
+
### The Test Subject
|
|
6
|
+
|
|
7
|
+
First, define the class you want to test:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
class Rectangle {
|
|
11
|
+
constructor(public width: number, public height: number) {}
|
|
12
|
+
|
|
13
|
+
setWidth(w: number) {
|
|
14
|
+
this.width = w;
|
|
15
|
+
}
|
|
16
|
+
setHeight(h: number) {
|
|
17
|
+
this.height = h;
|
|
18
|
+
}
|
|
19
|
+
getArea() {
|
|
20
|
+
return this.width * this.height;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Teseranto's 3 main functions
|
|
26
|
+
|
|
27
|
+
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
|
+
|
|
29
|
+
#### Node
|
|
30
|
+
|
|
31
|
+
```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";
|
|
37
|
+
|
|
38
|
+
export default Testeranto(
|
|
39
|
+
null,
|
|
40
|
+
RectangleTesterantoBaseTestSpecification,
|
|
41
|
+
RectangleTesterantoBaseTestImplementation,
|
|
42
|
+
RectangleTesterantoBaseInterface
|
|
43
|
+
);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Web
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import Testeranto from "testeranto/src/Web";
|
|
50
|
+
|
|
51
|
+
import { RectangleTesterantoBaseTestImplementation } from "./Rectangle.test.implementation";
|
|
52
|
+
import { RectangleTesterantoBaseTestSpecification } from "./Rectangle.test.specification";
|
|
53
|
+
import { RectangleTesterantoBaseInterface } from "./Rectangle.test.interface";
|
|
54
|
+
|
|
55
|
+
export default Testeranto(
|
|
56
|
+
null,
|
|
57
|
+
RectangleTesterantoBaseTestSpecification,
|
|
58
|
+
RectangleTesterantoBaseTestImplementation,
|
|
59
|
+
RectangleTesterantoBaseInterface
|
|
60
|
+
);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### Pure
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import Testeranto from "testeranto/src/Pure";
|
|
67
|
+
|
|
68
|
+
import { RectangleTesterantoBaseTestImplementation } from "./Rectangle.test.implementation";
|
|
69
|
+
import { RectangleTesterantoBaseTestSpecification } from "./Rectangle.test.specification";
|
|
70
|
+
import { RectangleTesterantoBaseInterface } from "./Rectangle.test.interface";
|
|
71
|
+
|
|
72
|
+
export default Testeranto(
|
|
73
|
+
null,
|
|
74
|
+
RectangleTesterantoBaseTestSpecification,
|
|
75
|
+
RectangleTesterantoBaseTestImplementation,
|
|
76
|
+
RectangleTesterantoBaseInterface
|
|
77
|
+
);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Testeranto functions and types
|
|
81
|
+
|
|
82
|
+
Every testeranto test has 4-5 components:
|
|
83
|
+
|
|
84
|
+
1. ITestSpecification
|
|
85
|
+
2. ITestImplementation
|
|
86
|
+
3. ITestInterface
|
|
87
|
+
4. Ibdd_in
|
|
88
|
+
5. Ibdd_out
|
|
89
|
+
6. the "modifier" type
|
|
90
|
+
|
|
91
|
+
#### The Specification aka ITestSpecification
|
|
92
|
+
|
|
93
|
+
The Specification defines the business logic of your tests, divorced from implementation details.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
export const RectangleTesterantoBaseTestSpecification: ITestSpecification<
|
|
97
|
+
I,
|
|
98
|
+
O
|
|
99
|
+
> = (Suite, Given, When, Then, Check) => {
|
|
100
|
+
return [
|
|
101
|
+
Suite.Default(
|
|
102
|
+
"Testing the Rectangle class",
|
|
103
|
+
{
|
|
104
|
+
test0: Given.Default(
|
|
105
|
+
["https://api.github.com/repos/adamwong246/testeranto/issues/8"],
|
|
106
|
+
[],
|
|
107
|
+
[Then.getWidth(2)]
|
|
108
|
+
),
|
|
109
|
+
test1: Given.Default(
|
|
110
|
+
[`Rectangles have width and height.`],
|
|
111
|
+
[When.setWidth(4), When.setHeight(5)],
|
|
112
|
+
[Then.getWidth(4), Then.getHeight(5), Then.area(20)]
|
|
113
|
+
),
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
[]
|
|
117
|
+
),
|
|
118
|
+
];
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### The Implementation aka ITestImplementation
|
|
123
|
+
|
|
124
|
+
The Implementation defines the hooks that the Specification will call.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
export const RectangleTesterantoBaseTestImplementation: ITestImplementation<
|
|
128
|
+
I,
|
|
129
|
+
O,
|
|
130
|
+
M
|
|
131
|
+
> = {
|
|
132
|
+
suites: {
|
|
133
|
+
Default: "a default suite",
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
givens: {
|
|
137
|
+
Default: () => new Rectangle(2, 2),
|
|
138
|
+
WidthAndHeightOf: (width, height) => new Rectangle(width, height),
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
whens: {
|
|
142
|
+
setWidth: (width: number) => (rectangle) => {
|
|
143
|
+
rectangle.setWidth(width);
|
|
144
|
+
return rectangle;
|
|
145
|
+
},
|
|
146
|
+
setHeight: (height: number) => (rectangle) => {
|
|
147
|
+
rectangle.setHeight(height);
|
|
148
|
+
return rectangle;
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
thens: {
|
|
153
|
+
getWidth: (expectedWidth) => (rectangle) => {
|
|
154
|
+
assert.equal(rectangle.getWidth(), expectedWidth);
|
|
155
|
+
return rectangle;
|
|
156
|
+
},
|
|
157
|
+
getHeight: (expectedHeight) => (rectangle) => {
|
|
158
|
+
assert.equal(rectangle.getHeight(), expectedHeight);
|
|
159
|
+
return rectangle;
|
|
160
|
+
},
|
|
161
|
+
area: (area) => (rectangle) => {
|
|
162
|
+
assert.equal(rectangle.area(), area);
|
|
163
|
+
return rectangle;
|
|
164
|
+
},
|
|
165
|
+
circumference: (circumference: number) => (rectangle: Rectangle) => {
|
|
166
|
+
assert.equal(rectangle.circumference(), circumference);
|
|
167
|
+
return rectangle;
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
checks: {
|
|
172
|
+
Default: () => new Rectangle(2, 2),
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### The Interface aka ITestInterface
|
|
178
|
+
|
|
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", and "after each", all of which are optional.
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
export const RectangleTesterantoBaseInterface: ITestInterface<I> = {
|
|
183
|
+
beforeEach: async (subject, i) => {
|
|
184
|
+
return i();
|
|
185
|
+
},
|
|
186
|
+
andWhen: async function (s, whenCB, tr, utils) {
|
|
187
|
+
return whenCB(s, utils);
|
|
188
|
+
},
|
|
189
|
+
butThen: async (s, t, tr, pm) => {
|
|
190
|
+
return t(s, pm);
|
|
191
|
+
},
|
|
192
|
+
afterEach: (z) => {
|
|
193
|
+
return z;
|
|
194
|
+
},
|
|
195
|
+
afterAll: () => {},
|
|
196
|
+
assertThis: (x: any, y) => {},
|
|
197
|
+
};
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### type I aka Ibdd_in
|
|
201
|
+
|
|
202
|
+
this type describes the "inner" shape of your BDD tests.
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
export type I = Ibdd_in<
|
|
206
|
+
null,
|
|
207
|
+
null,
|
|
208
|
+
Rectangle,
|
|
209
|
+
Rectangle,
|
|
210
|
+
Rectangle,
|
|
211
|
+
(...x) => (rectangle: Rectangle, utils: IPM) => Rectangle,
|
|
212
|
+
(rectangle: Rectangle, utils: IPM) => Rectangle
|
|
213
|
+
>;
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### type O aka Ibdd_out
|
|
217
|
+
|
|
218
|
+
this type describes the "outer" shape of your BDD tests.
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
export type O = Ibdd_out<
|
|
222
|
+
// Suite
|
|
223
|
+
{
|
|
224
|
+
Default: [string];
|
|
225
|
+
},
|
|
226
|
+
// "Given" are initial states
|
|
227
|
+
{
|
|
228
|
+
Default;
|
|
229
|
+
WidthOfOneAndHeightOfOne;
|
|
230
|
+
WidthAndHeightOf: [number, number];
|
|
231
|
+
},
|
|
232
|
+
// "Whens" are steps which change the state of the test subject
|
|
233
|
+
{
|
|
234
|
+
HeightIsPubliclySetTo: [number];
|
|
235
|
+
WidthIsPubliclySetTo: [number];
|
|
236
|
+
setWidth: [number];
|
|
237
|
+
setHeight: [number];
|
|
238
|
+
},
|
|
239
|
+
// "Thens" are steps which make assertions of the test subject
|
|
240
|
+
{
|
|
241
|
+
AreaPlusCircumference: [number];
|
|
242
|
+
circumference: [number];
|
|
243
|
+
getWidth: [number];
|
|
244
|
+
getHeight: [number];
|
|
245
|
+
area: [number];
|
|
246
|
+
prototype: [];
|
|
247
|
+
},
|
|
248
|
+
// "Checks" are similar to "Givens"
|
|
249
|
+
{
|
|
250
|
+
Default;
|
|
251
|
+
WidthOfOneAndHeightOfOne;
|
|
252
|
+
WidthAndHeightOf: [number, number];
|
|
253
|
+
}
|
|
254
|
+
>;
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### type M (optional)
|
|
258
|
+
|
|
259
|
+
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
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
export type M = {
|
|
263
|
+
givens: {
|
|
264
|
+
[K in keyof O["givens"]]: (...Iw: O["givens"][K]) => Rectangle;
|
|
265
|
+
};
|
|
266
|
+
whens: {
|
|
267
|
+
[K in keyof O["whens"]]: (
|
|
268
|
+
...Iw: O["whens"][K]
|
|
269
|
+
) => (rectangle: Rectangle, utils: PM) => Rectangle;
|
|
270
|
+
};
|
|
271
|
+
thens: {
|
|
272
|
+
[K in keyof O["thens"]]: (
|
|
273
|
+
...Iw: O["thens"][K]
|
|
274
|
+
) => (rectangle: Rectangle, utils: PM) => Rectangle;
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testeranto",
|
|
3
3
|
"description": "the AI powered BDD test framework for typescript projects",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.135.0",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "18.18.0"
|
|
7
7
|
},
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"import": "./dist/cjs-shim.js",
|
|
18
18
|
"require": "./dist/cjs-shim.js"
|
|
19
19
|
},
|
|
20
|
+
"./src/lib": {
|
|
21
|
+
"import": "./src/lib/index.ts",
|
|
22
|
+
"require": "./src/lib/index.ts"
|
|
23
|
+
},
|
|
20
24
|
"./src/lib/abstractBase": {
|
|
21
25
|
"import": "./src/lib/abstractBase.ts",
|
|
22
26
|
"require": "./src/lib/abstractBase.ts"
|
|
@@ -177,6 +181,7 @@
|
|
|
177
181
|
"esbuild-plugin-markdown": "^0.0.3",
|
|
178
182
|
"esbuild-plugin-polyfill-node": "^0.3.0",
|
|
179
183
|
"eslint": "^9.23.0",
|
|
184
|
+
"eslint-formatter-compact": "^8.40.0",
|
|
180
185
|
"eslint-plugin-import": "^2.31.0",
|
|
181
186
|
"eslint-plugin-react": "^7.31.11",
|
|
182
187
|
"eslint-plugin-react-hooks": "^5.1.0",
|
package/src/CoreTypes.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { ITTestResourceConfiguration } from "./lib";
|
|
2
|
+
|
|
3
|
+
import { IPM, ITestCheckCallback } from "./lib/types";
|
|
4
|
+
import {
|
|
5
|
+
GivenSpecification,
|
|
6
|
+
WhenSpecification,
|
|
7
|
+
ThenSpecification,
|
|
8
|
+
TestWhenImplementation,
|
|
9
|
+
Modify,
|
|
10
|
+
TestSuiteImplementation,
|
|
11
|
+
TestGivenImplementation,
|
|
12
|
+
TestThenImplementation,
|
|
13
|
+
TestCheckImplementation,
|
|
14
|
+
TestSuiteShape,
|
|
15
|
+
TestGivenShape,
|
|
16
|
+
TestWhenShape,
|
|
17
|
+
TestThenShape,
|
|
18
|
+
TestCheckShape,
|
|
19
|
+
SuiteSpecification,
|
|
20
|
+
} from "./Types";
|
|
21
|
+
|
|
22
|
+
/////////////////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
export type ITestInterface<
|
|
25
|
+
I extends Ibdd_in<
|
|
26
|
+
unknown,
|
|
27
|
+
unknown,
|
|
28
|
+
unknown,
|
|
29
|
+
unknown,
|
|
30
|
+
unknown,
|
|
31
|
+
unknown,
|
|
32
|
+
unknown
|
|
33
|
+
>
|
|
34
|
+
> = {
|
|
35
|
+
assertThis: (x: I["then"]) => any;
|
|
36
|
+
andWhen: (
|
|
37
|
+
store: I["istore"],
|
|
38
|
+
whenCB: I["when"],
|
|
39
|
+
testResource: ITTestResourceConfiguration,
|
|
40
|
+
pm: IPM
|
|
41
|
+
) => Promise<I["istore"]>;
|
|
42
|
+
butThen: (
|
|
43
|
+
store: I["istore"],
|
|
44
|
+
thenCB: I["then"],
|
|
45
|
+
testResource: ITTestResourceConfiguration,
|
|
46
|
+
pm: IPM
|
|
47
|
+
) => Promise<I["iselection"]>;
|
|
48
|
+
afterAll: (store: I["istore"], pm: IPM) => any;
|
|
49
|
+
afterEach: (store: I["istore"], key: string, pm: IPM) => Promise<unknown>;
|
|
50
|
+
beforeAll: (
|
|
51
|
+
input: I["iinput"],
|
|
52
|
+
testResource: ITTestResourceConfiguration,
|
|
53
|
+
pm: IPM
|
|
54
|
+
) => Promise<I["isubject"]>;
|
|
55
|
+
beforeEach: (
|
|
56
|
+
subject: I["isubject"],
|
|
57
|
+
initializer: (c?) => I["given"],
|
|
58
|
+
testResource: ITTestResourceConfiguration,
|
|
59
|
+
initialValues,
|
|
60
|
+
pm: IPM
|
|
61
|
+
) => Promise<I["istore"]>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/////////////////////////////////////////////////////////////////////////////////////////
|
|
65
|
+
|
|
66
|
+
export type ITestSpecification<
|
|
67
|
+
I extends Ibdd_in<
|
|
68
|
+
unknown,
|
|
69
|
+
unknown,
|
|
70
|
+
unknown,
|
|
71
|
+
unknown,
|
|
72
|
+
unknown,
|
|
73
|
+
unknown,
|
|
74
|
+
unknown
|
|
75
|
+
>,
|
|
76
|
+
O extends Ibdd_out<
|
|
77
|
+
TestSuiteShape,
|
|
78
|
+
TestGivenShape,
|
|
79
|
+
TestWhenShape,
|
|
80
|
+
TestThenShape,
|
|
81
|
+
TestCheckShape
|
|
82
|
+
>
|
|
83
|
+
> = (
|
|
84
|
+
Suite: SuiteSpecification<I, O>,
|
|
85
|
+
Given: GivenSpecification<I, O>,
|
|
86
|
+
When: WhenSpecification<I, O>,
|
|
87
|
+
Then: ThenSpecification<I, O>,
|
|
88
|
+
Check: ITestCheckCallback<I, O>
|
|
89
|
+
) => any[];
|
|
90
|
+
|
|
91
|
+
/////////////////////////////////////////////////////////////////////////////////////////
|
|
92
|
+
|
|
93
|
+
export type ITestImplementation<
|
|
94
|
+
I extends Ibdd_in<
|
|
95
|
+
unknown,
|
|
96
|
+
unknown,
|
|
97
|
+
unknown,
|
|
98
|
+
unknown,
|
|
99
|
+
unknown,
|
|
100
|
+
unknown,
|
|
101
|
+
unknown
|
|
102
|
+
>,
|
|
103
|
+
O extends Ibdd_out<
|
|
104
|
+
TestSuiteShape,
|
|
105
|
+
TestGivenShape,
|
|
106
|
+
TestWhenShape,
|
|
107
|
+
TestThenShape,
|
|
108
|
+
TestCheckShape
|
|
109
|
+
>,
|
|
110
|
+
modifier = {
|
|
111
|
+
whens: TestWhenImplementation<I, O>;
|
|
112
|
+
}
|
|
113
|
+
> = Modify<
|
|
114
|
+
{
|
|
115
|
+
suites: TestSuiteImplementation<O>;
|
|
116
|
+
givens: TestGivenImplementation<I, O>;
|
|
117
|
+
whens: TestWhenImplementation<I, O>;
|
|
118
|
+
thens: TestThenImplementation<I, O>;
|
|
119
|
+
checks: TestCheckImplementation<I, O>;
|
|
120
|
+
},
|
|
121
|
+
modifier
|
|
122
|
+
>;
|
|
123
|
+
|
|
124
|
+
/////////////////////////////////////////////////////////////////////////////////////////
|
|
125
|
+
|
|
126
|
+
export type Ibdd_out<
|
|
127
|
+
ISuites extends TestSuiteShape = TestSuiteShape,
|
|
128
|
+
IGivens extends TestGivenShape = TestGivenShape,
|
|
129
|
+
IWhens extends TestWhenShape = TestWhenShape,
|
|
130
|
+
IThens extends TestThenShape = TestThenShape,
|
|
131
|
+
IChecks extends TestCheckShape = TestCheckShape
|
|
132
|
+
> = {
|
|
133
|
+
suites: ISuites;
|
|
134
|
+
givens: IGivens;
|
|
135
|
+
whens: IWhens;
|
|
136
|
+
thens: IThens;
|
|
137
|
+
checks: IChecks;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/////////////////////////////////////////////////////////////////////////////////////////
|
|
141
|
+
|
|
142
|
+
export type Ibdd_in<
|
|
143
|
+
IInput, // Type of initial test input
|
|
144
|
+
ISubject, // Type of object being tested
|
|
145
|
+
IStore, // Type for storing test state between steps
|
|
146
|
+
ISelection, // Type for selecting state for assertions
|
|
147
|
+
IGiven, // Type for Given step functions
|
|
148
|
+
IWhen, // Type for When step functions
|
|
149
|
+
IThen // Type for Then step functions
|
|
150
|
+
> = {
|
|
151
|
+
/** Initial input required to start tests */
|
|
152
|
+
iinput: IInput;
|
|
153
|
+
|
|
154
|
+
/** The subject being tested (class, function, etc) */
|
|
155
|
+
isubject: ISubject;
|
|
156
|
+
|
|
157
|
+
/** Complete test state storage */
|
|
158
|
+
istore: IStore;
|
|
159
|
+
|
|
160
|
+
/** Selected portion of state for assertions */
|
|
161
|
+
iselection: ISelection;
|
|
162
|
+
|
|
163
|
+
/** Function type for Given steps */
|
|
164
|
+
given: IGiven;
|
|
165
|
+
|
|
166
|
+
/** Function type for When steps */
|
|
167
|
+
when: IWhen;
|
|
168
|
+
|
|
169
|
+
/** Function type for Then steps */
|
|
170
|
+
then: IThen;
|
|
171
|
+
};
|
package/src/Node.ts
CHANGED
|
@@ -4,23 +4,37 @@ import {
|
|
|
4
4
|
ITTestResourceConfiguration,
|
|
5
5
|
ITTestResourceRequest,
|
|
6
6
|
} from "./lib/index.js";
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import type {} from // INodeTestInterface,
|
|
8
|
+
// IT,
|
|
9
|
+
// ITestImplementation,
|
|
10
|
+
// ITestInterface,
|
|
11
|
+
// ITestSpecification,
|
|
12
|
+
// OT,
|
|
13
|
+
"./Types.js";
|
|
14
|
+
import { PM_Node } from "./PM/node.js";
|
|
15
|
+
import {
|
|
16
|
+
ITestSpecification,
|
|
10
17
|
ITestImplementation,
|
|
11
18
|
ITestInterface,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./
|
|
15
|
-
import { PM_Node } from "./PM/node.js";
|
|
19
|
+
Ibdd_in,
|
|
20
|
+
Ibdd_out,
|
|
21
|
+
} from "./CoreTypes.js";
|
|
16
22
|
|
|
17
23
|
let ipcfile;
|
|
18
24
|
|
|
19
|
-
export class NodeTesteranto<
|
|
20
|
-
I
|
|
21
|
-
|
|
25
|
+
export class NodeTesteranto<
|
|
26
|
+
I extends Ibdd_in<
|
|
27
|
+
unknown,
|
|
28
|
+
unknown,
|
|
29
|
+
unknown,
|
|
30
|
+
unknown,
|
|
31
|
+
unknown,
|
|
32
|
+
unknown,
|
|
33
|
+
unknown
|
|
34
|
+
>,
|
|
35
|
+
O extends Ibdd_out,
|
|
22
36
|
M
|
|
23
|
-
> {
|
|
37
|
+
> extends Testeranto<I, O, M> {
|
|
24
38
|
constructor(
|
|
25
39
|
input: I["iinput"],
|
|
26
40
|
testSpecification: ITestSpecification<I, O>,
|
|
@@ -145,8 +145,8 @@ export abstract class PM_WithEslintAndTsc extends PM_Base {
|
|
|
145
145
|
"testeranto",
|
|
146
146
|
"reports",
|
|
147
147
|
this.name,
|
|
148
|
-
platform,
|
|
149
148
|
entryPoint.split(".").slice(0, -1).join("."),
|
|
149
|
+
platform,
|
|
150
150
|
`tests.json`
|
|
151
151
|
);
|
|
152
152
|
|
|
@@ -159,6 +159,42 @@ export abstract class PM_WithEslintAndTsc extends PM_Base {
|
|
|
159
159
|
`featurePrompt.txt`
|
|
160
160
|
);
|
|
161
161
|
|
|
162
|
+
const logPath = path.join(
|
|
163
|
+
"testeranto",
|
|
164
|
+
"reports",
|
|
165
|
+
this.name,
|
|
166
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
167
|
+
platform,
|
|
168
|
+
`console_log.txt`
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const lintPath = path.join(
|
|
172
|
+
"testeranto",
|
|
173
|
+
"reports",
|
|
174
|
+
this.name,
|
|
175
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
176
|
+
platform,
|
|
177
|
+
`lint_errors.json`
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const typePath = path.join(
|
|
181
|
+
"testeranto",
|
|
182
|
+
"reports",
|
|
183
|
+
this.name,
|
|
184
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
185
|
+
platform,
|
|
186
|
+
`type_errors.txt`
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const messagePath = path.join(
|
|
190
|
+
"testeranto",
|
|
191
|
+
"reports",
|
|
192
|
+
this.name,
|
|
193
|
+
entryPoint.split(".").slice(0, -1).join("."),
|
|
194
|
+
platform,
|
|
195
|
+
`message`
|
|
196
|
+
);
|
|
197
|
+
|
|
162
198
|
fs.writeFileSync(
|
|
163
199
|
promptPath,
|
|
164
200
|
`
|
|
@@ -168,23 +204,18 @@ ${addableFiles
|
|
|
168
204
|
})
|
|
169
205
|
.join("\n")}
|
|
170
206
|
|
|
171
|
-
/read ${lintPather(entryPoint, platform, this.name)}
|
|
172
|
-
/read ${tscPather(entryPoint, platform, this.name)}
|
|
173
207
|
/read ${testPaths}
|
|
208
|
+
/read ${logPath}
|
|
209
|
+
/read ${typePath}
|
|
210
|
+
/read ${lintPath}
|
|
211
|
+
`
|
|
212
|
+
);
|
|
174
213
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
entryPoint,
|
|
179
|
-
platform,
|
|
180
|
-
this.name
|
|
181
|
-
)}. Implement any method which throws "Function not implemented. Resolve the lint errors described in ${lintPather(
|
|
182
|
-
entryPoint,
|
|
183
|
-
platform,
|
|
184
|
-
this.name
|
|
185
|
-
)}"
|
|
186
|
-
`
|
|
214
|
+
fs.writeFileSync(
|
|
215
|
+
messagePath,
|
|
216
|
+
`Fix the failing tests described in ${testPaths} and ${logPath}. DO NOT refactor beyond what is necessary. Always prefer minimal changes, focusing mostly on keeping the BDD tests passing`
|
|
187
217
|
);
|
|
218
|
+
|
|
188
219
|
this.summary[
|
|
189
220
|
entryPoint
|
|
190
221
|
].prompt = `aider --model deepseek/deepseek-chat --load testeranto/${
|
package/src/PM/index.ts
CHANGED
|
@@ -37,7 +37,7 @@ export abstract class PM {
|
|
|
37
37
|
abstract typeInto(selector: string, value: string): any;
|
|
38
38
|
abstract waitForSelector(p, sel: string);
|
|
39
39
|
abstract write(uid: number, contents: string): Promise<boolean>;
|
|
40
|
-
abstract writeFileSync(f: string, c: string
|
|
40
|
+
abstract writeFileSync(f: string, c: string): Promise<boolean>;
|
|
41
41
|
|
|
42
42
|
abstract launchSideCar(
|
|
43
43
|
n: number
|
package/src/PM/main.ts
CHANGED
|
@@ -238,7 +238,7 @@ export class PM_Main extends PM_WithEslintAndTsc {
|
|
|
238
238
|
waitForInitialPage: false,
|
|
239
239
|
executablePath,
|
|
240
240
|
|
|
241
|
-
headless:
|
|
241
|
+
headless: true,
|
|
242
242
|
|
|
243
243
|
dumpio: false,
|
|
244
244
|
devtools: false,
|
|
@@ -703,9 +703,14 @@ export class PM_Main extends PM_WithEslintAndTsc {
|
|
|
703
703
|
let haltReturns = false;
|
|
704
704
|
|
|
705
705
|
const ipcfile = "/tmp/tpipe_" + Math.random();
|
|
706
|
-
const child = spawn(
|
|
707
|
-
|
|
708
|
-
|
|
706
|
+
const child = spawn(
|
|
707
|
+
"node",
|
|
708
|
+
// "node --inspect-brk ",
|
|
709
|
+
[builtfile, testResources, ipcfile],
|
|
710
|
+
{
|
|
711
|
+
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
712
|
+
}
|
|
713
|
+
);
|
|
709
714
|
|
|
710
715
|
let buffer: Buffer<ArrayBufferLike> = new Buffer("");
|
|
711
716
|
|
|
@@ -770,7 +775,6 @@ export class PM_Main extends PM_WithEslintAndTsc {
|
|
|
770
775
|
oStream.write(`stdout > ${data}`);
|
|
771
776
|
});
|
|
772
777
|
child.on("close", (code) => {
|
|
773
|
-
console.log("close");
|
|
774
778
|
oStream.close();
|
|
775
779
|
server.close();
|
|
776
780
|
|
|
@@ -790,7 +794,6 @@ export class PM_Main extends PM_WithEslintAndTsc {
|
|
|
790
794
|
haltReturns = true;
|
|
791
795
|
});
|
|
792
796
|
child.on("exit", (code) => {
|
|
793
|
-
console.log("exit");
|
|
794
797
|
haltReturns = true;
|
|
795
798
|
|
|
796
799
|
for (let i = 0; i <= portsToUse.length; i++) {
|
|
@@ -798,8 +801,6 @@ export class PM_Main extends PM_WithEslintAndTsc {
|
|
|
798
801
|
this.ports[portsToUse[i]] = true; //port is open again
|
|
799
802
|
}
|
|
800
803
|
}
|
|
801
|
-
|
|
802
|
-
console.log("exitthis.ports", this.ports);
|
|
803
804
|
});
|
|
804
805
|
child.on("error", (e) => {
|
|
805
806
|
console.log("error");
|
|
@@ -852,10 +853,10 @@ export class PM_Main extends PM_WithEslintAndTsc {
|
|
|
852
853
|
}
|
|
853
854
|
// files[t].add(filepath);
|
|
854
855
|
|
|
855
|
-
fs.writeFileSync(
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
);
|
|
856
|
+
// fs.writeFileSync(
|
|
857
|
+
// destFolder + "/manifest.json",
|
|
858
|
+
// JSON.stringify(Array.from(files[src]))
|
|
859
|
+
// );
|
|
859
860
|
delete files[src];
|
|
860
861
|
|
|
861
862
|
Promise.all(screenshots[src] || []).then(() => {
|
|
@@ -1254,10 +1255,10 @@ export class PM_Main extends PM_WithEslintAndTsc {
|
|
|
1254
1255
|
}
|
|
1255
1256
|
// files[t].add(filepath);
|
|
1256
1257
|
|
|
1257
|
-
fs.writeFileSync(
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
);
|
|
1258
|
+
// fs.writeFileSync(
|
|
1259
|
+
// destFolder + "/manifest.json",
|
|
1260
|
+
// JSON.stringify(Array.from(files[src]))
|
|
1261
|
+
// );
|
|
1261
1262
|
delete files[src];
|
|
1262
1263
|
|
|
1263
1264
|
Promise.all(screenshots[src] || []).then(() => {
|