@lynxwall/cucumber-tsflow 5.0.4 → 5.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -51
- package/lib/behave.js +5 -15
- package/lib/cli/argv-parser.js +97 -107
- package/lib/cli/index.js +81 -96
- package/lib/cli/load-configuration.js +78 -89
- package/lib/cli/run.js +37 -47
- package/lib/cucumber/binding-decorator.js +164 -159
- package/lib/cucumber/binding-registry.js +198 -208
- package/lib/cucumber/hook-decorators.js +99 -109
- package/lib/cucumber/managed-scenario-context.js +71 -81
- package/lib/cucumber/message-collector.js +115 -125
- package/lib/cucumber/step-definition-decorators.js +86 -96
- package/lib/cucumber/utils.js +73 -83
- package/lib/esnode.js +3 -4
- package/lib/esvue.js +35 -46
- package/lib/formatters/behave-json-formatter.js +47 -58
- package/lib/formatters/tsflow-snippet-syntax.js +89 -99
- package/lib/gherkin/configuration.js +26 -36
- package/lib/gherkin/gherkin-feature.js +285 -295
- package/lib/gherkin/gherkin-manager.js +93 -103
- package/lib/gherkin/models.js +2 -12
- package/lib/index.js +9 -19
- package/lib/snippet.js +5 -15
- package/lib/transpilers/esbuild-transpiler.js +19 -29
- package/lib/transpilers/esbuild.js +51 -62
- package/lib/transpilers/vue-sfc/compiler.js +20 -30
- package/lib/transpilers/vue-sfc/index.d.ts +0 -2
- package/lib/transpilers/vue-sfc/index.js +44 -61
- package/lib/transpilers/vue-sfc/main.js +223 -235
- package/lib/transpilers/vue-sfc/script.js +40 -51
- package/lib/transpilers/vue-sfc/template.js +94 -105
- package/lib/transpilers/vue-sfc/types.js +2 -12
- package/lib/transpilers/vue-sfc/utils/descriptorCache.d.ts +1 -1
- package/lib/transpilers/vue-sfc/utils/descriptorCache.js +52 -62
- package/lib/transpilers/vue-sfc/utils/error.js +22 -32
- package/lib/transpilers/vue-sfc/utils/query.js +32 -42
- package/lib/tsnode.js +3 -4
- package/lib/tsvue.js +34 -45
- package/lib/types/scenario-context.js +4 -14
- package/lib/types/scenario-info.js +18 -28
- package/lib/types/step-binding-flags.js +57 -67
- package/lib/types/step-binding.js +4 -14
- package/lib/types/types.js +2 -12
- package/lib/utils/helpers.js +17 -27
- package/lib/utils/logger.js +7 -17
- package/lib/utils/our-callsite.d.ts +1 -0
- package/lib/utils/our-callsite.js +43 -50
- package/lib/version.d.ts +1 -1
- package/lib/version.js +6 -16
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Supports Vue3 files in cucumber tests.
|
|
|
10
10
|
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.
|
|
11
11
|
|
|
12
12
|
In addition, the following features have been added:
|
|
13
|
-
- Test runner using cucumber-tsflow command
|
|
13
|
+
- Test runner using the cucumber-tsflow command
|
|
14
14
|
- Uses underlying cucumber api to run tests
|
|
15
15
|
- Typescript and esbuild transpiler support
|
|
16
16
|
- Vue3 transformer used to handle .vue files in tests
|
|
@@ -20,7 +20,11 @@ In addition, the following features have been added:
|
|
|
20
20
|
- Boolean custom definition added to cucumber expressions
|
|
21
21
|
- A behave-json-formatter that fixes json so it can be used with Behave Pro
|
|
22
22
|
- tsflow-snippet-syntax used to format snippet examples
|
|
23
|
-
- snippets use the [Cucumber
|
|
23
|
+
- snippets use the [Cucumber Expressions](https://github.com/cucumber/cucumber-expressions#readme) Syntax for parameters
|
|
24
|
+
|
|
25
|
+
<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;">
|
|
26
|
+
<strong>Note:</strong> With recent updates you must use the <strong>cucumber-tsflow</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.
|
|
27
|
+
</div>
|
|
24
28
|
|
|
25
29
|
## Quick Start
|
|
26
30
|
|
|
@@ -40,6 +44,8 @@ npm install @lynxwall/cucumber-tsflow --save-dev
|
|
|
40
44
|
yarn add --dev @lynxwall/cucumber-tsflow
|
|
41
45
|
```
|
|
42
46
|
|
|
47
|
+
**Note**: Latest updates with context management requires use of cucumber-tsflow to execute tests. As a result, you do not need to install @cucumber/cucumber. All necessary cucumber packages are installed as dependencies of cucumber-tsflow. If you do have @cucumber/cucumber in dependencies please remove the reference to avoid conflicts.
|
|
48
|
+
|
|
43
49
|
### Create .feature files to describe your specifications
|
|
44
50
|
|
|
45
51
|
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':
|
|
@@ -58,7 +64,7 @@ Feature: Example Feature
|
|
|
58
64
|
|
|
59
65
|
### Create the Support Files to support the Feature
|
|
60
66
|
|
|
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.
|
|
67
|
+
By default, CucumberJS looks for support files beneath the 'features' folder. You can override this on the cucumber-tsflow 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.
|
|
62
68
|
|
|
63
69
|
Create a new 'ArithmeticSteps.ts' file:
|
|
64
70
|
|
|
@@ -90,21 +96,21 @@ export default class ArithmeticSteps {
|
|
|
90
96
|
}
|
|
91
97
|
```
|
|
92
98
|
|
|
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.
|
|
99
|
+
**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.
|
|
94
100
|
|
|
95
101
|
### Compiling your TypeScript Support Code
|
|
96
102
|
|
|
97
103
|
If not using one of the [transpilers](#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.
|
|
98
104
|
|
|
99
|
-
Running the cucumber-tsflow command
|
|
105
|
+
Running the cucumber-tsflow command will execute your features along with the support code that you've created in the class.
|
|
100
106
|
|
|
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](#context-injection)' to share state between running step definitions
|
|
107
|
+
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.
|
|
102
108
|
|
|
103
109
|
## Cucumber-tsflow Test Runner
|
|
104
110
|
|
|
105
|
-
|
|
111
|
+
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.
|
|
106
112
|
|
|
107
|
-
|
|
113
|
+
The following example demonstrates executing cucumber-tsflow from the command line to execute tests:
|
|
108
114
|
|
|
109
115
|
```bash
|
|
110
116
|
C:\GitHub\cucumber-js-tsflow (vue-plugin -> origin)
|
|
@@ -122,7 +128,7 @@ Loading configuration and step definitions...
|
|
|
122
128
|
0m00.075s (executing steps: 0m00.037s)
|
|
123
129
|
```
|
|
124
130
|
|
|
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
|
|
131
|
+
To recap, 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
132
|
|
|
127
133
|
### New Configuration options
|
|
128
134
|
|
|
@@ -149,9 +155,9 @@ The following transpilers are provided:
|
|
|
149
155
|
- **tsvue**: Uses typescript to transpile TypeScript code and adds a hook for .vue files, which transforms Vue SFC components into commonJS.
|
|
150
156
|
- **jsdom** is also loaded globally to support loading and testing Vue SFC components.
|
|
151
157
|
|
|
152
|
-
##### Using
|
|
158
|
+
##### Using the transpiler configuration option
|
|
153
159
|
|
|
154
|
-
When
|
|
160
|
+
When configuring cucumber to execute tests you can specify which transpiler to use with the `transpiler` configuration option as shown below:
|
|
155
161
|
|
|
156
162
|
```json
|
|
157
163
|
{
|
|
@@ -163,9 +169,9 @@ When using cucumber-tsflow to execute tests you can specify which transpiler to
|
|
|
163
169
|
|
|
164
170
|
```
|
|
165
171
|
|
|
166
|
-
#####
|
|
172
|
+
##### Alternate without using the transpiler option
|
|
167
173
|
|
|
168
|
-
|
|
174
|
+
You can also use the `requireModule` parameter to configure a transpiler. The following example shows how to configure cucumber to use the `esvue` transpiler with the `requireModule` option.
|
|
169
175
|
|
|
170
176
|
```json
|
|
171
177
|
{
|
|
@@ -191,7 +197,7 @@ If using VSCode to edit your project the following launch configurations can be
|
|
|
191
197
|
"type": "pwa-node",
|
|
192
198
|
"request": "launch",
|
|
193
199
|
"program": "${workspaceRoot}/node_modules/@lynxwall/cucumber-tsflow/bin/cucumber-tsflow",
|
|
194
|
-
"stopOnEntry":
|
|
200
|
+
"stopOnEntry": false,
|
|
195
201
|
"args": ["-p", "default"],
|
|
196
202
|
"cwd": "${workspaceRoot}",
|
|
197
203
|
"runtimeExecutable": null,
|
|
@@ -214,7 +220,7 @@ If using VSCode to edit your project the following launch configurations can be
|
|
|
214
220
|
"type": "pwa-node",
|
|
215
221
|
"request": "launch",
|
|
216
222
|
"program": "${workspaceRoot}/node_modules/@lynxwall/cucumber-tsflow/bin/cucumber-tsflow",
|
|
217
|
-
"stopOnEntry":
|
|
223
|
+
"stopOnEntry": false,
|
|
218
224
|
"args": ["--debug-file", "${file}", "-p", "default"],
|
|
219
225
|
"cwd": "${workspaceRoot}",
|
|
220
226
|
"runtimeExecutable": null,
|
|
@@ -229,6 +235,8 @@ If using VSCode to edit your project the following launch configurations can be
|
|
|
229
235
|
}
|
|
230
236
|
```
|
|
231
237
|
|
|
238
|
+
**Note:** When using `Debug Feature` you'll need to have the step definition file open as the current file in VSCode. The current file path is passed into the debugger as the ${file} argument for --debug-file.
|
|
239
|
+
|
|
232
240
|
## Bindings
|
|
233
241
|
|
|
234
242
|
Bindings provide the automation that connects a specification step in a Gherkin feature file to some code that
|
|
@@ -266,6 +274,44 @@ The function follows the same requirements of functions you would normally suppl
|
|
|
266
274
|
functions may be synchronous by returning nothing, use the callback, or return a `Promise<T>`. Additionally, the
|
|
267
275
|
function may also be `async` following the TypeScript async semantics.
|
|
268
276
|
|
|
277
|
+
### Boolean Custom Parameter
|
|
278
|
+
|
|
279
|
+
As mentioned, cucumber-tsflow uses Cucumber Expressions for snippet syntax, which provides different parameter types used in expressions. However, a boolean type is not provided by default.
|
|
280
|
+
|
|
281
|
+
As a result, a new custom parameter type has been added for boolean matches. For example, when a scenario step contains the words `true` or `false` they will be replaced with the `{boolean}` parameter expression and passed into the step function.
|
|
282
|
+
|
|
283
|
+
The following Scenario uses boolean values in the Given and Then statements:
|
|
284
|
+
|
|
285
|
+
```gherkin
|
|
286
|
+
Scenario: Boolean type supported
|
|
287
|
+
Given I pass true into a step
|
|
288
|
+
When checking the boolean value
|
|
289
|
+
Then we can see that true was passed in
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
The associated step definition replaces `true` in this scenario with a `{boolean}` expression as shown below:
|
|
293
|
+
|
|
294
|
+
```javascript
|
|
295
|
+
@given('I pass {boolean} into a step')
|
|
296
|
+
iPassbooleanIntoAStep(boolean: boolean): any {
|
|
297
|
+
this.boolValue = boolean;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@when('checking the boolean value')
|
|
301
|
+
checkingTheBooleanValue(): any {
|
|
302
|
+
expect(this.boolValue).not.to.be.undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@then('we can see that {boolean} was passed in')
|
|
306
|
+
weCanThatbooleanWasPassedIn(boolean: boolean): any {
|
|
307
|
+
expect(this.boolValue).to.equal(boolean);
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
More information on Cucumber Expressions and Custom Parameter Types can be found here: <https://github.com/cucumber/cucumber-expressions#readme>
|
|
312
|
+
|
|
313
|
+
### Step Tags
|
|
314
|
+
|
|
269
315
|
Step definitions can be conditionally selected for execution based on the tags of the scenario by supplying tags when using the binding
|
|
270
316
|
decorators:
|
|
271
317
|
|
|
@@ -286,7 +332,7 @@ public givenAValueBasedSearch(searchValue: string): void {
|
|
|
286
332
|
}
|
|
287
333
|
```
|
|
288
334
|
|
|
289
|
-
Note
|
|
335
|
+
**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>
|
|
290
336
|
|
|
291
337
|
## Hooks
|
|
292
338
|
|
|
@@ -316,15 +362,15 @@ class MySteps {
|
|
|
316
362
|
...
|
|
317
363
|
}
|
|
318
364
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
365
|
+
@beforeStep('@addNumbers')
|
|
366
|
+
public beforeStep() {
|
|
367
|
+
...
|
|
368
|
+
}
|
|
323
369
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
370
|
+
@afterStep('@addNumbers')
|
|
371
|
+
public afterStep() {
|
|
372
|
+
...
|
|
373
|
+
}
|
|
328
374
|
|
|
329
375
|
@after()
|
|
330
376
|
public afterAllScenarios(): void {
|
|
@@ -362,7 +408,7 @@ public givenAValueBasedSearch(searchValue: string): void {
|
|
|
362
408
|
|
|
363
409
|
tsflow currently doesn't have a way to define a global default step timeout,
|
|
364
410
|
|
|
365
|
-
but it can be easily done through
|
|
411
|
+
but it can be easily done through CucumberJS ```setDefaultTimeout``` function.
|
|
366
412
|
|
|
367
413
|
### Passing WrapperOptions
|
|
368
414
|
|
|
@@ -381,15 +427,13 @@ public givenAValueBasedSearch(searchValue: string): void {
|
|
|
381
427
|
|
|
382
428
|
### Using behave-json-formatter and tsflow-snippet-syntax
|
|
383
429
|
|
|
384
|
-
Changing the formatter used for generating json along with changing the Snippet Syntax can be done through the
|
|
430
|
+
Changing the formatter used for generating json along with changing the Snippet Syntax can be done through the CucumberJS configuration file.
|
|
385
431
|
|
|
386
|
-
If it doesn't already exist, create a file named cucumber.
|
|
432
|
+
If it doesn't already exist, create a file named cucumber.json at the root of your project. This is where we can configure different options for CucumberJS.
|
|
387
433
|
|
|
434
|
+
#### Using the behave json formatter
|
|
388
435
|
|
|
389
|
-
|
|
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.
|
|
436
|
+
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>
|
|
393
437
|
|
|
394
438
|
```javascript
|
|
395
439
|
{
|
|
@@ -402,26 +446,6 @@ Note: When using cucumber-tsflow the tsflow-snippet-syntax is configured by defa
|
|
|
402
446
|
}
|
|
403
447
|
```
|
|
404
448
|
|
|
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:
|
|
408
|
-
|
|
409
|
-
```javascript
|
|
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
|
-
}
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
The `format` line tells cucumber to generate a report using the behave-json-formatter.
|
|
422
|
-
|
|
423
|
-
The `formatOptions` line tells cucumber to generate example snippets using the tsflow-snippet-syntax.
|
|
424
|
-
|
|
425
449
|
## Sharing Data between Bindings
|
|
426
450
|
|
|
427
451
|
### Context Injection
|
package/lib/behave.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
3
|
if (k2 === undefined) k2 = k;
|
|
3
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -21,18 +22,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
22
|
__setModuleDefault(result, mod);
|
|
22
23
|
return result;
|
|
23
24
|
};
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
else if (typeof define === "function" && define.amd) {
|
|
30
|
-
define(["require", "exports", "./formatters/behave-json-formatter"], factory);
|
|
31
|
-
}
|
|
32
|
-
})(function (require, exports) {
|
|
33
|
-
"use strict";
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
const behave = __importStar(require("./formatters/behave-json-formatter"));
|
|
36
|
-
module.exports = behave;
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVoYXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2JlaGF2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0lBQUEsMkVBQTZEO0lBRTdELE1BQU0sQ0FBQyxPQUFPLEdBQUcsTUFBTSxDQUFDIn0=
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const behave = __importStar(require("./formatters/behave-json-formatter"));
|
|
27
|
+
module.exports = behave;
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVoYXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2JlaGF2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMkVBQTZEO0FBRTdELE1BQU0sQ0FBQyxPQUFPLEdBQUcsTUFBTSxDQUFDIn0=
|
package/lib/cli/argv-parser.js
CHANGED
|
@@ -1,117 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
4
|
};
|
|
4
|
-
(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (val) {
|
|
24
|
-
return [...memo, val];
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const commander_1 = require("commander");
|
|
7
|
+
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const gherkin_1 = require("@cucumber/gherkin");
|
|
10
|
+
const formatters_1 = __importDefault(require("@cucumber/cucumber/lib/formatter/helpers/formatters"));
|
|
11
|
+
const version_1 = require("../version");
|
|
12
|
+
const ArgvParser = {
|
|
13
|
+
collect(val, memo = []) {
|
|
14
|
+
if (val) {
|
|
15
|
+
return [...memo, val];
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
},
|
|
19
|
+
mergeJson(option) {
|
|
20
|
+
return function (str, memo = {}) {
|
|
21
|
+
let val;
|
|
22
|
+
try {
|
|
23
|
+
val = JSON.parse(str);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return function (str, memo = {}) {
|
|
30
|
-
let val;
|
|
31
|
-
try {
|
|
32
|
-
val = JSON.parse(str);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
const e = error;
|
|
36
|
-
throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`);
|
|
37
|
-
}
|
|
38
|
-
if (typeof val !== 'object' || Array.isArray(val)) {
|
|
39
|
-
throw new Error(`${option} must be passed JSON of an object: ${str}`);
|
|
40
|
-
}
|
|
41
|
-
return (0, lodash_merge_1.default)(memo, val);
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
mergeTags(value, memo) {
|
|
45
|
-
return memo ? `${memo} and (${value})` : `(${value})`;
|
|
46
|
-
},
|
|
47
|
-
validateCountOption(value, optionName) {
|
|
48
|
-
const numericValue = parseInt(value);
|
|
49
|
-
if (isNaN(numericValue) || numericValue < 0) {
|
|
50
|
-
throw new Error(`${optionName} must be a non negative integer`);
|
|
25
|
+
catch (error) {
|
|
26
|
+
const e = error;
|
|
27
|
+
throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`);
|
|
51
28
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
validateLanguage(value) {
|
|
55
|
-
if (!Object.keys(gherkin_1.dialects).includes(value)) {
|
|
56
|
-
throw new Error(`Unsupported ISO 639-1: ${value}`);
|
|
29
|
+
if (typeof val !== 'object' || Array.isArray(val)) {
|
|
30
|
+
throw new Error(`${option} must be passed JSON of an object: ${str}`);
|
|
57
31
|
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
32
|
+
return (0, lodash_merge_1.default)(memo, val);
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
mergeTags(value, memo) {
|
|
36
|
+
return memo ? `${memo} and (${value})` : `(${value})`;
|
|
37
|
+
},
|
|
38
|
+
validateCountOption(value, optionName) {
|
|
39
|
+
const numericValue = parseInt(value);
|
|
40
|
+
if (isNaN(numericValue) || numericValue < 0) {
|
|
41
|
+
throw new Error(`${optionName} must be a non negative integer`);
|
|
42
|
+
}
|
|
43
|
+
return numericValue;
|
|
44
|
+
},
|
|
45
|
+
validateLanguage(value) {
|
|
46
|
+
if (!Object.keys(gherkin_1.dialects).includes(value)) {
|
|
47
|
+
throw new Error(`Unsupported ISO 639-1: ${value}`);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
},
|
|
51
|
+
parse(argv) {
|
|
52
|
+
const program = new commander_1.Command(path_1.default.basename(argv[1]));
|
|
53
|
+
program
|
|
54
|
+
.storeOptionsAsProperties(false)
|
|
55
|
+
.usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')
|
|
56
|
+
.version(version_1.version, '-v, --version')
|
|
57
|
+
.option('-b, --backtrace', 'show full backtrace for errors')
|
|
58
|
+
.option('-c, --config <PATH>', 'specify configuration file')
|
|
59
|
+
.option('-d, --dry-run', 'invoke formatters without executing steps')
|
|
60
|
+
.option('--debug-file <STRING>', 'path to a file with steps for debugging')
|
|
61
|
+
.option('--exit, --force-exit', 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit')
|
|
62
|
+
.option('--fail-fast', 'abort the run on first failure')
|
|
63
|
+
.option('-f, --format <TYPE[:PATH]>', 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\n' +
|
|
64
|
+
formatters_1.default.buildFormattersDocumentationString(), ArgvParser.collect)
|
|
65
|
+
.option('--format-options <JSON>', 'provide options for formatters (repeatable)', ArgvParser.mergeJson('--format-options'))
|
|
66
|
+
.option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage)
|
|
67
|
+
.option('--i18n-languages', 'list languages')
|
|
68
|
+
.option('-i, --import <GLOB|DIR|FILE>', 'import files before executing features (repeatable)', ArgvParser.collect)
|
|
69
|
+
.option('--language <ISO 639-1>', 'provide the default language for feature files')
|
|
70
|
+
.option('--name <REGEXP>', 'only execute the scenarios with name matching the expression (repeatable)', ArgvParser.collect)
|
|
71
|
+
.option('--order <TYPE[:SEED]>', 'run scenarios in the specified order. Type should be `defined` or `random`')
|
|
72
|
+
.option('-p, --profile <NAME>', 'specify the profile to use (repeatable)', ArgvParser.collect, [])
|
|
73
|
+
.option('--parallel <NUMBER_OF_WORKERS>', 'run in parallel with the given number of workers', val => ArgvParser.validateCountOption(val, '--parallel'))
|
|
74
|
+
.option('--publish', 'Publish a report to https://reports.cucumber.io')
|
|
75
|
+
.option('--publish-quiet', "Don't print information banner about publishing reports")
|
|
76
|
+
.option('-r, --require <GLOB|DIR|FILE>', 'require files before executing features (repeatable)', ArgvParser.collect)
|
|
77
|
+
.option('--require-module <NODE_MODULE>', 'require node modules before requiring files (repeatable)', ArgvParser.collect)
|
|
78
|
+
.option('--retry <NUMBER_OF_RETRIES>', 'specify the number of times to retry failing test cases (default: 0)', val => ArgvParser.validateCountOption(val, '--retry'))
|
|
79
|
+
.option('--retry-tag-filter <EXPRESSION>', `only retries the features or scenarios with tags matching the expression (repeatable).
|
|
89
80
|
This option requires '--retry' to be specified.`, ArgvParser.mergeTags)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
81
|
+
.option('--strict', 'fail if there are pending steps')
|
|
82
|
+
.option('--no-strict', 'succeed even if there are pending steps')
|
|
83
|
+
.option('-t, --tags <EXPRESSION>', 'only execute the features or scenarios with tags matching the expression (repeatable)', ArgvParser.mergeTags)
|
|
84
|
+
.option('--transpiler <ESNODE|TSNODE|ESVUE|TSVUE>', `built-in transpiler to use. ESxxx transpilers use esbuild and TSxxx transpilers use typescript.\n
|
|
94
85
|
Vue versions of the transpilers add a hook for .vue transforms and initialize jsdom globally.\n
|
|
95
86
|
Default: ESNODE (esbuild without Vue support)`)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
options: {
|
|
106
|
-
config,
|
|
107
|
-
i18nKeywords,
|
|
108
|
-
i18nLanguages,
|
|
109
|
-
profile
|
|
110
|
-
},
|
|
111
|
-
configuration
|
|
112
|
-
};
|
|
87
|
+
.option('--world-parameters <JSON>', 'provide parameters that will be passed to the world constructor (repeatable)', ArgvParser.mergeJson('--world-parameters'));
|
|
88
|
+
program.addHelpText('afterAll', 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md');
|
|
89
|
+
program.parse(argv);
|
|
90
|
+
const { config, i18nKeywords, i18nLanguages, profile, ...regularStuff } = program.opts();
|
|
91
|
+
const configuration = regularStuff;
|
|
92
|
+
if (program.args.length > 0) {
|
|
93
|
+
configuration.paths = program.args;
|
|
113
94
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
95
|
+
return {
|
|
96
|
+
options: {
|
|
97
|
+
config,
|
|
98
|
+
i18nKeywords,
|
|
99
|
+
i18nLanguages,
|
|
100
|
+
profile
|
|
101
|
+
},
|
|
102
|
+
configuration
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
exports.default = ArgvParser;
|
|
107
|
+
//# sourceMappingURL=data:application/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