@lynxwall/cucumber-tsflow 6.1.1 → 6.2.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 (98) hide show
  1. package/README.md +62 -21
  2. package/lib/behave.d.ts +1 -1
  3. package/lib/behave.js +27 -27
  4. package/lib/cli/argv-parser.d.ts +24 -24
  5. package/lib/cli/argv-parser.js +103 -103
  6. package/lib/cli/index.d.ts +21 -22
  7. package/lib/cli/index.js +95 -101
  8. package/lib/cli/load-configuration.d.ts +20 -20
  9. package/lib/cli/load-configuration.js +101 -90
  10. package/lib/cli/run.d.ts +1 -1
  11. package/lib/cli/run.js +49 -47
  12. package/lib/cucumber/binding-decorator.d.ts +10 -10
  13. package/lib/cucumber/binding-decorator.js +180 -180
  14. package/lib/cucumber/binding-registry.d.ts +82 -82
  15. package/lib/cucumber/binding-registry.js +215 -215
  16. package/lib/cucumber/hook-decorators.d.ts +46 -46
  17. package/lib/cucumber/hook-decorators.js +102 -102
  18. package/lib/cucumber/managed-scenario-context.d.ts +21 -21
  19. package/lib/cucumber/managed-scenario-context.js +95 -95
  20. package/lib/cucumber/message-collector.d.ts +81 -81
  21. package/lib/cucumber/message-collector.js +250 -250
  22. package/lib/cucumber/parallel/coordinator.d.ts +79 -79
  23. package/lib/cucumber/parallel/coordinator.js +246 -246
  24. package/lib/cucumber/parallel/run-worker.d.ts +1 -1
  25. package/lib/cucumber/parallel/run-worker.js +31 -31
  26. package/lib/cucumber/parallel/worker.d.ts +30 -30
  27. package/lib/cucumber/parallel/worker.js +103 -103
  28. package/lib/cucumber/run-cucumber.d.ts +14 -14
  29. package/lib/cucumber/run-cucumber.js +118 -118
  30. package/lib/cucumber/runtime.d.ts +25 -25
  31. package/lib/cucumber/runtime.js +39 -39
  32. package/lib/cucumber/step-definition-decorators.d.ts +24 -24
  33. package/lib/cucumber/step-definition-decorators.js +91 -91
  34. package/lib/cucumber/utils.d.ts +16 -16
  35. package/lib/cucumber/utils.js +77 -77
  36. package/lib/esnode.js +18 -18
  37. package/lib/esvue.d.ts +1 -1
  38. package/lib/esvue.js +40 -40
  39. package/lib/formatters/behave-json-formatter.d.ts +49 -49
  40. package/lib/formatters/behave-json-formatter.js +74 -74
  41. package/lib/formatters/tsflow-snippet-syntax.d.ts +9 -9
  42. package/lib/formatters/tsflow-snippet-syntax.js +89 -89
  43. package/lib/gherkin/configuration.d.ts +30 -30
  44. package/lib/gherkin/configuration.js +26 -26
  45. package/lib/gherkin/gherkin-feature.d.ts +28 -28
  46. package/lib/gherkin/gherkin-feature.js +352 -352
  47. package/lib/gherkin/gherkin-manager.d.ts +29 -29
  48. package/lib/gherkin/gherkin-manager.js +143 -143
  49. package/lib/gherkin/models.d.ts +46 -46
  50. package/lib/gherkin/models.js +2 -2
  51. package/lib/index.d.ts +4 -4
  52. package/lib/index.js +22 -22
  53. package/lib/snippet.d.ts +1 -1
  54. package/lib/snippet.js +27 -27
  55. package/lib/transpilers/esbuild-transpiler.d.ts +4 -4
  56. package/lib/transpilers/esbuild-transpiler.js +18 -18
  57. package/lib/transpilers/esbuild.d.ts +12 -12
  58. package/lib/transpilers/esbuild.js +54 -54
  59. package/lib/transpilers/vue-sfc/compiler.d.ts +7 -7
  60. package/lib/transpilers/vue-sfc/compiler.js +21 -21
  61. package/lib/transpilers/vue-sfc/index.d.ts +23 -23
  62. package/lib/transpilers/vue-sfc/index.js +46 -46
  63. package/lib/transpilers/vue-sfc/main.d.ts +8 -8
  64. package/lib/transpilers/vue-sfc/main.js +247 -247
  65. package/lib/transpilers/vue-sfc/script.d.ts +5 -5
  66. package/lib/transpilers/vue-sfc/script.js +41 -41
  67. package/lib/transpilers/vue-sfc/template.d.ts +8 -8
  68. package/lib/transpilers/vue-sfc/template.js +101 -101
  69. package/lib/transpilers/vue-sfc/types.d.ts +55 -55
  70. package/lib/transpilers/vue-sfc/types.js +2 -2
  71. package/lib/transpilers/vue-sfc/utils/descriptorCache.d.ts +13 -13
  72. package/lib/transpilers/vue-sfc/utils/descriptorCache.js +67 -67
  73. package/lib/transpilers/vue-sfc/utils/error.d.ts +3 -3
  74. package/lib/transpilers/vue-sfc/utils/error.js +22 -22
  75. package/lib/transpilers/vue-sfc/utils/query.d.ts +13 -13
  76. package/lib/transpilers/vue-sfc/utils/query.js +35 -35
  77. package/lib/tsnode.js +17 -17
  78. package/lib/tsvue.d.ts +1 -1
  79. package/lib/tsvue.js +39 -39
  80. package/lib/types/scenario-context.d.ts +16 -16
  81. package/lib/types/scenario-context.js +17 -17
  82. package/lib/types/scenario-info.d.ts +16 -16
  83. package/lib/types/scenario-info.js +22 -22
  84. package/lib/types/step-binding-flags.d.ts +53 -53
  85. package/lib/types/step-binding-flags.js +59 -59
  86. package/lib/types/step-binding.d.ts +50 -50
  87. package/lib/types/step-binding.js +17 -17
  88. package/lib/types/types.d.ts +21 -21
  89. package/lib/types/types.js +2 -2
  90. package/lib/utils/helpers.d.ts +6 -6
  91. package/lib/utils/helpers.js +17 -17
  92. package/lib/utils/logger.d.ts +3 -3
  93. package/lib/utils/logger.js +29 -29
  94. package/lib/utils/our-callsite.d.ts +27 -27
  95. package/lib/utils/our-callsite.js +72 -72
  96. package/lib/version.d.ts +1 -1
  97. package/lib/version.js +5 -5
  98. package/package.json +11 -11
package/README.md CHANGED
@@ -2,18 +2,23 @@
2
2
 
3
3
  # cucumber-tsflow
4
4
 
5
- Provides 'specflow' like bindings for CucumberJS 9.1.0+ in TypeScript 4.0+.
5
+ Provides 'specflow' like bindings for CucumberJS 9.6.0+ in TypeScript 5.0+.
6
6
 
7
7
  Supports Vue3 files in cucumber tests.
8
8
 
9
9
  ## Fork description
10
+
10
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.
11
12
 
12
13
  In addition, the following features have been added:
14
+
13
15
  - Test runner using the cucumber-tsflow command.
14
16
  - Uses underlying cucumber api to run tests.
15
- - Returns three exit codes:
16
- - **0** = all scenarios passing, **1** = implemented scenarios are passing but there are pending, undefined or unknown scenario steps, **2** = one or more scenario steps have failed.
17
+ - Returns **four** exit codes:
18
+ - **0** - All scenarios passing.
19
+ - **1** - Invalid configuration or Unhandled exception when executing tests.
20
+ - **2** - Implemented scenarios are passing but there are pending, undefined or unknown scenario steps.
21
+ - **3** - One or more scenario steps have failed.
17
22
  - Typescript and esbuild transpiler support.
18
23
  - Vue3 transformer used to handle .vue files in tests.
19
24
  - Timeout in step definitions and hooks.
@@ -115,7 +120,7 @@ As mentioned previously, with recent updates cucumber-tsflow must be used to exe
115
120
 
116
121
  The following example demonstrates executing cucumber-tsflow from the command line to execute tests:
117
122
 
118
- ```cmd
123
+ ```bash
119
124
  C:\GitHub\cucumber-js-tsflow (dev -> origin)
120
125
  λ npx cucumber-tsflow
121
126
  Loading configuration and step definitions...
@@ -146,30 +151,68 @@ You can also add a script to package.json to execute the tests as shown below:
146
151
  }
147
152
  ```
148
153
 
149
- With this script in place you can execute the tests using npm or yarn,
154
+ With this script in place you can execute the tests using npm, pnpm or yarn,
150
155
 
151
- #### npm
156
+ **npm**
152
157
 
153
158
  ```bash
154
159
  npm run test
155
160
  ```
156
161
 
157
- #### yarn
162
+ **pnpm**
163
+
164
+ ```bash
165
+ pnpm test
166
+ ```
167
+
168
+ **yarn**
158
169
 
159
170
  ```bash
160
171
  yarn test
161
172
  ```
162
173
 
174
+ <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;">
175
+ <strong><span style="color: #000">Note:</span></strong> When executing cucumber-tsflow using scripts in package.json you will not have access to the exit code. This is due to the way that scripts are handled by package managers. If the command exit code is anything greater than 0, these scripts will always return 1. In other words, the commands shown above will return 0 or 1 regardless of the exit code returned from cucumber-tsflow.
176
+ </div>
177
+
178
+ ### Executing Tests with Continuous Integration (CI)
179
+
180
+ When executing tests as part of Continuous Integration (CI) operations you should use the following command to execute the tests from the folder that contains your cucumber and Typescript (tsconfig) configuration files that are associated with tests you want to execute.
181
+
182
+ ```bash
183
+ npx cucumber-tsflow -p default
184
+ ```
185
+
186
+ This will allow you to access the exit code that is returned from cucumber-tsflow.
187
+
188
+ **cmd shell**
189
+
190
+ ```bash
191
+ echo %errorlevel%
192
+ ```
193
+
194
+ **powershell**
195
+
196
+ ```bash
197
+ echo $LastExitCode
198
+ ```
199
+
200
+ **bash**
201
+
202
+ ```bash
203
+ echo $?
204
+ ```
205
+
163
206
  ## New Configuration options
164
207
 
165
208
  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>
166
209
 
167
210
  In addition to cucumber configuration options the following two options have been added:
168
211
 
169
- | Name | Type | Repeatable | CLI Option | Description | Default |
170
- | ------------ | -------- | ---------- | -------------- | ------------------------------------------------------------ | ------- |
212
+ | Name | Type | Repeatable | CLI Option | Description | Default |
213
+ | ------------ | -------- | ---------- | -------------- | ------------------------------------------------------------- | ------- |
171
214
  | `transpiler` | `string` | No | `--transpiler` | Name of the transpiler to use: esnode, esvue, tsnode or tsvue | esnode |
172
- | `debugFile` | `string` | No | `--debug-file` | Path to a file with steps for debugging | |
215
+ | `debugFile` | `string` | No | `--debug-file` | Path to a file with steps for debugging | |
173
216
 
174
217
  #### Transpiler and Vue3 supported
175
218
 
@@ -178,6 +221,7 @@ Using TypeScript with cucumberJs requires a couple of tsconfig.json parameters a
178
221
  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.
179
222
 
180
223
  The following transpilers are provided:
224
+
181
225
  - **esnode**: Uses esbuild to transpile TypeScript code for node test execution.
182
226
  - **esvue**: Uses esbuild to transpile TypeScript code and adds a hook for .vue files, which transforms Vue SFC components into commonJS.
183
227
  - **jsdom** is also loaded globally to support loading and testing Vue SFC components.
@@ -192,8 +236,7 @@ When configuring cucumber to execute tests you can specify which transpiler to u
192
236
  ```json
193
237
  {
194
238
  "default": {
195
- "transpiler": "esvue",
196
- "publishQuiet": true
239
+ "transpiler": "esvue"
197
240
  }
198
241
  }
199
242
  ```
@@ -205,8 +248,7 @@ You can also use the `requireModule` parameter to configure a transpiler. The fo
205
248
  ```json
206
249
  {
207
250
  "default": {
208
- "requireModule": ["@lynxwall/cucumber-tsflow/lib/esvue"],
209
- "publishQuiet": true
251
+ "requireModule": ["@lynxwall/cucumber-tsflow/lib/esvue"]
210
252
  }
211
253
  }
212
254
  ```
@@ -259,7 +301,7 @@ If using VSCode to edit your project the following launch configurations can be
259
301
  }
260
302
  ```
261
303
 
262
- **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.
304
+ **Note:** When using `Debug Feature` you'll need to have the step definition file open as the current file in VS Code. The current file path is passed into the debugger as the ${file} argument for --debug-file.
263
305
 
264
306
  ## Bindings
265
307
 
@@ -432,7 +474,7 @@ public givenAValueBasedSearch(searchValue: string): void {
432
474
 
433
475
  tsflow currently doesn't have a way to define a global default step timeout,
434
476
 
435
- but it can be easily done through CucumberJS ```setDefaultTimeout``` function.
477
+ but it can be easily done through CucumberJS `setDefaultTimeout` function.
436
478
 
437
479
  ### Passing WrapperOptions
438
480
 
@@ -464,8 +506,7 @@ The following example shows how to configure the behave formatter in cucumber.js
464
506
  "default": {
465
507
  "format": [
466
508
  "behave:cucumber_report.json"
467
- ],
468
- "publishQuiet": true
509
+ ]
469
510
  }
470
511
  }
471
512
  ```
@@ -478,7 +519,7 @@ Like 'specflow', cucumber-tsflow supports a simple dependency injection framewor
478
519
 
479
520
  To use context injection:
480
521
 
481
- - Create simple classes representing the shared data (they *must* have default constructors)
522
+ - Create simple classes representing the shared data (they _must_ have default constructors)
482
523
  - Define a constructor on the 'binding' classes that will require the shared data that accepts the context objects as parameters
483
524
  - Update the `@binding()` decorator to indicate the types of context objects that are required by the 'binding' class
484
525
 
@@ -519,7 +560,7 @@ export class Workspace {
519
560
  }
520
561
  ```
521
562
 
522
- Next you'll need to initialize the world property in a ***@before*** hook so that it's available to all steps in a scenario. My approach is to add a new file to the steps folder that is dedicated to initializing the class (Workspace in this example) in a ***@before*** hook.
563
+ Next you'll need to initialize the world property in a **_@before_** hook so that it's available to all steps in a scenario. My approach is to add a new file to the steps folder that is dedicated to initializing the class (Workspace in this example) in a **_@before_** hook.
523
564
 
524
565
  For this example I've added a file named world-context.ts with the following content:
525
566
 
@@ -541,6 +582,6 @@ export default class WorldContext {
541
582
  }
542
583
  ```
543
584
 
544
- As described in the section on Hooks, the ***beforeScenario*** function will be executed before each scenario. We're accessing a member property that was bound to the class instance during creation of each step class, and initializing the world property.
585
+ As described in the section on Hooks, the **_beforeScenario_** function will be executed before each scenario. We're accessing a member property that was bound to the class instance during creation of each step class, and initializing the world property.
545
586
 
546
587
  **NOTE:** Examples of this and other tests can be found in the GitHub repository.
package/lib/behave.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/lib/behave.js CHANGED
@@ -1,28 +1,28 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const behave = __importStar(require("./formatters/behave-json-formatter"));
27
- module.exports = behave;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const behave = __importStar(require("./formatters/behave-json-formatter"));
27
+ module.exports = behave;
28
28
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVoYXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2JlaGF2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMkVBQTZEO0FBRTdELE1BQU0sQ0FBQyxPQUFPLEdBQUcsTUFBTSxDQUFDIn0=
@@ -1,24 +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) => object;
19
- mergeTags(value: string, memo?: string): string;
20
- validateCountOption(value: string, optionName: string): number;
21
- validateLanguage(value: string): string;
22
- parse(argv: string[]): IParsedArgv;
23
- };
24
- export default ArgvParser;
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) => object;
19
+ mergeTags(value: string, memo?: string): string;
20
+ validateCountOption(value: string, optionName: string): number;
21
+ validateLanguage(value: string): string;
22
+ parse(argv: string[]): IParsedArgv;
23
+ };
24
+ export default ArgvParser;
@@ -1,107 +1,107 @@
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
- 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);
24
- }
25
- catch (error) {
26
- const e = error;
27
- throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`);
28
- }
29
- if (typeof val !== 'object' || Array.isArray(val)) {
30
- throw new Error(`${option} must be passed JSON of an object: ${str}`);
31
- }
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'))
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
+ 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);
24
+ }
25
+ catch (error) {
26
+ const e = error;
27
+ throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`);
28
+ }
29
+ if (typeof val !== 'object' || Array.isArray(val)) {
30
+ throw new Error(`${option} must be passed JSON of an object: ${str}`);
31
+ }
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
79
  .option('--retry-tag-filter <EXPRESSION>', `only retries the features or scenarios with tags matching the expression (repeatable).
80
- This option requires '--retry' to be specified.`, ArgvParser.mergeTags)
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)
80
+ This option requires '--retry' to be specified.`, ArgvParser.mergeTags)
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
84
  .option('--transpiler <ESNODE|TSNODE|ESVUE|TSVUE>', `built-in transpiler to use. ESxxx transpilers use esbuild and TSxxx transpilers use typescript.\n
85
85
  Vue versions of the transpilers add a hook for .vue transforms and initialize jsdom globally.\n
86
- Default: ESNODE (esbuild without Vue support)`)
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;
94
- }
95
- return {
96
- options: {
97
- config,
98
- i18nKeywords,
99
- i18nLanguages,
100
- profile
101
- },
102
- configuration
103
- };
104
- }
105
- };
106
- exports.default = ArgvParser;
86
+ Default: ESNODE (esbuild without Vue support)`)
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;
94
+ }
95
+ return {
96
+ options: {
97
+ config,
98
+ i18nKeywords,
99
+ i18nLanguages,
100
+ profile
101
+ },
102
+ configuration
103
+ };
104
+ }
105
+ };
106
+ exports.default = ArgvParser;
107
107
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJndi1wYXJzZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL2FyZ3YtcGFyc2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEseUNBQW9DO0FBQ3BDLGdFQUFpQztBQUNqQyxnREFBd0I7QUFDeEIsK0NBQTZDO0FBQzdDLHFHQUE2RTtBQUM3RSx3Q0FBcUM7QUFzQnJDLE1BQU0sVUFBVSxHQUFH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9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUMxRyxNQUFNLGFBQWEsR0FBa0MsWUFBWSxDQUFDO1FBQ2xFLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxNQUFNLEdBQUcsQ0FBQyxFQUFFO1lBQzVCLGFBQWEsQ0FBQyxLQUFLLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQztTQUNuQztRQUVELE9BQU87WUFDTixPQUFPLEVBQUU7Z0JBQ1IsTUFBTTtnQkFDTixZQUFZO2dCQUNaLGFBQWE7Z0JBQ2IsT0FBTzthQUNQO1lBQ0QsYUFBYTtTQUNiLENBQUM7SUFDSCxDQUFDO0NBQ0QsQ0FBQztBQUVGLGtCQUFlLFVBQVUsQ0FBQyJ9
@@ -1,22 +1,21 @@
1
- /// <reference types="node" />
2
- import { IFormatterStream } from '@cucumber/cucumber/lib/formatter';
3
- export interface ICliRunResult {
4
- shouldAdvertisePublish: boolean;
5
- shouldExitImmediately: boolean;
6
- success: boolean;
7
- }
8
- export default class Cli {
9
- private readonly argv;
10
- private readonly cwd;
11
- private readonly stdout;
12
- private readonly stderr;
13
- private readonly env;
14
- constructor({ argv, cwd, stdout, stderr, env }: {
15
- argv: string[];
16
- cwd: string;
17
- stdout: IFormatterStream;
18
- stderr: IFormatterStream;
19
- env: NodeJS.ProcessEnv;
20
- });
21
- run(): Promise<ICliRunResult>;
22
- }
1
+ /// <reference types="node" />
2
+ import { IFormatterStream } from '@cucumber/cucumber/lib/formatter';
3
+ export interface ICliRunResult {
4
+ shouldExitImmediately: boolean;
5
+ success: boolean;
6
+ }
7
+ export default class Cli {
8
+ private readonly argv;
9
+ private readonly cwd;
10
+ private readonly stdout;
11
+ private readonly stderr;
12
+ private readonly env;
13
+ constructor({ argv, cwd, stdout, stderr, env }: {
14
+ argv: string[];
15
+ cwd: string;
16
+ stdout: IFormatterStream;
17
+ stderr: IFormatterStream;
18
+ env: NodeJS.ProcessEnv;
19
+ });
20
+ run(): Promise<ICliRunResult>;
21
+ }