@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
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # cucumber-tsflow
4
4
 
5
- Provides 'specflow' like bindings for CucumberJS 9.6.0+ in TypeScript 5.0+.
5
+ Provides 'specflow' like bindings for CucumberJS 11.2.0 in TypeScript 5.8+.
6
6
 
7
7
  Supports Vue3 files in cucumber tests.
8
8
 
@@ -10,9 +10,25 @@ Supports Vue3 files in cucumber tests.
10
10
 
11
11
  This is a detached fork of <https://github.com/timjroberts/cucumber-js-tsflow>. It has had the <https://github.com/wudong/cucumber-js-tsflow/tree/before_after_all_hooks> branch merged into it, which adds support for beforeAll and afterAll hooks.
12
12
 
13
- In addition, the following features have been added:
13
+ This fork has been drastically modified from the original and will eventually be moved to a new project. In addition, the SpecFlow project has reached [end of life](https://reqnroll.net/news/2025/01/specflow-end-of-life-has-been-announced/), and this project will be rebranded. Further details will be provided in future updates. However, the new project will support the same functionality as cucumber-tsflow while providing additional tools and extensions.
14
+
15
+ ## Release Updates (7.1.0)
16
+
17
+ With this latest release, cucumber-tsflow has been refactored to support cucumber-js version 11.2.0 along with other updates that include:
18
+
19
+ - **Switch to package exports** with both cucumber-tsflow and most of cucumber-js Public types and functions exported. This allows developers to use cucumber-tsflow as a replacement for cucumber-js without requiring a peer installation. Most of the functionality is still executed in cucumber-js, cucumber-tsflow just extends cucumber-js to switch from support functions to support decorators with scoped context. This change is what allows you to use a SpecFlow type of structure for defining code that will execute BDD tests.
20
+ - **API support** that implements and extends the cucumber-js API.
21
+ - Support for Node 22 and Typescript 5.8.
22
+ - Switched to **official Typescript Decorators** with metadata support implemented in [Typescript 5.2](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#decorator-metadata).
23
+ - Transpiler configuration updates to support node and Typescript changes.
24
+ - Added a new section to this readme that describes [Transpilers and TypeScript](#transpilers-and-typescript) in more detail.
25
+
26
+ ## Features
27
+
28
+ This fork of cucumber-tsflow provides the following features that extend the original version:
14
29
 
15
30
  - Test runner using the cucumber-tsflow command.
31
+
16
32
  - Uses underlying cucumber api to run tests.
17
33
  - Returns **four** exit codes:
18
34
  - **0** - All scenarios passing.
@@ -20,7 +36,7 @@ In addition, the following features have been added:
20
36
  - **2** - Implemented scenarios are passing but there are pending, undefined or unknown scenario steps.
21
37
  - **3** - One or more scenario steps have failed.
22
38
 
23
- - Typescript and esbuild transpiler support.
39
+ - CommonJS transpilers using either esbuild or ts-node.
24
40
 
25
41
  - Vue3 transformer used to handle .vue files in tests.
26
42
 
@@ -38,13 +54,14 @@ In addition, the following features have been added:
38
54
 
39
55
  - A behave-json-formatter that fixes json so it can be used with Behave Pro.
40
56
 
57
+ - A junit-bamboo formatter that generates xml compatible with the Bamboo JUnit plugin.
58
+
41
59
  - tsflow-snippet-syntax used to format snippet examples.
60
+
42
61
  - snippets use the [Cucumber Expressions](https://github.com/cucumber/cucumber-expressions#readme) Syntax for parameters.
43
62
 
44
63
  - [Context Injection](#context-injection) updates with support to initialize the context before each scenario test run and dispose the context after a scenario has finished executing.
45
64
 
46
-
47
-
48
65
  <div style="padding: 15px; border: 1px solid transparent; border-color: transparent; margin-bottom: 20px; border-radius: 4px; color: #8a6d3b; background-color: #fcf8e3; border-color: #faebcc;">
49
66
  <strong><span style="color: #000">Note:</span></strong> With recent updates you must use the <strong><span style="color: #000">cucumber-tsflow</span></strong> command to execute tests. This command executes the same API calls that cucumber-js does and supports all of the options and features as cucumber-js along with new features listed above.
50
67
  </div>
@@ -61,6 +78,12 @@ cucumber-tsflow uses TypeScript Decorators to create SpecFlow like bindings for
61
78
  npm install @lynxwall/cucumber-tsflow --save-dev
62
79
  ```
63
80
 
81
+ #### pnpm
82
+
83
+ ```bash
84
+ pnpm add @lynxwall/cucumber-tsflow --save-dev
85
+ ```
86
+
64
87
  #### yarn
65
88
 
66
89
  ```bash
@@ -129,6 +152,75 @@ Running the cucumber-tsflow command will execute your features along with the su
129
152
 
130
153
  In this quick example test state is encapsulated directly in the class. As your test suite grows larger and step definitions get shared between multiple classes, you can begin using '[Context Injection](#context-injection)' to share state between running step definitions.
131
154
 
155
+ ## Transpilers and TypeScript
156
+
157
+ Cucumber-tsflow provides several [transpilers](#transpiler-and-vue3-supported) that can be used in your configuration. However, you are not required to use them. If a different configuration or transpiler is needed you can copy code from one of the provided transpilers.
158
+
159
+ This section focuses on the Typescript configuration used to transpile your test code, and any dependencies, into JavaScript that is executed within the cucumber-js test runner.
160
+
161
+ ### CommonJS and ESM
162
+
163
+ The transpilers included with cucumber-tsflow transpile to **CommonJS** and do not support projects with `"type": "module"` in your `package.json`. However, [esModuleinterop](https://www.typescriptlang.org/tsconfig/#esModuleInterop) is enabled by default, which allows you to write code using ECMAScript (ESM) standards and import ESM modules in your test code.
164
+
165
+ ### TypeScript Configuration
166
+
167
+ All of the transpilers included with cucumber-tsflow use the same TypeScript configuration, which take precedence when running your tests using one of these transpilers. In other words, while each transpiler is different, they all use the same tsconfig settings, which are shown below:
168
+
169
+ ```json
170
+ compilerOptions: {
171
+ module: 'nodeNext',
172
+ target: 'es2022',
173
+ strict: true,
174
+ resolveJsonModule: true,
175
+ esModuleInterop: true,
176
+ skipLibCheck: true,
177
+ lib: ['es2022', 'esnext.decorators']
178
+ },
179
+ ```
180
+
181
+ When test runs are started, the settings from your local tsconfig.json are loaded first and then the settings from the transpiler will override the specific settings shown above. As a result, you should use these transpilers in projects that will support these settings.
182
+
183
+ For example, the settings from the cucumber-tsflow vue test project is shown below:
184
+
185
+ ```json
186
+ "compilerOptions": {
187
+ "baseUrl": ".",
188
+ "target": "es2022",
189
+ "module": "Node18",
190
+ "strict": true,
191
+ "importHelpers": true,
192
+ "skipLibCheck": true,
193
+ "esModuleInterop": true,
194
+ "forceConsistentCasingInFileNames": true,
195
+ "useDefineForClassFields": true,
196
+ "inlineSourceMap": true,
197
+ "allowJs": true,
198
+ "removeComments": false,
199
+ "lib": ["es2022", "esnext.decorators"],
200
+ "typeRoots": ["../../node_modules/@types"]
201
+ },
202
+ ```
203
+
204
+ These settings are similar to the default transpiler settings, which will not cause an issue. The only change will be the module from Node18 to nodeNext. Any other settings that are not included in the transpiler default will also be applied when the transpiler is executed.
205
+
206
+ ### esbuild Transpilers
207
+
208
+ Cucumber-tsflow provides two esbuild transpilers: one with esbuild and support for Vue using the vue-sfc transpiler, and another that only uses the esbuild transpiler. Both cucumber-tsflow transpilers use the same esbuild transpiler, which is configured to generate CommonJS, as shown below:
209
+
210
+ ```typescript
211
+ const commonOptions: CommonOptions = {
212
+ format: 'cjs',
213
+ logLevel: 'info',
214
+ target: [`es2020`],
215
+ minify: false,
216
+ sourcemap: 'external'
217
+ };
218
+ ```
219
+
220
+ As you can see, this also uses the same target as the typescript configuration. In addition, minify is set to false, which makes it easy to debug and step into code when running tests.
221
+
222
+ As mentioned at the beginning of this section, there are several transpilers provided, which can be used with your test project. The [transpilers](#transpiler-and-vue3-supported) section below provides information on how to configure your project to use one of these transpilers.
223
+
132
224
  ## Cucumber-tsflow Test Runner
133
225
 
134
226
  As mentioned previously, with recent updates cucumber-tsflow must be used to execute tests. The reason for this update was to replace before and after hooks previously used to manage context with a message handler. Executing tests with cucumber-tsflow uses the same API calls that cucumber-js does. The only differences are updates to support new configuration parameters along with updates to step definitions that set the correct location.
@@ -220,19 +312,19 @@ echo $?
220
312
 
221
313
  ## New Configuration options
222
314
 
223
- As mentioned, when using cucumber-tsflow to execute tests all of the configuration options documented here are supported: <https://github.com/cucumber/cucumber-js/blob/v8.0.0/docs/configuration.md>
315
+ As mentioned, when using cucumber-tsflow to execute tests all of the configuration options documented here are supported: <https://github.com/cucumber/cucumber-js/blob/v11.2.0/docs/configuration.md>
224
316
 
225
317
  In addition to cucumber configuration options the following two options have been added:
226
318
 
227
- | Name | Type | Repeatable | CLI Option | Description | Default |
228
- | ---------------- | --------- | ---------- | -------------------- | ------------------------------------------------------------ | ------- |
319
+ | Name | Type | Repeatable | CLI Option | Description | Default |
320
+ | ---------------- | --------- | ---------- | -------------------- | ------------------------------------------------------------- | ------- |
229
321
  | `transpiler` | `string` | No | `--transpiler` | Name of the transpiler to use: esnode, esvue, tsnode or tsvue | esnode |
230
- | `debugFile` | `string` | No | `--debug-file` | Path to a file with steps for debugging | |
231
- | `enableVueStyle` | `boolean` | No | `--enable-vue-style` | Enable Vue `<style>` block when compiling Vue SFC. | false |
322
+ | `debugFile` | `string` | No | `--debug-file` | Path to a file with steps for debugging | |
323
+ | `enableVueStyle` | `boolean` | No | `--enable-vue-style` | Enable Vue `<style>` block when compiling Vue SFC. | false |
232
324
 
233
- #### Transpiler and Vue3 supported
325
+ ### Transpiler and Vue3 supported
234
326
 
235
- Using TypeScript with cucumberJs requires a couple of tsconfig.json parameters as described here: [Transpiling](https://github.com/cucumber/cucumber-js/blob/v9.1.0/docs/transpiling.md)
327
+ Using TypeScript with cucumber-js requires setting tsconfig.json parameters as described here: [cucumber-js Transpiling](https://github.com/cucumber/cucumber-js/blob/v11.2.0/docs/transpiling.md). In addition, there is no support for transpiling Vue files with cucumber-js.
236
328
 
237
329
  As a result, cucumber-tsflow adds several configurations for transpiling TypeScript code using the recommended configuration. In addition, support has been added to transform .vue files during test execution allowing you to test Vue SFC components using cucumber.
238
330
 
@@ -247,6 +339,10 @@ The following transpilers are provided:
247
339
  - **tsvue**: Uses typescript to transpile TypeScript code and adds a hook for .vue files, which transforms Vue SFC components into commonJS.
248
340
  - **jsdom** is also loaded globally to support loading and testing Vue SFC components.
249
341
 
342
+ <div style="padding: 15px; border: 1px solid transparent; border-color: transparent; margin-bottom: 20px; border-radius: 4px; color: #8a6d3b; background-color: #fcf8e3; border-color: #faebcc;">
343
+ <strong><span style="color: #000">Note:</span></strong> The transpilers provide with cucumber-tsflow will only support CommonJS modules. In other words, if your package.json file has 'type: module' you will not be able to use these transpilers. However, you can use ts-node for transpiling as documented here: <a ref='https://github.com/cucumber/cucumber-js/blob/v11.2.0/docs/transpiling.md#esm'>Transpiling</a>
344
+ </div>
345
+
250
346
  ##### Using the transpiler configuration option
251
347
 
252
348
  When configuring cucumber to execute tests you can specify which transpiler to use with the `transpiler` configuration option as shown below:
@@ -266,12 +362,12 @@ You can also use the `requireModule` parameter to configure a transpiler. The fo
266
362
  ```json
267
363
  {
268
364
  "default": {
269
- "requireModule": ["@lynxwall/cucumber-tsflow/lib/esvue"]
365
+ "requireModule": ["@lynxwall/cucumber-tsflow/esvue"]
270
366
  }
271
367
  }
272
368
  ```
273
369
 
274
- #### Debug File support
370
+ ### Debug File support
275
371
 
276
372
  The new `debugFile` configuration option allows you to specify a .ts file with step definitions that you want to debug. This will search for a matching feature and execute the tests in that feature. This option is helpful when debugging tests and you don't want to run all of the tests.
277
373
 
@@ -284,9 +380,9 @@ If using VSCode to edit your project the following launch configurations can be
284
380
  "name": "Debug All",
285
381
  "type": "node",
286
382
  "request": "launch",
287
- "program": "${workspaceRoot}/node_modules/@lynxwall/cucumber-tsflow/bin/cucumber-tsflow",
383
+ "program": "${workspaceRoot}/node_modules/@lynxwall/cucumber-tsflow/bin/cucumber-tsflow/vue",
288
384
  "stopOnEntry": true,
289
- "args": ["-p", "default"],
385
+ "args": ["-p", "esvue"],
290
386
  "cwd": "${workspaceRoot}",
291
387
  "runtimeExecutable": null,
292
388
  "runtimeArgs": ["--nolazy"],
@@ -305,9 +401,9 @@ If using VSCode to edit your project the following launch configurations can be
305
401
  "name": "Debug Feature",
306
402
  "type": "node",
307
403
  "request": "launch",
308
- "program": "${workspaceRoot}/node_modules/@lynxwall/cucumber-tsflow/bin/cucumber-tsflow",
404
+ "program": "${workspaceRoot}/node_modules/@lynxwall/cucumber-tsflow/bin/cucumber-tsflow/vue",
309
405
  "stopOnEntry": true,
310
- "args": ["--debug-file", "${file}", "-p", "default"],
406
+ "args": ["--debug-file", "${file}", "-p", "esvue"],
311
407
  "cwd": "${workspaceRoot}",
312
408
  "runtimeExecutable": null,
313
409
  "runtimeArgs": ["--nolazy"],
@@ -416,7 +512,7 @@ public givenAValueBasedSearch(searchValue: string): void {
416
512
  }
417
513
  ```
418
514
 
419
- **Note**: Tags added to steps work the same as "Tagged Hooks" documented here: <https://github.com/cucumber/cucumber-js/blob/v8.0.0/docs/support_files/hooks.md>
515
+ **Note**: Tags added to steps work the same as "Tagged Hooks" documented here: <https://github.com/cucumber/cucumber-js/blob/v11.2.0/docs/support_files/hooks.md>
420
516
 
421
517
  ## Hooks
422
518
 
@@ -517,7 +613,7 @@ If it doesn't already exist, create a file named cucumber.json at the root of yo
517
613
 
518
614
  #### Using the behave json formatter
519
615
 
520
- The following example shows how to configure the behave formatter in cucumber.json. The tsflow-snippet-syntax module is configured as the default snippet syntax and does not require configuration. However, you can override the snippet syntax as documented here: <https://github.com/cucumber/cucumber-js/blob/v8.0.0/docs/custom_snippet_syntaxes.md>
616
+ The following example shows how to configure the behave formatter in cucumber.json. The tsflow-snippet-syntax module is configured as the default snippet syntax and does not require configuration. However, you can override the snippet syntax as documented here: <https://github.com/cucumber/cucumber-js/blob/v11.2.0/docs/custom_snippet_syntaxes.md>
521
617
 
522
618
  ```typescript
523
619
  {
@@ -549,32 +645,32 @@ Like 'specflow', cucumber-tsflow supports a simple dependency injection framewor
549
645
 
550
646
  ### Sharing Data between Steps and Bindings
551
647
 
552
- Each scenario in a feature will get a new instance of the *Context* object when the steps associated with a scenario are executed. Hooks and steps used by the scenario will have access to the same instance of a "Scenario Context" during execution of the test steps. In addition, if steps of a scenario are implemented in separate bindings, those steps will still have access to the same instance of the *Context* object created for the scenario.
648
+ Each scenario in a feature will get a new instance of the _Context_ object when the steps associated with a scenario are executed. Hooks and steps used by the scenario will have access to the same instance of a "Scenario Context" during execution of the test steps. In addition, if steps of a scenario are implemented in separate bindings, those steps will still have access to the same instance of the _Context_ object created for the scenario.
553
649
 
554
650
  **Recent Updates:**
555
651
 
556
652
  - versions >= 6.5.2
653
+
557
654
  - Updated execution of the `initialize()` function to pass in argument that is an object with information about the Test Case (Scenario).
558
655
  - The object passed in will be in the form:
559
656
  `{ pickle, gherkinDocument, testCaseStartedId } : StartTestCaseInfo`
560
657
  - Updated execution of the `dispose()` function to pass in argument that is an object with information about the Test Case (Scenario).
561
658
  - The object passed in will be in the form:
562
659
  `{ pickle, gherkinDocument, result, willBeRetried, testCaseStartedId } : EndTestCaseInfo`
563
-
660
+
564
661
  - versions >= 6.5.0
565
662
  - Context classes now support an `initialize()` function that can be defined synchronous or asynchronous. The `initialize()` function is called after the `BeforeAll` hook and before any other hooks or steps. This provides the ability to initialize a scenario context before any tests are executed with support for async operations.
566
663
  - Context classes have always supported a `dispose()` function for cleanup. However, with latest updates the `dispose()` function can be defined synchronously or asynchronously.
567
664
  - versions >= 6.4.0
568
665
  - The current Cucumber World object is now available as a constructor parameter on all classes defined for Context Injection. For more information on the World object see: [Access to Cucumber.js World object](#access-to-cucumber.js-world-object).
569
666
 
570
-
571
667
  ### Using Context Injection
572
668
 
573
669
  With Context Injection you first need to define one or more classes that will be injected into a binding instance. Next, you'll need to add the context types to the `@binding` decorator and implement a constructor that passes initialized instances of the context type into the binding instance.
574
670
 
575
671
  **Defining a Context class:**
576
672
 
577
- - Create a simple *Context* class representing the shared data. The class can have no constructor or a default empty constructor. However, to access the Cucumber World object you should define a constructor as shown in the example below.
673
+ - Create a simple _Context_ class representing the shared data. The class can have no constructor or a default empty constructor. However, to access the Cucumber World object you should define a constructor as shown in the example below.
578
674
 
579
675
  **Synchronous example:**
580
676
 
@@ -593,7 +689,7 @@ export class ScenarioContext {
593
689
  public initialize({ pickle, gherkinDocument }: StartTestCaseInfo): void {
594
690
  this.id = this.makeid(5);
595
691
  console.log(`Sync init: ${this.id}`);
596
- console.log(`Start Test Case: ${this.getFeatureAndScenario(gherkinDocument.uri!, pickle.name)}`);
692
+ console.log(`Start Test Case: ${this.getFeatureAndScenario(gherkinDocument.uri!, pickle.name)}`);
597
693
  }
598
694
  public dispose({ pickle, gherkinDocument }: EndTestCaseInfo): void {
599
695
  console.log(`Sync dispose: ${this.id}`);
@@ -647,11 +743,9 @@ export class ScenarioContext {
647
743
  }
648
744
  ```
649
745
 
650
-
651
-
652
746
  **Initialize Binding in Step class:**
653
747
 
654
- - Update the `@binding()` decorator to indicate the types of context objects that are required by the 'binding' class. You can include up to nine separate *Context* objects.
748
+ - Update the `@binding()` decorator to indicate the types of context objects that are required by the 'binding' class. You can include up to nine separate _Context_ objects.
655
749
  - Define a constructor on the `@binding` class with steps that need access to the shared data that accepts one or more context objects as parameters based on initialization of the `@binding` decorator.
656
750
 
657
751
  **Single Context class example:**
@@ -688,7 +782,10 @@ import { expect } from 'chai';
688
782
 
689
783
  @binding([ScenarioContext, SyncContext])
690
784
  export default class InjectionTestSteps1 {
691
- constructor(private context: ScenarioContext, private syncContext: SyncContext) {}
785
+ constructor(
786
+ private context: ScenarioContext,
787
+ private syncContext: SyncContext
788
+ ) {}
692
789
 
693
790
  @given('The Workspace is available and valid')
694
791
  theWorkspaceIsAvailableAndValid() {
@@ -706,8 +803,6 @@ export default class InjectionTestSteps1 {
706
803
  }
707
804
  ```
708
805
 
709
-
710
-
711
806
  ### Access to Cucumber.js World object
712
807
 
713
808
  The context object that you inject can also be configured to access the [World](https://github.com/cucumber/cucumber-js/blob/main/docs/support_files/world.md) object from Cucumber.js, which provides the following:
@@ -716,7 +811,7 @@ The context object that you inject can also be configured to access the [World](
716
811
  - `log`: a method for [logging](https://github.com/cucumber/cucumber-js/blob/main/docs/support_files/attachments.md#logging) information from hooks/steps
717
812
  - `parameters`: an object of parameters passed in via configuration
718
813
 
719
- Starting with version **6.4.0** the Cucumber World object is now passed into a *Context* class as a constructor parameter as shown below:
814
+ Starting with version **6.4.0** the Cucumber World object is now passed into a _Context_ class as a constructor parameter as shown below:
720
815
 
721
816
  ```typescript
722
817
  import { World } from '@cucumber/cucumber';
@@ -739,15 +834,15 @@ In the example shown above, the world object instance passed in to the construct
739
834
 
740
835
  **NOTE:** `BeforeAll` and `AfterAll` hooks do not have access to the scenario context.
741
836
 
742
- *Context* classes, as demonstrated by the `ScenarioContext` example above, also support a `dispose()` function that is called when the execution of a test scenario is complete.
837
+ _Context_ classes, as demonstrated by the `ScenarioContext` example above, also support a `dispose()` function that is called when the execution of a test scenario is complete.
743
838
 
744
839
  With instance initialization, and dispose functionality, you have the ability to initialize common support operations and data needed for scenario test runs, and cleanup any resources when scenario test runs are complete.
745
840
 
746
841
  ### Access to the World object without using a constructor
747
842
 
748
- **NOTE:** This approach of accessing the Cucumber World object is still supported. However, the ability to access the world object during *Context* initialization provides much better control over when context data is initialized versus relying on execution of a hook. As a result, using a `@before` hook as shown below is not recommended.
843
+ **NOTE:** This approach of accessing the Cucumber World object is still supported. However, the ability to access the world object during _Context_ initialization provides much better control over when context data is initialized versus relying on execution of a hook. As a result, using a `@before` hook as shown below is not recommended.
749
844
 
750
- With this approach, you would define a world property on simple *Context* class that you're injecting:
845
+ With this approach, you would define a world property on simple _Context_ class that you're injecting:
751
846
 
752
847
  ```typescript
753
848
  import { World } from '@cucumber/cucumber';
package/api/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /*
2
+ allows TypeScript to see `@cucumber/cucumber/api` where it doesn't yet support
3
+ subpath exports, see <https://github.com/microsoft/TypeScript/issues/33079>
4
+ */
5
+
6
+ export * from '../lib/api';
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
2
-
3
- require('../lib/cli/run.js').default();
1
+ #!/usr/bin/env node
2
+
3
+ require('../lib/cli/run.js').default();
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../lib/cli/run.js').default();
@@ -0,0 +1,17 @@
1
+ /**
2
+ * JavaScript API for running and extending Cucumber
3
+ *
4
+ * @packageDocumentation
5
+ * @module api
6
+ * @remarks
7
+ * These docs cover the API used for running Cucumber-tsflow programmatically. The entry point is `@lynxwall/cucumber-tsflow/api`.
8
+ */
9
+ export { IConfiguration } from '@cucumber/cucumber/lib/configuration/index';
10
+ export { IRunEnvironment } from '@cucumber/cucumber/lib/environment/index';
11
+ export { IPickleOrder } from '@cucumber/cucumber/lib/filter/index';
12
+ export { IPublishConfig } from '@cucumber/cucumber/lib/publish/index';
13
+ export * from './load-configuration';
14
+ export * from '@cucumber/cucumber/lib/api/load_sources';
15
+ export * from './load-support';
16
+ export * from './run-cucumber';
17
+ export * from '@cucumber/cucumber/lib/api/types';
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * JavaScript API for running and extending Cucumber
4
+ *
5
+ * @packageDocumentation
6
+ * @module api
7
+ * @remarks
8
+ * These docs cover the API used for running Cucumber-tsflow programmatically. The entry point is `@lynxwall/cucumber-tsflow/api`.
9
+ */
10
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }) : (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ o[k2] = m[k];
20
+ }));
21
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ __exportStar(require("./load-configuration"), exports);
26
+ __exportStar(require("@cucumber/cucumber/lib/api/load_sources"), exports);
27
+ __exportStar(require("./load-support"), exports);
28
+ __exportStar(require("./run-cucumber"), exports);
29
+ __exportStar(require("@cucumber/cucumber/lib/api/types"), exports);
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;AAMH,uDAAqC;AACrC,0EAAwD;AACxD,iDAA+B;AAC/B,iDAA+B;AAC/B,mEAAiD","sourcesContent":["/**\r\n * JavaScript API for running and extending Cucumber\r\n *\r\n * @packageDocumentation\r\n * @module api\r\n * @remarks\r\n * These docs cover the API used for running Cucumber-tsflow programmatically. The entry point is `@lynxwall/cucumber-tsflow/api`.\r\n */\r\n\r\nexport { IConfiguration } from '@cucumber/cucumber/lib/configuration/index';\r\nexport { IRunEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nexport { IPickleOrder } from '@cucumber/cucumber/lib/filter/index';\r\nexport { IPublishConfig } from '@cucumber/cucumber/lib/publish/index';\r\nexport * from './load-configuration';\r\nexport * from '@cucumber/cucumber/lib/api/load_sources';\r\nexport * from './load-support';\r\nexport * from './run-cucumber';\r\nexport * from '@cucumber/cucumber/lib/api/types';\r\n"]}
@@ -0,0 +1,21 @@
1
+ import { ILoadConfigurationOptions, IRunConfiguration } from '@cucumber/cucumber/lib/api/types';
2
+ import { IRunEnvironment } from '@cucumber/cucumber/lib/environment/index';
3
+ import { ITsflowConfiguration } from '../cli/argv-parser';
4
+ export interface ITsflowResolvedConfiguration {
5
+ /**
6
+ * The final flat configuration object resolved from the configuration file/profiles plus any extra provided.
7
+ */
8
+ useConfiguration: ITsflowConfiguration;
9
+ /**
10
+ * The format that can be passed into `runCucumber`.
11
+ */
12
+ runConfiguration: IRunConfiguration;
13
+ }
14
+ /**
15
+ * Load user-authored configuration to be used in a test run.
16
+ *
17
+ * @public
18
+ * @param options - Coordinates required to find configuration.
19
+ * @param environment - Project environment.
20
+ */
21
+ export declare const loadConfiguration: (options?: ILoadConfigurationOptions, environment?: IRunEnvironment) => Promise<ITsflowResolvedConfiguration>;
@@ -0,0 +1,127 @@
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.loadConfiguration = void 0;
7
+ const locate_file_1 = require("@cucumber/cucumber/lib/configuration/locate_file");
8
+ const index_1 = require("@cucumber/cucumber/lib/configuration/index");
9
+ const validate_configuration_1 = require("@cucumber/cucumber/lib/configuration/validate_configuration");
10
+ const convert_configuration_1 = require("@cucumber/cucumber/lib/api/convert_configuration");
11
+ const index_2 = require("@cucumber/cucumber/lib/environment/index");
12
+ const helpers_1 = require("../utils/helpers");
13
+ const gherkin_manager_1 = __importDefault(require("../gherkin/gherkin-manager"));
14
+ const ansis_1 = __importDefault(require("ansis"));
15
+ /**
16
+ * Load user-authored configuration to be used in a test run.
17
+ *
18
+ * @public
19
+ * @param options - Coordinates required to find configuration.
20
+ * @param environment - Project environment.
21
+ */
22
+ const loadConfiguration = async (options = {}, environment = {}) => {
23
+ const { cwd, env, logger } = (0, index_2.makeEnvironment)(environment);
24
+ const configFile = options.file ?? (0, locate_file_1.locateFile)(cwd);
25
+ if (configFile) {
26
+ logger.debug(`Configuration will be loaded from "${configFile}"`);
27
+ }
28
+ else if (configFile === false) {
29
+ logger.debug('Skipping configuration file resolution');
30
+ }
31
+ else {
32
+ logger.debug('No configuration file found');
33
+ }
34
+ const profileConfiguration = configFile ? await (0, index_1.fromFile)(logger, cwd, configFile, options.profiles) : {};
35
+ // if a feature was passed in on command line it's added
36
+ // to the provided configuration as paths. We need to clear
37
+ // any paths from configuration so that only the feature passed
38
+ // in is executed.
39
+ const paths = options.provided.paths;
40
+ if (paths && paths?.length > 0) {
41
+ profileConfiguration.paths = [];
42
+ }
43
+ const original = (0, index_1.mergeConfigurations)(index_1.DEFAULT_CONFIGURATION, profileConfiguration, (0, index_1.parseConfiguration)(logger, 'Provided', options.provided));
44
+ switch (original.transpiler) {
45
+ case 'esvue':
46
+ original.requireModule.push('@lynxwall/cucumber-tsflow/lib/esvue');
47
+ break;
48
+ case 'tsvue':
49
+ original.requireModule.push('@lynxwall/cucumber-tsflow/lib/tsvue');
50
+ break;
51
+ case 'tsnode':
52
+ original.requireModule.push('@lynxwall/cucumber-tsflow/lib/tsnode');
53
+ break;
54
+ default:
55
+ // defaulting to esbuild
56
+ original.requireModule.push('@lynxwall/cucumber-tsflow/lib/esnode');
57
+ break;
58
+ }
59
+ // set the snippet syntax
60
+ if (!original.formatOptions.snippetSyntax) {
61
+ original.formatOptions.snippetSyntax = '@lynxwall/cucumber-tsflow/snippet';
62
+ }
63
+ // look for behave format
64
+ for (let idx = 0; idx < original.format.length; idx++) {
65
+ if (typeof original.format[idx] === 'string') {
66
+ const formatItem = original.format[idx];
67
+ if (formatItem.startsWith('behave:')) {
68
+ original.format[idx] = formatItem.replace('behave', '@lynxwall/cucumber-tsflow/behave');
69
+ }
70
+ }
71
+ else if (original.format[idx].length > 0) {
72
+ const formatItem = original.format[idx][0];
73
+ if (formatItem.startsWith('behave')) {
74
+ const newVal = formatItem.replace('behave', '@lynxwall/cucumber-tsflow/behave');
75
+ original.format[idx] = original.format[idx].length > 1 ? [newVal, original.format[idx][1]] : [newVal];
76
+ }
77
+ }
78
+ }
79
+ // look for junitbamboo format
80
+ for (let idx = 0; idx < original.format.length; idx++) {
81
+ if (typeof original.format[idx] === 'string') {
82
+ const formatItem = original.format[idx];
83
+ if (formatItem.startsWith('junitbamboo:')) {
84
+ original.format[idx] = formatItem.replace('junitbamboo', '@lynxwall/cucumber-tsflow/junitbamboo');
85
+ }
86
+ }
87
+ else if (original.format[idx].length > 0) {
88
+ const formatItem = original.format[idx][0];
89
+ if (formatItem.startsWith('junitbamboo')) {
90
+ const newVal = formatItem.replace('junitbamboo', '@lynxwall/cucumber-tsflow/junitbamboo');
91
+ original.format[idx] = original.format[idx].length > 1 ? [newVal, original.format[idx][1]] : [newVal];
92
+ }
93
+ }
94
+ }
95
+ // check to see if a debugFile was passed in
96
+ if ((0, helpers_1.hasStringValue)(original.debugFile)) {
97
+ // Initialize gherkin manager with path to feature files
98
+ const gherkin = new gherkin_manager_1.default();
99
+ await gherkin.loadFeatures(original.paths);
100
+ const features = gherkin.findFeaturesByStepFile(original.debugFile);
101
+ if (features.length > 0) {
102
+ original.paths = [];
103
+ features.forEach(x => original.paths.push(x.featureFile));
104
+ }
105
+ else {
106
+ // log a message if the feature path is not found
107
+ logger.warn(ansis_1.default.yellow(`\nUnable to find feature for debugFile: ${original.debugFile}`));
108
+ logger.warn(ansis_1.default.yellow('All tests will be executed\n'));
109
+ }
110
+ }
111
+ // check to see if enable-vue-style was set
112
+ // if not, default it to false
113
+ if (original.enableVueStyle === null || original.enableVueStyle === undefined) {
114
+ original.enableVueStyle = false;
115
+ }
116
+ // set our global parameter used by the Vue transpiler
117
+ // to determine if Vue Style Blocks should be enabled
118
+ global.enableVueStyle = original.enableVueStyle;
119
+ (0, validate_configuration_1.validateConfiguration)(original, logger);
120
+ const runnable = await (0, convert_configuration_1.convertConfiguration)(logger, original, env);
121
+ return {
122
+ useConfiguration: original,
123
+ runConfiguration: runnable
124
+ };
125
+ };
126
+ exports.loadConfiguration = loadConfiguration;
127
+ //# sourceMappingURL=load-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-configuration.js","sourceRoot":"","sources":["../../src/api/load-configuration.ts"],"names":[],"mappings":";;;;;;AACA,kFAA8E;AAC9E,sEAMoD;AACpD,wGAAoG;AACpG,4FAAwF;AACxF,oEAA4F;AAE5F,8CAAkD;AAClD,iFAAwD;AACxD,kDAA0B;AAc1B;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,KAAK,EACrC,UAAqC,EAAE,EACvC,cAA+B,EAAE,EACO,EAAE;IAC1C,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,uBAAe,EAAC,WAAW,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,IAA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qBAgH5B","sourcesContent":["import { ILoadConfigurationOptions, IRunConfiguration } from '@cucumber/cucumber/lib/api/types';\r\nimport { locateFile } from '@cucumber/cucumber/lib/configuration/locate_file';\r\nimport {\r\n\tDEFAULT_CONFIGURATION,\r\n\tfromFile,\r\n\tIConfiguration,\r\n\tparseConfiguration,\r\n\tmergeConfigurations\r\n} from '@cucumber/cucumber/lib/configuration/index';\r\nimport { validateConfiguration } from '@cucumber/cucumber/lib/configuration/validate_configuration';\r\nimport { convertConfiguration } from '@cucumber/cucumber/lib/api/convert_configuration';\r\nimport { IRunEnvironment, makeEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nimport { ITsflowConfiguration } from '../cli/argv-parser';\r\nimport { hasStringValue } from '../utils/helpers';\r\nimport GherkinManager from '../gherkin/gherkin-manager';\r\nimport chalk from 'ansis';\r\nimport logger from '../utils/logger';\r\n\r\nexport interface ITsflowResolvedConfiguration {\r\n\t/**\r\n\t * The final flat configuration object resolved from the configuration file/profiles plus any extra provided.\r\n\t */\r\n\tuseConfiguration: ITsflowConfiguration;\r\n\t/**\r\n\t * The format that can be passed into `runCucumber`.\r\n\t */\r\n\trunConfiguration: IRunConfiguration;\r\n}\r\n\r\n/**\r\n * Load user-authored configuration to be used in a test run.\r\n *\r\n * @public\r\n * @param options - Coordinates required to find configuration.\r\n * @param environment - Project environment.\r\n */\r\nexport const loadConfiguration = async (\r\n\toptions: ILoadConfigurationOptions = {},\r\n\tenvironment: IRunEnvironment = {}\r\n): Promise<ITsflowResolvedConfiguration> => {\r\n\tconst { cwd, env, logger } = makeEnvironment(environment);\r\n\tconst configFile = options.file ?? locateFile(cwd);\r\n\tif (configFile) {\r\n\t\tlogger.debug(`Configuration will be loaded from \"${configFile}\"`);\r\n\t} else if (configFile === false) {\r\n\t\tlogger.debug('Skipping configuration file resolution');\r\n\t} else {\r\n\t\tlogger.debug('No configuration file found');\r\n\t}\r\n\tconst profileConfiguration = configFile ? await fromFile(logger, cwd, configFile, options.profiles) : {};\r\n\r\n\t// if a feature was passed in on command line it's added\r\n\t// to the provided configuration as paths. We need to clear\r\n\t// any paths from configuration so that only the feature passed\r\n\t// in is executed.\r\n\tconst paths = (options.provided as Partial<IConfiguration>).paths;\r\n\tif (paths && paths?.length > 0) {\r\n\t\tprofileConfiguration.paths = [];\r\n\t}\r\n\r\n\tconst original = mergeConfigurations(\r\n\t\tDEFAULT_CONFIGURATION,\r\n\t\tprofileConfiguration,\r\n\t\tparseConfiguration(logger, 'Provided', options.provided)\r\n\t) as ITsflowConfiguration;\r\n\r\n\tswitch (original.transpiler) {\r\n\t\tcase 'esvue':\r\n\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/esvue');\r\n\t\t\tbreak;\r\n\t\tcase 'tsvue':\r\n\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/tsvue');\r\n\t\t\tbreak;\r\n\t\tcase 'tsnode':\r\n\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/tsnode');\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\t// defaulting to esbuild\r\n\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/esnode');\r\n\t\t\tbreak;\r\n\t}\r\n\t// set the snippet syntax\r\n\tif (!original.formatOptions.snippetSyntax) {\r\n\t\toriginal.formatOptions.snippetSyntax = '@lynxwall/cucumber-tsflow/snippet';\r\n\t}\r\n\t// look for behave format\r\n\tfor (let idx = 0; idx < original.format.length; idx++) {\r\n\t\tif (typeof original.format[idx] === 'string') {\r\n\t\t\tconst formatItem = original.format[idx] as string;\r\n\t\t\tif (formatItem.startsWith('behave:')) {\r\n\t\t\t\toriginal.format[idx] = formatItem.replace('behave', '@lynxwall/cucumber-tsflow/behave');\r\n\t\t\t}\r\n\t\t} else if (original.format[idx].length > 0) {\r\n\t\t\tconst formatItem = original.format[idx][0] as string;\r\n\t\t\tif (formatItem.startsWith('behave')) {\r\n\t\t\t\tconst newVal = formatItem.replace('behave', '@lynxwall/cucumber-tsflow/behave');\r\n\t\t\t\toriginal.format[idx] = original.format[idx].length > 1 ? [newVal, original.format[idx][1]] : [newVal];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// look for junitbamboo format\r\n\tfor (let idx = 0; idx < original.format.length; idx++) {\r\n\t\tif (typeof original.format[idx] === 'string') {\r\n\t\t\tconst formatItem = original.format[idx] as string;\r\n\t\t\tif (formatItem.startsWith('junitbamboo:')) {\r\n\t\t\t\toriginal.format[idx] = formatItem.replace('junitbamboo', '@lynxwall/cucumber-tsflow/junitbamboo');\r\n\t\t\t}\r\n\t\t} else if (original.format[idx].length > 0) {\r\n\t\t\tconst formatItem = original.format[idx][0] as string;\r\n\t\t\tif (formatItem.startsWith('junitbamboo')) {\r\n\t\t\t\tconst newVal = formatItem.replace('junitbamboo', '@lynxwall/cucumber-tsflow/junitbamboo');\r\n\t\t\t\toriginal.format[idx] = original.format[idx].length > 1 ? [newVal, original.format[idx][1]] : [newVal];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// check to see if a debugFile was passed in\r\n\tif (hasStringValue(original.debugFile)) {\r\n\t\t// Initialize gherkin manager with path to feature files\r\n\t\tconst gherkin = new GherkinManager();\r\n\t\tawait gherkin.loadFeatures(original.paths);\r\n\t\tconst features = gherkin.findFeaturesByStepFile(original.debugFile);\r\n\t\tif (features.length > 0) {\r\n\t\t\toriginal.paths = [];\r\n\t\t\tfeatures.forEach(x => original.paths.push(x.featureFile));\r\n\t\t} else {\r\n\t\t\t// log a message if the feature path is not found\r\n\t\t\tlogger.warn(chalk.yellow(`\\nUnable to find feature for debugFile: ${original.debugFile}`));\r\n\t\t\tlogger.warn(chalk.yellow('All tests will be executed\\n'));\r\n\t\t}\r\n\t}\r\n\r\n\t// check to see if enable-vue-style was set\r\n\t// if not, default it to false\r\n\tif (original.enableVueStyle === null || original.enableVueStyle === undefined) {\r\n\t\toriginal.enableVueStyle = false;\r\n\t}\r\n\t// set our global parameter used by the Vue transpiler\r\n\t// to determine if Vue Style Blocks should be enabled\r\n\tglobal.enableVueStyle = original.enableVueStyle;\r\n\r\n\tvalidateConfiguration(original, logger);\r\n\tconst runnable = await convertConfiguration(logger, original, env);\r\n\treturn {\r\n\t\tuseConfiguration: original,\r\n\t\trunConfiguration: runnable\r\n\t};\r\n};\r\n"]}
@@ -0,0 +1,10 @@
1
+ import { IRunEnvironment } from '@cucumber/cucumber/lib/environment/index';
2
+ import { ILoadSupportOptions, ISupportCodeLibrary } from '@cucumber/cucumber/lib/api/types';
3
+ /**
4
+ * Load support code for use in test runs
5
+ *
6
+ * @public
7
+ * @param options - Options required to find the support code
8
+ * @param environment - Project environment
9
+ */
10
+ export declare function loadSupport(options: ILoadSupportOptions, environment?: IRunEnvironment): Promise<ISupportCodeLibrary>;