@cucumber/cucumber 7.2.1 → 8.0.0-rc.1
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 +11 -4
- package/lib/cli/argv_parser.d.ts +1 -2
- package/lib/cli/argv_parser.js +8 -12
- package/lib/cli/argv_parser.js.map +1 -1
- package/lib/cli/configuration_builder.d.ts +0 -1
- package/lib/cli/configuration_builder.js +20 -21
- package/lib/cli/configuration_builder.js.map +1 -1
- package/lib/cli/helpers.d.ts +1 -0
- package/lib/cli/helpers.js +49 -22
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/i18n.js +6 -6
- package/lib/cli/i18n.js.map +1 -1
- package/lib/cli/index.d.ts +1 -1
- package/lib/cli/index.js +35 -29
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/profile_loader.d.ts +3 -3
- package/lib/cli/profile_loader.js +17 -10
- package/lib/cli/profile_loader.js.map +1 -1
- package/lib/cli/publish_banner.js +1 -1
- package/lib/cli/publish_banner.js.map +1 -1
- package/lib/formatter/builder.d.ts +5 -4
- package/lib/formatter/builder.js +38 -52
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/get_color_fns.d.ts +6 -2
- package/lib/formatter/get_color_fns.js +18 -12
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +15 -17
- package/lib/formatter/helpers/event_data_collector.js +19 -12
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/formatter/helpers/formatters.d.ts +6 -0
- package/lib/formatter/helpers/formatters.js +41 -0
- package/lib/formatter/helpers/formatters.js.map +1 -0
- package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -6
- package/lib/formatter/helpers/gherkin_document_parser.js +24 -40
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +6 -6
- package/lib/formatter/helpers/issue_helpers.js +6 -8
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/keyword_type.js +1 -5
- package/lib/formatter/helpers/keyword_type.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.d.ts +9 -10
- package/lib/formatter/helpers/pickle_parser.js +8 -17
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -2
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.d.ts +2 -2
- package/lib/formatter/helpers/summary_helpers.js +39 -20
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +34 -15
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +5 -5
- package/lib/formatter/helpers/test_case_attempt_parser.js +30 -15
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.d.ts +3 -3
- package/lib/formatter/helpers/usage_helpers/index.js +48 -45
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
- package/lib/formatter/html_formatter.d.ts +1 -0
- package/lib/formatter/html_formatter.js +2 -1
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/http_stream.js +1 -1
- package/lib/formatter/http_stream.js.map +1 -1
- package/lib/formatter/index.d.ts +1 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +22 -27
- package/lib/formatter/json_formatter.js +62 -30
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.d.ts +1 -0
- package/lib/formatter/message_formatter.js +2 -1
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +7 -6
- package/lib/formatter/progress_bar_formatter.js +5 -4
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +3 -2
- package/lib/formatter/progress_formatter.js +30 -10
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/rerun_formatter.d.ts +1 -0
- package/lib/formatter/rerun_formatter.js +33 -11
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.d.ts +1 -0
- package/lib/formatter/snippets_formatter.js +22 -2
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +3 -3
- package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +3 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +1 -1
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -1
- package/lib/formatter/summary_formatter.d.ts +3 -2
- package/lib/formatter/summary_formatter.js +4 -4
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.d.ts +1 -0
- package/lib/formatter/usage_formatter.js +24 -5
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.d.ts +1 -0
- package/lib/formatter/usage_json_formatter.js +1 -0
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/importer.js +13 -0
- package/lib/index.d.ts +15 -12
- package/lib/index.js +6 -3
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.d.ts +3 -4
- package/lib/models/data_table.js +9 -7
- package/lib/models/data_table.js.map +1 -1
- package/lib/models/definition.d.ts +2 -2
- package/lib/models/definition.js.map +1 -1
- package/lib/models/step_definition.js +1 -2
- package/lib/models/step_definition.js.map +1 -1
- package/lib/models/test_case_hook_definition.d.ts +2 -2
- package/lib/models/test_case_hook_definition.js.map +1 -1
- package/lib/models/test_step_hook_definition.d.ts +2 -2
- package/lib/models/test_step_hook_definition.js.map +1 -1
- package/lib/pickle_filter.d.ts +9 -11
- package/lib/pickle_filter.js +9 -9
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/assemble_test_cases.d.ts +13 -0
- package/lib/runtime/assemble_test_cases.js +88 -0
- package/lib/runtime/assemble_test_cases.js.map +1 -0
- package/lib/runtime/attachment_manager/index.d.ts +2 -2
- package/lib/runtime/attachment_manager/index.js +23 -4
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/helpers.d.ts +3 -2
- package/lib/runtime/helpers.js +36 -1
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +3 -4
- package/lib/runtime/index.js +27 -43
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/command_types.d.ts +10 -9
- package/lib/runtime/parallel/command_types.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +9 -9
- package/lib/runtime/parallel/coordinator.js +62 -55
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -2
- package/lib/runtime/parallel/worker.js +23 -21
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/step_runner.d.ts +3 -3
- package/lib/runtime/step_runner.js +16 -14
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.d.ts +4 -4
- package/lib/runtime/stopwatch.js +21 -2
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +51 -0
- package/lib/runtime/test_case_runner.js +253 -0
- package/lib/runtime/test_case_runner.js.map +1 -0
- package/lib/stack_trace_filter.js +4 -5
- package/lib/stack_trace_filter.js.map +1 -1
- package/lib/step_arguments.d.ts +4 -4
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/build_helpers.js +14 -10
- package/lib/support_code_library_builder/build_helpers.js.map +1 -1
- package/lib/support_code_library_builder/index.d.ts +9 -7
- package/lib/support_code_library_builder/index.js +10 -24
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +22 -23
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/support_code_library_builder/validate_arguments.js +14 -19
- package/lib/support_code_library_builder/validate_arguments.js.map +1 -1
- package/lib/support_code_library_builder/world.d.ts +7 -1
- package/lib/support_code_library_builder/world.js.map +1 -1
- package/lib/time.d.ts +3 -10
- package/lib/time.js +39 -48
- package/lib/time.js.map +1 -1
- package/lib/user_code_runner.js +7 -14
- package/lib/user_code_runner.js.map +1 -1
- package/lib/value_checker.d.ts +2 -2
- package/lib/value_checker.js.map +1 -1
- package/lib/wrapper.mjs +38 -0
- package/package.json +73 -64
- package/CHANGELOG.md +0 -1881
- package/lib/runtime/pickle_runner.d.ts +0 -67
- package/lib/runtime/pickle_runner.js +0 -305
- package/lib/runtime/pickle_runner.js.map +0 -1
- package/lib/status.d.ts +0 -3
- package/lib/status.js +0 -5
- package/lib/status.js.map +0 -1
- package/lib/support_code_library_builder/finalize_helpers.d.ts +0 -10
- package/lib/support_code_library_builder/finalize_helpers.js +0 -26
- package/lib/support_code_library_builder/finalize_helpers.js.map +0 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ We've put a demo of Cucumber.js to [run in your browser](https://cucumber.github
|
|
|
22
22
|
|
|
23
23
|
## Help & support
|
|
24
24
|
|
|
25
|
-
* See here: https://cucumber.io/support
|
|
25
|
+
* See here: https://cucumber.io/support.
|
|
26
26
|
|
|
27
27
|
## Contributing
|
|
28
28
|
|
|
@@ -52,11 +52,9 @@ $ npm install cucumber@6
|
|
|
52
52
|
|
|
53
53
|
## Documentation
|
|
54
54
|
|
|
55
|
-
The following documentation is for master. See below
|
|
55
|
+
The following documentation is for master. See below the documentation for older versions.
|
|
56
56
|
|
|
57
57
|
* [CLI](/docs/cli.md)
|
|
58
|
-
* [Custom Formatters](/docs/custom_formatters.md)
|
|
59
|
-
* [Custom Snippet Syntaxes](/docs/custom_snippet_syntaxes.md)
|
|
60
58
|
* [NodeJs Example](/docs/nodejs_example.md)
|
|
61
59
|
* Support Files
|
|
62
60
|
* [World](/docs/support_files/world.md)
|
|
@@ -66,6 +64,15 @@ The following documentation is for master. See below for documentation for older
|
|
|
66
64
|
* [Data Table Interface](/docs/support_files/data_table_interface.md)
|
|
67
65
|
* [Attachments](/docs/support_files/attachments.md)
|
|
68
66
|
* [API Reference](/docs/support_files/api_reference.md)
|
|
67
|
+
* Guides
|
|
68
|
+
* [Dry Run](./docs/dry_run.md)
|
|
69
|
+
* [ES Modules](./docs/esm.md)
|
|
70
|
+
* [Formatters](./docs/formatters.md)
|
|
71
|
+
* [Running in parallel](./docs/parallel.md)
|
|
72
|
+
* [Profiles](./docs/profiles.md)
|
|
73
|
+
* [Rerunning just failures](./docs/rerun.md)
|
|
74
|
+
* [Retrying flaky scenarios](./docs/retry.md)
|
|
75
|
+
* [Snippets for undefined steps](./docs/snippets.md)
|
|
69
76
|
* [FAQ](/docs/faq.md)
|
|
70
77
|
|
|
71
78
|
#### Documentation for older versions
|
package/lib/cli/argv_parser.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface IParsedArgvFormatOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export interface IParsedArgvOptions {
|
|
13
13
|
backtrace: boolean;
|
|
14
|
+
config: string;
|
|
14
15
|
dryRun: boolean;
|
|
15
16
|
exit: boolean;
|
|
16
17
|
failFast: boolean;
|
|
@@ -22,7 +23,6 @@ export interface IParsedArgvOptions {
|
|
|
22
23
|
name: string[];
|
|
23
24
|
order: string;
|
|
24
25
|
parallel: number;
|
|
25
|
-
predictableIds: boolean;
|
|
26
26
|
profile: string[];
|
|
27
27
|
publish: boolean;
|
|
28
28
|
publishQuiet: boolean;
|
|
@@ -46,6 +46,5 @@ declare const ArgvParser: {
|
|
|
46
46
|
validateLanguage(value: string): string;
|
|
47
47
|
validateRetryOptions(options: IParsedArgvOptions): void;
|
|
48
48
|
parse(argv: string[]): IParsedArgv;
|
|
49
|
-
lint(fullArgv: string[]): void;
|
|
50
49
|
};
|
|
51
50
|
export default ArgvParser;
|
package/lib/cli/argv_parser.js
CHANGED
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
7
6
|
const commander_1 = require("commander");
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
9
8
|
const gherkin_1 = require("@cucumber/gherkin");
|
|
9
|
+
const formatters_1 = __importDefault(require("../formatter/helpers/formatters"));
|
|
10
10
|
// Using require instead of import so compiled typescript will have the desired folder structure
|
|
11
11
|
const { version } = require('../../package.json'); // eslint-disable-line @typescript-eslint/no-var-requires
|
|
12
12
|
const ArgvParser = {
|
|
@@ -24,10 +24,10 @@ const ArgvParser = {
|
|
|
24
24
|
const e = error;
|
|
25
25
|
throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`);
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
27
|
+
if (typeof val !== 'object' || Array.isArray(val)) {
|
|
28
28
|
throw new Error(`${option} must be passed JSON of an object: ${str}`);
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return { ...memo, ...val };
|
|
31
31
|
};
|
|
32
32
|
},
|
|
33
33
|
mergeTags(value, memo) {
|
|
@@ -41,7 +41,7 @@ const ArgvParser = {
|
|
|
41
41
|
return numericValue;
|
|
42
42
|
},
|
|
43
43
|
validateLanguage(value) {
|
|
44
|
-
if (!
|
|
44
|
+
if (!Object.keys(gherkin_1.dialects).includes(value)) {
|
|
45
45
|
throw new Error(`Unsupported ISO 639-1: ${value}`);
|
|
46
46
|
}
|
|
47
47
|
return value;
|
|
@@ -58,10 +58,12 @@ const ArgvParser = {
|
|
|
58
58
|
.usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')
|
|
59
59
|
.version(version, '-v, --version')
|
|
60
60
|
.option('-b, --backtrace', 'show full backtrace for errors')
|
|
61
|
+
.option('-c, --config <TYPE[:PATH]>', 'specify configuration file')
|
|
61
62
|
.option('-d, --dry-run', 'invoke formatters without executing steps', false)
|
|
62
63
|
.option('--exit', 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit', false)
|
|
63
64
|
.option('--fail-fast', 'abort the run on first failure', false)
|
|
64
|
-
.option('-f, --format <TYPE[:PATH]>', 'specify the output format, optionally supply PATH to redirect formatter output (repeatable)'
|
|
65
|
+
.option('-f, --format <TYPE[:PATH]>', 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\n' +
|
|
66
|
+
formatters_1.default.buildFormattersDocumentationString(), ArgvParser.collect, [])
|
|
65
67
|
.option('--format-options <JSON>', 'provide options for formatters (repeatable)', ArgvParser.mergeJson('--format-options'), {})
|
|
66
68
|
.option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage, '')
|
|
67
69
|
.option('--i18n-languages', 'list languages', false)
|
|
@@ -71,13 +73,12 @@ const ArgvParser = {
|
|
|
71
73
|
.option('--order <TYPE[:SEED]>', 'run scenarios in the specified order. Type should be `defined` or `random`', 'defined')
|
|
72
74
|
.option('-p, --profile <NAME>', 'specify the profile to use (repeatable)', ArgvParser.collect, [])
|
|
73
75
|
.option('--parallel <NUMBER_OF_WORKERS>', 'run in parallel with the given number of workers', (val) => ArgvParser.validateCountOption(val, '--parallel'), 0)
|
|
74
|
-
.option('--predictable-ids', 'Use predictable ids in messages (option ignored if using parallel)', false)
|
|
75
76
|
.option('--publish', 'Publish a report to https://reports.cucumber.io', false)
|
|
76
77
|
.option('--publish-quiet', "Don't print information banner about publishing reports", false)
|
|
77
78
|
.option('-r, --require <GLOB|DIR|FILE>', 'require files before executing features (repeatable)', ArgvParser.collect, [])
|
|
78
79
|
.option('--require-module <NODE_MODULE>', 'require node modules before requiring files (repeatable)', ArgvParser.collect, [])
|
|
79
80
|
.option('--retry <NUMBER_OF_RETRIES>', 'specify the number of times to retry failing test cases (default: 0)', (val) => ArgvParser.validateCountOption(val, '--retry'), 0)
|
|
80
|
-
.option('--
|
|
81
|
+
.option('--retry-tag-filter <EXPRESSION>', `only retries the features or scenarios with tags matching the expression (repeatable).
|
|
81
82
|
This option requires '--retry' to be specified.`, ArgvParser.mergeTags, '')
|
|
82
83
|
.option('-t, --tags <EXPRESSION>', 'only execute the features or scenarios with tags matching the expression (repeatable)', ArgvParser.mergeTags, '')
|
|
83
84
|
.option('--world-parameters <JSON>', 'provide parameters that will be passed to the world constructor (repeatable)', ArgvParser.mergeJson('--world-parameters'), {});
|
|
@@ -94,11 +95,6 @@ const ArgvParser = {
|
|
|
94
95
|
args: program.args,
|
|
95
96
|
};
|
|
96
97
|
},
|
|
97
|
-
lint(fullArgv) {
|
|
98
|
-
if (fullArgv.includes('--retryTagFilter')) {
|
|
99
|
-
console.warn('the argument --retryTagFilter is deprecated and will be removed in a future release; please use --retry-tag-filter');
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
98
|
};
|
|
103
99
|
exports.default = ArgvParser;
|
|
104
100
|
//# sourceMappingURL=argv_parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/cli/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,oDAAsB;AACtB,yCAAmC;AACnC,gDAAuB;AACvB,+CAA4C;AAG5C,gGAAgG;AAChG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA,CAAC,yDAAyD;AA6C3G,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,IAAS;QAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACd,OAAO,IAAI,CAAA;IACb,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,IAAY;YACxC,IAAI,GAAW,CAAA;YACf,IAAI;gBACF,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACtB;YAAC,OAAO,KAAK,EAAE;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C,OAAO,CAAC,IAAI,CACV,oHAAoH,CACrH,CAAA;SACF;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import _ from 'lodash'\nimport { Command } from 'commander'\nimport path from 'path'\nimport { dialects } from '@cucumber/gherkin'\nimport { SnippetInterface } from '../formatter/step_definition_snippet_builder/snippet_syntax'\n\n// Using require instead of import so compiled typescript will have the desired folder structure\nconst { version } = require('../../package.json') // eslint-disable-line @typescript-eslint/no-var-requires\n\nexport interface IParsedArgvFormatRerunOptions {\n separator?: string\n}\n\nexport interface IParsedArgvFormatOptions {\n colorsEnabled?: boolean\n rerun?: IParsedArgvFormatRerunOptions\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n [customKey: string]: any\n}\n\nexport interface IParsedArgvOptions {\n backtrace: boolean\n dryRun: boolean\n exit: boolean\n failFast: boolean\n format: string[]\n formatOptions: IParsedArgvFormatOptions\n i18nKeywords: string\n i18nLanguages: boolean\n language: string\n name: string[]\n order: string\n parallel: number\n predictableIds: boolean\n profile: string[]\n publish: boolean\n publishQuiet: boolean\n require: string[]\n requireModule: string[]\n retry: number\n retryTagFilter: string\n strict: boolean\n tags: string\n worldParameters: object\n}\n\nexport interface IParsedArgv {\n args: string[]\n options: IParsedArgvOptions\n}\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[]): T[] {\n memo.push(val)\n return memo\n },\n\n mergeJson(option: string): (str: string, memo: object) => object {\n return function (str: string, memo: object) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (!_.isPlainObject(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return _.merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo: string): string {\n return memo === '' ? `(${value})` : `${memo} and (${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!_.includes(_.keys(dialects), value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n validateRetryOptions(options: IParsedArgvOptions): void {\n if (options.retryTagFilter !== '' && options.retry === 0) {\n throw new Error(\n 'a positive --retry count must be specified when setting --retry-tag-filter'\n )\n }\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command(path.basename(argv[1]))\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option(\n '-d, --dry-run',\n 'invoke formatters without executing steps',\n false\n )\n .option(\n '--exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit',\n false\n )\n .option('--fail-fast', 'abort the run on first failure', false)\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options'),\n {}\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage,\n ''\n )\n .option('--i18n-languages', 'list languages', false)\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files',\n 'en'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect,\n []\n )\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`',\n 'defined'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel'),\n 0\n )\n .option(\n '--predictable-ids',\n 'Use predictable ids in messages (option ignored if using parallel)',\n false\n )\n .option(\n '--publish',\n 'Publish a report to https://reports.cucumber.io',\n false\n )\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\",\n false\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry'),\n 0\n )\n .option(\n '--retryTagFilter, --retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags,\n ''\n )\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags,\n ''\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters'),\n {}\n )\n\n program.on('--help', () => {\n /* eslint-disable no-console */\n console.log(\n ' For more details please visit https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md\\n'\n )\n /* eslint-enable no-console */\n })\n\n program.parse(argv)\n const options = program.opts() as IParsedArgvOptions\n ArgvParser.validateRetryOptions(options)\n\n return {\n options,\n args: program.args,\n }\n },\n\n lint(fullArgv: string[]): void {\n if (fullArgv.includes('--retryTagFilter')) {\n console.warn(\n 'the argument --retryTagFilter is deprecated and will be removed in a future release; please use --retry-tag-filter'\n )\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
1
|
+
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/cli/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gDAAuB;AACvB,+CAA4C;AAE5C,iFAAwD;AAExD,gGAAgG;AAChG,MAAM,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AAE;YACxB,+BAA+B;YAC/B,OAAO,CAAC,GAAG,CACT,mGAAmG,CACpG,CAAA;YACD,8BAA8B;QAChC,CAAC,CAAC,CAAA;QAEF,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,MAAM,OAAO,GAAuB,OAAO,CAAC,IAAI,EAAE,CAAA;QAClD,UAAU,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;QAExC,OAAO;YACL,OAAO;YACP,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport path from 'path'\nimport { dialects } from '@cucumber/gherkin'\nimport { SnippetInterface } from '../formatter/step_definition_snippet_builder/snippet_syntax'\nimport Formatters from '../formatter/helpers/formatters'\n\n// Using require instead of import so compiled typescript will have the desired folder structure\nconst { version } = require('../../package.json') // eslint-disable-line @typescript-eslint/no-var-requires\n\nexport interface IParsedArgvFormatRerunOptions {\n separator?: string\n}\n\nexport interface IParsedArgvFormatOptions {\n colorsEnabled?: boolean\n rerun?: IParsedArgvFormatRerunOptions\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n [customKey: string]: any\n}\n\nexport interface IParsedArgvOptions {\n backtrace: boolean\n config: string\n dryRun: boolean\n exit: boolean\n failFast: boolean\n format: string[]\n formatOptions: IParsedArgvFormatOptions\n i18nKeywords: string\n i18nLanguages: boolean\n language: string\n name: string[]\n order: string\n parallel: number\n profile: string[]\n publish: boolean\n publishQuiet: boolean\n require: string[]\n requireModule: string[]\n retry: number\n retryTagFilter: string\n strict: boolean\n tags: string\n worldParameters: object\n}\n\nexport interface IParsedArgv {\n args: string[]\n options: IParsedArgvOptions\n}\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[]): T[] {\n memo.push(val)\n return memo\n },\n\n mergeJson(option: string): (str: string, memo: object) => object {\n return function (str: string, memo: object) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return { ...memo, ...val }\n }\n },\n\n mergeTags(value: string, memo: string): string {\n return memo === '' ? `(${value})` : `${memo} and (${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n validateRetryOptions(options: IParsedArgvOptions): void {\n if (options.retryTagFilter !== '' && options.retry === 0) {\n throw new Error(\n 'a positive --retry count must be specified when setting --retry-tag-filter'\n )\n }\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command(path.basename(argv[1]))\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <TYPE[:PATH]>', 'specify configuration file')\n .option(\n '-d, --dry-run',\n 'invoke formatters without executing steps',\n false\n )\n .option(\n '--exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit',\n false\n )\n .option('--fail-fast', 'abort the run on first failure', false)\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Formatters.buildFormattersDocumentationString(),\n ArgvParser.collect,\n []\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options'),\n {}\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage,\n ''\n )\n .option('--i18n-languages', 'list languages', false)\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files',\n 'en'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect,\n []\n )\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`',\n 'defined'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel'),\n 0\n )\n .option(\n '--publish',\n 'Publish a report to https://reports.cucumber.io',\n false\n )\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\",\n false\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry'),\n 0\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags,\n ''\n )\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags,\n ''\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters'),\n {}\n )\n\n program.on('--help', () => {\n /* eslint-disable no-console */\n console.log(\n ' For more details please visit https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md\\n'\n )\n /* eslint-enable no-console */\n })\n\n program.parse(argv)\n const options: IParsedArgvOptions = program.opts()\n ArgvParser.validateRetryOptions(options)\n\n return {\n options,\n args: program.args,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
@@ -3,12 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
7
6
|
const argv_parser_1 = __importDefault(require("./argv_parser"));
|
|
8
7
|
const fs_1 = __importDefault(require("mz/fs"));
|
|
9
8
|
const path_1 = __importDefault(require("path"));
|
|
10
9
|
const option_splitter_1 = __importDefault(require("./option_splitter"));
|
|
11
|
-
const bluebird_1 = __importDefault(require("bluebird"));
|
|
12
10
|
const glob_1 = __importDefault(require("glob"));
|
|
13
11
|
const util_1 = require("util");
|
|
14
12
|
const value_checker_1 = require("../value_checker");
|
|
@@ -16,7 +14,6 @@ const DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports';
|
|
|
16
14
|
class ConfigurationBuilder {
|
|
17
15
|
constructor({ argv, cwd }) {
|
|
18
16
|
this.cwd = cwd;
|
|
19
|
-
argv_parser_1.default.lint(argv);
|
|
20
17
|
const parsedArgv = argv_parser_1.default.parse(argv);
|
|
21
18
|
this.args = parsedArgv.args;
|
|
22
19
|
this.options = parsedArgv.options;
|
|
@@ -37,7 +34,7 @@ class ConfigurationBuilder {
|
|
|
37
34
|
if (unexpandedSupportCodePaths.length === 0) {
|
|
38
35
|
unexpandedSupportCodePaths = this.getFeatureDirectoryPaths(featurePaths);
|
|
39
36
|
}
|
|
40
|
-
supportCodePaths = await this.expandPaths(unexpandedSupportCodePaths, '
|
|
37
|
+
supportCodePaths = await this.expandPaths(unexpandedSupportCodePaths, '.@(js|mjs)');
|
|
41
38
|
}
|
|
42
39
|
return {
|
|
43
40
|
featureDefaultLanguage: this.options.language,
|
|
@@ -55,11 +52,9 @@ class ConfigurationBuilder {
|
|
|
55
52
|
names: this.options.name,
|
|
56
53
|
tagExpression: this.options.tags,
|
|
57
54
|
},
|
|
58
|
-
predictableIds: this.options.predictableIds,
|
|
59
55
|
profiles: this.options.profile,
|
|
60
56
|
runtimeOptions: {
|
|
61
57
|
dryRun: this.options.dryRun,
|
|
62
|
-
predictableIds: this.options.predictableIds,
|
|
63
58
|
failFast: this.options.failFast,
|
|
64
59
|
filterStacktraces: !this.options.backtrace,
|
|
65
60
|
retry: this.options.retry,
|
|
@@ -74,24 +69,25 @@ class ConfigurationBuilder {
|
|
|
74
69
|
};
|
|
75
70
|
}
|
|
76
71
|
async expandPaths(unexpandedPaths, defaultExtension) {
|
|
77
|
-
const expandedPaths = await
|
|
72
|
+
const expandedPaths = await Promise.all(unexpandedPaths.map(async (unexpandedPath) => {
|
|
78
73
|
const matches = await util_1.promisify(glob_1.default)(unexpandedPath, {
|
|
79
74
|
absolute: true,
|
|
80
75
|
cwd: this.cwd,
|
|
81
76
|
});
|
|
82
|
-
const expanded = await
|
|
77
|
+
const expanded = await Promise.all(matches.map(async (match) => {
|
|
83
78
|
if (path_1.default.extname(match) === '') {
|
|
84
79
|
return await util_1.promisify(glob_1.default)(`${match}/**/*${defaultExtension}`);
|
|
85
80
|
}
|
|
86
81
|
return [match];
|
|
87
|
-
});
|
|
88
|
-
return
|
|
89
|
-
});
|
|
90
|
-
return
|
|
82
|
+
}));
|
|
83
|
+
return expanded.flat();
|
|
84
|
+
}));
|
|
85
|
+
return expandedPaths.flat().map((x) => path_1.default.normalize(x));
|
|
91
86
|
}
|
|
92
87
|
async expandFeaturePaths(featurePaths) {
|
|
93
88
|
featurePaths = featurePaths.map((p) => p.replace(/(:\d+)*$/g, '')); // Strip line numbers
|
|
94
|
-
|
|
89
|
+
featurePaths = [...new Set(featurePaths)]; // Deduplicate the feature files
|
|
90
|
+
return await this.expandPaths(featurePaths, '.feature');
|
|
95
91
|
}
|
|
96
92
|
getFeatureDirectoryPaths(featurePaths) {
|
|
97
93
|
const featureDirs = featurePaths.map((featurePath) => {
|
|
@@ -108,7 +104,7 @@ class ConfigurationBuilder {
|
|
|
108
104
|
}
|
|
109
105
|
return path_1.default.relative(this.cwd, featureDir);
|
|
110
106
|
});
|
|
111
|
-
return
|
|
107
|
+
return [...new Set(featureDirs)];
|
|
112
108
|
}
|
|
113
109
|
isPublishing() {
|
|
114
110
|
return (this.options.publish ||
|
|
@@ -129,7 +125,10 @@ class ConfigurationBuilder {
|
|
|
129
125
|
const publishUrl = value_checker_1.valueOrDefault(process.env.CUCUMBER_PUBLISH_URL, DEFAULT_CUCUMBER_PUBLISH_URL);
|
|
130
126
|
mapping[publishUrl] = 'message';
|
|
131
127
|
}
|
|
132
|
-
return
|
|
128
|
+
return Object.keys(mapping).map((outputTo) => ({
|
|
129
|
+
outputTo,
|
|
130
|
+
type: mapping[outputTo],
|
|
131
|
+
}));
|
|
133
132
|
}
|
|
134
133
|
isTruthyString(s) {
|
|
135
134
|
if (s === undefined) {
|
|
@@ -139,21 +138,21 @@ class ConfigurationBuilder {
|
|
|
139
138
|
}
|
|
140
139
|
async getUnexpandedFeaturePaths() {
|
|
141
140
|
if (this.args.length > 0) {
|
|
142
|
-
const nestedFeaturePaths = await
|
|
141
|
+
const nestedFeaturePaths = await Promise.all(this.args.map(async (arg) => {
|
|
143
142
|
const filename = path_1.default.basename(arg);
|
|
144
143
|
if (filename[0] === '@') {
|
|
145
144
|
const filePath = path_1.default.join(this.cwd, arg);
|
|
146
145
|
const content = await fs_1.default.readFile(filePath, 'utf8');
|
|
147
|
-
return
|
|
146
|
+
return content.split('\n').map((x) => x.trim());
|
|
148
147
|
}
|
|
149
148
|
return [arg];
|
|
150
|
-
});
|
|
151
|
-
const featurePaths =
|
|
149
|
+
}));
|
|
150
|
+
const featurePaths = nestedFeaturePaths.flat();
|
|
152
151
|
if (featurePaths.length > 0) {
|
|
153
|
-
return featurePaths;
|
|
152
|
+
return featurePaths.filter((x) => x !== '');
|
|
154
153
|
}
|
|
155
154
|
}
|
|
156
|
-
return ['features/**/*.feature'];
|
|
155
|
+
return ['features/**/*.{feature,feature.md}'];
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
exports.default = ConfigurationBuilder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration_builder.js","sourceRoot":"","sources":["../../src/cli/configuration_builder.ts"],"names":[],"mappings":";;;;;AAAA,oDAAsB;AACtB,gEAGsB;AACtB,+CAAsB;AACtB,gDAAuB;AACvB,wEAA8C;AAC9C,wDAA+B;AAC/B,gDAAuB;AACvB,+BAAgC;AAGhC,oDAAiD;AAgCjD,MAAM,4BAA4B,GAAG,0CAA0C,CAAA;AAE/E,MAAqB,oBAAoB;IAYvC,YAAY,EAAE,IAAI,EAAE,GAAG,EAAmC;QACxD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QAEd,qBAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrB,MAAM,UAAU,GAAG,qBAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACzC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAA;IACnC,CAAC;IAlBD,MAAM,CAAC,KAAK,CAAC,KAAK,CAChB,OAAwC;QAExC,MAAM,OAAO,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAA;QACjD,OAAO,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IAC9B,CAAC;IAeD,KAAK,CAAC,KAAK;QACT,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAA;QACrD,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAA;QACpD,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,yBAAyB,EAAE,CAAA;QACrE,IAAI,YAAY,GAAa,EAAE,CAAA;QAC/B,IAAI,gBAAgB,GAAa,EAAE,CAAA;QACnC,IAAI,mBAAmB,KAAK,EAAE,IAAI,CAAC,iBAAiB,EAAE;YACpD,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AC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;oBACzC,MAAM,OAAO,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;oBACnD,OAAO,gBAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,gBAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAA;iBAClE;gBACD,OAAO,CAAC,GAAG,CAAC,CAAA;YACd,CAAC,CAAC,CAAA;YACF,MAAM,YAAY,GAAG,gBAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;YAClD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,OAAO,YAAY,CAAA;aACpB;SACF;QACD,OAAO,CAAC,uBAAuB,CAAC,CAAA;IAClC,CAAC;CACF;AAhLD,uCAgLC","sourcesContent":["import _ from 'lodash'\nimport ArgvParser, {\n IParsedArgvFormatOptions,\n IParsedArgvOptions,\n} from './argv_parser'\nimport fs from 'mz/fs'\nimport path from 'path'\nimport OptionSplitter from './option_splitter'\nimport bluebird from 'bluebird'\nimport glob from 'glob'\nimport { promisify } from 'util'\nimport { IPickleFilterOptions } from '../pickle_filter'\nimport { IRuntimeOptions } from '../runtime'\nimport { valueOrDefault } from '../value_checker'\n\nexport interface IConfigurationFormat {\n outputTo: string\n type: string\n}\n\nexport interface IConfiguration {\n featureDefaultLanguage: string\n featurePaths: string[]\n formats: IConfigurationFormat[]\n formatOptions: IParsedArgvFormatOptions\n publishing: boolean\n listI18nKeywordsFor: string\n listI18nLanguages: boolean\n order: string\n parallel: number\n pickleFilterOptions: IPickleFilterOptions\n predictableIds: boolean\n profiles: string[]\n runtimeOptions: IRuntimeOptions\n shouldExitImmediately: boolean\n supportCodePaths: string[]\n supportCodeRequiredModules: string[]\n suppressPublishAdvertisement: boolean\n}\n\nexport interface INewConfigurationBuilderOptions {\n argv: string[]\n cwd: string\n}\n\nconst DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports'\n\nexport default class ConfigurationBuilder {\n static async build(\n options: INewConfigurationBuilderOptions\n ): Promise<IConfiguration> {\n const builder = new ConfigurationBuilder(options)\n return await builder.build()\n }\n\n private readonly cwd: string\n private readonly args: string[]\n private readonly options: IParsedArgvOptions\n\n constructor({ argv, cwd }: INewConfigurationBuilderOptions) {\n this.cwd = cwd\n\n ArgvParser.lint(argv)\n const parsedArgv = ArgvParser.parse(argv)\n this.args = parsedArgv.args\n this.options = parsedArgv.options\n }\n\n async build(): Promise<IConfiguration> {\n const listI18nKeywordsFor = this.options.i18nKeywords\n const listI18nLanguages = this.options.i18nLanguages\n const unexpandedFeaturePaths = await this.getUnexpandedFeaturePaths()\n let featurePaths: string[] = []\n let supportCodePaths: string[] = []\n if (listI18nKeywordsFor === '' && !listI18nLanguages) {\n featurePaths = await this.expandFeaturePaths(unexpandedFeaturePaths)\n let unexpandedSupportCodePaths = this.options.require\n if (unexpandedSupportCodePaths.length === 0) {\n unexpandedSupportCodePaths = this.getFeatureDirectoryPaths(featurePaths)\n }\n supportCodePaths = await this.expandPaths(\n unexpandedSupportCodePaths,\n '.js'\n )\n }\n return {\n featureDefaultLanguage: this.options.language,\n featurePaths,\n formats: this.getFormats(),\n formatOptions: this.options.formatOptions,\n publishing: this.isPublishing(),\n listI18nKeywordsFor,\n listI18nLanguages,\n order: this.options.order,\n parallel: this.options.parallel,\n pickleFilterOptions: {\n cwd: this.cwd,\n featurePaths: unexpandedFeaturePaths,\n names: this.options.name,\n tagExpression: this.options.tags,\n },\n predictableIds: this.options.predictableIds,\n profiles: this.options.profile,\n runtimeOptions: {\n dryRun: this.options.dryRun,\n predictableIds: this.options.predictableIds,\n failFast: this.options.failFast,\n filterStacktraces: !this.options.backtrace,\n retry: this.options.retry,\n retryTagFilter: this.options.retryTagFilter,\n strict: this.options.strict,\n worldParameters: this.options.worldParameters,\n },\n shouldExitImmediately: this.options.exit,\n supportCodePaths,\n supportCodeRequiredModules: this.options.requireModule,\n suppressPublishAdvertisement: this.isPublishAdvertisementSuppressed(),\n }\n }\n\n async expandPaths(\n unexpandedPaths: string[],\n defaultExtension: string\n ): Promise<string[]> {\n const expandedPaths = await bluebird.map(\n unexpandedPaths,\n async (unexpandedPath) => {\n const matches = await promisify(glob)(unexpandedPath, {\n absolute: true,\n cwd: this.cwd,\n })\n const expanded = await bluebird.map(matches, async (match) => {\n if (path.extname(match) === '') {\n return await promisify(glob)(`${match}/**/*${defaultExtension}`)\n }\n return [match]\n })\n return _.flatten(expanded)\n }\n )\n return _.flatten(expandedPaths).map((x) => path.normalize(x))\n }\n\n async expandFeaturePaths(featurePaths: string[]): Promise<string[]> {\n featurePaths = featurePaths.map((p) => p.replace(/(:\\d+)*$/g, '')) // Strip line numbers\n return this.expandPaths(featurePaths, '.feature')\n }\n\n getFeatureDirectoryPaths(featurePaths: string[]): string[] {\n const featureDirs = featurePaths.map((featurePath) => {\n let featureDir = path.dirname(featurePath)\n let childDir: string\n let parentDir = featureDir\n while (childDir !== parentDir) {\n childDir = parentDir\n parentDir = path.dirname(childDir)\n if (path.basename(parentDir) === 'features') {\n featureDir = parentDir\n break\n }\n }\n return path.relative(this.cwd, featureDir)\n })\n return _.uniq(featureDirs)\n }\n\n isPublishing(): boolean {\n return (\n this.options.publish ||\n this.isTruthyString(process.env.CUCUMBER_PUBLISH_ENABLED) ||\n process.env.CUCUMBER_PUBLISH_TOKEN !== undefined\n )\n }\n\n isPublishAdvertisementSuppressed(): boolean {\n return (\n this.options.publishQuiet ||\n this.isTruthyString(process.env.CUCUMBER_PUBLISH_QUIET)\n )\n }\n\n getFormats(): IConfigurationFormat[] {\n const mapping: { [key: string]: string } = { '': 'progress' }\n this.options.format.forEach((format) => {\n const [type, outputTo] = OptionSplitter.split(format)\n mapping[outputTo] = type\n })\n if (this.isPublishing()) {\n const publishUrl = valueOrDefault(\n process.env.CUCUMBER_PUBLISH_URL,\n DEFAULT_CUCUMBER_PUBLISH_URL\n )\n\n mapping[publishUrl] = 'message'\n }\n return _.map(mapping, (type, outputTo) => ({ outputTo, type }))\n }\n\n isTruthyString(s: string | undefined): boolean {\n if (s === undefined) {\n return false\n }\n return s.match(/^(false|no|0)$/i) === null\n }\n\n async getUnexpandedFeaturePaths(): Promise<string[]> {\n if (this.args.length > 0) {\n const nestedFeaturePaths = await bluebird.map(this.args, async (arg) => {\n const filename = path.basename(arg)\n if (filename[0] === '@') {\n const filePath = path.join(this.cwd, arg)\n const content = await fs.readFile(filePath, 'utf8')\n return _.chain(content).split('\\n').map(_.trim).compact().value()\n }\n return [arg]\n })\n const featurePaths = _.flatten(nestedFeaturePaths)\n if (featurePaths.length > 0) {\n return featurePaths\n }\n }\n return ['features/**/*.feature']\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"configuration_builder.js","sourceRoot":"","sources":["../../src/cli/configuration_builder.ts"],"names":[],"mappings":";;;;;AAAA,gEAGsB;AACtB,+CAAsB;AACtB,gDAAuB;AACvB,wEAA8C;AAC9C,gDAAuB;AACvB,+BAAgC;AAGhC,oDAAiD;AA+BjD,MAAM,4BAA4B,GAAG,0CAA0C,CAAA;AAE/E,MAAqB,oBAAoB;IAYvC,YAAY,EAAE,IAAI,EAAE,GAAG,EAAmC;QACxD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,MAAM,UAAU,GAAG,qBAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACzC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAA;IACnC,CAAC;IAhBD,MAAM,CAAC,KAAK,CAAC,KAAK,CAChB,OAAwC;QAExC,MAAM,OAAO,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAA;QACjD,OAAO,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IAC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iBAAiB,CAAC,KAAK,IAAI,CAAA;IAC5C,CAAC;IAED,KAAK,CAAC,yBAAyB;QAC7B,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC1C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBAC1B,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;gBACnC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;oBACvB,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;oBACzC,MAAM,OAAO,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;oBACnD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;iBAChD;gBACD,OAAO,CAAC,GAAG,CAAC,CAAA;YACd,CAAC,CAAC,CACH,CAAA;YACD,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAI,EAAE,CAAA;YAC9C,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;aAC5C;SACF;QACD,OAAO,CAAC,oCAAoC,CAAC,CAAA;IAC/C,CAAC;CACF;AAnLD,uCAmLC","sourcesContent":["import ArgvParser, {\n IParsedArgvFormatOptions,\n IParsedArgvOptions,\n} from './argv_parser'\nimport fs from 'mz/fs'\nimport path from 'path'\nimport OptionSplitter from './option_splitter'\nimport glob from 'glob'\nimport { promisify } from 'util'\nimport { IPickleFilterOptions } from '../pickle_filter'\nimport { IRuntimeOptions } from '../runtime'\nimport { valueOrDefault } from '../value_checker'\n\nexport interface IConfigurationFormat {\n outputTo: string\n type: string\n}\n\nexport interface IConfiguration {\n featureDefaultLanguage: string\n featurePaths: string[]\n formats: IConfigurationFormat[]\n formatOptions: IParsedArgvFormatOptions\n publishing: boolean\n listI18nKeywordsFor: string\n listI18nLanguages: boolean\n order: string\n parallel: number\n pickleFilterOptions: IPickleFilterOptions\n profiles: string[]\n runtimeOptions: IRuntimeOptions\n shouldExitImmediately: boolean\n supportCodePaths: string[]\n supportCodeRequiredModules: string[]\n suppressPublishAdvertisement: boolean\n}\n\nexport interface INewConfigurationBuilderOptions {\n argv: string[]\n cwd: string\n}\n\nconst DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports'\n\nexport default class ConfigurationBuilder {\n static async build(\n options: INewConfigurationBuilderOptions\n ): Promise<IConfiguration> {\n const builder = new ConfigurationBuilder(options)\n return await builder.build()\n }\n\n private readonly cwd: string\n private readonly args: string[]\n private readonly options: IParsedArgvOptions\n\n constructor({ argv, cwd }: INewConfigurationBuilderOptions) {\n this.cwd = cwd\n const parsedArgv = ArgvParser.parse(argv)\n this.args = parsedArgv.args\n this.options = parsedArgv.options\n }\n\n async build(): Promise<IConfiguration> {\n const listI18nKeywordsFor = this.options.i18nKeywords\n const listI18nLanguages = this.options.i18nLanguages\n const unexpandedFeaturePaths = await this.getUnexpandedFeaturePaths()\n let featurePaths: string[] = []\n let supportCodePaths: string[] = []\n if (listI18nKeywordsFor === '' && !listI18nLanguages) {\n featurePaths = await this.expandFeaturePaths(unexpandedFeaturePaths)\n let unexpandedSupportCodePaths = this.options.require\n if (unexpandedSupportCodePaths.length === 0) {\n unexpandedSupportCodePaths = this.getFeatureDirectoryPaths(featurePaths)\n }\n supportCodePaths = await this.expandPaths(\n unexpandedSupportCodePaths,\n '.@(js|mjs)'\n )\n }\n return {\n featureDefaultLanguage: this.options.language,\n featurePaths,\n formats: this.getFormats(),\n formatOptions: this.options.formatOptions,\n publishing: this.isPublishing(),\n listI18nKeywordsFor,\n listI18nLanguages,\n order: this.options.order,\n parallel: this.options.parallel,\n pickleFilterOptions: {\n cwd: this.cwd,\n featurePaths: unexpandedFeaturePaths,\n names: this.options.name,\n tagExpression: this.options.tags,\n },\n profiles: this.options.profile,\n runtimeOptions: {\n dryRun: this.options.dryRun,\n failFast: this.options.failFast,\n filterStacktraces: !this.options.backtrace,\n retry: this.options.retry,\n retryTagFilter: this.options.retryTagFilter,\n strict: this.options.strict,\n worldParameters: this.options.worldParameters,\n },\n shouldExitImmediately: this.options.exit,\n supportCodePaths,\n supportCodeRequiredModules: this.options.requireModule,\n suppressPublishAdvertisement: this.isPublishAdvertisementSuppressed(),\n }\n }\n\n async expandPaths(\n unexpandedPaths: string[],\n defaultExtension: string\n ): Promise<string[]> {\n const expandedPaths = await Promise.all(\n unexpandedPaths.map(async (unexpandedPath) => {\n const matches = await promisify(glob)(unexpandedPath, {\n absolute: true,\n cwd: this.cwd,\n })\n const expanded = await Promise.all(\n matches.map(async (match) => {\n if (path.extname(match) === '') {\n return await promisify(glob)(`${match}/**/*${defaultExtension}`)\n }\n return [match]\n })\n )\n return expanded.flat()\n })\n )\n return expandedPaths.flat().map((x) => path.normalize(x))\n }\n\n async expandFeaturePaths(featurePaths: string[]): Promise<string[]> {\n featurePaths = featurePaths.map((p) => p.replace(/(:\\d+)*$/g, '')) // Strip line numbers\n featurePaths = [...new Set(featurePaths)] // Deduplicate the feature files\n return await this.expandPaths(featurePaths, '.feature')\n }\n\n getFeatureDirectoryPaths(featurePaths: string[]): string[] {\n const featureDirs = featurePaths.map((featurePath) => {\n let featureDir = path.dirname(featurePath)\n let childDir: string\n let parentDir = featureDir\n while (childDir !== parentDir) {\n childDir = parentDir\n parentDir = path.dirname(childDir)\n if (path.basename(parentDir) === 'features') {\n featureDir = parentDir\n break\n }\n }\n return path.relative(this.cwd, featureDir)\n })\n return [...new Set(featureDirs)]\n }\n\n isPublishing(): boolean {\n return (\n this.options.publish ||\n this.isTruthyString(process.env.CUCUMBER_PUBLISH_ENABLED) ||\n process.env.CUCUMBER_PUBLISH_TOKEN !== undefined\n )\n }\n\n isPublishAdvertisementSuppressed(): boolean {\n return (\n this.options.publishQuiet ||\n this.isTruthyString(process.env.CUCUMBER_PUBLISH_QUIET)\n )\n }\n\n getFormats(): IConfigurationFormat[] {\n const mapping: { [key: string]: string } = { '': 'progress' }\n this.options.format.forEach((format) => {\n const [type, outputTo] = OptionSplitter.split(format)\n mapping[outputTo] = type\n })\n if (this.isPublishing()) {\n const publishUrl = valueOrDefault(\n process.env.CUCUMBER_PUBLISH_URL,\n DEFAULT_CUCUMBER_PUBLISH_URL\n )\n\n mapping[publishUrl] = 'message'\n }\n return Object.keys(mapping).map((outputTo) => ({\n outputTo,\n type: mapping[outputTo],\n }))\n }\n\n isTruthyString(s: string | undefined): boolean {\n if (s === undefined) {\n return false\n }\n return s.match(/^(false|no|0)$/i) === null\n }\n\n async getUnexpandedFeaturePaths(): Promise<string[]> {\n if (this.args.length > 0) {\n const nestedFeaturePaths = await Promise.all(\n this.args.map(async (arg) => {\n const filename = path.basename(arg)\n if (filename[0] === '@') {\n const filePath = path.join(this.cwd, arg)\n const content = await fs.readFile(filePath, 'utf8')\n return content.split('\\n').map((x) => x.trim())\n }\n return [arg]\n })\n )\n const featurePaths = nestedFeaturePaths.flat()\n if (featurePaths.length > 0) {\n return featurePaths.filter((x) => x !== '')\n }\n }\n return ['features/**/*.{feature,feature.md}']\n }\n}\n"]}
|
package/lib/cli/helpers.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ interface IParseGherkinMessageStreamRequest {
|
|
|
20
20
|
}
|
|
21
21
|
export declare function parseGherkinMessageStream({ cwd, eventBroadcaster, eventDataCollector, gherkinMessageStream, order, pickleFilter, }: IParseGherkinMessageStreamRequest): Promise<string[]>;
|
|
22
22
|
export declare function orderPickleIds(pickleIds: string[], order: string): void;
|
|
23
|
+
export declare function isJavaScript(filePath: string): boolean;
|
|
23
24
|
export declare function emitMetaMessage(eventBroadcaster: EventEmitter): Promise<void>;
|
|
24
25
|
export declare function emitSupportCodeMessages({ eventBroadcaster, supportCodeLibrary, newId, }: {
|
|
25
26
|
eventBroadcaster: EventEmitter;
|
package/lib/cli/helpers.js
CHANGED
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
23
|
};
|
|
5
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.emitSupportCodeMessages = exports.emitMetaMessage = exports.orderPickleIds = exports.parseGherkinMessageStream = exports.getExpandedArgv = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
25
|
+
exports.emitSupportCodeMessages = exports.emitMetaMessage = exports.isJavaScript = exports.orderPickleIds = exports.parseGherkinMessageStream = exports.getExpandedArgv = void 0;
|
|
8
26
|
const argv_parser_1 = __importDefault(require("./argv_parser"));
|
|
9
27
|
const profile_loader_1 = __importDefault(require("./profile_loader"));
|
|
10
28
|
const knuth_shuffle_seeded_1 = __importDefault(require("knuth-shuffle-seeded"));
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
29
|
const value_checker_1 = require("../value_checker");
|
|
13
30
|
const option_splitter_1 = __importDefault(require("./option_splitter"));
|
|
14
|
-
const
|
|
31
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
15
32
|
const create_meta_1 = __importDefault(require("@cucumber/create-meta"));
|
|
16
33
|
const support_code_library_builder_1 = require("../support_code_library_builder");
|
|
17
|
-
const StepDefinitionPatternType = messages_1.messages.StepDefinition.StepDefinitionPattern.StepDefinitionPatternType;
|
|
18
34
|
async function getExpandedArgv({ argv, cwd, }) {
|
|
19
35
|
const { options } = argv_parser_1.default.parse(argv);
|
|
20
36
|
let fullArgv = argv;
|
|
21
|
-
const profileArgv = await new profile_loader_1.default(cwd).getArgv(options.profile);
|
|
37
|
+
const profileArgv = await new profile_loader_1.default(cwd).getArgv(options.profile, options.config);
|
|
22
38
|
if (profileArgv.length > 0) {
|
|
23
|
-
fullArgv =
|
|
39
|
+
fullArgv = argv.slice(0, 2).concat(profileArgv).concat(argv.slice(2));
|
|
24
40
|
}
|
|
25
41
|
return fullArgv;
|
|
26
42
|
}
|
|
@@ -39,7 +55,7 @@ async function parseGherkinMessageStream({ cwd, eventBroadcaster, eventDataColle
|
|
|
39
55
|
}
|
|
40
56
|
}
|
|
41
57
|
if (value_checker_1.doesHaveValue(envelope.parseError)) {
|
|
42
|
-
reject(new Error(`Parse error in '${
|
|
58
|
+
reject(new Error(`Parse error in '${envelope.parseError.source.uri}': ${envelope.parseError.message}`));
|
|
43
59
|
}
|
|
44
60
|
});
|
|
45
61
|
gherkinMessageStream.on('end', () => {
|
|
@@ -68,12 +84,18 @@ function orderPickleIds(pickleIds, order) {
|
|
|
68
84
|
}
|
|
69
85
|
}
|
|
70
86
|
exports.orderPickleIds = orderPickleIds;
|
|
87
|
+
function isJavaScript(filePath) {
|
|
88
|
+
return (filePath.endsWith('.js') ||
|
|
89
|
+
filePath.endsWith('.mjs') ||
|
|
90
|
+
filePath.endsWith('.cjs'));
|
|
91
|
+
}
|
|
92
|
+
exports.isJavaScript = isJavaScript;
|
|
71
93
|
async function emitMetaMessage(eventBroadcaster) {
|
|
72
94
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
73
95
|
const { version } = require('../../package.json');
|
|
74
|
-
eventBroadcaster.emit('envelope',
|
|
96
|
+
eventBroadcaster.emit('envelope', {
|
|
75
97
|
meta: create_meta_1.default('cucumber-js', version, process.env),
|
|
76
|
-
})
|
|
98
|
+
});
|
|
77
99
|
}
|
|
78
100
|
exports.emitMetaMessage = emitMetaMessage;
|
|
79
101
|
function emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId) {
|
|
@@ -82,7 +104,7 @@ function emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId) {
|
|
|
82
104
|
if (support_code_library_builder_1.builtinParameterTypes.includes(parameterType.name)) {
|
|
83
105
|
continue;
|
|
84
106
|
}
|
|
85
|
-
|
|
107
|
+
const envelope = {
|
|
86
108
|
parameterType: {
|
|
87
109
|
id: newId(),
|
|
88
110
|
name: parameterType.name,
|
|
@@ -90,26 +112,28 @@ function emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId) {
|
|
|
90
112
|
regularExpressions: parameterType.regexpStrings,
|
|
91
113
|
useForSnippets: parameterType.useForSnippets,
|
|
92
114
|
},
|
|
93
|
-
}
|
|
115
|
+
};
|
|
116
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
94
117
|
}
|
|
95
118
|
}
|
|
96
119
|
function emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster) {
|
|
97
120
|
for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {
|
|
98
|
-
|
|
121
|
+
const envelope = {
|
|
99
122
|
undefinedParameterType,
|
|
100
|
-
}
|
|
123
|
+
};
|
|
124
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
101
125
|
}
|
|
102
126
|
}
|
|
103
127
|
function emitStepDefinitions(supportCodeLibrary, eventBroadcaster) {
|
|
104
128
|
supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {
|
|
105
|
-
|
|
129
|
+
const envelope = {
|
|
106
130
|
stepDefinition: {
|
|
107
131
|
id: stepDefinition.id,
|
|
108
132
|
pattern: {
|
|
109
133
|
source: stepDefinition.pattern.toString(),
|
|
110
134
|
type: typeof stepDefinition.pattern === 'string'
|
|
111
|
-
? StepDefinitionPatternType.CUCUMBER_EXPRESSION
|
|
112
|
-
: StepDefinitionPatternType.REGULAR_EXPRESSION,
|
|
135
|
+
? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION
|
|
136
|
+
: messages.StepDefinitionPatternType.REGULAR_EXPRESSION,
|
|
113
137
|
},
|
|
114
138
|
sourceReference: {
|
|
115
139
|
uri: stepDefinition.uri,
|
|
@@ -118,7 +142,8 @@ function emitStepDefinitions(supportCodeLibrary, eventBroadcaster) {
|
|
|
118
142
|
},
|
|
119
143
|
},
|
|
120
144
|
},
|
|
121
|
-
}
|
|
145
|
+
};
|
|
146
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
122
147
|
});
|
|
123
148
|
}
|
|
124
149
|
function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
|
|
@@ -126,7 +151,7 @@ function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
126
151
|
[]
|
|
127
152
|
.concat(supportCodeLibrary.beforeTestCaseHookDefinitions, supportCodeLibrary.afterTestCaseHookDefinitions)
|
|
128
153
|
.forEach((testCaseHookDefinition) => {
|
|
129
|
-
|
|
154
|
+
const envelope = {
|
|
130
155
|
hook: {
|
|
131
156
|
id: testCaseHookDefinition.id,
|
|
132
157
|
tagExpression: testCaseHookDefinition.tagExpression,
|
|
@@ -137,7 +162,8 @@ function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
137
162
|
},
|
|
138
163
|
},
|
|
139
164
|
},
|
|
140
|
-
}
|
|
165
|
+
};
|
|
166
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
141
167
|
});
|
|
142
168
|
}
|
|
143
169
|
function emitTestRunHooks(supportCodeLibrary, eventBroadcaster) {
|
|
@@ -145,7 +171,7 @@ function emitTestRunHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
145
171
|
[]
|
|
146
172
|
.concat(supportCodeLibrary.beforeTestRunHookDefinitions, supportCodeLibrary.afterTestRunHookDefinitions)
|
|
147
173
|
.forEach((testRunHookDefinition) => {
|
|
148
|
-
|
|
174
|
+
const envelope = {
|
|
149
175
|
hook: {
|
|
150
176
|
id: testRunHookDefinition.id,
|
|
151
177
|
sourceReference: {
|
|
@@ -155,7 +181,8 @@ function emitTestRunHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
155
181
|
},
|
|
156
182
|
},
|
|
157
183
|
},
|
|
158
|
-
}
|
|
184
|
+
};
|
|
185
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
159
186
|
});
|
|
160
187
|
}
|
|
161
188
|
function emitSupportCodeMessages({ eventBroadcaster, supportCodeLibrary, newId, }) {
|
package/lib/cli/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,gEAAsC;AACtC,sEAA4C;AAC5C,gFAA0C;AAC1C,gDAAuB;AAIvB,oDAAgD;AAChD,wEAA8C;AAE9C,iDAA0D;AAC1D,wEAA8C;AAI9C,kFAAuE;AAEvE,MAAM,yBAAyB,GAC7B,mBAAQ,CAAC,cAAc,CAAC,qBAAqB,CAAC,yBAAyB,CAAA;AAOlE,KAAK,UAAU,eAA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BAA2B,CAC/C;SACA,OAAO,CAAC,CAAC,qBAA4C,EAAE,EAAE;QACxD,gBAAgB,CAAC,IAAI,CACnB,UAAU,EACV,mBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC3B,IAAI,EAAE;gBACJ,EAAE,EAAE,qBAAqB,CAAC,EAAE;gBAC5B,eAAe,EAAE;oBACf,GAAG,EAAE,qBAAqB,CAAC,GAAG;oBAC9B,QAAQ,EAAE;wBACR,IAAI,EAAE,qBAAqB,CAAC,IAAI;qBACjC;iBACF;aACF;SACF,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAA;AACN,CAAC;AAED,SAAgB,uBAAuB,CAAC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,GAKN;IACC,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC/D,2BAA2B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACjE,mBAAmB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACzD,iBAAiB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACvD,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;AACxD,CAAC;AAdD,0DAcC","sourcesContent":["import _ from 'lodash'\nimport ArgvParser from './argv_parser'\nimport ProfileLoader from './profile_loader'\nimport shuffle from 'knuth-shuffle-seeded'\nimport path from 'path'\nimport { EventEmitter } from 'events'\nimport PickleFilter from '../pickle_filter'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { doesHaveValue } from '../value_checker'\nimport OptionSplitter from './option_splitter'\nimport { Readable } from 'stream'\nimport { IdGenerator, messages } from '@cucumber/messages'\nimport createMeta from '@cucumber/create-meta'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport { builtinParameterTypes } from '../support_code_library_builder'\n\nconst StepDefinitionPatternType =\n messages.StepDefinition.StepDefinitionPattern.StepDefinitionPatternType\n\nexport interface IGetExpandedArgvRequest {\n argv: string[]\n cwd: string\n}\n\nexport async function getExpandedArgv({\n argv,\n cwd,\n}: IGetExpandedArgvRequest): Promise<string[]> {\n const { options } = ArgvParser.parse(argv)\n let fullArgv = argv\n const profileArgv = await new ProfileLoader(cwd).getArgv(options.profile)\n if (profileArgv.length > 0) {\n fullArgv = _.concat(argv.slice(0, 2), profileArgv, argv.slice(2))\n }\n return fullArgv\n}\n\ninterface IParseGherkinMessageStreamRequest {\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n gherkinMessageStream: Readable\n order: string\n pickleFilter: PickleFilter\n}\n\nexport async function parseGherkinMessageStream({\n cwd,\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order,\n pickleFilter,\n}: IParseGherkinMessageStreamRequest): Promise<string[]> {\n return await new Promise<string[]>((resolve, reject) => {\n const result: string[] = []\n gherkinMessageStream.on('data', (envelope: messages.IEnvelope) => {\n eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.pickle)) {\n const pickle = envelope.pickle\n const pickleId = pickle.id\n const gherkinDocument = eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n if (pickleFilter.matches({ gherkinDocument, pickle })) {\n result.push(pickleId)\n }\n }\n if (doesHaveValue(envelope.parseError)) {\n reject(\n new Error(\n `Parse error in '${path.relative(\n cwd,\n envelope.parseError.source.uri\n )}': ${envelope.parseError.message}`\n )\n )\n }\n })\n gherkinMessageStream.on('end', () => {\n orderPickleIds(result, order)\n resolve(result)\n })\n gherkinMessageStream.on('error', reject)\n })\n}\n\n// Orders the pickleIds in place - morphs input\nexport function orderPickleIds(pickleIds: string[], order: string): void {\n let [type, seed] = OptionSplitter.split(order)\n switch (type) {\n case 'defined':\n break\n case 'random':\n if (seed === '') {\n seed = Math.floor(Math.random() * 1000 * 1000).toString()\n console.warn(`Random order using seed: ${seed}`)\n }\n shuffle(pickleIds, seed)\n break\n default:\n throw new Error(\n 'Unrecgonized order type. Should be `defined` or `random`'\n )\n }\n}\n\nexport async function emitMetaMessage(\n eventBroadcaster: EventEmitter\n): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { version } = require('../../package.json')\n eventBroadcaster.emit(\n 'envelope',\n new messages.Envelope({\n meta: createMeta('cucumber-js', version, process.env),\n })\n )\n}\n\nfunction emitParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter,\n newId: IdGenerator.NewId\n): void {\n for (const parameterType of supportCodeLibrary.parameterTypeRegistry\n .parameterTypes) {\n if (builtinParameterTypes.includes(parameterType.name)) {\n continue\n }\n eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n parameterType: {\n id: newId(),\n name: parameterType.name,\n preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,\n regularExpressions: parameterType.regexpStrings,\n useForSnippets: parameterType.useForSnippets,\n },\n })\n )\n }\n}\n\nfunction emitUndefinedParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {\n eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n undefinedParameterType,\n })\n )\n }\n}\n\nfunction emitStepDefinitions(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {\n eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n stepDefinition: {\n id: stepDefinition.id,\n pattern: {\n source: stepDefinition.pattern.toString(),\n type:\n typeof stepDefinition.pattern === 'string'\n ? StepDefinitionPatternType.CUCUMBER_EXPRESSION\n : StepDefinitionPatternType.REGULAR_EXPRESSION,\n },\n sourceReference: {\n uri: stepDefinition.uri,\n location: {\n line: stepDefinition.line,\n },\n },\n },\n })\n )\n })\n}\n\nfunction emitTestCaseHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n supportCodeLibrary.afterTestCaseHookDefinitions\n )\n .forEach((testCaseHookDefinition: TestCaseHookDefinition) => {\n eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n hook: {\n id: testCaseHookDefinition.id,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: {\n uri: testCaseHookDefinition.uri,\n location: {\n line: testCaseHookDefinition.line,\n },\n },\n },\n })\n )\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestRunHookDefinitions,\n supportCodeLibrary.afterTestRunHookDefinitions\n )\n .forEach((testRunHookDefinition: TestRunHookDefinition) => {\n eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n hook: {\n id: testRunHookDefinition.id,\n sourceReference: {\n uri: testRunHookDefinition.uri,\n location: {\n line: testRunHookDefinition.line,\n },\n },\n },\n })\n )\n })\n}\n\nexport function emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n}: {\n eventBroadcaster: EventEmitter\n supportCodeLibrary: ISupportCodeLibrary\n newId: IdGenerator.NewId\n}): void {\n emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId)\n emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster)\n emitStepDefinitions(supportCodeLibrary, eventBroadcaster)\n emitTestCaseHooks(supportCodeLibrary, eventBroadcaster)\n emitTestRunHooks(supportCodeLibrary, eventBroadcaster)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAsC;AACtC,sEAA4C;AAC5C,gFAA0C;AAI1C,oD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C;iBACF;aACF;SACF,CAAA;QACD,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;AACN,CAAC;AAED,SAAS,gBAAgB,CACvB,kBAAuC,EACvC,gBAA8B;IAE9B,CAAC;IAAA,EAAE;SACA,MAAM,CACL,kBAAkB,CAAC,4BAA4B,EAC/C,kBAAkB,CAAC,2BAA2B,CAC/C;SACA,OAAO,CAAC,CAAC,qBAA4C,EAAE,EAAE;QACxD,MAAM,QAAQ,GAAsB;YAClC,IAAI,EAAE;gBACJ,EAAE,EAAE,qBAAqB,CAAC,EAAE;gBAC5B,eAAe,EAAE;oBACf,GAAG,EAAE,qBAAqB,CAAC,GAAG;oBAC9B,QAAQ,EAAE;wBACR,IAAI,EAAE,qBAAqB,CAAC,IAAI;qBACjC;iBACF;aACF;SACF,CAAA;QACD,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;AACN,CAAC;AAED,SAAgB,uBAAuB,CAAC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,GAKN;IACC,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC/D,2BAA2B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACjE,mBAAmB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACzD,iBAAiB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACvD,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;AACxD,CAAC;AAdD,0DAcC","sourcesContent":["import ArgvParser from './argv_parser'\nimport ProfileLoader from './profile_loader'\nimport shuffle from 'knuth-shuffle-seeded'\nimport { EventEmitter } from 'events'\nimport PickleFilter from '../pickle_filter'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { doesHaveValue } from '../value_checker'\nimport OptionSplitter from './option_splitter'\nimport { Readable } from 'stream'\nimport { IdGenerator } from '@cucumber/messages'\nimport * as messages from '@cucumber/messages'\nimport createMeta from '@cucumber/create-meta'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport { builtinParameterTypes } from '../support_code_library_builder'\n\nexport interface IGetExpandedArgvRequest {\n argv: string[]\n cwd: string\n}\n\nexport async function getExpandedArgv({\n argv,\n cwd,\n}: IGetExpandedArgvRequest): Promise<string[]> {\n const { options } = ArgvParser.parse(argv)\n let fullArgv = argv\n const profileArgv = await new ProfileLoader(cwd).getArgv(\n options.profile,\n options.config\n )\n if (profileArgv.length > 0) {\n fullArgv = argv.slice(0, 2).concat(profileArgv).concat(argv.slice(2))\n }\n return fullArgv\n}\n\ninterface IParseGherkinMessageStreamRequest {\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n gherkinMessageStream: Readable\n order: string\n pickleFilter: PickleFilter\n}\n\nexport async function parseGherkinMessageStream({\n cwd,\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order,\n pickleFilter,\n}: IParseGherkinMessageStreamRequest): Promise<string[]> {\n return await new Promise<string[]>((resolve, reject) => {\n const result: string[] = []\n gherkinMessageStream.on('data', (envelope: messages.Envelope) => {\n eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.pickle)) {\n const pickle = envelope.pickle\n const pickleId = pickle.id\n const gherkinDocument = eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n if (pickleFilter.matches({ gherkinDocument, pickle })) {\n result.push(pickleId)\n }\n }\n if (doesHaveValue(envelope.parseError)) {\n reject(\n new Error(\n `Parse error in '${envelope.parseError.source.uri}': ${envelope.parseError.message}`\n )\n )\n }\n })\n gherkinMessageStream.on('end', () => {\n orderPickleIds(result, order)\n resolve(result)\n })\n gherkinMessageStream.on('error', reject)\n })\n}\n\n// Orders the pickleIds in place - morphs input\nexport function orderPickleIds(pickleIds: string[], order: string): void {\n let [type, seed] = OptionSplitter.split(order)\n switch (type) {\n case 'defined':\n break\n case 'random':\n if (seed === '') {\n seed = Math.floor(Math.random() * 1000 * 1000).toString()\n console.warn(`Random order using seed: ${seed}`)\n }\n shuffle(pickleIds, seed)\n break\n default:\n throw new Error(\n 'Unrecgonized order type. Should be `defined` or `random`'\n )\n }\n}\n\nexport function isJavaScript(filePath: string): boolean {\n return (\n filePath.endsWith('.js') ||\n filePath.endsWith('.mjs') ||\n filePath.endsWith('.cjs')\n )\n}\n\nexport async function emitMetaMessage(\n eventBroadcaster: EventEmitter\n): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { version } = require('../../package.json')\n eventBroadcaster.emit('envelope', {\n meta: createMeta('cucumber-js', version, process.env),\n })\n}\n\nfunction emitParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter,\n newId: IdGenerator.NewId\n): void {\n for (const parameterType of supportCodeLibrary.parameterTypeRegistry\n .parameterTypes) {\n if (builtinParameterTypes.includes(parameterType.name)) {\n continue\n }\n const envelope: messages.Envelope = {\n parameterType: {\n id: newId(),\n name: parameterType.name,\n preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,\n regularExpressions: parameterType.regexpStrings,\n useForSnippets: parameterType.useForSnippets,\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitUndefinedParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {\n const envelope: messages.Envelope = {\n undefinedParameterType,\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitStepDefinitions(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {\n const envelope: messages.Envelope = {\n stepDefinition: {\n id: stepDefinition.id,\n pattern: {\n source: stepDefinition.pattern.toString(),\n type:\n typeof stepDefinition.pattern === 'string'\n ? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION\n : messages.StepDefinitionPatternType.REGULAR_EXPRESSION,\n },\n sourceReference: {\n uri: stepDefinition.uri,\n location: {\n line: stepDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestCaseHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n supportCodeLibrary.afterTestCaseHookDefinitions\n )\n .forEach((testCaseHookDefinition: TestCaseHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testCaseHookDefinition.id,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: {\n uri: testCaseHookDefinition.uri,\n location: {\n line: testCaseHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestRunHookDefinitions,\n supportCodeLibrary.afterTestRunHookDefinitions\n )\n .forEach((testRunHookDefinition: TestRunHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testRunHookDefinition.id,\n sourceReference: {\n uri: testRunHookDefinition.uri,\n location: {\n line: testRunHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nexport function emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n}: {\n eventBroadcaster: EventEmitter\n supportCodeLibrary: ISupportCodeLibrary\n newId: IdGenerator.NewId\n}): void {\n emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId)\n emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster)\n emitStepDefinitions(supportCodeLibrary, eventBroadcaster)\n emitTestCaseHooks(supportCodeLibrary, eventBroadcaster)\n emitTestRunHooks(supportCodeLibrary, eventBroadcaster)\n}\n"]}
|