@lynxwall/cucumber-tsflow 6.5.7 → 7.1.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.
Files changed (235) hide show
  1. package/README.md +130 -35
  2. package/api/index.d.ts +6 -0
  3. package/bin/cucumber-tsflow +3 -3
  4. package/bin/cucumber-tsflow.js +3 -0
  5. package/lib/api/index.d.ts +17 -0
  6. package/lib/api/index.js +30 -0
  7. package/lib/api/index.js.map +1 -0
  8. package/lib/api/load-configuration.d.ts +21 -0
  9. package/lib/api/load-configuration.js +127 -0
  10. package/lib/api/load-configuration.js.map +1 -0
  11. package/lib/api/load-support.d.ts +10 -0
  12. package/lib/api/load-support.js +48 -0
  13. package/lib/api/load-support.js.map +1 -0
  14. package/lib/api/run-cucumber.d.ts +16 -0
  15. package/lib/api/run-cucumber.js +151 -0
  16. package/lib/api/run-cucumber.js.map +1 -0
  17. package/lib/api/wrapper.mjs +6 -0
  18. package/lib/behave.js +19 -9
  19. package/lib/behave.js.map +1 -0
  20. package/lib/bindings/binding-context.d.ts +17 -0
  21. package/lib/bindings/binding-context.js +36 -0
  22. package/lib/bindings/binding-context.js.map +1 -0
  23. package/lib/{cucumber → bindings}/binding-decorator.d.ts +2 -2
  24. package/lib/bindings/binding-decorator.js +201 -0
  25. package/lib/bindings/binding-decorator.js.map +1 -0
  26. package/lib/{cucumber → bindings}/binding-registry.d.ts +10 -10
  27. package/lib/bindings/binding-registry.js +232 -0
  28. package/lib/bindings/binding-registry.js.map +1 -0
  29. package/lib/{cucumber → bindings}/hook-decorators.d.ts +6 -6
  30. package/lib/{cucumber → bindings}/hook-decorators.js +18 -16
  31. package/lib/bindings/hook-decorators.js.map +1 -0
  32. package/lib/bindings/step-binding.d.ts +60 -0
  33. package/lib/bindings/step-binding.js +6 -0
  34. package/lib/bindings/step-binding.js.map +1 -0
  35. package/lib/{cucumber/step-definition-decorators.d.ts → bindings/step-decorators.d.ts} +3 -3
  36. package/lib/bindings/step-decorators.js +97 -0
  37. package/lib/bindings/step-decorators.js.map +1 -0
  38. package/lib/bindings/types.d.ts +72 -0
  39. package/lib/bindings/types.js +58 -0
  40. package/lib/bindings/types.js.map +1 -0
  41. package/lib/cli/argv-parser.js +3 -3
  42. package/lib/cli/argv-parser.js.map +1 -0
  43. package/lib/cli/index.d.ts +1 -2
  44. package/lib/cli/index.js +12 -40
  45. package/lib/cli/index.js.map +1 -0
  46. package/lib/cli/load-configuration.d.ts +2 -1
  47. package/lib/cli/load-configuration.js +12 -10
  48. package/lib/cli/load-configuration.js.map +1 -0
  49. package/lib/cli/run.js +5 -7
  50. package/lib/cli/run.js.map +1 -0
  51. package/lib/cucumber/coordinator.d.ts +15 -0
  52. package/lib/cucumber/coordinator.js +40 -0
  53. package/lib/cucumber/coordinator.js.map +1 -0
  54. package/lib/cucumber/make-runtime.d.ts +12 -16
  55. package/lib/cucumber/make-runtime.js +10 -33
  56. package/lib/cucumber/make-runtime.js.map +1 -0
  57. package/lib/cucumber/managed-scenario-context.d.ts +3 -3
  58. package/lib/cucumber/managed-scenario-context.js +24 -24
  59. package/lib/cucumber/managed-scenario-context.js.map +1 -0
  60. package/lib/cucumber/message-collector.d.ts +3 -0
  61. package/lib/cucumber/message-collector.js +38 -16
  62. package/lib/cucumber/message-collector.js.map +1 -0
  63. package/lib/cucumber/parallel/adapter.d.ts +46 -0
  64. package/lib/cucumber/parallel/adapter.js +156 -0
  65. package/lib/cucumber/parallel/adapter.js.map +1 -0
  66. package/lib/cucumber/parallel/run-worker.d.ts +1 -1
  67. package/lib/cucumber/parallel/run-worker.js +8 -16
  68. package/lib/cucumber/parallel/run-worker.js.map +1 -0
  69. package/lib/cucumber/parallel/worker.d.ts +10 -14
  70. package/lib/cucumber/parallel/worker.js +59 -68
  71. package/lib/cucumber/parallel/worker.js.map +1 -0
  72. package/lib/cucumber/run-cucumber.d.ts +5 -3
  73. package/lib/cucumber/run-cucumber.js +59 -38
  74. package/lib/cucumber/run-cucumber.js.map +1 -0
  75. package/lib/cucumber/serial/adapter.d.ts +12 -0
  76. package/lib/cucumber/serial/adapter.js +24 -0
  77. package/lib/cucumber/serial/adapter.js.map +1 -0
  78. package/lib/cucumber/test-case-info.js +1 -1
  79. package/lib/cucumber/test-case-info.js.map +1 -0
  80. package/lib/cucumber/test-case-runner.d.ts +2 -2
  81. package/lib/cucumber/test-case-runner.js +47 -19
  82. package/lib/cucumber/test-case-runner.js.map +1 -0
  83. package/lib/cucumber/utils.js +1 -1
  84. package/lib/cucumber/utils.js.map +1 -0
  85. package/lib/cucumber/worker.d.ts +17 -0
  86. package/lib/cucumber/worker.js +57 -0
  87. package/lib/cucumber/worker.js.map +1 -0
  88. package/lib/esnode.d.ts +1 -0
  89. package/lib/esnode.js +5 -7
  90. package/lib/esnode.js.map +1 -0
  91. package/lib/esvue.js +3 -6
  92. package/lib/esvue.js.map +1 -0
  93. package/lib/formatter/behave-json-formatter.d.ts +49 -0
  94. package/lib/formatter/behave-json-formatter.js +85 -0
  95. package/lib/formatter/behave-json-formatter.js.map +1 -0
  96. package/lib/formatter/junit-bamboo-formatter.d.ts +17 -0
  97. package/lib/formatter/junit-bamboo-formatter.js +175 -0
  98. package/lib/formatter/junit-bamboo-formatter.js.map +1 -0
  99. package/lib/formatter/step-definition-snippit-syntax/tsflow-snippet-syntax.d.ts +9 -0
  100. package/lib/formatter/step-definition-snippit-syntax/tsflow-snippet-syntax.js +85 -0
  101. package/lib/formatter/step-definition-snippit-syntax/tsflow-snippet-syntax.js.map +1 -0
  102. package/lib/formatters/behave-json-formatter.js +18 -8
  103. package/lib/formatters/behave-json-formatter.js.map +1 -0
  104. package/lib/formatters/junit-bamboo-formatter.js +2 -2
  105. package/lib/formatters/junit-bamboo-formatter.js.map +1 -0
  106. package/lib/formatters/tsflow-snippet-syntax.js +2 -3
  107. package/lib/formatters/tsflow-snippet-syntax.js.map +1 -0
  108. package/lib/gherkin/configuration.d.ts +4 -4
  109. package/lib/gherkin/configuration.js +1 -1
  110. package/lib/gherkin/configuration.js.map +1 -0
  111. package/lib/gherkin/gherkin-feature.js +18 -8
  112. package/lib/gherkin/gherkin-feature.js.map +1 -0
  113. package/lib/gherkin/gherkin-manager.js +2 -2
  114. package/lib/gherkin/gherkin-manager.js.map +1 -0
  115. package/lib/gherkin/models.d.ts +1 -1
  116. package/lib/gherkin/models.js +1 -1
  117. package/lib/gherkin/models.js.map +1 -0
  118. package/lib/index.d.ts +42 -5
  119. package/lib/index.js +114 -8
  120. package/lib/index.js.map +1 -0
  121. package/lib/junitbamboo.js +19 -9
  122. package/lib/junitbamboo.js.map +1 -0
  123. package/lib/runtime/coordinator.d.ts +15 -0
  124. package/lib/runtime/coordinator.js +40 -0
  125. package/lib/runtime/coordinator.js.map +1 -0
  126. package/lib/runtime/make-runtime.d.ts +22 -0
  127. package/lib/runtime/make-runtime.js +17 -0
  128. package/lib/runtime/make-runtime.js.map +1 -0
  129. package/lib/runtime/managed-scenario-context.d.ts +52 -0
  130. package/lib/runtime/managed-scenario-context.js +149 -0
  131. package/lib/runtime/managed-scenario-context.js.map +1 -0
  132. package/lib/runtime/message-collector.d.ts +98 -0
  133. package/lib/runtime/message-collector.js +284 -0
  134. package/lib/runtime/message-collector.js.map +1 -0
  135. package/lib/runtime/parallel/adapter.d.ts +47 -0
  136. package/lib/runtime/parallel/adapter.js +159 -0
  137. package/lib/runtime/parallel/adapter.js.map +1 -0
  138. package/lib/runtime/parallel/run-worker.d.ts +1 -0
  139. package/lib/runtime/parallel/run-worker.js +24 -0
  140. package/lib/runtime/parallel/run-worker.js.map +1 -0
  141. package/lib/runtime/parallel/types.d.ts +13 -0
  142. package/lib/runtime/parallel/types.js +3 -0
  143. package/lib/runtime/parallel/types.js.map +1 -0
  144. package/lib/runtime/parallel/worker.d.ts +44 -0
  145. package/lib/runtime/parallel/worker.js +118 -0
  146. package/lib/runtime/parallel/worker.js.map +1 -0
  147. package/lib/runtime/scenario-context.d.ts +16 -0
  148. package/lib/runtime/scenario-context.js +18 -0
  149. package/lib/runtime/scenario-context.js.map +1 -0
  150. package/lib/runtime/scenario-info.d.ts +16 -0
  151. package/lib/runtime/scenario-info.js +23 -0
  152. package/lib/runtime/scenario-info.js.map +1 -0
  153. package/lib/runtime/serial/adapter.d.ts +12 -0
  154. package/lib/runtime/serial/adapter.js +24 -0
  155. package/lib/runtime/serial/adapter.js.map +1 -0
  156. package/lib/runtime/test-case-info.d.ts +23 -0
  157. package/lib/runtime/test-case-info.js +3 -0
  158. package/lib/runtime/test-case-info.js.map +1 -0
  159. package/lib/runtime/test-case-runner.d.ts +48 -0
  160. package/lib/runtime/test-case-runner.js +345 -0
  161. package/lib/runtime/test-case-runner.js.map +1 -0
  162. package/lib/runtime/utils.d.ts +16 -0
  163. package/lib/runtime/utils.js +78 -0
  164. package/lib/runtime/utils.js.map +1 -0
  165. package/lib/runtime/worker.d.ts +17 -0
  166. package/lib/runtime/worker.js +57 -0
  167. package/lib/runtime/worker.js.map +1 -0
  168. package/lib/snippet.js +20 -10
  169. package/lib/snippet.js.map +1 -0
  170. package/lib/transpilers/esbuild-transpiler.d.ts +1 -1
  171. package/lib/transpilers/esbuild-transpiler.js +1 -1
  172. package/lib/transpilers/esbuild-transpiler.js.map +1 -0
  173. package/lib/transpilers/esbuild.js +4 -4
  174. package/lib/transpilers/esbuild.js.map +1 -0
  175. package/lib/transpilers/vue-sfc/compiler.js +1 -1
  176. package/lib/transpilers/vue-sfc/compiler.js.map +1 -0
  177. package/lib/transpilers/vue-sfc/index.d.ts +4 -4
  178. package/lib/transpilers/vue-sfc/index.js +1 -2
  179. package/lib/transpilers/vue-sfc/index.js.map +1 -0
  180. package/lib/transpilers/vue-sfc/main.d.ts +1 -1
  181. package/lib/transpilers/vue-sfc/main.js +1 -1
  182. package/lib/transpilers/vue-sfc/main.js.map +1 -0
  183. package/lib/transpilers/vue-sfc/script.js +1 -2
  184. package/lib/transpilers/vue-sfc/script.js.map +1 -0
  185. package/lib/transpilers/vue-sfc/template.d.ts +1 -1
  186. package/lib/transpilers/vue-sfc/template.js +2 -3
  187. package/lib/transpilers/vue-sfc/template.js.map +1 -0
  188. package/lib/transpilers/vue-sfc/types.d.ts +2 -2
  189. package/lib/transpilers/vue-sfc/types.js +1 -1
  190. package/lib/transpilers/vue-sfc/types.js.map +1 -0
  191. package/lib/transpilers/vue-sfc/utils/descriptorCache.js +1 -1
  192. package/lib/transpilers/vue-sfc/utils/descriptorCache.js.map +1 -0
  193. package/lib/transpilers/vue-sfc/utils/error.js +1 -1
  194. package/lib/transpilers/vue-sfc/utils/error.js.map +1 -0
  195. package/lib/transpilers/vue-sfc/utils/query.js +1 -1
  196. package/lib/transpilers/vue-sfc/utils/query.js.map +1 -0
  197. package/lib/tsconfig.node.tsbuildinfo +1 -0
  198. package/lib/tsnode.d.ts +1 -0
  199. package/lib/tsnode.js +4 -6
  200. package/lib/tsnode.js.map +1 -0
  201. package/lib/tsvue.js +3 -6
  202. package/lib/tsvue.js.map +1 -0
  203. package/lib/types/parallel.d.ts +11 -0
  204. package/lib/types/parallel.js +3 -0
  205. package/lib/types/parallel.js.map +1 -0
  206. package/lib/types/scenario-context.js +1 -1
  207. package/lib/types/scenario-context.js.map +1 -0
  208. package/lib/types/scenario-info.js +1 -1
  209. package/lib/types/scenario-info.js.map +1 -0
  210. package/lib/types/step-binding-flags.js +1 -1
  211. package/lib/types/step-binding-flags.js.map +1 -0
  212. package/lib/types/step-binding.d.ts +30 -20
  213. package/lib/types/step-binding.js +1 -1
  214. package/lib/types/step-binding.js.map +1 -0
  215. package/lib/types/types.js +1 -1
  216. package/lib/types/types.js.map +1 -0
  217. package/lib/utils/helpers.js +1 -1
  218. package/lib/utils/helpers.js.map +1 -0
  219. package/lib/utils/logger.d.ts +2 -2
  220. package/lib/utils/logger.js +7 -26
  221. package/lib/utils/logger.js.map +1 -0
  222. package/lib/utils/our-callsite.js +18 -8
  223. package/lib/utils/our-callsite.js.map +1 -0
  224. package/lib/version.d.ts +1 -1
  225. package/lib/version.js +2 -2
  226. package/lib/version.js.map +1 -0
  227. package/lib/wrapper.mjs +56 -0
  228. package/package.json +65 -27
  229. package/lib/cucumber/binding-decorator.js +0 -181
  230. package/lib/cucumber/binding-registry.js +0 -231
  231. package/lib/cucumber/parallel/coordinator.d.ts +0 -79
  232. package/lib/cucumber/parallel/coordinator.js +0 -247
  233. package/lib/cucumber/runtime.d.ts +0 -40
  234. package/lib/cucumber/runtime.js +0 -85
  235. package/lib/cucumber/step-definition-decorators.js +0 -92
@@ -1,6 +1,6 @@
1
- import { ISupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';
2
- import { StepBinding } from '../types/step-binding';
3
- import { ContextType, StepPattern, TagName } from '../types/types';
1
+ import { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';
2
+ import { StepBinding } from './step-binding';
3
+ import { ContextType, StepPattern, TagName } from './types';
4
4
  /**
5
5
  * Represents the default step pattern.
6
6
  */
@@ -13,8 +13,8 @@ export declare const DEFAULT_TAG = "*";
13
13
  * A metadata registry that captures information about bindings and their bound step bindings.
14
14
  */
15
15
  export declare class BindingRegistry {
16
- private _bindings;
17
- private _targetBindings;
16
+ private _stepBindings;
17
+ private _classBindings;
18
18
  /**
19
19
  * Gets the binding registry singleton.
20
20
  *
@@ -25,20 +25,20 @@ export declare class BindingRegistry {
25
25
  * Updates the binding registry with information about the context types required by a
26
26
  * binding class.
27
27
  *
28
- * @param targetPrototype The class representing the binding (constructor function).
28
+ * @param classPrototype The class representing the binding (constructor function).
29
29
  * @param contextTypes An array of [[ContextType]] that define the types of objects that
30
30
  * should be injected into the binding class during a scenario execution.
31
31
  */
32
- registerContextTypesForTarget(targetPrototype: any, contextTypes?: ContextType[]): void;
32
+ registerContextTypesForClass(classPrototype: any, contextTypes?: ContextType[]): void;
33
33
  /**
34
34
  * Retrieves the context types that have been registered for a given binding class.
35
35
  *
36
- * @param targetPrototype The class representing the binding (constructor function).
36
+ * @param classPrototype The class representing the binding (constructor function).
37
37
  *
38
38
  * @returns An array of [[ContextType]] that have been registered for the specified
39
39
  * binding class.
40
40
  */
41
- getContextTypesForTarget(targetPrototype: any): ContextType[];
41
+ getContextTypesForClass(classPrototype: any): ContextType[];
42
42
  /**
43
43
  * Updates the binding registry indexes with a step binding.
44
44
  *
@@ -70,7 +70,7 @@ export declare class BindingRegistry {
70
70
  * @param library
71
71
  * @returns
72
72
  */
73
- updateSupportCodeLibrary: (library: ISupportCodeLibrary) => ISupportCodeLibrary;
73
+ updateSupportCodeLibrary: (library: SupportCodeLibrary) => SupportCodeLibrary;
74
74
  /**
75
75
  * Maps an array of tag names to an array of associated step bindings.
76
76
  *
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BindingRegistry = exports.DEFAULT_TAG = exports.DEFAULT_STEP_PATTERN = void 0;
7
+ const underscore_1 = __importDefault(require("underscore"));
8
+ const step_binding_1 = require("./step-binding");
9
+ const logger_1 = __importDefault(require("../utils/logger"));
10
+ /**
11
+ * Represents the default step pattern.
12
+ */
13
+ exports.DEFAULT_STEP_PATTERN = '/.*/';
14
+ /**
15
+ * Represents the default tag.
16
+ */
17
+ exports.DEFAULT_TAG = '*';
18
+ /**
19
+ * A metadata registry that captures information about bindings and their bound step bindings.
20
+ */
21
+ class BindingRegistry {
22
+ _stepBindings = new Map();
23
+ _classBindings = new Map();
24
+ /**
25
+ * Gets the binding registry singleton.
26
+ *
27
+ * @returns A [[BindingRegistry]].
28
+ */
29
+ static get instance() {
30
+ const BINDING_REGISTRY_SLOTNAME = '__CUCUMBER_TSFLOW_BINDINGREGISTRY';
31
+ const registry = global[BINDING_REGISTRY_SLOTNAME];
32
+ if (!registry) {
33
+ global[BINDING_REGISTRY_SLOTNAME] = new BindingRegistry();
34
+ }
35
+ return registry || global[BINDING_REGISTRY_SLOTNAME];
36
+ }
37
+ /**
38
+ * Updates the binding registry with information about the context types required by a
39
+ * binding class.
40
+ *
41
+ * @param classPrototype The class representing the binding (constructor function).
42
+ * @param contextTypes An array of [[ContextType]] that define the types of objects that
43
+ * should be injected into the binding class during a scenario execution.
44
+ */
45
+ registerContextTypesForClass(classPrototype, contextTypes) {
46
+ if (!contextTypes) {
47
+ return;
48
+ }
49
+ let targetDecorations = this._classBindings.get(classPrototype);
50
+ if (!targetDecorations) {
51
+ targetDecorations = {
52
+ stepBindings: [],
53
+ contextTypes: []
54
+ };
55
+ this._classBindings.set(classPrototype, targetDecorations);
56
+ }
57
+ targetDecorations.contextTypes = contextTypes;
58
+ }
59
+ /**
60
+ * Retrieves the context types that have been registered for a given binding class.
61
+ *
62
+ * @param classPrototype The class representing the binding (constructor function).
63
+ *
64
+ * @returns An array of [[ContextType]] that have been registered for the specified
65
+ * binding class.
66
+ */
67
+ getContextTypesForClass(classPrototype) {
68
+ const targetBinding = this._classBindings.get(classPrototype);
69
+ if (!targetBinding) {
70
+ return [];
71
+ }
72
+ return targetBinding.contextTypes;
73
+ }
74
+ /**
75
+ * Updates the binding registry indexes with a step binding.
76
+ *
77
+ * @param stepBinding The step binding that is to be registered with the binding registry.
78
+ */
79
+ registerStepBinding(stepBinding) {
80
+ if (!stepBinding.tags) {
81
+ stepBinding.tags = exports.DEFAULT_TAG;
82
+ }
83
+ if (stepBinding.tags !== exports.DEFAULT_TAG && !stepBinding.tags.startsWith('@')) {
84
+ // tslint:disable-next-line:no-console
85
+ logger_1.default.debug('tag should start with @; tsflow has stopped to automatically prepend @ for you.');
86
+ }
87
+ const stepPattern = stepBinding.stepPattern
88
+ ? stepBinding.stepPattern.toString()
89
+ : exports.DEFAULT_STEP_PATTERN;
90
+ let tagMap = this._stepBindings.get(stepPattern);
91
+ if (!tagMap) {
92
+ tagMap = new Map();
93
+ this._stepBindings.set(stepPattern, tagMap);
94
+ }
95
+ let stepBindings = tagMap.get(stepBinding.tags);
96
+ if (!stepBindings) {
97
+ stepBindings = [];
98
+ tagMap.set(stepBinding.tags, stepBindings);
99
+ }
100
+ if (!stepBindings.some(b => isSameStepBinding(stepBinding, b))) {
101
+ stepBindings.push(stepBinding);
102
+ }
103
+ // Index the step binding for the target
104
+ let targetBinding = this._classBindings.get(stepBinding.classPrototype);
105
+ if (!targetBinding) {
106
+ targetBinding = {
107
+ stepBindings: [],
108
+ contextTypes: []
109
+ };
110
+ this._classBindings.set(stepBinding.classPrototype, targetBinding);
111
+ }
112
+ if (!targetBinding.stepBindings.some(b => isSameStepBinding(stepBinding, b))) {
113
+ targetBinding.stepBindings.push(stepBinding);
114
+ }
115
+ function isSameStepBinding(a, b) {
116
+ return (a.callsite.filename === b.callsite.filename &&
117
+ a.callsite.lineNumber === b.callsite.lineNumber &&
118
+ String(a.tags) === String(b.tags) &&
119
+ String(a.stepPattern) === String(b.stepPattern));
120
+ }
121
+ }
122
+ /**
123
+ * Retrieves the step bindings that have been registered for a given binding class.
124
+ *
125
+ * @param targetPrototype The class representing the binding (constructor function).
126
+ *
127
+ * @returns An array of [[StepBinding]] objects that have been registered for the specified
128
+ * binding class.
129
+ */
130
+ getStepBindingsForTarget(targetPrototype) {
131
+ const targetBinding = this._classBindings.get(targetPrototype);
132
+ if (!targetBinding) {
133
+ return [];
134
+ }
135
+ return targetBinding.stepBindings;
136
+ }
137
+ /**
138
+ * Retrieves the step bindings for a given step pattern and collection of tag names.
139
+ *
140
+ * @param stepPattern The step pattern to search.
141
+ * @param tags An array of [[TagName]] to search.
142
+ *
143
+ * @returns An array of [[StepBinding]] that map to the given step pattern and set of tag names.
144
+ */
145
+ getStepBindings(stepPattern, tags) {
146
+ const tagMap = this._stepBindings.get(stepPattern);
147
+ if (!tagMap) {
148
+ return [];
149
+ }
150
+ const matchingStepBindings = this.mapTagNamesToStepBindings(tags, tagMap);
151
+ if (matchingStepBindings.length > 0) {
152
+ return matchingStepBindings;
153
+ }
154
+ return this.mapTagNamesToStepBindings(['*'], tagMap);
155
+ }
156
+ getStepBindingByCucumberKey(cucumberKey) {
157
+ let result = undefined;
158
+ for (const [_, binding] of this._classBindings) {
159
+ for (const stepBinding of binding.stepBindings) {
160
+ if (stepBinding.cucumberKey === cucumberKey) {
161
+ result = stepBinding;
162
+ break;
163
+ }
164
+ }
165
+ if (result) {
166
+ break;
167
+ }
168
+ }
169
+ return result;
170
+ }
171
+ /**
172
+ * Updates the SupportCodeLibrary from Cucumber with
173
+ * callsite information from tsflow bindings
174
+ * @param library
175
+ * @returns
176
+ */
177
+ updateSupportCodeLibrary = (library) => {
178
+ this._classBindings.forEach(binding => {
179
+ binding.stepBindings.forEach(stepBinding => {
180
+ let cucumberDefinition = undefined;
181
+ switch (stepBinding.bindingType) {
182
+ case step_binding_1.StepBindingFlags.beforeAll:
183
+ cucumberDefinition = library.beforeTestRunHookDefinitions.find(s => s.options.cucumberKey === stepBinding.cucumberKey);
184
+ break;
185
+ case step_binding_1.StepBindingFlags.before:
186
+ cucumberDefinition = library.beforeTestCaseHookDefinitions.find(s => s.options.cucumberKey === stepBinding.cucumberKey);
187
+ break;
188
+ case step_binding_1.StepBindingFlags.beforeStep:
189
+ cucumberDefinition = library.beforeTestStepHookDefinitions.find(s => s.options.cucumberKey === stepBinding.cucumberKey);
190
+ break;
191
+ case step_binding_1.StepBindingFlags.given:
192
+ cucumberDefinition = library.stepDefinitions.find(s => s.options.cucumberKey === stepBinding.cucumberKey);
193
+ break;
194
+ case step_binding_1.StepBindingFlags.when:
195
+ cucumberDefinition = library.stepDefinitions.find(s => s.options.cucumberKey === stepBinding.cucumberKey);
196
+ break;
197
+ case step_binding_1.StepBindingFlags.then:
198
+ cucumberDefinition = library.stepDefinitions.find(s => s.options.cucumberKey === stepBinding.cucumberKey);
199
+ break;
200
+ case step_binding_1.StepBindingFlags.afterStep:
201
+ cucumberDefinition = library.afterTestStepHookDefinitions.find(s => s.options.cucumberKey === stepBinding.cucumberKey);
202
+ break;
203
+ case step_binding_1.StepBindingFlags.after:
204
+ cucumberDefinition = library.afterTestCaseHookDefinitions.find(s => s.options.cucumberKey === stepBinding.cucumberKey);
205
+ break;
206
+ case step_binding_1.StepBindingFlags.afterAll:
207
+ cucumberDefinition = library.afterTestRunHookDefinitions.find(s => s.options.cucumberKey === stepBinding.cucumberKey);
208
+ break;
209
+ }
210
+ if (cucumberDefinition) {
211
+ cucumberDefinition.line = stepBinding.callsite.lineNumber;
212
+ cucumberDefinition.uri = stepBinding.callsite.filename;
213
+ }
214
+ });
215
+ });
216
+ return library;
217
+ };
218
+ /**
219
+ * Maps an array of tag names to an array of associated step bindings.
220
+ *
221
+ * @param tags An array of [[TagName]].
222
+ * @param tagMap The map of [[TagName]] -> [[StepBinding]] to use when mapping.
223
+ *
224
+ * @returns An array of [[StepBinding]].
225
+ */
226
+ mapTagNamesToStepBindings(tags, tagMap) {
227
+ const matchingStepBindings = underscore_1.default.flatten(underscore_1.default.map(tags, tag => tagMap.get(tag)));
228
+ return underscore_1.default.reject(matchingStepBindings, stepBinding => stepBinding === undefined);
229
+ }
230
+ }
231
+ exports.BindingRegistry = BindingRegistry;
232
+ //# sourceMappingURL=binding-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-registry.js","sourceRoot":"","sources":["../../src/bindings/binding-registry.ts"],"names":[],"mappings":";;;;;;AACA,4DAA2B;AAC3B,iDAA+D;AAE/D,6DAAqC;AAiBrC;;GAEG;AACU,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAE3C;;GAEG;AACU,QAAA,WAAW,GAAG,GAAG,CAAC;AAE/B;;GAEG;AACH,MAAa,eAAe;IACnB,aAAa,GAAG,IAAI,GAAG,EAA4C,CAAC;IACpE,cAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;IAEtD;;;;OAIG;IACI,MAAM,KAAK,QAAQ;QACzB,MAAM,yBAAyB,GAAG,mCAAmC,CAAC;QAEtE,MAAM,QAAQ,GAAI,MAAc,CAAC,yBAAyB,CAAC,CAAC;QAE5D,IAAI,CAAC,QAA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C;oBACxB,kBAAkB,CAAC,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC;oBAC1D,kBAAkB,CAAC,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACxD,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IAChB,CAAC,CAAC;IAEF;;;;;;;OAOG;IACK,yBAAyB,CAAC,IAAe,EAAE,MAAmC;QACrF,MAAM,oBAAoB,GAAgC,oBAAC,CAAC,OAAO,CAAC,oBAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEzG,OAAO,oBAAC,CAAC,MAAM,CAAC,oBAAoB,EAAE,WAAW,CAAC,EAAE,CAAC,WAAW,KAAK,SAAS,CAAkB,CAAC;IAClG,CAAC;CACD;AA7QD,0CA6QC","sourcesContent":["import { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport _ from 'underscore';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport { ContextType, StepPattern, TagName } from './types';\r\nimport logger from '../utils/logger';\r\n\r\n/**\r\n * Describes the binding metadata that is associated with a binding class.\r\n */\r\ninterface ClassBinding {\r\n\t/**\r\n\t * A reference to the step bindings that are associated with the binding class.\r\n\t */\r\n\tstepBindings: StepBinding[];\r\n\r\n\t/**\r\n\t * The context types that are to be injected into the binding class during execution.\r\n\t */\r\n\tcontextTypes: ContextType[];\r\n}\r\n\r\n/**\r\n * Represents the default step pattern.\r\n */\r\nexport const DEFAULT_STEP_PATTERN = '/.*/';\r\n\r\n/**\r\n * Represents the default tag.\r\n */\r\nexport const DEFAULT_TAG = '*';\r\n\r\n/**\r\n * A metadata registry that captures information about bindings and their bound step bindings.\r\n */\r\nexport class BindingRegistry {\r\n\tprivate _stepBindings = new Map<StepPattern, Map<TagName, StepBinding[]>>();\r\n\tprivate _classBindings = new Map<any, ClassBinding>();\r\n\r\n\t/**\r\n\t * Gets the binding registry singleton.\r\n\t *\r\n\t * @returns A [[BindingRegistry]].\r\n\t */\r\n\tpublic static get instance(): BindingRegistry {\r\n\t\tconst BINDING_REGISTRY_SLOTNAME = '__CUCUMBER_TSFLOW_BINDINGREGISTRY';\r\n\r\n\t\tconst registry = (global as any)[BINDING_REGISTRY_SLOTNAME];\r\n\r\n\t\tif (!registry) {\r\n\t\t\t(global as any)[BINDING_REGISTRY_SLOTNAME] = new BindingRegistry();\r\n\t\t}\r\n\r\n\t\treturn registry || (global as any)[BINDING_REGISTRY_SLOTNAME];\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the binding registry with information about the context types required by a\r\n\t * binding class.\r\n\t *\r\n\t * @param classPrototype The class representing the binding (constructor function).\r\n\t * @param contextTypes An array of [[ContextType]] that define the types of objects that\r\n\t * should be injected into the binding class during a scenario execution.\r\n\t */\r\n\tpublic registerContextTypesForClass(classPrototype: any, contextTypes?: ContextType[]): void {\r\n\t\tif (!contextTypes) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tlet targetDecorations = this._classBindings.get(classPrototype);\r\n\r\n\t\tif (!targetDecorations) {\r\n\t\t\ttargetDecorations = {\r\n\t\t\t\tstepBindings: [],\r\n\t\t\t\tcontextTypes: []\r\n\t\t\t};\r\n\r\n\t\t\tthis._classBindings.set(classPrototype, targetDecorations);\r\n\t\t}\r\n\r\n\t\ttargetDecorations.contextTypes = contextTypes;\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the context types that have been registered for a given binding class.\r\n\t *\r\n\t * @param classPrototype The class representing the binding (constructor function).\r\n\t *\r\n\t * @returns An array of [[ContextType]] that have been registered for the specified\r\n\t * binding class.\r\n\t */\r\n\tpublic getContextTypesForClass(classPrototype: any): ContextType[] {\r\n\t\tconst targetBinding = this._classBindings.get(classPrototype);\r\n\r\n\t\tif (!targetBinding) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\treturn targetBinding.contextTypes;\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the binding registry indexes with a step binding.\r\n\t *\r\n\t * @param stepBinding The step binding that is to be registered with the binding registry.\r\n\t */\r\n\tpublic registerStepBinding(stepBinding: StepBinding): void {\r\n\t\tif (!stepBinding.tags) {\r\n\t\t\tstepBinding.tags = DEFAULT_TAG;\r\n\t\t}\r\n\r\n\t\tif (stepBinding.tags !== DEFAULT_TAG && !stepBinding.tags.startsWith('@')) {\r\n\t\t\t// tslint:disable-next-line:no-console\r\n\t\t\tlogger.debug('tag should start with @; tsflow has stopped to automatically prepend @ for you.');\r\n\t\t}\r\n\r\n\t\tconst stepPattern: StepPattern = stepBinding.stepPattern\r\n\t\t\t? stepBinding.stepPattern.toString()\r\n\t\t\t: DEFAULT_STEP_PATTERN;\r\n\r\n\t\tlet tagMap = this._stepBindings.get(stepPattern);\r\n\r\n\t\tif (!tagMap) {\r\n\t\t\ttagMap = new Map<TagName, StepBinding[]>();\r\n\r\n\t\t\tthis._stepBindings.set(stepPattern, tagMap);\r\n\t\t}\r\n\r\n\t\tlet stepBindings = tagMap.get(stepBinding.tags);\r\n\r\n\t\tif (!stepBindings) {\r\n\t\t\tstepBindings = [];\r\n\r\n\t\t\ttagMap.set(stepBinding.tags, stepBindings);\r\n\t\t}\r\n\r\n\t\tif (!stepBindings.some(b => isSameStepBinding(stepBinding, b))) {\r\n\t\t\tstepBindings.push(stepBinding);\r\n\t\t}\r\n\r\n\t\t// Index the step binding for the target\r\n\r\n\t\tlet targetBinding = this._classBindings.get(stepBinding.classPrototype);\r\n\r\n\t\tif (!targetBinding) {\r\n\t\t\ttargetBinding = {\r\n\t\t\t\tstepBindings: [],\r\n\t\t\t\tcontextTypes: []\r\n\t\t\t};\r\n\r\n\t\t\tthis._classBindings.set(stepBinding.classPrototype, targetBinding);\r\n\t\t}\r\n\r\n\t\tif (!targetBinding.stepBindings.some(b => isSameStepBinding(stepBinding, b))) {\r\n\t\t\ttargetBinding.stepBindings.push(stepBinding);\r\n\t\t}\r\n\r\n\t\tfunction isSameStepBinding(a: StepBinding, b: StepBinding) {\r\n\t\t\treturn (\r\n\t\t\t\ta.callsite.filename === b.callsite.filename &&\r\n\t\t\t\ta.callsite.lineNumber === b.callsite.lineNumber &&\r\n\t\t\t\tString(a.tags) === String(b.tags) &&\r\n\t\t\t\tString(a.stepPattern) === String(b.stepPattern)\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the step bindings that have been registered for a given binding class.\r\n\t *\r\n\t * @param targetPrototype The class representing the binding (constructor function).\r\n\t *\r\n\t * @returns An array of [[StepBinding]] objects that have been registered for the specified\r\n\t * binding class.\r\n\t */\r\n\tpublic getStepBindingsForTarget(targetPrototype: any): StepBinding[] {\r\n\t\tconst targetBinding = this._classBindings.get(targetPrototype);\r\n\r\n\t\tif (!targetBinding) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\treturn targetBinding.stepBindings;\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the step bindings for a given step pattern and collection of tag names.\r\n\t *\r\n\t * @param stepPattern The step pattern to search.\r\n\t * @param tags An array of [[TagName]] to search.\r\n\t *\r\n\t * @returns An array of [[StepBinding]] that map to the given step pattern and set of tag names.\r\n\t */\r\n\tpublic getStepBindings(stepPattern: StepPattern, tags: TagName[]): StepBinding[] {\r\n\t\tconst tagMap = this._stepBindings.get(stepPattern);\r\n\r\n\t\tif (!tagMap) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\tconst matchingStepBindings = this.mapTagNamesToStepBindings(tags, tagMap);\r\n\r\n\t\tif (matchingStepBindings.length > 0) {\r\n\t\t\treturn matchingStepBindings;\r\n\t\t}\r\n\r\n\t\treturn this.mapTagNamesToStepBindings(['*'], tagMap);\r\n\t}\r\n\r\n\tpublic getStepBindingByCucumberKey(cucumberKey: string): StepBinding | undefined {\r\n\t\tlet result: StepBinding | undefined = undefined;\r\n\t\tfor (const [_, binding] of this._classBindings) {\r\n\t\t\tfor (const stepBinding of binding.stepBindings) {\r\n\t\t\t\tif (stepBinding.cucumberKey === cucumberKey) {\r\n\t\t\t\t\tresult = stepBinding;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (result) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the SupportCodeLibrary from Cucumber with\r\n\t * callsite information from tsflow bindings\r\n\t * @param library\r\n\t * @returns\r\n\t */\r\n\tpublic updateSupportCodeLibrary = (library: SupportCodeLibrary): SupportCodeLibrary => {\r\n\t\tthis._classBindings.forEach(binding => {\r\n\t\t\tbinding.stepBindings.forEach(stepBinding => {\r\n\t\t\t\tlet cucumberDefinition: any | undefined = undefined;\r\n\t\t\t\tswitch (stepBinding.bindingType) {\r\n\t\t\t\t\tcase StepBindingFlags.beforeAll:\r\n\t\t\t\t\t\tcucumberDefinition = library.beforeTestRunHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.before:\r\n\t\t\t\t\t\tcucumberDefinition = library.beforeTestCaseHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.beforeStep:\r\n\t\t\t\t\t\tcucumberDefinition = library.beforeTestStepHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.given:\r\n\t\t\t\t\t\tcucumberDefinition = library.stepDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.when:\r\n\t\t\t\t\t\tcucumberDefinition = library.stepDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.then:\r\n\t\t\t\t\t\tcucumberDefinition = library.stepDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.afterStep:\r\n\t\t\t\t\t\tcucumberDefinition = library.afterTestStepHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.after:\r\n\t\t\t\t\t\tcucumberDefinition = library.afterTestCaseHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.afterAll:\r\n\t\t\t\t\t\tcucumberDefinition = library.afterTestRunHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tif (cucumberDefinition) {\r\n\t\t\t\t\tcucumberDefinition.line = stepBinding.callsite.lineNumber;\r\n\t\t\t\t\tcucumberDefinition.uri = stepBinding.callsite.filename;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\t\treturn library;\r\n\t};\r\n\r\n\t/**\r\n\t * Maps an array of tag names to an array of associated step bindings.\r\n\t *\r\n\t * @param tags An array of [[TagName]].\r\n\t * @param tagMap The map of [[TagName]] -> [[StepBinding]] to use when mapping.\r\n\t *\r\n\t * @returns An array of [[StepBinding]].\r\n\t */\r\n\tprivate mapTagNamesToStepBindings(tags: TagName[], tagMap: Map<TagName, StepBinding[]>): StepBinding[] {\r\n\t\tconst matchingStepBindings: (StepBinding | undefined)[] = _.flatten(_.map(tags, tag => tagMap.get(tag)));\r\n\r\n\t\treturn _.reject(matchingStepBindings, stepBinding => stepBinding === undefined) as StepBinding[];\r\n\t}\r\n}\r\n"]}
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @param timeout Optional timeout in milliseconds
6
6
  */
7
- export declare function beforeAll(timeout?: number): MethodDecorator;
7
+ export declare function beforeAll(timeout?: number): any;
8
8
  /**
9
9
  * A method decorator that marks the associated function as a 'Before Scenario' step. The function is
10
10
  * executed before each scenario.
@@ -12,7 +12,7 @@ export declare function beforeAll(timeout?: number): MethodDecorator;
12
12
  * @param tags Optional tag or tags associated with a scenario.
13
13
  * @param timeout Optional timeout in milliseconds
14
14
  */
15
- export declare function before(tags?: string, timeout?: number): MethodDecorator;
15
+ export declare function before(tags?: string, timeout?: number): any;
16
16
  /**
17
17
  * A method decorator that marks the associated function as a 'Before Step' step. The function is
18
18
  * executed before each step.
@@ -20,14 +20,14 @@ export declare function before(tags?: string, timeout?: number): MethodDecorator
20
20
  * @param tags Optional tag or tags associated with a scenario.
21
21
  * @param timeout Optional timeout in milliseconds
22
22
  */
23
- export declare function beforeStep(tags?: string, timeout?: number): MethodDecorator;
23
+ export declare function beforeStep(tags?: string, timeout?: number): any;
24
24
  /**
25
25
  * A method decorator that marks the associated function as an 'After All Scenario' step. The function is
26
26
  * executed after all scenarios are executed.
27
27
  *
28
28
  * @param timeout Optional timeout in milliseconds
29
29
  */
30
- export declare function afterAll(timeout?: number): MethodDecorator;
30
+ export declare function afterAll(timeout?: number): any;
31
31
  /**
32
32
  * A method decorator that marks the associated function as an 'After Scenario' step. The function is
33
33
  * executed after each scenario.
@@ -35,7 +35,7 @@ export declare function afterAll(timeout?: number): MethodDecorator;
35
35
  * @param tags Optional tag or tags associated with a scenario.
36
36
  * @param timeout Optional timeout in milliseconds
37
37
  */
38
- export declare function after(tags?: string, timeout?: number): MethodDecorator;
38
+ export declare function after(tags?: string, timeout?: number): any;
39
39
  /**
40
40
  * A method decorator that marks the associated function as a 'After Step' step. The function is
41
41
  * executed after each step.
@@ -43,4 +43,4 @@ export declare function after(tags?: string, timeout?: number): MethodDecorator;
43
43
  * @param tags Optional tag or tags associated with a scenario.
44
44
  * @param timeout Optional timeout in milliseconds
45
45
  */
46
- export declare function afterStep(tags?: string, timeout?: number): MethodDecorator;
46
+ export declare function afterStep(tags?: string, timeout?: number): any;
@@ -3,11 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.afterStep = exports.after = exports.afterAll = exports.beforeStep = exports.before = exports.beforeAll = void 0;
7
- const binding_registry_1 = require("./binding-registry");
6
+ exports.beforeAll = beforeAll;
7
+ exports.before = before;
8
+ exports.beforeStep = beforeStep;
9
+ exports.afterAll = afterAll;
10
+ exports.after = after;
11
+ exports.afterStep = afterStep;
8
12
  const our_callsite_1 = require("../utils/our-callsite");
9
- const step_binding_1 = require("../types/step-binding");
13
+ const step_binding_1 = require("./step-binding");
10
14
  const short_uuid_1 = __importDefault(require("short-uuid"));
15
+ const binding_context_1 = require("./binding-context");
11
16
  /**
12
17
  * A method decorator that marks the associated function as a 'Before All Scenario' step. The function is
13
18
  * executed before all scenarios are executed.
@@ -18,7 +23,6 @@ function beforeAll(timeout) {
18
23
  const callSite = our_callsite_1.Callsite.capture();
19
24
  return createDecoratorFactory(step_binding_1.StepBindingFlags.beforeAll, callSite, undefined, timeout);
20
25
  }
21
- exports.beforeAll = beforeAll;
22
26
  /**
23
27
  * A method decorator that marks the associated function as a 'Before Scenario' step. The function is
24
28
  * executed before each scenario.
@@ -30,7 +34,6 @@ function before(tags, timeout) {
30
34
  const callSite = our_callsite_1.Callsite.capture();
31
35
  return createDecoratorFactory(step_binding_1.StepBindingFlags.before, callSite, tags, timeout);
32
36
  }
33
- exports.before = before;
34
37
  /**
35
38
  * A method decorator that marks the associated function as a 'Before Step' step. The function is
36
39
  * executed before each step.
@@ -42,7 +45,6 @@ function beforeStep(tags, timeout) {
42
45
  const callSite = our_callsite_1.Callsite.capture();
43
46
  return createDecoratorFactory(step_binding_1.StepBindingFlags.beforeStep, callSite, tags, timeout);
44
47
  }
45
- exports.beforeStep = beforeStep;
46
48
  /**
47
49
  * A method decorator that marks the associated function as an 'After All Scenario' step. The function is
48
50
  * executed after all scenarios are executed.
@@ -53,7 +55,6 @@ function afterAll(timeout) {
53
55
  const callSite = our_callsite_1.Callsite.capture();
54
56
  return createDecoratorFactory(step_binding_1.StepBindingFlags.afterAll, callSite, undefined, timeout);
55
57
  }
56
- exports.afterAll = afterAll;
57
58
  /**
58
59
  * A method decorator that marks the associated function as an 'After Scenario' step. The function is
59
60
  * executed after each scenario.
@@ -65,7 +66,6 @@ function after(tags, timeout) {
65
66
  const callSite = our_callsite_1.Callsite.capture();
66
67
  return createDecoratorFactory(step_binding_1.StepBindingFlags.after, callSite, tags, timeout);
67
68
  }
68
- exports.after = after;
69
69
  /**
70
70
  * A method decorator that marks the associated function as a 'After Step' step. The function is
71
71
  * executed after each step.
@@ -77,18 +77,20 @@ function afterStep(tags, timeout) {
77
77
  const callSite = our_callsite_1.Callsite.capture();
78
78
  return createDecoratorFactory(step_binding_1.StepBindingFlags.afterStep, callSite, tags, timeout);
79
79
  }
80
- exports.afterStep = afterStep;
81
80
  function checkTag(tag) {
82
81
  return tag;
83
82
  }
84
83
  function createDecoratorFactory(flag, callSite, tag, timeout) {
85
- return (target, propertyKey, descriptor) => {
84
+ return function hookDecorator(target, context) {
86
85
  const stepBinding = {
87
86
  stepPattern: '',
88
87
  bindingType: flag,
89
- targetPrototype: target,
90
- targetPropertyKey: propertyKey,
91
- argsLength: target[propertyKey].length,
88
+ classPrototype: undefined,
89
+ classPropertyKey: context.name,
90
+ stepFunction: target,
91
+ stepIsStatic: context.static,
92
+ stepArgsLength: target.length,
93
+ tags: tag,
92
94
  timeout: timeout,
93
95
  callsite: callSite,
94
96
  cucumberKey: (0, short_uuid_1.default)().new()
@@ -96,8 +98,8 @@ function createDecoratorFactory(flag, callSite, tag, timeout) {
96
98
  if (tag) {
97
99
  stepBinding.tags = checkTag(tag);
98
100
  }
99
- binding_registry_1.BindingRegistry.instance.registerStepBinding(stepBinding);
100
- return descriptor;
101
+ (0, binding_context_1.addStepBinding)(context, stepBinding);
102
+ return;
101
103
  };
102
104
  }
103
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9vay1kZWNvcmF0b3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2N1Y3VtYmVyL2hvb2stZGVjb3JhdG9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSx5REFBcUQ7QUFDckQsd0RBQWlEO0FBQ2pELHdEQUFzRTtBQUN0RSw0REFBbUM7QUFFbkM7Ozs7O0dBS0c7QUFDSCxTQUFnQixTQUFTLENBQUMsT0FBZ0I7SUFDekMsTUFBTSxRQUFRLEdBQUcsdUJBQVEsQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUNwQyxPQUFPLHNCQUFzQixDQUFDLCtCQUFnQixDQUFDLFNBQVMsRUFBRSxRQUFRLEVBQUUsU0FBUyxFQUFFLE9BQU8sQ0FBQyxDQUFDO0FBQ3pGLENBQUM7QUFIRCw4QkFHQztBQUNEOzs7Ozs7R0FNRztBQUNILFNBQWdCLE1BQU0sQ0FBQyxJQUFhLEVBQUUsT0FBZ0I7SUFDckQsTU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,OAAO,EAAE,CAAC;IACpC,OAAO,sBAAsB,CAAC,+BAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAChF,CAAC;AACD;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,IAAa,EAAE,OAAgB;IACxD,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,OAAO,sBAAsB,CAAC,+BAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACpF,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC5B,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAsB,EAAE,QAAkB,EAAE,GAAY,EAAE,OAAgB;IACzG,OAAO,SAAS,aAAa,CAAC,MAAgB,EAAE,OAAoC;QACnF,MAAM,WAAW,GAAgB;YAChC,WAAW,EAAE,EAAE;YACf,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,SAAS;YACzB,gBAAgB,EAAE,OAAO,CAAC,IAAI;YAC9B,YAAY,EAAE,MAAM;YACpB,YAAY,EAAE,OAAO,CAAC,MAAM;YAC5B,cAAc,EAAE,MAAM,CAAC,MAAM;YAC7B,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,OAAO;YAChB,QAAQ,EAAE,QAAQ;YAClB,WAAW,EAAE,IAAA,oBAAS,GAAE,CAAC,GAAG,EAAE;SAC9B,CAAC;QAEF,IAAI,GAAG,EAAE,CAAC;YACT,WAAW,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAClC,CAAC;QACD,IAAA,gCAAc,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAErC,OAAO;IACR,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { Callsite } from '../utils/our-callsite';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport shortUuid from 'short-uuid';\r\nimport { addStepBinding } from './binding-context';\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Before All Scenario' step. The function is\r\n * executed before all scenarios are executed.\r\n *\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function beforeAll(timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.beforeAll, callSite, undefined, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as a 'Before Scenario' step. The function is\r\n * executed before each scenario.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function before(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.before, callSite, tags, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as a 'Before Step' step. The function is\r\n * executed before each step.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function beforeStep(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.beforeStep, callSite, tags, timeout);\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as an 'After All Scenario' step. The function is\r\n * executed after all scenarios are executed.\r\n *\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function afterAll(timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.afterAll, callSite, undefined, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as an 'After Scenario' step. The function is\r\n * executed after each scenario.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function after(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.after, callSite, tags, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as a 'After Step' step. The function is\r\n * executed after each step.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function afterStep(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.afterStep, callSite, tags, timeout);\r\n}\r\n\r\nfunction checkTag(tag: string): string {\r\n\treturn tag;\r\n}\r\n\r\nfunction createDecoratorFactory(flag: StepBindingFlags, callSite: Callsite, tag?: string, timeout?: number) {\r\n\treturn function hookDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\tconst stepBinding: StepBinding = {\r\n\t\t\tstepPattern: '',\r\n\t\t\tbindingType: flag,\r\n\t\t\tclassPrototype: undefined,\r\n\t\t\tclassPropertyKey: context.name,\r\n\t\t\tstepFunction: target,\r\n\t\t\tstepIsStatic: context.static,\r\n\t\t\tstepArgsLength: target.length,\r\n\t\t\ttags: tag,\r\n\t\t\ttimeout: timeout,\r\n\t\t\tcallsite: callSite,\r\n\t\t\tcucumberKey: shortUuid().new()\r\n\t\t};\r\n\r\n\t\tif (tag) {\r\n\t\t\tstepBinding.tags = checkTag(tag);\r\n\t\t}\r\n\t\taddStepBinding(context, stepBinding);\r\n\r\n\t\treturn;\r\n\t};\r\n}\r\n"]}
@@ -0,0 +1,60 @@
1
+ import { Callsite } from '../utils/our-callsite';
2
+ import { StepBindingFlags } from './types';
3
+ /**
4
+ * Encapsulates data about a step binding.
5
+ */
6
+ export interface StepBinding {
7
+ /**
8
+ * The callsite of the step binding.
9
+ */
10
+ callsite: Callsite;
11
+ /**
12
+ * The typescript 'binding' class that is associated with the current step.
13
+ */
14
+ classPrototype: any;
15
+ /**
16
+ * The function name that is associated with the current step.
17
+ */
18
+ classPropertyKey: string | symbol;
19
+ /**
20
+ * Key passed in with options in cucumber step bindings.
21
+ * This property is used to match tsflow step definitions
22
+ * with cucumber step definitions.
23
+ */
24
+ cucumberKey: string;
25
+ /**
26
+ * The step binding type.
27
+ */
28
+ bindingType: StepBindingFlags;
29
+ /**
30
+ * The step pattern.
31
+ */
32
+ stepPattern: RegExp | string;
33
+ /**
34
+ * Function for this step that's passed in from the decorator.
35
+ */
36
+ stepFunction: Function | undefined;
37
+ /**
38
+ * Flag to indicate if the target is static or not.
39
+ * If true than we don't 'apply' to the class instance.
40
+ */
41
+ stepIsStatic: boolean;
42
+ /**
43
+ * The number of arguments for the step, which is captured in
44
+ * the decorator using arguments.length.
45
+ */
46
+ stepArgsLength: number;
47
+ /**
48
+ * The optional tag(s) that are associated with the current step.
49
+ */
50
+ tags?: string;
51
+ /**
52
+ * The optiomal timeout that is associated with the current step.
53
+ */
54
+ timeout?: number;
55
+ /**
56
+ * The wrapper Option passing to cucumber
57
+ */
58
+ wrapperOption?: any;
59
+ }
60
+ export { StepBindingFlags } from './types';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StepBindingFlags = void 0;
4
+ var types_1 = require("./types");
5
+ Object.defineProperty(exports, "StepBindingFlags", { enumerable: true, get: function () { return types_1.StepBindingFlags; } });
6
+ //# sourceMappingURL=step-binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-binding.js","sourceRoot":"","sources":["../../src/bindings/step-binding.ts"],"names":[],"mappings":";;;AAwEA,iCAA2C;AAAlC,yGAAA,gBAAgB,OAAA","sourcesContent":["import { Callsite } from '../utils/our-callsite';\r\nimport { StepBindingFlags } from './types';\r\n\r\n/**\r\n * Encapsulates data about a step binding.\r\n */\r\nexport interface StepBinding {\r\n\t/**\r\n\t * The callsite of the step binding.\r\n\t */\r\n\tcallsite: Callsite;\r\n\r\n\t/**\r\n\t * The typescript 'binding' class that is associated with the current step.\r\n\t */\r\n\tclassPrototype: any;\r\n\r\n\t/**\r\n\t * The function name that is associated with the current step.\r\n\t */\r\n\tclassPropertyKey: string | symbol;\r\n\r\n\t/**\r\n\t * Key passed in with options in cucumber step bindings.\r\n\t * This property is used to match tsflow step definitions\r\n\t * with cucumber step definitions.\r\n\t */\r\n\tcucumberKey: string;\r\n\r\n\t/**\r\n\t * The step binding type.\r\n\t */\r\n\tbindingType: StepBindingFlags;\r\n\r\n\t/**\r\n\t * The step pattern.\r\n\t */\r\n\tstepPattern: RegExp | string;\r\n\r\n\t/**\r\n\t * Function for this step that's passed in from the decorator.\r\n\t */\r\n\tstepFunction: Function | undefined;\r\n\r\n\t/**\r\n\t * Flag to indicate if the target is static or not.\r\n\t * If true than we don't 'apply' to the class instance.\r\n\t */\r\n\tstepIsStatic: boolean;\r\n\r\n\t/**\r\n\t * The number of arguments for the step, which is captured in\r\n\t * the decorator using arguments.length.\r\n\t */\r\n\tstepArgsLength: number;\r\n\r\n\t/**\r\n\t * The optional tag(s) that are associated with the current step.\r\n\t */\r\n\ttags?: string;\r\n\r\n\t/**\r\n\t * The optiomal timeout that is associated with the current step.\r\n\t */\r\n\ttimeout?: number;\r\n\r\n\t/**\r\n\t * The wrapper Option passing to cucumber\r\n\t */\r\n\twrapperOption?: any;\r\n}\r\n\r\nexport { StepBindingFlags } from './types';\r\n"]}
@@ -5,7 +5,7 @@
5
5
  * @param tag An optional tag.
6
6
  * @param timeout An optional timeout.
7
7
  */
8
- export declare function given(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): MethodDecorator;
8
+ export declare function given(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any;
9
9
  /**
10
10
  * A method decorator that marks the associated function as a 'When' step.
11
11
  *
@@ -13,7 +13,7 @@ export declare function given(stepPattern: RegExp | string, tag?: string, timeou
13
13
  * @param tag An optional tag.
14
14
  * @param timeout An optional timeout.
15
15
  */
16
- export declare function when(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): MethodDecorator;
16
+ export declare function when(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any;
17
17
  /**
18
18
  * A method decorator that marks the associated function as a 'Then' step.
19
19
  *
@@ -21,4 +21,4 @@ export declare function when(stepPattern: RegExp | string, tag?: string, timeout
21
21
  * @param tag An optional tag.
22
22
  * @param timeout An optional timeout.
23
23
  */
24
- export declare function then(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): MethodDecorator;
24
+ export declare function then(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any;