racejar 2.0.0 → 2.0.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/dist/_chunks-dts/step-definitions.d.ts +2 -1
- package/dist/_chunks-dts/step-definitions.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/jest/index.d.ts +2 -1
- package/dist/jest/index.d.ts.map +1 -0
- package/dist/playwright/index.d.ts +2 -1
- package/dist/playwright/index.d.ts.map +1 -0
- package/dist/vitest/index.d.ts +2 -1
- package/dist/vitest/index.d.ts.map +1 -0
- package/package.json +6 -6
- package/src/compile-feature.ts +0 -178
- package/src/create-parameter-type.ts +0 -29
- package/src/hooks.ts +0 -32
- package/src/index.ts +0 -4
- package/src/jest/index.ts +0 -1
- package/src/jest/jest-gherkin-driver.ts +0 -59
- package/src/playwright/index.ts +0 -1
- package/src/playwright/playwright-gherkin-driver.ts +0 -89
- package/src/step-definitions.ts +0 -83
- package/src/vitest/index.ts +0 -1
- package/src/vitest/vitest-gherkin-driver.ts +0 -59
|
@@ -41,4 +41,5 @@ declare function When<TContext extends Record<string, any> = object, TParamA = u
|
|
|
41
41
|
* @public
|
|
42
42
|
*/
|
|
43
43
|
declare function Then<TContext extends Record<string, any> = object, TParamA = undefined, TParamB = undefined, TParamC = undefined>(text: string, callback: StepDefinitionCallback<TContext, TParamA, TParamB, TParamC>): StepDefinition<TContext, TParamA, TParamB, TParamC>;
|
|
44
|
-
export { When as a, Hook as c, Then as i, HookCallback as l, StepDefinition as n, After as o, StepDefinitionCallback as r, Before as s, Given as t };
|
|
44
|
+
export { When as a, Hook as c, Then as i, HookCallback as l, StepDefinition as n, After as o, StepDefinitionCallback as r, Before as s, Given as t };
|
|
45
|
+
//# sourceMappingURL=step-definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-definitions.d.ts","names":[],"sources":["../../src/hooks.ts","../../src/step-definitions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,ECqCY,ODrCZ,ECqCqB,ODrCrB,CAAA;;;;AAClB,iBC2CS,ID3CT,CAAA,iBC4CY,MD5CZ,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,MAAA,EAAA,UAAA,SAAA,EAAA,UAAA,SAAA,EAAA,UAAA,SAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,QAAA,ECkDK,sBDlDL,CCkD4B,QDlD5B,ECkDsC,ODlDtC,ECkD+C,ODlD/C,ECkDwD,ODlDxD,CAAA,CAAA,ECmDJ,cDnDI,CCmDW,QDnDX,ECmDqB,ODnDrB,ECmD8B,ODnD9B,ECmDuC,ODnDvC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -41,4 +41,5 @@ type ParameterTypeConfig<TType = string> = {
|
|
|
41
41
|
* @public
|
|
42
42
|
*/
|
|
43
43
|
declare function createParameterType<TType = string>(config: ParameterTypeConfig<TType>): ParameterType<TType>;
|
|
44
|
-
export { After, Before, CompiledFeature, Given, Hook, HookCallback, type ParameterType, ParameterTypeConfig, StepDefinition, StepDefinitionCallback, Then, When, compileFeature, createParameterType };
|
|
44
|
+
export { After, Before, CompiledFeature, Given, Hook, HookCallback, type ParameterType, ParameterTypeConfig, StepDefinition, StepDefinitionCallback, Then, When, compileFeature, createParameterType };
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/compile-feature.ts","../src/create-parameter-type.ts"],"sourcesContent":[],"mappings":";;AAaA;;;AAOmD,KAPvC,eAOuC,CAAA,qBAPF,MAOE,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,MAAA,CAAA,GAAA;EAAtC,IAAA,EAAA,MAAA;EAHE,GAAA,EAAA,MAAA,GAAA,MAAA,GAAA,SAAA;EAKuB,SAAA,EALvB,KAKuB,CAAA;IAAiB,IAAA,EAAA,MAAA;IAAtC,GAAA,EAAA,MAAA,GAAA,MAAA,GAA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A,CAAA,MAAA,ECLN,mBDKM,CCLc,KDKd,CAAA,CAAA,ECJb,aDIa,CCJC,KDID,CAAA"}
|
package/dist/jest/index.d.ts
CHANGED
|
@@ -14,4 +14,5 @@ declare function Feature<TContext extends Record<string, any> = object>({
|
|
|
14
14
|
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>;
|
|
15
15
|
parameterTypes?: Array<ParameterType<unknown>>;
|
|
16
16
|
}): void;
|
|
17
|
-
export { Feature };
|
|
17
|
+
export { Feature };
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/jest/jest-gherkin-driver.ts"],"sourcesContent":[],"mappings":";;AASA;;;AAEE,iBAFc,OAEd,CAAA,iBAFuC,MAEvC,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,MAAA,CAAA,CAAA;EAAA,WAAA;EAAA,KAAA;EAAA,eAAA;EAAA;CAAA,EAAA;EACA,WAAA,EAAA,MAAA;EACA,KAAA,EAGO,KAHP,CAGa,IAHb,CAGkB,QAHlB,CAAA,CAAA;EAGkB,eAAA,EACD,KADC,CACK,cADL,CACoB,QADpB,EAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,CAAA;EAAL,cAAA,CAAA,EAEI,KAFJ,CAEU,aAFV,CAAA,OAAA,CAAA,CAAA;CAAN,CAAA,EAAA,IAAA"}
|
|
@@ -22,4 +22,5 @@ declare function Feature<TContext extends PlaywrightContext = PlaywrightContext>
|
|
|
22
22
|
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>;
|
|
23
23
|
parameterTypes?: Array<ParameterType<unknown>>;
|
|
24
24
|
}): void;
|
|
25
|
-
export { Feature, PlaywrightContext };
|
|
25
|
+
export { Feature, PlaywrightContext };
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/playwright/playwright-gherkin-driver.ts"],"sourcesContent":[],"mappings":";;;AAUuD,KAElD,iBAAA,GAAoB,kBAAH,GACpB,qBADoB,GAEpB,oBAFoB,GAGpB,uBAHoB;;;;AAGpB,KAKU,iBAAA,GAAoB,MAL9B,CAAA,QAAA,EAAA,GAAA,CAAA,GAAA;EAAuB,UAAA,EAMX,iBANW;AAKzB,CAAA;AAOA;;;AAGE,iBAHc,OAGd,CAAA,iBAFiB,iBAEjB,GAFqC,iBAErC,CAAA,CAAA;EAAA,WAAA;EAAA,KAAA;EAAA,eAAA;EAAA;CAAA,EAAA;EACA,WAAA,EAAA,MAAA;EACA,KAAA,CAAA,EAIQ,KAJR,CAIc,IAJd,CAImB,QAJnB,CAAA,CAAA;EACA,eAAA,EAIiB,KAJjB,CAIuB,cAJvB,CAIsC,QAJtC,EAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,CAAA;EAGmB,cAAA,CAAA,EAEF,KAFE,CAEI,aAFJ,CAAA,OAAA,CAAA,CAAA;CAAL,CAAA,EAAA,IAAA"}
|
package/dist/vitest/index.d.ts
CHANGED
|
@@ -14,4 +14,5 @@ declare function Feature<TContext extends Record<string, any> = object>({
|
|
|
14
14
|
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>;
|
|
15
15
|
parameterTypes?: Array<ParameterType<unknown>>;
|
|
16
16
|
}): void;
|
|
17
|
-
export { Feature };
|
|
17
|
+
export { Feature };
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/vitest/vitest-gherkin-driver.ts"],"sourcesContent":[],"mappings":";;AASA;;;AAEE,iBAFc,OAEd,CAAA,iBAFuC,MAEvC,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,MAAA,CAAA,CAAA;EAAA,WAAA;EAAA,KAAA;EAAA,eAAA;EAAA;CAAA,EAAA;EACA,WAAA,EAAA,MAAA;EACA,KAAA,CAAA,EAGQ,KAHR,CAGc,IAHd,CAGmB,QAHnB,CAAA,CAAA;EAGmB,eAAA,EACF,KADE,CACI,cADJ,CACmB,QADnB,EAAA,GAAA,EAAA,GAAA,EAAA,GAAA,CAAA,CAAA;EAAL,cAAA,CAAA,EAEG,KAFH,CAES,aAFT,CAAA,OAAA,CAAA,CAAA;CAAN,CAAA,EAAA,IAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "racejar",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A testing framework agnostic Gherkin driver",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cucumber",
|
|
@@ -44,8 +44,7 @@
|
|
|
44
44
|
"main": "./dist/index.js",
|
|
45
45
|
"types": "./dist/index.d.ts",
|
|
46
46
|
"files": [
|
|
47
|
-
"dist"
|
|
48
|
-
"src"
|
|
47
|
+
"dist"
|
|
49
48
|
],
|
|
50
49
|
"dependencies": {
|
|
51
50
|
"@cucumber/cucumber-expressions": "^18.0.1",
|
|
@@ -55,14 +54,15 @@
|
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"@jest/globals": "^30.2.0",
|
|
57
56
|
"@playwright/test": "^1.56.1",
|
|
58
|
-
"@sanity/pkg-utils": "^
|
|
57
|
+
"@sanity/pkg-utils": "^10.1.1",
|
|
58
|
+
"@sanity/tsconfig": "^1.0.0",
|
|
59
59
|
"typescript": "5.9.3",
|
|
60
|
-
"vitest": "^4.0.
|
|
60
|
+
"vitest": "^4.0.14"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@jest/globals": "^30.2.0",
|
|
64
64
|
"@playwright/test": "^1.56.1",
|
|
65
|
-
"vitest": "^4.0.
|
|
65
|
+
"vitest": "^4.0.14"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=20.19 <22 || >=22.12"
|
package/src/compile-feature.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import type {ParameterType} from '@cucumber/cucumber-expressions'
|
|
2
|
-
import {
|
|
3
|
-
CucumberExpression,
|
|
4
|
-
ParameterTypeRegistry,
|
|
5
|
-
} from '@cucumber/cucumber-expressions'
|
|
6
|
-
import * as Gherkin from '@cucumber/gherkin'
|
|
7
|
-
import * as Messages from '@cucumber/messages'
|
|
8
|
-
import type {Hook} from './hooks'
|
|
9
|
-
import type {StepDefinition} from './step-definitions'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export type CompiledFeature<TStepContext extends Record<string, any> = object> =
|
|
15
|
-
{
|
|
16
|
-
name: string
|
|
17
|
-
tag: 'only' | 'skip' | undefined
|
|
18
|
-
scenarios: Array<{
|
|
19
|
-
name: string
|
|
20
|
-
tag: 'only' | 'skip' | undefined
|
|
21
|
-
steps: Array<(stepContext?: TStepContext) => Promise<void> | void>
|
|
22
|
-
}>
|
|
23
|
-
beforeHooks: Array<(stepContext?: TStepContext) => Promise<void> | void>
|
|
24
|
-
afterHooks: Array<(stepContext?: TStepContext) => Promise<void> | void>
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
export function compileFeature<
|
|
31
|
-
TContext extends Record<string, any> = object,
|
|
32
|
-
TStepContext extends Record<string, any> = object,
|
|
33
|
-
>({
|
|
34
|
-
featureText,
|
|
35
|
-
hooks,
|
|
36
|
-
stepDefinitions,
|
|
37
|
-
parameterTypes,
|
|
38
|
-
}: {
|
|
39
|
-
featureText: string
|
|
40
|
-
hooks?: Array<Hook<TStepContext>>
|
|
41
|
-
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>
|
|
42
|
-
parameterTypes?: Array<ParameterType<unknown>>
|
|
43
|
-
}): CompiledFeature<TStepContext> {
|
|
44
|
-
const uuidFn = Messages.IdGenerator.uuid()
|
|
45
|
-
const builder = new Gherkin.AstBuilder(uuidFn)
|
|
46
|
-
const matcher = new Gherkin.GherkinClassicTokenMatcher()
|
|
47
|
-
const parser = new Gherkin.Parser(builder, matcher)
|
|
48
|
-
|
|
49
|
-
const gherkinDocument = parser.parse(featureText)
|
|
50
|
-
const pickles = Gherkin.compile(
|
|
51
|
-
gherkinDocument,
|
|
52
|
-
(gherkinDocument.feature?.name ?? '').replace(' ', '-'),
|
|
53
|
-
uuidFn,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
const parameterTypeRegistry = new ParameterTypeRegistry()
|
|
57
|
-
if (parameterTypes) {
|
|
58
|
-
parameterTypes.forEach((parameterType) => {
|
|
59
|
-
parameterTypeRegistry.defineParameterType(parameterType)
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (!gherkinDocument.feature) {
|
|
64
|
-
throw new Error('No feature found')
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const stepImplementations = stepDefinitions.map((stepDefinition) => {
|
|
68
|
-
const expression = new CucumberExpression(
|
|
69
|
-
stepDefinition.text,
|
|
70
|
-
parameterTypeRegistry,
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
type: stepDefinition.type,
|
|
75
|
-
text: stepDefinition.text,
|
|
76
|
-
expression,
|
|
77
|
-
callback: stepDefinition.callback,
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const skippedFeature = gherkinDocument.feature.tags.some(
|
|
82
|
-
(tag) => tag.name === '@skip',
|
|
83
|
-
)
|
|
84
|
-
const onlyFeature = gherkinDocument.feature.tags.some(
|
|
85
|
-
(tag) => tag.name === '@only',
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
if (skippedFeature && onlyFeature) {
|
|
89
|
-
throw new Error('Feature cannot have both @skip and @only tags')
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
let context = {} as TContext
|
|
93
|
-
|
|
94
|
-
const scenarios = pickles.map((pickle) => {
|
|
95
|
-
const skippedPickle = pickle.tags.some((tag) => tag.name === '@skip')
|
|
96
|
-
const onlyPickle = pickle.tags.some((tag) => tag.name === '@only')
|
|
97
|
-
context = {} as TContext
|
|
98
|
-
|
|
99
|
-
const steps = pickle.steps.map((step) => {
|
|
100
|
-
const matchingSteps = stepImplementations
|
|
101
|
-
.filter((stepImplementation) => stepImplementation.type === step.type)
|
|
102
|
-
.flatMap((stepImplementation) => {
|
|
103
|
-
const args = stepImplementation.expression.match(step.text)
|
|
104
|
-
|
|
105
|
-
if (args) {
|
|
106
|
-
return [
|
|
107
|
-
{
|
|
108
|
-
...stepImplementation,
|
|
109
|
-
args,
|
|
110
|
-
},
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return []
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
const matchingStep = matchingSteps[0]
|
|
118
|
-
|
|
119
|
-
if (!matchingStep) {
|
|
120
|
-
throw new Error(`No implementation found for step: ${step.text}`)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (matchingSteps.length > 1) {
|
|
124
|
-
throw new Error(`Multiple implementations found for step: ${step.text}`)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const args = matchingStep.args.map((arg) => arg.getValue(matchingStep))
|
|
128
|
-
if (step.argument?.dataTable) {
|
|
129
|
-
args.push(
|
|
130
|
-
step.argument.dataTable.rows.map((row) =>
|
|
131
|
-
row.cells.map((cell) => cell.value),
|
|
132
|
-
),
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
if (step.argument?.docString) {
|
|
136
|
-
args.push(step.argument.docString.content)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return (stepContext: TStepContext | undefined) =>
|
|
140
|
-
matchingStep.callback(
|
|
141
|
-
Object.assign(context, stepContext),
|
|
142
|
-
args[0],
|
|
143
|
-
args[1],
|
|
144
|
-
args[2],
|
|
145
|
-
)
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
name: pickle.name,
|
|
150
|
-
tag: skippedFeature
|
|
151
|
-
? ('skip' as const)
|
|
152
|
-
: skippedPickle
|
|
153
|
-
? ('skip' as const)
|
|
154
|
-
: onlyPickle
|
|
155
|
-
? ('only' as const)
|
|
156
|
-
: undefined,
|
|
157
|
-
steps,
|
|
158
|
-
}
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
return {
|
|
162
|
-
tag: skippedFeature ? 'skip' : onlyFeature ? 'only' : undefined,
|
|
163
|
-
name: gherkinDocument.feature.name,
|
|
164
|
-
scenarios,
|
|
165
|
-
beforeHooks: (hooks ?? [])
|
|
166
|
-
.filter((hook) => hook.type === 'Before')
|
|
167
|
-
.map(
|
|
168
|
-
(hook) => (stepContext: TStepContext | undefined) =>
|
|
169
|
-
hook.callback(Object.assign(context, stepContext)),
|
|
170
|
-
),
|
|
171
|
-
afterHooks: (hooks ?? [])
|
|
172
|
-
.filter((hook) => hook.type === 'After')
|
|
173
|
-
.map(
|
|
174
|
-
(hook) => (stepContext: TStepContext | undefined) =>
|
|
175
|
-
hook.callback(Object.assign(context, stepContext)),
|
|
176
|
-
),
|
|
177
|
-
}
|
|
178
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {ParameterType, type RegExps} from '@cucumber/cucumber-expressions'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export type ParameterTypeConfig<TType = string> = {
|
|
7
|
-
readonly name: string
|
|
8
|
-
matcher: RegExps
|
|
9
|
-
type?: (...args: unknown[]) => TType
|
|
10
|
-
transform?: (...match: string[]) => TType
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type {ParameterType}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
export function createParameterType<TType = string>(
|
|
19
|
-
config: ParameterTypeConfig<TType>,
|
|
20
|
-
): ParameterType<TType> {
|
|
21
|
-
return new ParameterType(
|
|
22
|
-
config.name,
|
|
23
|
-
config.matcher,
|
|
24
|
-
config.type ?? String,
|
|
25
|
-
config.transform,
|
|
26
|
-
false,
|
|
27
|
-
true,
|
|
28
|
-
)
|
|
29
|
-
}
|
package/src/hooks.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
export type Hook<TContext extends Record<string, any> = object> = {
|
|
5
|
-
type: 'Before' | 'After'
|
|
6
|
-
callback: HookCallback<TContext>
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export type HookCallback<TContext extends Record<string, any> = object> = (
|
|
13
|
-
context: TContext,
|
|
14
|
-
) => Promise<void> | void
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export function Before<TContext extends Record<string, any> = object>(
|
|
20
|
-
callback: HookCallback<TContext>,
|
|
21
|
-
): Hook<TContext> {
|
|
22
|
-
return {type: 'Before', callback}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
export function After<TContext extends Record<string, any> = object>(
|
|
29
|
-
callback: HookCallback<TContext>,
|
|
30
|
-
): Hook<TContext> {
|
|
31
|
-
return {type: 'After', callback}
|
|
32
|
-
}
|
package/src/index.ts
DELETED
package/src/jest/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './jest-gherkin-driver'
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type {ParameterType} from '@cucumber/cucumber-expressions'
|
|
2
|
-
import {afterEach, beforeEach, describe, test} from '@jest/globals'
|
|
3
|
-
import {compileFeature} from '../compile-feature'
|
|
4
|
-
import type {Hook} from '../hooks'
|
|
5
|
-
import type {StepDefinition} from '../step-definitions'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export function Feature<TContext extends Record<string, any> = object>({
|
|
11
|
-
featureText,
|
|
12
|
-
hooks,
|
|
13
|
-
stepDefinitions,
|
|
14
|
-
parameterTypes,
|
|
15
|
-
}: {
|
|
16
|
-
featureText: string
|
|
17
|
-
hooks: Array<Hook<TContext>>
|
|
18
|
-
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>
|
|
19
|
-
parameterTypes?: Array<ParameterType<unknown>>
|
|
20
|
-
}) {
|
|
21
|
-
const feature = compileFeature({
|
|
22
|
-
featureText,
|
|
23
|
-
hooks: hooks ?? [],
|
|
24
|
-
stepDefinitions,
|
|
25
|
-
parameterTypes: parameterTypes ?? [],
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const describeFn =
|
|
29
|
-
feature.tag === 'only'
|
|
30
|
-
? describe.only
|
|
31
|
-
: feature.tag === 'skip'
|
|
32
|
-
? describe.skip
|
|
33
|
-
: describe
|
|
34
|
-
|
|
35
|
-
describeFn(feature.name, () => {
|
|
36
|
-
for (const before of feature.beforeHooks) {
|
|
37
|
-
beforeEach(before)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
for (const after of feature.afterHooks) {
|
|
41
|
-
afterEach(after)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
for (const scenario of feature.scenarios) {
|
|
45
|
-
const testFn =
|
|
46
|
-
scenario.tag === 'only'
|
|
47
|
-
? test.only
|
|
48
|
-
: scenario.tag === 'skip'
|
|
49
|
-
? test.skip
|
|
50
|
-
: test
|
|
51
|
-
|
|
52
|
-
testFn(scenario.name, async () => {
|
|
53
|
-
for (const step of scenario.steps) {
|
|
54
|
-
await step()
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
}
|
package/src/playwright/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './playwright-gherkin-driver'
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import type {ParameterType} from '@cucumber/cucumber-expressions'
|
|
2
|
-
import {
|
|
3
|
-
test,
|
|
4
|
-
type PlaywrightTestArgs,
|
|
5
|
-
type PlaywrightTestOptions,
|
|
6
|
-
type PlaywrightWorkerArgs,
|
|
7
|
-
type PlaywrightWorkerOptions,
|
|
8
|
-
} from '@playwright/test'
|
|
9
|
-
import {compileFeature} from '../compile-feature'
|
|
10
|
-
import type {Hook} from '../hooks'
|
|
11
|
-
import type {StepDefinition} from '../step-definitions'
|
|
12
|
-
|
|
13
|
-
type PlaywrightOptions = PlaywrightTestArgs &
|
|
14
|
-
PlaywrightTestOptions &
|
|
15
|
-
PlaywrightWorkerArgs &
|
|
16
|
-
PlaywrightWorkerOptions
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
export type PlaywrightContext = Record<'string', any> & {
|
|
22
|
-
playwright: PlaywrightOptions
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
export function Feature<
|
|
29
|
-
TContext extends PlaywrightContext = PlaywrightContext,
|
|
30
|
-
>({
|
|
31
|
-
featureText,
|
|
32
|
-
hooks,
|
|
33
|
-
stepDefinitions,
|
|
34
|
-
parameterTypes,
|
|
35
|
-
}: {
|
|
36
|
-
featureText: string
|
|
37
|
-
hooks?: Array<Hook<TContext>>
|
|
38
|
-
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>
|
|
39
|
-
parameterTypes?: Array<ParameterType<unknown>>
|
|
40
|
-
}) {
|
|
41
|
-
const feature = compileFeature({
|
|
42
|
-
featureText,
|
|
43
|
-
hooks: hooks ?? [],
|
|
44
|
-
stepDefinitions,
|
|
45
|
-
parameterTypes: parameterTypes ?? [],
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const describeFn =
|
|
49
|
-
feature.tag === 'only'
|
|
50
|
-
? test.describe.only
|
|
51
|
-
: feature.tag === 'skip'
|
|
52
|
-
? test.describe.skip
|
|
53
|
-
: test.describe
|
|
54
|
-
|
|
55
|
-
describeFn(feature.name, () => {
|
|
56
|
-
for (const before of feature.beforeHooks) {
|
|
57
|
-
test.beforeEach(async (playwrightOptions) => {
|
|
58
|
-
await before({
|
|
59
|
-
playwright: playwrightOptions,
|
|
60
|
-
} as TContext)
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
for (const after of feature.afterHooks) {
|
|
65
|
-
test.afterEach(async (playwrightOptions) => {
|
|
66
|
-
await after({
|
|
67
|
-
playwright: playwrightOptions,
|
|
68
|
-
} as TContext)
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
for (const scenario of feature.scenarios) {
|
|
73
|
-
const testFn =
|
|
74
|
-
scenario.tag === 'only'
|
|
75
|
-
? test.only
|
|
76
|
-
: scenario.tag === 'skip'
|
|
77
|
-
? test.skip
|
|
78
|
-
: test
|
|
79
|
-
|
|
80
|
-
testFn(scenario.name, async (playwrightOptions) => {
|
|
81
|
-
for (const step of scenario.steps) {
|
|
82
|
-
await step({
|
|
83
|
-
playwright: playwrightOptions,
|
|
84
|
-
} as TContext)
|
|
85
|
-
}
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
}
|
package/src/step-definitions.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
export type StepDefinitionCallback<
|
|
5
|
-
TContext extends Record<string, any> = object,
|
|
6
|
-
TParamA = undefined,
|
|
7
|
-
TParamB = undefined,
|
|
8
|
-
TParamC = undefined,
|
|
9
|
-
> = TParamA extends undefined
|
|
10
|
-
? (context: TContext) => Promise<void> | void
|
|
11
|
-
: TParamB extends undefined
|
|
12
|
-
? (context: TContext, paramA: TParamA) => Promise<void> | void
|
|
13
|
-
: TParamC extends undefined
|
|
14
|
-
? (
|
|
15
|
-
context: TContext,
|
|
16
|
-
paramA: TParamA,
|
|
17
|
-
paramB: TParamB,
|
|
18
|
-
) => Promise<void> | void
|
|
19
|
-
: (
|
|
20
|
-
context: TContext,
|
|
21
|
-
paramA: TParamA,
|
|
22
|
-
paramB: TParamB,
|
|
23
|
-
paramC: TParamC,
|
|
24
|
-
) => Promise<void> | void
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export type StepDefinition<
|
|
30
|
-
TContext extends Record<string, any> = object,
|
|
31
|
-
TParamA = undefined,
|
|
32
|
-
TParamB = undefined,
|
|
33
|
-
TParamC = undefined,
|
|
34
|
-
> = {
|
|
35
|
-
type: 'Context' | 'Action' | 'Outcome'
|
|
36
|
-
text: string
|
|
37
|
-
callback: StepDefinitionCallback<TContext, TParamA, TParamB, TParamC>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export function Given<
|
|
44
|
-
TContext extends Record<string, any> = object,
|
|
45
|
-
TParamA = undefined,
|
|
46
|
-
TParamB = undefined,
|
|
47
|
-
TParamC = undefined,
|
|
48
|
-
>(
|
|
49
|
-
text: string,
|
|
50
|
-
callback: StepDefinitionCallback<TContext, TParamA, TParamB, TParamC>,
|
|
51
|
-
): StepDefinition<TContext, TParamA, TParamB, TParamC> {
|
|
52
|
-
return {type: 'Context', text, callback}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export function When<
|
|
59
|
-
TContext extends Record<string, any> = object,
|
|
60
|
-
TParamA = undefined,
|
|
61
|
-
TParamB = undefined,
|
|
62
|
-
TParamC = undefined,
|
|
63
|
-
>(
|
|
64
|
-
text: string,
|
|
65
|
-
callback: StepDefinitionCallback<TContext, TParamA, TParamB, TParamC>,
|
|
66
|
-
): StepDefinition<TContext, TParamA, TParamB, TParamC> {
|
|
67
|
-
return {type: 'Action', text, callback}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @public
|
|
72
|
-
*/
|
|
73
|
-
export function Then<
|
|
74
|
-
TContext extends Record<string, any> = object,
|
|
75
|
-
TParamA = undefined,
|
|
76
|
-
TParamB = undefined,
|
|
77
|
-
TParamC = undefined,
|
|
78
|
-
>(
|
|
79
|
-
text: string,
|
|
80
|
-
callback: StepDefinitionCallback<TContext, TParamA, TParamB, TParamC>,
|
|
81
|
-
): StepDefinition<TContext, TParamA, TParamB, TParamC> {
|
|
82
|
-
return {type: 'Outcome', text, callback}
|
|
83
|
-
}
|
package/src/vitest/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './vitest-gherkin-driver'
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type {ParameterType} from '@cucumber/cucumber-expressions'
|
|
2
|
-
import {afterEach, beforeEach, describe, test} from 'vitest'
|
|
3
|
-
import {compileFeature} from '../compile-feature'
|
|
4
|
-
import type {Hook} from '../hooks'
|
|
5
|
-
import type {StepDefinition} from '../step-definitions'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export function Feature<TContext extends Record<string, any> = object>({
|
|
11
|
-
featureText,
|
|
12
|
-
hooks,
|
|
13
|
-
stepDefinitions,
|
|
14
|
-
parameterTypes,
|
|
15
|
-
}: {
|
|
16
|
-
featureText: string
|
|
17
|
-
hooks?: Array<Hook<TContext>>
|
|
18
|
-
stepDefinitions: Array<StepDefinition<TContext, any, any, any>>
|
|
19
|
-
parameterTypes?: Array<ParameterType<unknown>>
|
|
20
|
-
}) {
|
|
21
|
-
const feature = compileFeature({
|
|
22
|
-
featureText,
|
|
23
|
-
hooks: hooks ?? [],
|
|
24
|
-
stepDefinitions,
|
|
25
|
-
parameterTypes: parameterTypes ?? [],
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const describeFn =
|
|
29
|
-
feature.tag === 'only'
|
|
30
|
-
? describe.only
|
|
31
|
-
: feature.tag === 'skip'
|
|
32
|
-
? describe.skip
|
|
33
|
-
: describe
|
|
34
|
-
|
|
35
|
-
describeFn(feature.name, () => {
|
|
36
|
-
for (const before of feature.beforeHooks) {
|
|
37
|
-
beforeEach(before)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
for (const after of feature.afterHooks) {
|
|
41
|
-
afterEach(after)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
for (const scenario of feature.scenarios) {
|
|
45
|
-
const testFn =
|
|
46
|
-
scenario.tag === 'only'
|
|
47
|
-
? test.only
|
|
48
|
-
: scenario.tag === 'skip'
|
|
49
|
-
? test.skip
|
|
50
|
-
: test
|
|
51
|
-
|
|
52
|
-
testFn(scenario.name, async () => {
|
|
53
|
-
for (const step of scenario.steps) {
|
|
54
|
-
await step()
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
}
|