@lynxwall/cucumber-tsflow 4.1.6 → 5.0.2

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 (76) hide show
  1. package/README.md +243 -71
  2. package/bin/cucumber-tsflow +1 -1
  3. package/lib/behave.js +25 -2
  4. package/lib/cli/argv-parser.d.ts +24 -0
  5. package/lib/cli/argv-parser.js +117 -0
  6. package/lib/cli/index.d.ts +22 -0
  7. package/lib/cli/index.js +105 -0
  8. package/lib/cli/load-configuration.d.ts +20 -0
  9. package/lib/cli/load-configuration.js +98 -0
  10. package/lib/cli/run.d.ts +1 -0
  11. package/lib/cli/run.js +54 -0
  12. package/lib/cucumber/binding-decorator.js +75 -87
  13. package/lib/cucumber/binding-registry.d.ts +8 -0
  14. package/lib/cucumber/binding-registry.js +62 -11
  15. package/lib/cucumber/hook-decorators.d.ts +30 -12
  16. package/lib/cucumber/hook-decorators.js +54 -23
  17. package/lib/cucumber/managed-scenario-context.js +6 -3
  18. package/lib/cucumber/message-collector.d.ts +55 -0
  19. package/lib/cucumber/message-collector.js +143 -0
  20. package/lib/cucumber/step-definition-decorators.js +15 -8
  21. package/lib/cucumber/utils.d.ts +16 -0
  22. package/lib/cucumber/utils.js +88 -0
  23. package/lib/esnode.d.ts +0 -0
  24. package/lib/esnode.js +20 -0
  25. package/lib/{tsflow.d.ts → esvue.d.ts} +0 -0
  26. package/lib/esvue.js +52 -0
  27. package/lib/formatters/behave-json-formatter.d.ts +36 -5
  28. package/lib/formatters/behave-json-formatter.js +36 -12
  29. package/lib/formatters/tsflow-snippet-syntax.js +44 -14
  30. package/lib/gherkin/configuration.d.ts +30 -0
  31. package/lib/gherkin/configuration.js +37 -0
  32. package/lib/gherkin/gherkin-feature.d.ts +28 -0
  33. package/lib/gherkin/gherkin-feature.js +345 -0
  34. package/lib/gherkin/gherkin-manager.d.ts +29 -0
  35. package/lib/gherkin/gherkin-manager.js +123 -0
  36. package/lib/gherkin/models.d.ts +45 -0
  37. package/lib/{tsflow.js → gherkin/models.js} +2 -4
  38. package/lib/snippet.d.ts +1 -0
  39. package/lib/snippet.js +38 -0
  40. package/lib/transpilers/esbuild-transpiler.d.ts +4 -0
  41. package/lib/transpilers/esbuild-transpiler.js +31 -0
  42. package/lib/transpilers/esbuild.d.ts +12 -0
  43. package/lib/transpilers/esbuild.js +66 -0
  44. package/lib/transpilers/vue-sfc/compiler.d.ts +7 -0
  45. package/lib/transpilers/vue-sfc/compiler.js +32 -0
  46. package/lib/transpilers/vue-sfc/index.d.ts +25 -0
  47. package/lib/transpilers/vue-sfc/index.js +62 -0
  48. package/lib/transpilers/vue-sfc/main.d.ts +8 -0
  49. package/lib/transpilers/vue-sfc/main.js +266 -0
  50. package/lib/transpilers/vue-sfc/script.d.ts +5 -0
  51. package/lib/transpilers/vue-sfc/script.js +53 -0
  52. package/lib/transpilers/vue-sfc/template.d.ts +8 -0
  53. package/lib/transpilers/vue-sfc/template.js +113 -0
  54. package/lib/transpilers/vue-sfc/types.d.ts +55 -0
  55. package/lib/transpilers/vue-sfc/types.js +13 -0
  56. package/lib/transpilers/vue-sfc/utils/descriptorCache.d.ts +13 -0
  57. package/lib/transpilers/vue-sfc/utils/descriptorCache.js +67 -0
  58. package/lib/transpilers/vue-sfc/utils/error.d.ts +3 -0
  59. package/lib/transpilers/vue-sfc/utils/error.js +33 -0
  60. package/lib/transpilers/vue-sfc/utils/query.d.ts +13 -0
  61. package/lib/transpilers/vue-sfc/utils/query.js +46 -0
  62. package/lib/tsnode.js +7 -9
  63. package/lib/tsvue.d.ts +1 -21
  64. package/lib/tsvue.js +47 -45
  65. package/lib/types/step-binding-flags.d.ts +9 -1
  66. package/lib/types/step-binding-flags.js +10 -2
  67. package/lib/types/step-binding.d.ts +8 -2
  68. package/lib/types/step-binding.js +1 -1
  69. package/lib/utils/helpers.d.ts +6 -0
  70. package/lib/utils/helpers.js +28 -0
  71. package/lib/utils/logger.js +25 -2
  72. package/lib/utils/our-callsite.d.ts +1 -0
  73. package/lib/utils/our-callsite.js +33 -4
  74. package/lib/version.d.ts +1 -0
  75. package/lib/version.js +16 -0
  76. package/package.json +21 -10
package/README.md CHANGED
@@ -4,38 +4,43 @@
4
4
 
5
5
  Provides 'specflow' like bindings for CucumberJS in TypeScript 1.7+.
6
6
 
7
- This is a fork of the original cucumber-tsflow found here: [cucumber-tsflow](https://github.com/timjroberts/cucumber-js-tsflow)
7
+ Supports Vue3 files in cucumber tests.
8
8
 
9
- This fork contains the following updates:
9
+ ## Fork description
10
+ This is a detached fork of <a href="https://github.com/timjroberts/cucumber-js-tsflow" target="_blank">https://github.com/timjroberts/cucumber-js-tsflow</a>. It has had the <a href="https://github.com/wudong/cucumber-js-tsflow/tree/before_after_all_hooks" target="_blank">https://github.com/wudong/cucumber-js-tsflow/tree/before_after_all_hooks</a> branch merged into it, which adds support for beforeAll and afterAll hooks.
10
11
 
11
- - Updated to use latest version of Cucumber (@cucumber/cucumber).
12
- - Bug fixes related to tags.
13
- - Added Timeout in step definition and hooks.
14
- - Added WrapperOptions in step definitions.
15
- - Added BeforeAll and AfterAll Hooks.
16
- - Added a behave-json-formatter that fixes json so it can be used with Behave Pro.
17
- - Added tsflow-snippet-syntax used to format snippet examples.
18
- - examples use the [Cucumber Syntax](https://github.com/cucumber/cucumber-expressions#readme) for parameters.
12
+ In addition, the following features have been added:
13
+ - Test runner using cucumber-tsflow command line
14
+ - Uses underlying cucumber api to run tests
15
+ - Typescript and esbuild transpiler support
16
+ - Vue3 transformer used to handle .vue files in tests
17
+ - Timeout in step definitions and hooks
18
+ - WrapperOptions in step definitions
19
+ - BeforeStep and AfterStep Hooks
20
+ - Boolean custom definition added to cucumber expressions
21
+ - A behave-json-formatter that fixes json so it can be used with Behave Pro
22
+ - tsflow-snippet-syntax used to format snippet examples
23
+ - snippets use the <a href="https://github.com/cucumber/cucumber-expressions#readme" target="_blank">Cucumber Syntax</a> for parameters
19
24
 
20
- ### Quick Start
25
+ ## Quick Start
21
26
 
22
- cucumber-tsflow uses TypeScript Decorators to create SpecFlow like bindings for TypeScript classes and methods that allow those classes and methods to be used in your CucumberJS support files. As such, cucumber-tsflow has a peer dependency on CucumberJS, and you still run your specifications using the cucumber command line tool.
27
+ cucumber-tsflow uses TypeScript Decorators to create SpecFlow like bindings for TypeScript classes and methods that allow those classes and methods to be used in your CucumberJS support files. As such, cucumber-tsflow has a dependency on CucumberJS and extends CucumberJS functionality. However, you can run your specifications using the cucumber-tsflow command line tool.
23
28
 
24
- ##### Install @cucumber/cucumber and @lynxwall/cucumber-tsflow
29
+ ### Install @lynxwall/cucumber-tsflow
25
30
 
26
- ###### npm
31
+ #### npm
27
32
 
28
33
  ```bash
29
- npm install @cucumber/cucumber @lynxwall/cucumber-tsflow --save-dev
34
+ npm install @lynxwall/cucumber-tsflow --save-dev
30
35
  ```
31
36
 
32
- ###### yarn
37
+ #### yarn
33
38
 
34
39
  ```bash
35
- yarn add --dev @cucumber/cucumber @lynxwall/cucumber-tsflow
40
+ yarn add --dev @lynxwall/cucumber-tsflow
36
41
  ```
37
42
 
38
- ###### Create .feature files to describe your specifications
43
+ ### Create .feature files to describe your specifications
39
44
 
40
45
  By default, CucumberJS looks for .feature files in a folder called 'features', so create that folder and then create a new file called 'my_feature.feature':
41
46
 
@@ -46,13 +51,14 @@ Feature: Example Feature
46
51
  This is an example feature
47
52
 
48
53
  Scenario: Adding two numbers
49
- Given I enter "2" and "8"
50
- Then I receive the result "10"
54
+ Given I enter 2 and 8
55
+ When checking the results
56
+ Then I receive the result 10
51
57
  ```
52
58
 
53
- ###### Create the Support Files to support the Feature
59
+ ### Create the Support Files to support the Feature
54
60
 
55
- By default, CucumberJS looks for support files beneath the 'features' folder. You can override this on the cucumber command line by specifying the '-r' option. However, let's work with the default and create our code in the default location. We need to write step definitions to support the two steps that we created above.
61
+ By default, CucumberJS looks for support files beneath the 'features' folder. You can override this on the cucumber command line by specifying the '-r' option. However, let's work with the default and create our code in the default location. We need to write step definitions to support the three steps that we created above.
56
62
 
57
63
  Create a new 'ArithmeticSteps.ts' file:
58
64
 
@@ -62,36 +68,168 @@ Create a new 'ArithmeticSteps.ts' file:
62
68
  import { binding, given, then } from "@lynxwall/cucumber-tsflow";
63
69
 
64
70
  @binding()
65
- class ArithmeticSteps {
66
- private computedResult: number;
71
+ export default class ArithmeticSteps {
72
+ private computedResult = 0;
67
73
 
68
- @given('I enter {string} and {string}')
69
- iEnterstringAndstring(num1: string, num2: string): any {
70
- this.computedResult = parseInt(num1) + parseInt(num2);
74
+ @given('I enter {int} and {int}')
75
+ iEnterintAndint(int: number, int2: number): any {
76
+ this.computedResult = int + int2;
71
77
  }
72
78
 
73
- @then('I receive the result {string}')
74
- iReceiveTheResultstring(expectedResult: string): any {
75
- if (parseInt(expectedResult) !== this.computedResult) {
76
- throw new Error('Arithmetic Error');
77
- }
79
+ @when('checking the results')
80
+ checkingTheResults(): any {
81
+ expect(this.computedResult).to.be.greaterThan(0);
82
+ }
83
+
84
+ @then('I receive the result {int}')
85
+ iReceiveTheResultint(int: number): any {
86
+ if (int !== this.computedResult) {
87
+ throw new Error('Arithmetic Error');
88
+ }
78
89
  }
79
90
  }
80
-
81
- export = ArithmeticSteps;
82
91
  ```
83
92
 
84
93
  Note how the cucumber-tsflow Decorators are being used to bind the methods in the class. During runtime, these Decorators simply call the Cucumber code on your behalf in order to register callbacks with Given(), When(), Then(), etc. The callbacks that are being registered with Cucumber are wrappers around your bound class.
85
94
 
86
- ###### Compiling your TypeScript Support Code
95
+ ### Compiling your TypeScript Support Code
87
96
 
88
- You'll also need a `tsconfig.json` file to compile your code. You'll also need to ensure that the `"moduleResolution": "node"` compiler option is set in order to bring in the typings that are shipped with cucumber-tsflow.
97
+ If not using one of the [transpilers](/cucumber-js-tsflow#transpiler-and-vue3-supported) listed below you'll need a `tsconfig.json` file to compile your code. You'll also need to ensure that the `"moduleResolution": "node"` compiler option is set in order to bring in the typings that are shipped with cucumber-tsflow.
89
98
 
90
- Once compiled, running the cucumber command line should execute your features along with the support code that you've created in the class.
99
+ Running the cucumber-tsflow command line should execute your features along with the support code that you've created in the class.
91
100
 
92
101
  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' to share state between running step definitions (see below).
93
102
 
94
- ### Bindings
103
+ ## Cucumber-tsflow Test Runner
104
+
105
+ While the cucumber-js command line can be used to execute cucumber-tsflow tests, many of the new features will not be available. For instance, when using cucumber-js all reports will contain the wrong location information. In addition, new configuration parameters --transpiler and --debug-file are not available.
106
+
107
+ In order to provide correct location information (step-definition file and line number), along with support for new configuration parameters. You can run cucumber tests using the cucumber-tsflow command line. The following example demonstrates executing cucumber-tsflow from the command line to execute tests:
108
+
109
+ ```bash
110
+ C:\GitHub\cucumber-js-tsflow (vue-plugin -> origin)
111
+ λ npx cucumber-tsflow
112
+ Loading configuration and step definitions...
113
+ .....@basic after hook is called.
114
+ ......@basic after hook is called.
115
+ ........@tags1 after hook is called.
116
+ .....@tagging afterTag method is called
117
+ .......<Suspense> is an experimental feature and its API will likely change.
118
+ ..
119
+
120
+ 7 scenarios (7 passed)
121
+ 20 steps (20 passed)
122
+ 0m00.075s (executing steps: 0m00.037s)
123
+ ```
124
+
125
+ cucumber-tsflow extends cucumber-js, which means that all options and features provided by cucumber-js are supported with cucumber-tsflow. In other words, when executing tests using cucumber-tsflow the underlying cucumber api is actually used to run the tests.
126
+
127
+ ### New Configuration options
128
+
129
+ As mentioned, when using cucumber-tsflow to execute tests all of the configuration options documented here are supported: <a href="https://github.com/cucumber/cucumber-js/blob/v8.0.0/docs/configuration.md" target="_blank">https://github.com/cucumber/cucumber-js/blob/v8.0.0/docs/configuration.md</a>
130
+
131
+ In addition to cucumber configuration options the following two options have been added:
132
+
133
+ | Name | Type | Repeatable | CLI Option | Description | Default |
134
+ |-------------------|------------|------------|---------------------------|-------------------------------------------------------------------------------------------------------------------|---------|
135
+ | `transpiler` | `string` | No | `--transpiler` | Name of the transpiler to use: esnode, esvue, tsnode or tsvue | esnode |
136
+ | `debugFile` | `string` | No | `--debug-file` | Path to a file with steps for debugging | |
137
+
138
+ #### Transpiler and Vue3 supported
139
+
140
+ Using TypeScript with cucumberJs requires a couple of tsconfig.json parameters and the output needs to be commonJS as documented here: <a href="https://github.com/cucumber/cucumber-js/blob/v8.0.0/docs/transpiling.md" target="_blank">https://github.com/cucumber/cucumber-js/blob/v8.0.0/docs/transpiling.md</a>
141
+
142
+ 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.
143
+
144
+ The following transpilers are provided:
145
+ - **esnode**: Uses esbuild to transpile TypeScript code for node test execution.
146
+ - **esvue**: Uses esbuild to transpile TypeScript code and adds a hook for .vue files, which transforms Vue SFC components into commonJS.
147
+ - **jsdom** is also loaded globally to support loading and testing Vue SFC components.
148
+ - **tsnode**: Uses typescript to transpile TypeScript code for node test execution.
149
+ - **tsvue**: Uses typescript to transpile TypeScript code and adds a hook for .vue files, which transforms Vue SFC components into commonJS.
150
+ - **jsdom** is also loaded globally to support loading and testing Vue SFC components.
151
+
152
+ ##### Using cucumber-tsflow command line
153
+
154
+ When using cucumber-tsflow to execute tests you can specify which transpiler to use with the `transpiler` configuration option as shown below:
155
+
156
+ ```json
157
+ {
158
+ "default": {
159
+ "transpiler": "esvue",
160
+ "publishQuiet": true
161
+ }
162
+ }
163
+
164
+ ```
165
+
166
+ ##### Using cucumber-js command line
167
+
168
+ If using cucumber-js to execute tests you can still use one of the new transpiler configurations with the `requireModule` configuration option as shown below:
169
+
170
+ ```json
171
+ {
172
+ "default": {
173
+ "requireModule": ["@lynxwall/cucumber-tsflow/lib/esvue"],
174
+ "publishQuiet": true
175
+ }
176
+ }
177
+
178
+ ```
179
+
180
+ #### Debug File support
181
+
182
+ 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.
183
+
184
+ If using VSCode to edit your project the following launch configurations can be used:
185
+
186
+ ##### Debug All
187
+
188
+ ```json
189
+ {
190
+ "name": "Debug All",
191
+ "type": "pwa-node",
192
+ "request": "launch",
193
+ "program": "${workspaceRoot}/node_modules/@lynxwall/cucumber-tsflow/bin/cucumber-tsflow",
194
+ "stopOnEntry": true,
195
+ "args": ["-p", "default"],
196
+ "cwd": "${workspaceRoot}",
197
+ "runtimeExecutable": null,
198
+ "runtimeArgs": ["--nolazy"],
199
+ "env": {
200
+ "NODE_ENV": "development"
201
+ },
202
+ "externalConsole": false,
203
+ "console": "integratedTerminal",
204
+ "sourceMaps": true,
205
+ "outDir": null
206
+ }
207
+ ```
208
+
209
+ ##### Debug Feature
210
+
211
+ ```json
212
+ {
213
+ "name": "Debug Feature",
214
+ "type": "pwa-node",
215
+ "request": "launch",
216
+ "program": "${workspaceRoot}/node_modules/@lynxwall/cucumber-tsflow/bin/cucumber-tsflow",
217
+ "stopOnEntry": true,
218
+ "args": ["--debug-file", "${file}", "-p", "default"],
219
+ "cwd": "${workspaceRoot}",
220
+ "runtimeExecutable": null,
221
+ "runtimeArgs": ["--nolazy"],
222
+ "env": {
223
+ "NODE_ENV": "development"
224
+ },
225
+ "externalConsole": false,
226
+ "console": "integratedTerminal",
227
+ "sourceMaps": true,
228
+ "outDir": null
229
+ }
230
+ ```
231
+
232
+ ## Bindings
95
233
 
96
234
  Bindings provide the automation that connects a specification step in a Gherkin feature file to some code that
97
235
  executes for that step. When using Cucumber with TypeScript you can define this automation using a 'binding' class:
@@ -100,16 +238,12 @@ executes for that step. When using Cucumber with TypeScript you can define this
100
238
  import { binding } from "@lynxwall/cucumber-tsflow";
101
239
 
102
240
  @binding()
103
- class MySteps {
241
+ export default class MySteps {
104
242
  ...
105
243
  }
106
-
107
- export = MySteps;
108
244
  ```
109
245
 
110
- *Note*: You must use the `export = <type>;` because Cucumber expects exports in this manner.
111
-
112
- ### Step Definitions
246
+ ## Step Definitions
113
247
 
114
248
  Step definitions can be bound to automation code in a 'binding' class by implementing a public function that is
115
249
  bound with a 'given', 'when' or 'then' binding decorator:
@@ -118,23 +252,21 @@ bound with a 'given', 'when' or 'then' binding decorator:
118
252
  import { binding, given, when, then } from "@lynxwall/cucumber-tsflow";
119
253
 
120
254
  @binding()
121
- class MySteps {
255
+ export default class MySteps {
122
256
  ...
123
- @given(/I perform a search using the value "([^"]*)"/)
257
+ @given('I perform a search using the value {string}')
124
258
  public givenAValueBasedSearch(searchValue: string): void {
125
259
  ...
126
260
  }
127
261
  ...
128
262
  }
129
-
130
- export = MySteps;
131
263
  ```
132
264
 
133
265
  The function follows the same requirements of functions you would normally supply to Cucumber which means that the
134
266
  functions may be synchronous by returning nothing, use the callback, or return a `Promise<T>`. Additionally, the
135
267
  function may also be `async` following the TypeScript async semantics.
136
268
 
137
- Step definitions may also be scoped at a tag level by supplying an optional tag name when using the binding
269
+ Step definitions can be conditionally selected for execution based on the tags of the scenario by supplying tags when using the binding
138
270
  decorators:
139
271
 
140
272
  ```javascript
@@ -154,23 +286,29 @@ public givenAValueBasedSearch(searchValue: string): void {
154
286
  }
155
287
  ```
156
288
 
157
- #### Hooks
289
+ Note: Tags added to steps work the same as "Tagged Hooks" documented here: <a href="https://github.com/cucumber/cucumber-js/blob/v8.0.0/docs/support_files/hooks.md" target="_blank">https://github.com/cucumber/cucumber-js/blob/v8.0.0/docs/support_files/hooks.md</a>
290
+
291
+ ## Hooks
158
292
 
159
293
  Hooks can be used to perform additional automation on specific events such as before or after scenario execution.
160
294
  Hooks can be restricted to run for only features or scenarios with a specific tag:
161
295
 
162
296
  ```typescript
163
- import { binding, before, after } from "@lynxwall/cucumber-tsflow";
297
+ import { binding, beforeAll, before, beforeStep, afterStep, after, afterAll } from "@lynxwall/cucumber-tsflow";
164
298
 
165
299
  @binding()
166
300
  class MySteps {
167
301
  ...
302
+ @beforeAll()
303
+ public beforeAllTests(): void {
304
+ ...
305
+ }
306
+
168
307
  @before()
169
308
  public beforeAllScenarios(): void {
170
309
  ...
171
310
  }
172
- ...
173
-
311
+
174
312
  @before("@requireTempDir")
175
313
  public async beforeAllScenariosRequiringTempDirectory(): Promise<void> {
176
314
  let tempDirInfo = await this.createTemporaryDirectory();
@@ -178,6 +316,16 @@ class MySteps {
178
316
  ...
179
317
  }
180
318
 
319
+ @beforeStep('@addNumbers')
320
+ beforeStep() {
321
+ ...
322
+ }
323
+
324
+ @afterStep('@addNumbers')
325
+ afterStep() {
326
+ ...
327
+ }
328
+
181
329
  @after()
182
330
  public afterAllScenarios(): void {
183
331
  ...
@@ -187,12 +335,17 @@ class MySteps {
187
335
  public afterAllScenarios(): void {
188
336
  ...
189
337
  }
338
+
339
+ @afterAll()
340
+ public afterAllTests(): void {
341
+ ...
342
+ }
190
343
  }
191
344
 
192
345
  export = MySteps;
193
346
  ```
194
347
 
195
- #### Timeout in step definition and hooks
348
+ ### Timeout in step definition and hooks
196
349
 
197
350
  In step definition and hooks, we can set timeout. For example, to set the timeout for a step to be 20000ms, we can do:
198
351
 
@@ -211,7 +364,7 @@ tsflow currently doesn't have a way to define a global default step timeout,
211
364
 
212
365
  but it can be easily done through cucumber.js ```setDefaultTimeout``` function.
213
366
 
214
- #### Passing WrapperOptions
367
+ ### Passing WrapperOptions
215
368
 
216
369
  In step definition, we can pass additional wrapper options to cucumber js. For example:
217
370
 
@@ -226,31 +379,52 @@ public givenAValueBasedSearch(searchValue: string): void {
226
379
 
227
380
  ```
228
381
 
229
- #### Using behave-json-formatter and tsflow-snippet-syntax
382
+ ### Using behave-json-formatter and tsflow-snippet-syntax
230
383
 
231
384
  Changing the formatter used for generating json along with changing the Snippet Syntax can be done through the cucumber.js configuration file.
232
385
 
233
386
  If it doesn't already exist, create a file named cucumber.js at the root of your project. This is where we can configure different options for cucumber.js.
234
387
 
235
- The following example shows how to configure the formatter and snippet syntax:
388
+
389
+ #### Using cucumber-tsflow command line
390
+
391
+ The following example shows how to configure the behave formatter when using the cucumber-tsflow command line.
392
+ Note: When using cucumber-tsflow the tsflow-snippet-syntax is configured by default.
393
+
394
+ ```javascript
395
+ {
396
+ "default": {
397
+ "format": [
398
+ "behave:cucumber_report.json"
399
+ ],
400
+ "publishQuiet": true
401
+ }
402
+ }
403
+ ```
404
+
405
+ #### Using cucumber-js command line
406
+
407
+ The following example shows how to configure the formatter and snippet syntax when using the cucumber-js command line:
236
408
 
237
409
  ```javascript
238
- module.exports = {
239
- default: [
240
- '--format node_modules/@lynxwall/cucumber-tsflow/dist/behave-json-formatter:cucumber_report.json',
241
- '--format-options \'{"snippetSyntax": "node_modules/@lynxwall/cucumber-tsflow/dist/tsflow-snippet-syntax"}\'',
242
- '--publish-quiet'
243
- ].join(' ')
244
- };
410
+ {
411
+ "default": {
412
+ "format": [
413
+ "node_modules/@lynxwall/cucumber-tsflow/lib/behave.js:cucumber_report.json"
414
+ ],
415
+ "formatOptions": { "snippetSyntax": "node_modules/@lynxwall/cucumber-tsflow/lib/snippet.js" },
416
+ "publishQuiet": true
417
+ }
418
+ }
245
419
  ```
246
420
 
247
- The first line tells cucumber to generate a report using the behave-json-formatter.
421
+ The `format` line tells cucumber to generate a report using the behave-json-formatter.
248
422
 
249
- The next line tells cucumber to generate example snippets using the tsflow-snippet-syntax.
423
+ The `formatOptions` line tells cucumber to generate example snippets using the tsflow-snippet-syntax.
250
424
 
251
- ### Sharing Data between Bindings
425
+ ## Sharing Data between Bindings
252
426
 
253
- #### Context Injection
427
+ ### Context Injection
254
428
 
255
429
  Like 'specflow', cucumber-tsflow supports a simple dependency injection framework that will instantitate and inject
256
430
  class instances into 'binding' classes for each execuing scenario.
@@ -268,7 +442,7 @@ import { binding, before, after } from "@lynxwall/cucumber-tsflow";
268
442
  import { Workspace } from "./Workspace";
269
443
 
270
444
  @binding([Workspace])
271
- class MySteps {
445
+ export default class MySteps {
272
446
  constructor(protected workspace: Workspace)
273
447
  { }
274
448
 
@@ -279,6 +453,4 @@ class MySteps {
279
453
  this.workspace.updateFolder(tempDirInfo);
280
454
  }
281
455
  }
282
-
283
- export = MySteps;
284
456
  ```
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- console.log('Hello!');
2
+ require('../lib/cli/run.js').default();
package/lib/behave.js CHANGED
@@ -1,3 +1,26 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
1
24
  (function (factory) {
2
25
  if (typeof module === "object" && typeof module.exports === "object") {
3
26
  var v = factory(require, exports);
@@ -9,7 +32,7 @@
9
32
  })(function (require, exports) {
10
33
  "use strict";
11
34
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const behave = require("./formatters/behave-json-formatter");
35
+ const behave = __importStar(require("./formatters/behave-json-formatter"));
13
36
  module.exports = behave;
14
37
  });
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVoYXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2JlaGF2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztJQUFBLDZEQUE2RDtJQUU3RCxNQUFNLENBQUMsT0FBTyxHQUFHLE1BQU0sQ0FBQyJ9
38
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVoYXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2JlaGF2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0lBQUEsMkVBQTZEO0lBRTdELE1BQU0sQ0FBQyxPQUFPLEdBQUcsTUFBTSxDQUFDIn0=
@@ -0,0 +1,24 @@
1
+ import { IConfiguration } from '@cucumber/cucumber/lib/configuration/types';
2
+ export interface IParsedArgvOptions {
3
+ config?: string;
4
+ i18nKeywords?: string;
5
+ i18nLanguages?: boolean;
6
+ profile: string[];
7
+ }
8
+ export interface ITsflowConfiguration extends IConfiguration {
9
+ debugFile: string;
10
+ transpiler: string;
11
+ }
12
+ export interface IParsedArgv {
13
+ options: IParsedArgvOptions;
14
+ configuration: Partial<ITsflowConfiguration>;
15
+ }
16
+ declare const ArgvParser: {
17
+ collect<T>(val: T, memo?: T[]): T[] | undefined;
18
+ mergeJson(option: string): (str: string, memo?: object | undefined) => object;
19
+ mergeTags(value: string, memo?: string | undefined): string;
20
+ validateCountOption(value: string, optionName: string): number;
21
+ validateLanguage(value: string): string;
22
+ parse(argv: string[]): IParsedArgv;
23
+ };
24
+ export default ArgvParser;