@step-forge/step-forge 0.0.5 → 0.0.7-beta
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/dist/types/src/builderTypeUtils.d.ts +14 -0
- package/dist/types/src/common.d.ts +32 -0
- package/dist/types/src/given.d.ts +73 -0
- package/{src/index.ts → dist/types/src/index.d.ts} +0 -1
- package/dist/types/src/then.d.ts +73 -0
- package/dist/types/src/utils.d.ts +5 -0
- package/dist/types/src/when.d.ts +72 -0
- package/dist/types/src/world.d.ts +21 -0
- package/package.json +9 -8
- package/.eslintignore +0 -6
- package/.eslintrc +0 -18
- package/.prettierignore +0 -6
- package/.prettierrc +0 -15
- package/CHANGELOG.md +0 -28
- package/cucumber.mjs +0 -38
- package/docs/assets/state_deps.gif +0 -0
- package/dts-bundle-generator.config.ts +0 -11
- package/features/basic.feature +0 -21
- package/features/exported.feature +0 -6
- package/features/steps/commonSteps.ts +0 -93
- package/features/steps/exportedSteps.ts +0 -42
- package/features/steps/world.ts +0 -29
- package/src/builderTypeUtils.ts +0 -27
- package/src/common.ts +0 -138
- package/src/given.ts +0 -102
- package/src/then.ts +0 -128
- package/src/utils.ts +0 -74
- package/src/vite-env.d.ts.old +0 -1
- package/src/when.ts +0 -118
- package/src/world.ts +0 -90
- package/test/givenCompilationTests.ts +0 -130
- package/test/testUtils.ts +0 -30
- package/test/thenCompilationTests.ts +0 -207
- package/test/whenCompilationTests.ts +0 -157
- package/ts-node-esm-register.js +0 -8
- package/tsconfig.cucumber.json +0 -23
- package/tsconfig.json +0 -26
- package/vite.config.ts +0 -36
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { givenBuilder } from "../src/given";
|
|
2
|
-
import { SampleGivenState } from "./testUtils";
|
|
3
|
-
|
|
4
|
-
// Simplest possible example
|
|
5
|
-
givenBuilder<SampleGivenState>()
|
|
6
|
-
.statement("Given a user")
|
|
7
|
-
.step(() => {
|
|
8
|
-
return {
|
|
9
|
-
a: "user",
|
|
10
|
-
};
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// Simple dependency example
|
|
14
|
-
givenBuilder<SampleGivenState>()
|
|
15
|
-
.statement("Given a user")
|
|
16
|
-
.dependencies({
|
|
17
|
-
given: {
|
|
18
|
-
a: "required",
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
.step(({ given }) => {
|
|
22
|
-
return {
|
|
23
|
-
b: `I love ${given.a}`,
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Simple variables example
|
|
28
|
-
givenBuilder<SampleGivenState>()
|
|
29
|
-
.statement((v1: string, v2: number) => `Given a user ${v1} ${v2}`)
|
|
30
|
-
.step(({ variables: [v1, v2] }) => {
|
|
31
|
-
return {
|
|
32
|
-
b: `I love ${v1} ${v2}`,
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Complex example
|
|
37
|
-
givenBuilder<SampleGivenState>()
|
|
38
|
-
.statement((v1: string, v2: number) => `Given a user ${v1} ${v2}`)
|
|
39
|
-
.dependencies({
|
|
40
|
-
given: {
|
|
41
|
-
a: "required",
|
|
42
|
-
b: "optional",
|
|
43
|
-
c: "required",
|
|
44
|
-
},
|
|
45
|
-
})
|
|
46
|
-
.step(({ variables: [v1, v2], given: { a, b, c } }) => {
|
|
47
|
-
return {
|
|
48
|
-
b: `I love ${v1} ${v2} ${a} ${b} ${c}`,
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// ----- Should not compile section ----
|
|
53
|
-
|
|
54
|
-
// @ts-expect-error - Should not compile without a statement
|
|
55
|
-
givenBuilder<SampleGivenState>().step(() => {
|
|
56
|
-
return {
|
|
57
|
-
a: "user",
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
givenBuilder<SampleGivenState>()
|
|
62
|
-
.statement(() => "Given a user")
|
|
63
|
-
// @ts-expect-error - Should not compile since no variables are declared
|
|
64
|
-
.step(({ variables: [v1, v2] }) => {
|
|
65
|
-
return {
|
|
66
|
-
a: `I love ${v1} ${v2}`,
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// TODO: Currently resolves variables to `any[]` which is incorrect
|
|
71
|
-
givenBuilder<SampleGivenState>()
|
|
72
|
-
.statement("Given a user")
|
|
73
|
-
// @ts-expect-error - Should not compile since no variables are declared
|
|
74
|
-
.step(({ variables: [v1, v2] }) => {
|
|
75
|
-
return {
|
|
76
|
-
a: `I love ${v1} ${v2}`,
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
givenBuilder<SampleGivenState>()
|
|
81
|
-
.statement(
|
|
82
|
-
(v1: string, v2: number, v3: boolean) => `Given a user ${v1} ${v2} ${v3}`
|
|
83
|
-
)
|
|
84
|
-
// @ts-expect-error - Should not compile since the number of variables exceeds the number declared
|
|
85
|
-
.step(({ variables: [v1, v2, v3, v4] }) => {
|
|
86
|
-
return {
|
|
87
|
-
a: `I love ${v1} ${v2} ${v3} ${v4}`,
|
|
88
|
-
};
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
givenBuilder<SampleGivenState>()
|
|
92
|
-
.statement("Given a user")
|
|
93
|
-
.dependencies({ given: { a: "required" } })
|
|
94
|
-
.step(({ given }) => {
|
|
95
|
-
return {
|
|
96
|
-
// @ts-expect-error - Should not compile if we attempt to access a part of state that was not declared as a dependency
|
|
97
|
-
b: `I love ${given.b}`,
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
givenBuilder<SampleGivenState>()
|
|
102
|
-
.statement("a user")
|
|
103
|
-
// @ts-expect-error - Should not compile if we attempt to access a part of state that was not declared as a dependency
|
|
104
|
-
.dependencies({ when: { a: "required" } })
|
|
105
|
-
.step(({ when }) => {
|
|
106
|
-
return {
|
|
107
|
-
// @ts-expect-error - Should not compile if we attempt to access a part of state that was not declared as a dependency
|
|
108
|
-
b: `I love ${when.c}`,
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
givenBuilder<SampleGivenState>()
|
|
113
|
-
.statement("Given a user")
|
|
114
|
-
.dependencies({ given: { a: "optional" } })
|
|
115
|
-
.step(({ given }) => {
|
|
116
|
-
// @ts-expect-error - Should not compile since a is optional and can be undefined
|
|
117
|
-
const strictA: string = given.a;
|
|
118
|
-
return {
|
|
119
|
-
b: `I love ${strictA}`,
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
givenBuilder<SampleGivenState>()
|
|
124
|
-
.statement("Given a user")
|
|
125
|
-
// @ts-expect-error - Should not compile since the return type is not a partial of given state
|
|
126
|
-
.step(() => {
|
|
127
|
-
return {
|
|
128
|
-
f: "hello",
|
|
129
|
-
};
|
|
130
|
-
});
|
package/test/testUtils.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createBasicWorld } from "../src/world";
|
|
2
|
-
|
|
3
|
-
export const sampleGivenState = {
|
|
4
|
-
a: "stuff",
|
|
5
|
-
b: "things",
|
|
6
|
-
c: 3,
|
|
7
|
-
};
|
|
8
|
-
export type SampleGivenState = typeof sampleGivenState;
|
|
9
|
-
|
|
10
|
-
export const sampleWhenState = {
|
|
11
|
-
d: 1,
|
|
12
|
-
e: "other stuff",
|
|
13
|
-
f: [3, 4, 5],
|
|
14
|
-
};
|
|
15
|
-
export type SampleWhenState = typeof sampleWhenState;
|
|
16
|
-
|
|
17
|
-
export const sampleThenState = {
|
|
18
|
-
g: 1,
|
|
19
|
-
h: 2,
|
|
20
|
-
i: { j: "k" },
|
|
21
|
-
};
|
|
22
|
-
export type SampleThenState = typeof sampleThenState;
|
|
23
|
-
|
|
24
|
-
export const sampleWorld = createBasicWorld<
|
|
25
|
-
SampleGivenState,
|
|
26
|
-
SampleWhenState,
|
|
27
|
-
SampleThenState
|
|
28
|
-
>();
|
|
29
|
-
|
|
30
|
-
export type SampleWorld = typeof sampleWorld;
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { thenBuilder } from "../src/then";
|
|
2
|
-
import {
|
|
3
|
-
SampleGivenState,
|
|
4
|
-
SampleThenState,
|
|
5
|
-
SampleWhenState,
|
|
6
|
-
} from "./testUtils";
|
|
7
|
-
|
|
8
|
-
// Simplest possible example
|
|
9
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
10
|
-
.statement("Then we should see something")
|
|
11
|
-
.step(() => {
|
|
12
|
-
return {
|
|
13
|
-
i: { j: "result" },
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// Simple dependency on given state example
|
|
18
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
19
|
-
.statement("Then we should see something")
|
|
20
|
-
.dependencies({
|
|
21
|
-
given: {
|
|
22
|
-
a: "required",
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
.step(({ given }) => {
|
|
26
|
-
return {
|
|
27
|
-
i: { j: `Result with ${given.a}` },
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Simple dependency on when state example
|
|
32
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
33
|
-
.statement("Then we should see something")
|
|
34
|
-
.dependencies({
|
|
35
|
-
when: {
|
|
36
|
-
d: "required",
|
|
37
|
-
},
|
|
38
|
-
})
|
|
39
|
-
.step(({ when }) => {
|
|
40
|
-
return {
|
|
41
|
-
i: { j: `Result with ${when.d}` },
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Simple dependency on then state example
|
|
46
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
47
|
-
.statement("Then we should see something")
|
|
48
|
-
.dependencies({
|
|
49
|
-
then: {
|
|
50
|
-
g: "required",
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
.step(({ then }) => {
|
|
54
|
-
return {
|
|
55
|
-
i: { j: `Result with ${then.g}` },
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// Simple variables example
|
|
60
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
61
|
-
.statement((v1: string, v2: number) => `Then we should see ${v1} ${v2} times`)
|
|
62
|
-
.step(({ variables: [v1, v2] }) => {
|
|
63
|
-
return {
|
|
64
|
-
i: { j: `Result ${v1} ${v2}` },
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Complex example with all dependencies
|
|
69
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
70
|
-
.statement((v1: string, v2: number) => `Then we should see ${v1} ${v2} times`)
|
|
71
|
-
.dependencies({
|
|
72
|
-
given: {
|
|
73
|
-
a: "required",
|
|
74
|
-
b: "optional",
|
|
75
|
-
},
|
|
76
|
-
when: {
|
|
77
|
-
d: "required",
|
|
78
|
-
e: "optional",
|
|
79
|
-
},
|
|
80
|
-
then: {
|
|
81
|
-
g: "required",
|
|
82
|
-
h: "optional",
|
|
83
|
-
},
|
|
84
|
-
})
|
|
85
|
-
.step(
|
|
86
|
-
({
|
|
87
|
-
variables: [v1, v2],
|
|
88
|
-
given: { a, b },
|
|
89
|
-
when: { d, e },
|
|
90
|
-
then: { g, h },
|
|
91
|
-
}) => {
|
|
92
|
-
return {
|
|
93
|
-
i: { j: `Result ${v1} ${v2} with ${a} ${b} ${d} ${e} ${g} ${h}` },
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
// ----- Should not compile section ----
|
|
99
|
-
|
|
100
|
-
// @ts-expect-error - Should not compile without a statement
|
|
101
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>().step(() => {
|
|
102
|
-
return {
|
|
103
|
-
i: { j: "result" },
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
108
|
-
.statement(() => "Then we should see something")
|
|
109
|
-
// @ts-expect-error - Should not compile since no variables are declared
|
|
110
|
-
.step(({ variables: [v1, v2] }) => {
|
|
111
|
-
return {
|
|
112
|
-
i: { j: `Result ${v1} ${v2}` },
|
|
113
|
-
};
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
117
|
-
.statement("Then we should see something")
|
|
118
|
-
// @ts-expect-error - Should not compile since no variables are declared
|
|
119
|
-
.step(({ variables: [v1, v2] }) => {
|
|
120
|
-
return {
|
|
121
|
-
i: { j: `Result ${v1} ${v2}` },
|
|
122
|
-
};
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
126
|
-
.statement(
|
|
127
|
-
(v1: string, v2: number, v3: boolean) =>
|
|
128
|
-
`Then we should see ${v1} ${v2} ${v3}`
|
|
129
|
-
)
|
|
130
|
-
// @ts-expect-error - Should not compile since the number of variables exceeds the number declared
|
|
131
|
-
.step(({ variables: [v1, v2, v3, v4] }) => {
|
|
132
|
-
return {
|
|
133
|
-
i: { j: `Result ${v1} ${v2} ${v3} ${v4}` },
|
|
134
|
-
};
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
138
|
-
.statement("Then we should see something")
|
|
139
|
-
.dependencies({ given: { a: "required" } })
|
|
140
|
-
.step(({ given }) => {
|
|
141
|
-
return {
|
|
142
|
-
// @ts-expect-error - Should not compile if we attempt to access a part of state that was not declared as a dependency
|
|
143
|
-
i: { j: `Result ${given.b}` },
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
148
|
-
.statement("Then we should see something")
|
|
149
|
-
.dependencies({ when: { d: "required" } })
|
|
150
|
-
.step(({ when }) => {
|
|
151
|
-
return {
|
|
152
|
-
// @ts-expect-error - Should not compile if we attempt to access a part of state that was not declared as a dependency
|
|
153
|
-
i: { j: `Result ${when.f}` },
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
158
|
-
.statement("Then we should see something")
|
|
159
|
-
.dependencies({ then: { g: "required" } })
|
|
160
|
-
.step(({ then }) => {
|
|
161
|
-
return {
|
|
162
|
-
// @ts-expect-error - Should not compile if we attempt to access a part of state that was not declared as a dependency
|
|
163
|
-
i: { j: `Result ${then.i}` },
|
|
164
|
-
};
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
168
|
-
.statement("Then we should see something")
|
|
169
|
-
.dependencies({ given: { a: "optional" } })
|
|
170
|
-
.step(({ given }) => {
|
|
171
|
-
// @ts-expect-error - Should not compile since a is optional and can be undefined
|
|
172
|
-
const strictA: string = given.a;
|
|
173
|
-
return {
|
|
174
|
-
i: { j: `Result ${strictA}` },
|
|
175
|
-
};
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
179
|
-
.statement("Then we should see something")
|
|
180
|
-
.dependencies({ when: { e: "optional" } })
|
|
181
|
-
.step(({ when }) => {
|
|
182
|
-
// @ts-expect-error - Should not compile since e is optional and can be undefined
|
|
183
|
-
const strictE: string = when.e;
|
|
184
|
-
return {
|
|
185
|
-
i: { j: `Result ${strictE}` },
|
|
186
|
-
};
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
190
|
-
.statement("Then we should see something")
|
|
191
|
-
.dependencies({ then: { h: "optional" } })
|
|
192
|
-
.step(({ then }) => {
|
|
193
|
-
// @ts-expect-error - Should not compile since h is optional and can be undefined
|
|
194
|
-
const strictH: string = then.h;
|
|
195
|
-
return {
|
|
196
|
-
i: { j: `Result ${strictH}` },
|
|
197
|
-
};
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
thenBuilder<SampleGivenState, SampleWhenState, SampleThenState>()
|
|
201
|
-
.statement("Then we should see something")
|
|
202
|
-
// @ts-expect-error - Should not compile since the return type is not a partial of then state
|
|
203
|
-
.step(() => {
|
|
204
|
-
return {
|
|
205
|
-
a: "hello",
|
|
206
|
-
};
|
|
207
|
-
});
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { whenBuilder } from "../src/when";
|
|
2
|
-
import { SampleGivenState, SampleWhenState } from "./testUtils";
|
|
3
|
-
|
|
4
|
-
// Simplest possible example
|
|
5
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
6
|
-
.statement("When a user does something")
|
|
7
|
-
.step(() => {
|
|
8
|
-
return {
|
|
9
|
-
e: "action",
|
|
10
|
-
};
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// Simple dependency on given state example
|
|
14
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
15
|
-
.statement("When a user does something")
|
|
16
|
-
.dependencies({
|
|
17
|
-
given: {
|
|
18
|
-
a: "required",
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
.step(({ given }) => {
|
|
22
|
-
return {
|
|
23
|
-
e: `Action with ${given.a}`,
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Simple dependency on when state example
|
|
28
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
29
|
-
.statement("When a user does something")
|
|
30
|
-
.dependencies({
|
|
31
|
-
when: {
|
|
32
|
-
d: "required",
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
.step(({ when }) => {
|
|
36
|
-
return {
|
|
37
|
-
e: `Action with ${when.d}`,
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Simple variables example
|
|
42
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
43
|
-
.statement((v1: string, v2: number) => `When a user does ${v1} ${v2} times`)
|
|
44
|
-
.step(({ variables: [v1, v2] }) => {
|
|
45
|
-
return {
|
|
46
|
-
e: `Action ${v1} ${v2}`,
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// Complex example with both dependencies
|
|
51
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
52
|
-
.statement((v1: string, v2: number) => `When a user does ${v1} ${v2} times`)
|
|
53
|
-
.dependencies({
|
|
54
|
-
given: {
|
|
55
|
-
a: "required",
|
|
56
|
-
b: "optional",
|
|
57
|
-
},
|
|
58
|
-
when: {
|
|
59
|
-
d: "required",
|
|
60
|
-
e: "optional",
|
|
61
|
-
},
|
|
62
|
-
})
|
|
63
|
-
.step(({ variables: [v1, v2], given: { a, b }, when: { d, e } }) => {
|
|
64
|
-
return {
|
|
65
|
-
e: `Action ${v1} ${v2} with ${a} ${b} ${d} ${e}`,
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// ----- Should not compile section ----
|
|
70
|
-
|
|
71
|
-
// @ts-expect-error - Should not compile without a statement
|
|
72
|
-
whenBuilder<SampleGivenState, SampleWhenState>().step(() => {
|
|
73
|
-
return {
|
|
74
|
-
a: "action",
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
79
|
-
.statement(() => "When a user does something")
|
|
80
|
-
// @ts-expect-error - Should not compile since no variables are declared
|
|
81
|
-
.step(({ variables: [v1, v2] }) => {
|
|
82
|
-
return {
|
|
83
|
-
a: `Action ${v1} ${v2}`,
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
88
|
-
.statement("When a user does something")
|
|
89
|
-
// @ts-expect-error - Should not compile since no variables are declared
|
|
90
|
-
.step(({ variables: [v1, v2] }) => {
|
|
91
|
-
return {
|
|
92
|
-
a: `Action ${v1} ${v2}`,
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
97
|
-
.statement(
|
|
98
|
-
(v1: string, v2: number, v3: boolean) =>
|
|
99
|
-
`When a user does ${v1} ${v2} ${v3}`
|
|
100
|
-
)
|
|
101
|
-
// @ts-expect-error - Should not compile since the number of variables exceeds the number declared
|
|
102
|
-
.step(({ variables: [v1, v2, v3, v4] }) => {
|
|
103
|
-
return {
|
|
104
|
-
a: `Action ${v1} ${v2} ${v3} ${v4}`,
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
109
|
-
.statement("When a user does something")
|
|
110
|
-
.dependencies({ given: { a: "required" } })
|
|
111
|
-
.step(({ given }) => {
|
|
112
|
-
return {
|
|
113
|
-
// @ts-expect-error - Should not compile if we attempt to access a part of state that was not declared as a dependency
|
|
114
|
-
e: `Action ${given.b}`,
|
|
115
|
-
};
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
119
|
-
.statement("When a user does something")
|
|
120
|
-
.dependencies({ when: { d: "required" } })
|
|
121
|
-
.step(({ when }) => {
|
|
122
|
-
return {
|
|
123
|
-
// @ts-expect-error - Should not compile if we attempt to access a part of state that was not declared as a dependency
|
|
124
|
-
e: `Action ${when.f}`,
|
|
125
|
-
};
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
129
|
-
.statement("When a user does something")
|
|
130
|
-
.dependencies({ given: { a: "optional" } })
|
|
131
|
-
.step(({ given }) => {
|
|
132
|
-
// @ts-expect-error - Should not compile since a is optional and can be undefined
|
|
133
|
-
const strictA: string = given.a;
|
|
134
|
-
return {
|
|
135
|
-
e: `Action ${strictA}`,
|
|
136
|
-
};
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
140
|
-
.statement("When a user does something")
|
|
141
|
-
.dependencies({ when: { e: "optional" } })
|
|
142
|
-
.step(({ when }) => {
|
|
143
|
-
// @ts-expect-error - Should not compile since a is optional and can be undefined
|
|
144
|
-
const strictE: string = when.e;
|
|
145
|
-
return {
|
|
146
|
-
f: [strictE.length],
|
|
147
|
-
};
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
whenBuilder<SampleGivenState, SampleWhenState>()
|
|
151
|
-
.statement("When a user does something")
|
|
152
|
-
// @ts-expect-error - Should not compile since the return type is not a partial of when state
|
|
153
|
-
.step(() => {
|
|
154
|
-
return {
|
|
155
|
-
a: "hello",
|
|
156
|
-
};
|
|
157
|
-
});
|
package/ts-node-esm-register.js
DELETED
package/tsconfig.cucumber.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"allowImportingTsExtensions": true,
|
|
9
|
-
"noEmit": true,
|
|
10
|
-
"moduleDetection": "force",
|
|
11
|
-
"baseUrl": ".",
|
|
12
|
-
"paths": {
|
|
13
|
-
"@/*": ["./src/*"],
|
|
14
|
-
"@@/*": ["./*"]
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"ts-node": {
|
|
18
|
-
"esm": true,
|
|
19
|
-
"experimentalSpecifierResolution": "node"
|
|
20
|
-
},
|
|
21
|
-
"include": ["features/**/*.ts", "src/**/*.ts"],
|
|
22
|
-
"exclude": ["node_modules", "src/vite-env.d.ts"]
|
|
23
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"rootDir": ".",
|
|
4
|
-
"paths": {
|
|
5
|
-
"@/*": ["./src/*"],
|
|
6
|
-
"@@/*": ["./*"]
|
|
7
|
-
},
|
|
8
|
-
"target": "ESNext",
|
|
9
|
-
"useDefineForClassFields": true,
|
|
10
|
-
"module": "ESNext",
|
|
11
|
-
"lib": ["ESNext", "DOM"],
|
|
12
|
-
"moduleResolution": "Node",
|
|
13
|
-
"strict": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"esModuleInterop": true,
|
|
17
|
-
"noEmit": true,
|
|
18
|
-
"noUnusedLocals": true,
|
|
19
|
-
"noUnusedParameters": true,
|
|
20
|
-
"noImplicitReturns": true,
|
|
21
|
-
"forceConsistentCasingInFileNames": true,
|
|
22
|
-
"types": ["vite/client", "node"]
|
|
23
|
-
},
|
|
24
|
-
"include": ["src"],
|
|
25
|
-
"exclude": ["**/*.test.ts", "node_modules", "test/**", ".history/**"]
|
|
26
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/// <reference types="vitest" />
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { defineConfig } from "vite";
|
|
4
|
-
import packageJson from "./package.json";
|
|
5
|
-
|
|
6
|
-
const getPackageName = () => {
|
|
7
|
-
return packageJson.name;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const fileName = {
|
|
11
|
-
es: `${getPackageName()}.js`,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const formats = Object.keys(fileName) as Array<keyof typeof fileName>;
|
|
15
|
-
|
|
16
|
-
export default defineConfig({
|
|
17
|
-
base: "./",
|
|
18
|
-
build: {
|
|
19
|
-
outDir: "./build/dist",
|
|
20
|
-
lib: {
|
|
21
|
-
entry: path.resolve(__dirname, "src/index.ts"),
|
|
22
|
-
name: `step-forge`,
|
|
23
|
-
formats,
|
|
24
|
-
fileName: format => fileName[format],
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
test: {
|
|
28
|
-
watch: false,
|
|
29
|
-
},
|
|
30
|
-
resolve: {
|
|
31
|
-
alias: [
|
|
32
|
-
{ find: "@", replacement: path.resolve(__dirname, "src") },
|
|
33
|
-
{ find: "@@", replacement: path.resolve(__dirname) },
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
});
|