-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
types.ts
183 lines (170 loc) · 5.61 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import * as messages from '@cucumber/messages'
import TestCaseHookDefinition from '../models/test_case_hook_definition'
import TestStepHookDefinition from '../models/test_step_hook_definition'
import TestRunHookDefinition from '../models/test_run_hook_definition'
import StepDefinition from '../models/step_definition'
import { ParameterTypeRegistry } from '@cucumber/cucumber-expressions'
import { IWorld } from './world'
export type DefineStepPattern = string | RegExp
export type ParallelAssignmentValidator = (
pickle: messages.Pickle,
runningPickles: messages.Pickle[]
) => boolean
export interface ITestCaseHookParameter {
gherkinDocument: messages.GherkinDocument
pickle: messages.Pickle
result?: messages.TestStepResult
testCaseStartedId: string
}
export interface ITestStepHookParameter {
gherkinDocument: messages.GherkinDocument
pickle: messages.Pickle
pickleStep: messages.PickleStep
result: messages.TestStepResult
testCaseStartedId: string
testStepId: string
}
export type TestCaseHookFunction<WorldType> = (
this: WorldType,
arg: ITestCaseHookParameter
) => any | Promise<any>
export type TestStepHookFunction<WorldType> = (
this: WorldType,
arg: ITestStepHookParameter
) => any | Promise<any>
export type TestStepFunction<WorldType> = (
this: WorldType,
...args: any[]
) => any | Promise<any>
export interface IDefineStepOptions {
timeout?: number
wrapperOptions?: any
}
export interface IDefineTestCaseHookOptions {
name?: string
tags?: string
timeout?: number
}
export interface IDefineTestStepHookOptions {
tags?: string
timeout?: number
}
export interface IDefineTestRunHookOptions {
timeout?: number
}
export interface IParameterTypeDefinition<T> {
name: string
regexp: readonly RegExp[] | readonly string[] | RegExp | string
transformer: (...match: string[]) => T
useForSnippets?: boolean
preferForRegexpMatch?: boolean
}
export interface IDefineSupportCodeMethods {
defineParameterType: (options: IParameterTypeDefinition<any>) => void
defineStep: (<WorldType = IWorld>(
pattern: DefineStepPattern,
code: TestStepFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
pattern: DefineStepPattern,
options: IDefineStepOptions,
code: TestStepFunction<WorldType>
) => void)
setDefaultTimeout: (milliseconds: number) => void
setDefinitionFunctionWrapper: (fn: Function) => void
setParallelCanAssign: (fn: ParallelAssignmentValidator) => void
setWorldConstructor: (fn: any) => void
After: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) &
(<WorldType = IWorld>(
tags: string,
code: TestCaseHookFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
options: IDefineTestCaseHookOptions,
code: TestCaseHookFunction<WorldType>
) => void)
AfterStep: (<WorldType = IWorld>(
code: TestStepHookFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
tags: string,
code: TestStepHookFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
options: IDefineTestStepHookOptions,
code: TestStepHookFunction<WorldType>
) => void)
AfterAll: ((code: Function) => void) &
((options: IDefineTestRunHookOptions, code: Function) => void)
Before: (<WorldType = IWorld>(
code: TestCaseHookFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
tags: string,
code: TestCaseHookFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
options: IDefineTestCaseHookOptions,
code: TestCaseHookFunction<WorldType>
) => void)
BeforeStep: (<WorldType = IWorld>(
code: TestStepHookFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
tags: string,
code: TestStepHookFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
options: IDefineTestStepHookOptions,
code: TestStepHookFunction<WorldType>
) => void)
BeforeAll: ((code: Function) => void) &
((options: IDefineTestRunHookOptions, code: Function) => void)
Given: (<WorldType = IWorld>(
pattern: DefineStepPattern,
code: TestStepFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
pattern: DefineStepPattern,
options: IDefineStepOptions,
code: TestStepFunction<WorldType>
) => void)
Then: (<WorldType = IWorld>(
pattern: DefineStepPattern,
code: TestStepFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
pattern: DefineStepPattern,
options: IDefineStepOptions,
code: TestStepFunction<WorldType>
) => void)
When: (<WorldType = IWorld>(
pattern: DefineStepPattern,
code: TestStepFunction<WorldType>
) => void) &
(<WorldType = IWorld>(
pattern: DefineStepPattern,
options: IDefineStepOptions,
code: TestStepFunction<WorldType>
) => void)
}
export interface ISupportCodeCoordinates {
requireModules: string[]
requirePaths: string[]
importPaths: string[]
}
export interface ISupportCodeLibrary {
readonly originalCoordinates: ISupportCodeCoordinates
readonly afterTestCaseHookDefinitions: TestCaseHookDefinition[]
readonly afterTestStepHookDefinitions: TestStepHookDefinition[]
readonly afterTestRunHookDefinitions: TestRunHookDefinition[]
readonly beforeTestCaseHookDefinitions: TestCaseHookDefinition[]
readonly beforeTestStepHookDefinitions: TestStepHookDefinition[]
readonly beforeTestRunHookDefinitions: TestRunHookDefinition[]
readonly defaultTimeout: number
readonly stepDefinitions: StepDefinition[]
readonly undefinedParameterTypes: messages.UndefinedParameterType[]
readonly parameterTypeRegistry: ParameterTypeRegistry
readonly World: any
readonly parallelCanAssign: ParallelAssignmentValidator
}