@cucumber/cucumber 7.2.1 → 7.3.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.
- package/CHANGELOG.md +28 -1
- package/lib/cli/configuration_builder.js +3 -3
- package/lib/cli/configuration_builder.js.map +1 -1
- package/lib/cli/helpers.js +40 -18
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/index.js +23 -15
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/profile_loader.d.ts +1 -2
- package/lib/cli/profile_loader.js.map +1 -1
- package/lib/formatter/get_color_fns.d.ts +2 -2
- package/lib/formatter/get_color_fns.js +7 -8
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +14 -17
- package/lib/formatter/helpers/event_data_collector.js +14 -8
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -6
- package/lib/formatter/helpers/gherkin_document_parser.js +1 -4
- 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 +5 -6
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.d.ts +9 -10
- 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 +32 -14
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +33 -14
- 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 +27 -9
- 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 +30 -13
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
- package/lib/formatter/html_formatter.js +1 -1
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +21 -27
- package/lib/formatter/json_formatter.js +50 -23
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.js +1 -1
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +6 -6
- package/lib/formatter/progress_bar_formatter.js +3 -3
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +2 -2
- package/lib/formatter/progress_formatter.js +29 -10
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/rerun_formatter.js +22 -4
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.js +21 -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.map +1 -1
- package/lib/formatter/summary_formatter.d.ts +2 -2
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.js +22 -3
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/index.d.ts +14 -12
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.d.ts +3 -4
- 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/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 +4 -4
- 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 +2 -2
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +4 -3
- package/lib/runtime/index.js +31 -13
- 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 +10 -9
- package/lib/runtime/parallel/coordinator.js +54 -43
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -2
- package/lib/runtime/parallel/worker.js +8 -14
- 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 -12
- 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/{pickle_runner.d.ts → test_case_runner.d.ts} +16 -32
- package/lib/runtime/{pickle_runner.js → test_case_runner.js} +104 -147
- package/lib/runtime/test_case_runner.js.map +1 -0
- package/lib/step_arguments.d.ts +4 -4
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/index.d.ts +9 -7
- package/lib/support_code_library_builder/index.js +10 -10
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +20 -22
- package/lib/support_code_library_builder/types.js.map +1 -1
- 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 +2 -10
- package/lib/time.js +24 -48
- package/lib/time.js.map +1 -1
- package/package.json +33 -33
- 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/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,32 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
|
|
|
19
19
|
|
|
20
20
|
### Fixed
|
|
21
21
|
|
|
22
|
+
## [7.3.0] (2021-06-17)
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
* Experimental support for [Markdown](https://github.com/cucumber/common/blob/main/gherkin/MARKDOWN_WITH_GHERKIN.md)
|
|
27
|
+
([#1645](https://github.com/cucumber/cucumber-js/pull/1645))
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
* All `testCase` messages now emitted upfront at the start of the run (relevant for formatter authors) ([#1408](https://github.com/cucumber/cucumber-js/issues/1408)
|
|
32
|
+
[#1669](https://github.com/cucumber/cucumber-js/pull/1669))
|
|
33
|
+
* Clarify that the JSON formatter will not be removed any time soon
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
* `this` now has correct TypeScript type in support code functions ([#1667](https://github.com/cucumber/cucumber-js/issues/1667) [#1690](https://github.com/cucumber/cucumber-js/pull/1690))
|
|
38
|
+
* Progress bar formatter now reports total step count correctly ([#1579](https://github.com/cucumber/cucumber-js/issues/1579)
|
|
39
|
+
[#1669](https://github.com/cucumber/cucumber-js/pull/1669))
|
|
40
|
+
* Rerun functionality will now run nothing if the rerun file is empty from the previous run ([#1302](https://github.com/cucumber/cucumber-js/issues/1302) [#1568](https://github.com/cucumber/cucumber-js/pull/1568))
|
|
41
|
+
* All messages now emitted with project-relative `uri`s
|
|
42
|
+
([#1534](https://github.com/cucumber/cucumber-js/issues/1534)
|
|
43
|
+
[#1672](https://github.com/cucumber/cucumber-js/pull/1672))
|
|
44
|
+
* Json formatter now works with tagged examples
|
|
45
|
+
([#1621](https://github.com/cucumber/cucumber-js/issues/1621)
|
|
46
|
+
[#1651](https://github.com/cucumber/cucumber-js/pull/1651))
|
|
47
|
+
|
|
22
48
|
## [7.2.1] (2021-04-21)
|
|
23
49
|
|
|
24
50
|
### Fixed
|
|
@@ -1825,7 +1851,8 @@ be used to get the name / tags of the running scenario. ([#947](https://github.c
|
|
|
1825
1851
|
|
|
1826
1852
|
|
|
1827
1853
|
<!-- Releases -->
|
|
1828
|
-
[Unreleased]: https://github.com/cucumber/cucumber-js/compare/v7.
|
|
1854
|
+
[Unreleased]: https://github.com/cucumber/cucumber-js/compare/v7.3.0...master
|
|
1855
|
+
[7.3.0]: https://github.com/cucumber/cucumber-js/compare/7.3.0-rc.0...7.0.0
|
|
1829
1856
|
[7.2.1]: https://github.com/cucumber/cucumber-js/compare/7.2.1-rc.0...7.0.0
|
|
1830
1857
|
[7.2.0]: https://github.com/cucumber/cucumber-js/compare/7.2.0-rc.0...7.0.0
|
|
1831
1858
|
[7.1.0]: https://github.com/cucumber/cucumber-js/compare/7.1.0-rc.0...7.0.0
|
|
@@ -144,16 +144,16 @@ class ConfigurationBuilder {
|
|
|
144
144
|
if (filename[0] === '@') {
|
|
145
145
|
const filePath = path_1.default.join(this.cwd, arg);
|
|
146
146
|
const content = await fs_1.default.readFile(filePath, 'utf8');
|
|
147
|
-
return lodash_1.default.chain(content).split('\n').map(lodash_1.default.trim).
|
|
147
|
+
return lodash_1.default.chain(content).split('\n').map(lodash_1.default.trim).value();
|
|
148
148
|
}
|
|
149
149
|
return [arg];
|
|
150
150
|
});
|
|
151
151
|
const featurePaths = lodash_1.default.flatten(nestedFeaturePaths);
|
|
152
152
|
if (featurePaths.length > 0) {
|
|
153
|
-
return featurePaths;
|
|
153
|
+
return lodash_1.default.compact(featurePaths);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
return ['features/**/*.feature'];
|
|
156
|
+
return ['features/**/*.{feature,feature.md}'];
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
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,IA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AC,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,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,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,CA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IAAI,CAAC,KAAK,SAAS,EAAE;YACnB,OAAO,KAAK,CAAA;SACb;QACD,OAAO,CAAC,CAAC,KAAK,CAAC,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,kBAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;gBACrE,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,gBAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,gBAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAA;iBACxD;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,gBAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;aAC/B;SACF;QACD,OAAO,CAAC,oCAAoC,CAAC,CAAA;IAC/C,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).value()\n }\n return [arg]\n })\n const featurePaths = _.flatten(nestedFeaturePaths)\n if (featurePaths.length > 0) {\n return _.compact(featurePaths)\n }\n }\n return ['features/**/*.{feature,feature.md}']\n }\n}\n"]}
|
package/lib/cli/helpers.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
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
|
};
|
|
@@ -8,13 +27,11 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
27
|
const argv_parser_1 = __importDefault(require("./argv_parser"));
|
|
9
28
|
const profile_loader_1 = __importDefault(require("./profile_loader"));
|
|
10
29
|
const knuth_shuffle_seeded_1 = __importDefault(require("knuth-shuffle-seeded"));
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
30
|
const value_checker_1 = require("../value_checker");
|
|
13
31
|
const option_splitter_1 = __importDefault(require("./option_splitter"));
|
|
14
|
-
const
|
|
32
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
15
33
|
const create_meta_1 = __importDefault(require("@cucumber/create-meta"));
|
|
16
34
|
const support_code_library_builder_1 = require("../support_code_library_builder");
|
|
17
|
-
const StepDefinitionPatternType = messages_1.messages.StepDefinition.StepDefinitionPattern.StepDefinitionPatternType;
|
|
18
35
|
async function getExpandedArgv({ argv, cwd, }) {
|
|
19
36
|
const { options } = argv_parser_1.default.parse(argv);
|
|
20
37
|
let fullArgv = argv;
|
|
@@ -39,7 +56,7 @@ async function parseGherkinMessageStream({ cwd, eventBroadcaster, eventDataColle
|
|
|
39
56
|
}
|
|
40
57
|
}
|
|
41
58
|
if (value_checker_1.doesHaveValue(envelope.parseError)) {
|
|
42
|
-
reject(new Error(`Parse error in '${
|
|
59
|
+
reject(new Error(`Parse error in '${envelope.parseError.source.uri}': ${envelope.parseError.message}`));
|
|
43
60
|
}
|
|
44
61
|
});
|
|
45
62
|
gherkinMessageStream.on('end', () => {
|
|
@@ -71,9 +88,9 @@ exports.orderPickleIds = orderPickleIds;
|
|
|
71
88
|
async function emitMetaMessage(eventBroadcaster) {
|
|
72
89
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
73
90
|
const { version } = require('../../package.json');
|
|
74
|
-
eventBroadcaster.emit('envelope',
|
|
91
|
+
eventBroadcaster.emit('envelope', {
|
|
75
92
|
meta: create_meta_1.default('cucumber-js', version, process.env),
|
|
76
|
-
})
|
|
93
|
+
});
|
|
77
94
|
}
|
|
78
95
|
exports.emitMetaMessage = emitMetaMessage;
|
|
79
96
|
function emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId) {
|
|
@@ -82,7 +99,7 @@ function emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId) {
|
|
|
82
99
|
if (support_code_library_builder_1.builtinParameterTypes.includes(parameterType.name)) {
|
|
83
100
|
continue;
|
|
84
101
|
}
|
|
85
|
-
|
|
102
|
+
const envelope = {
|
|
86
103
|
parameterType: {
|
|
87
104
|
id: newId(),
|
|
88
105
|
name: parameterType.name,
|
|
@@ -90,26 +107,28 @@ function emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId) {
|
|
|
90
107
|
regularExpressions: parameterType.regexpStrings,
|
|
91
108
|
useForSnippets: parameterType.useForSnippets,
|
|
92
109
|
},
|
|
93
|
-
}
|
|
110
|
+
};
|
|
111
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
94
112
|
}
|
|
95
113
|
}
|
|
96
114
|
function emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster) {
|
|
97
115
|
for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {
|
|
98
|
-
|
|
116
|
+
const envelope = {
|
|
99
117
|
undefinedParameterType,
|
|
100
|
-
}
|
|
118
|
+
};
|
|
119
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
101
120
|
}
|
|
102
121
|
}
|
|
103
122
|
function emitStepDefinitions(supportCodeLibrary, eventBroadcaster) {
|
|
104
123
|
supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {
|
|
105
|
-
|
|
124
|
+
const envelope = {
|
|
106
125
|
stepDefinition: {
|
|
107
126
|
id: stepDefinition.id,
|
|
108
127
|
pattern: {
|
|
109
128
|
source: stepDefinition.pattern.toString(),
|
|
110
129
|
type: typeof stepDefinition.pattern === 'string'
|
|
111
|
-
? StepDefinitionPatternType.CUCUMBER_EXPRESSION
|
|
112
|
-
: StepDefinitionPatternType.REGULAR_EXPRESSION,
|
|
130
|
+
? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION
|
|
131
|
+
: messages.StepDefinitionPatternType.REGULAR_EXPRESSION,
|
|
113
132
|
},
|
|
114
133
|
sourceReference: {
|
|
115
134
|
uri: stepDefinition.uri,
|
|
@@ -118,7 +137,8 @@ function emitStepDefinitions(supportCodeLibrary, eventBroadcaster) {
|
|
|
118
137
|
},
|
|
119
138
|
},
|
|
120
139
|
},
|
|
121
|
-
}
|
|
140
|
+
};
|
|
141
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
122
142
|
});
|
|
123
143
|
}
|
|
124
144
|
function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
|
|
@@ -126,7 +146,7 @@ function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
126
146
|
[]
|
|
127
147
|
.concat(supportCodeLibrary.beforeTestCaseHookDefinitions, supportCodeLibrary.afterTestCaseHookDefinitions)
|
|
128
148
|
.forEach((testCaseHookDefinition) => {
|
|
129
|
-
|
|
149
|
+
const envelope = {
|
|
130
150
|
hook: {
|
|
131
151
|
id: testCaseHookDefinition.id,
|
|
132
152
|
tagExpression: testCaseHookDefinition.tagExpression,
|
|
@@ -137,7 +157,8 @@ function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
137
157
|
},
|
|
138
158
|
},
|
|
139
159
|
},
|
|
140
|
-
}
|
|
160
|
+
};
|
|
161
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
141
162
|
});
|
|
142
163
|
}
|
|
143
164
|
function emitTestRunHooks(supportCodeLibrary, eventBroadcaster) {
|
|
@@ -145,7 +166,7 @@ function emitTestRunHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
145
166
|
[]
|
|
146
167
|
.concat(supportCodeLibrary.beforeTestRunHookDefinitions, supportCodeLibrary.afterTestRunHookDefinitions)
|
|
147
168
|
.forEach((testRunHookDefinition) => {
|
|
148
|
-
|
|
169
|
+
const envelope = {
|
|
149
170
|
hook: {
|
|
150
171
|
id: testRunHookDefinition.id,
|
|
151
172
|
sourceReference: {
|
|
@@ -155,7 +176,8 @@ function emitTestRunHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
155
176
|
},
|
|
156
177
|
},
|
|
157
178
|
},
|
|
158
|
-
}
|
|
179
|
+
};
|
|
180
|
+
eventBroadcaster.emit('envelope', envelope);
|
|
159
181
|
});
|
|
160
182
|
}
|
|
161
183
|
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;AAE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AAA;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,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
|
+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,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 _ from 'lodash'\nimport 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(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.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 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"]}
|
package/lib/cli/index.js
CHANGED
|
@@ -117,7 +117,15 @@ class Cli {
|
|
|
117
117
|
getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }) {
|
|
118
118
|
supportCodeRequiredModules.map((module) => require(module));
|
|
119
119
|
support_code_library_builder_1.default.reset(this.cwd, newId);
|
|
120
|
-
supportCodePaths.forEach((codePath) =>
|
|
120
|
+
supportCodePaths.forEach((codePath) => {
|
|
121
|
+
try {
|
|
122
|
+
require(codePath);
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
console.error(e.stack);
|
|
126
|
+
console.error('codepath: ' + codePath);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
121
129
|
return support_code_library_builder_1.default.finalize();
|
|
122
130
|
}
|
|
123
131
|
async run() {
|
|
@@ -152,15 +160,19 @@ class Cli {
|
|
|
152
160
|
const gherkinMessageStream = gherkin_streams_1.GherkinStreams.fromPaths(configuration.featurePaths, {
|
|
153
161
|
defaultDialect: configuration.featureDefaultLanguage,
|
|
154
162
|
newId,
|
|
163
|
+
relativeTo: this.cwd,
|
|
155
164
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
let pickleIds = [];
|
|
166
|
+
if (configuration.featurePaths.length > 0) {
|
|
167
|
+
pickleIds = await helpers_2.parseGherkinMessageStream({
|
|
168
|
+
cwd: this.cwd,
|
|
169
|
+
eventBroadcaster,
|
|
170
|
+
eventDataCollector,
|
|
171
|
+
gherkinMessageStream,
|
|
172
|
+
order: configuration.order,
|
|
173
|
+
pickleFilter: new pickle_filter_1.default(configuration.pickleFilterOptions),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
164
176
|
helpers_2.emitSupportCodeMessages({
|
|
165
177
|
eventBroadcaster,
|
|
166
178
|
supportCodeLibrary,
|
|
@@ -173,17 +185,13 @@ class Cli {
|
|
|
173
185
|
eventBroadcaster,
|
|
174
186
|
eventDataCollector,
|
|
175
187
|
options: configuration.runtimeOptions,
|
|
188
|
+
newId,
|
|
176
189
|
pickleIds,
|
|
177
190
|
supportCodeLibrary,
|
|
178
191
|
supportCodePaths: configuration.supportCodePaths,
|
|
179
192
|
supportCodeRequiredModules: configuration.supportCodeRequiredModules,
|
|
180
193
|
});
|
|
181
|
-
await
|
|
182
|
-
parallelRuntimeCoordinator.run(configuration.parallel, (s) => {
|
|
183
|
-
success = s;
|
|
184
|
-
resolve();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
194
|
+
success = await parallelRuntimeCoordinator.run(configuration.parallel);
|
|
187
195
|
}
|
|
188
196
|
else {
|
|
189
197
|
const runtime = new runtime_1.default({
|
package/lib/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyD;AACzD,uCAKkB;AAClB,2DAAqD;AACrD,6CAA8B;AAC9B,oFAGgC;AAChC,mCAAqC;AACrC,mEAAmD;AACnD,+CAAsB;AACtB,gDAAuB;AACvB,qEAA2C;AAC3C,wDAA+B;AAC/B,kFAAwE;AACxE,yDAAgC;AAChC,mGAAuE;AACvE,iDAAgD;AAGhD,oDAAmD;AACnD,+DAA0D;AAG1D,2EAAiD;AACjD,mCAAiC;AAEjC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,sBAAW,CAAA;AAqB1C,MAAqB,GAAG;IAKtB,YAAY,EACV,IAAI,EACJ,GAAG,EACH,MAAM,GAKP;QACC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,QAAQ,GAAG,MAAM,yBAAe,CAAC;YACrC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAA;QACF,OAA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gB;gBAChB,kBAAkB;gBAClB,OAAO,EAAE,aAAa,CAAC,cAAc;gBACrC,SAAS;gBACT,kBAAkB;gBAClB,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;gBAChD,0BAA0B,EAAE,aAAa,CAAC,0BAA0B;aACrE,CAAC,CAAA;YACF,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAClC,0BAA0B,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;oBAC3D,OAAO,GAAG,CAAC,CAAA;oBACX,OAAO,EAAE,CAAA;gBACX,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;SACH;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC;gBAC1B,gBAAgB;gBAChB,kBAAkB;gBAClB,OAAO,EAAE,aAAa,CAAC,cAAc;gBACrC,KAAK;gBACL,SAAS;gBACT,kBAAkB;aACnB,CAAC,CAAA;YACF,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;SAChC;QACD,MAAM,OAAO,EAAE,CAAA;QACf,OAAO;YACL,qBAAqB,EAAE,aAAa,CAAC,qBAAqB;YAC1D,OAAO;SACR,CAAA;IACH,CAAC;CACF;AArMD,sBAqMC","sourcesContent":["import { EventDataCollector } from '../formatter/helpers'\nimport {\n emitMetaMessage,\n emitSupportCodeMessages,\n getExpandedArgv,\n parseGherkinMessageStream,\n} from './helpers'\nimport { validateInstall } from './install_validator'\nimport * as I18n from './i18n'\nimport ConfigurationBuilder, {\n IConfiguration,\n IConfigurationFormat,\n} from './configuration_builder'\nimport { EventEmitter } from 'events'\nimport FormatterBuilder from '../formatter/builder'\nimport fs from 'mz/fs'\nimport path from 'path'\nimport PickleFilter from '../pickle_filter'\nimport bluebird from 'bluebird'\nimport ParallelRuntimeCoordinator from '../runtime/parallel/coordinator'\nimport Runtime from '../runtime'\nimport supportCodeLibraryBuilder from '../support_code_library_builder'\nimport { IdGenerator } from '@cucumber/messages'\nimport { IFormatterStream } from '../formatter'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport { doesNotHaveValue } from '../value_checker'\nimport { GherkinStreams } from '@cucumber/gherkin-streams'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { IParsedArgvFormatOptions } from './argv_parser'\nimport HttpStream from '../formatter/http_stream'\nimport { Writable } from 'stream'\n\nconst { incrementing, uuid } = IdGenerator\n\nexport interface ICliRunResult {\n shouldExitImmediately: boolean\n success: boolean\n}\n\ninterface IInitializeFormattersRequest {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n formatOptions: IParsedArgvFormatOptions\n formats: IConfigurationFormat[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\ninterface IGetSupportCodeLibraryRequest {\n newId: IdGenerator.NewId\n supportCodeRequiredModules: string[]\n supportCodePaths: string[]\n}\n\nexport default class Cli {\n private readonly argv: string[]\n private readonly cwd: string\n private readonly stdout: IFormatterStream\n\n constructor({\n argv,\n cwd,\n stdout,\n }: {\n argv: string[]\n cwd: string\n stdout: IFormatterStream\n }) {\n this.argv = argv\n this.cwd = cwd\n this.stdout = stdout\n }\n\n async getConfiguration(): Promise<IConfiguration> {\n const fullArgv = await getExpandedArgv({\n argv: this.argv,\n cwd: this.cwd,\n })\n return await ConfigurationBuilder.build({\n argv: fullArgv,\n cwd: this.cwd,\n })\n }\n\n async initializeFormatters({\n eventBroadcaster,\n eventDataCollector,\n formatOptions,\n formats,\n supportCodeLibrary,\n }: IInitializeFormattersRequest): Promise<() => Promise<void>> {\n const formatters = await bluebird.map(\n formats,\n async ({ type, outputTo }) => {\n let stream: IFormatterStream = this.stdout\n if (outputTo !== '') {\n if (outputTo.match(/^https?:\\/\\//) !== null) {\n const headers: { [key: string]: string } = {}\n if (process.env.CUCUMBER_PUBLISH_TOKEN !== undefined) {\n headers.Authorization = `Bearer ${process.env.CUCUMBER_PUBLISH_TOKEN}`\n }\n\n stream = new HttpStream(outputTo, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n console.error(responseBody)\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n } else {\n const fd = await fs.open(path.resolve(this.cwd, outputTo), 'w')\n stream = fs.createWriteStream(null, { fd })\n }\n }\n\n stream.on('error', (error) => {\n console.error(error.message)\n process.exit(1)\n })\n\n const typeOptions = {\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n log: stream.write.bind(stream),\n parsedArgvOptions: formatOptions,\n stream,\n cleanup:\n stream === this.stdout\n ? async () => await Promise.resolve()\n : bluebird.promisify(stream.end.bind(stream)),\n supportCodeLibrary,\n }\n if (doesNotHaveValue(formatOptions.colorsEnabled)) {\n typeOptions.parsedArgvOptions.colorsEnabled = (stream as TtyWriteStream).isTTY\n }\n if (type === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {\n const outputToName = outputTo === '' ? 'stdout' : outputTo\n console.warn(\n `Cannot use 'progress-bar' formatter for output to '${outputToName}' as not a TTY. Switching to 'progress' formatter.`\n )\n type = 'progress'\n }\n return FormatterBuilder.build(type, typeOptions)\n }\n )\n return async function () {\n await bluebird.each(formatters, async (formatter) => {\n await formatter.finished()\n })\n }\n }\n\n getSupportCodeLibrary({\n newId,\n supportCodeRequiredModules,\n supportCodePaths,\n }: IGetSupportCodeLibraryRequest): ISupportCodeLibrary {\n supportCodeRequiredModules.map((module) => require(module))\n supportCodeLibraryBuilder.reset(this.cwd, newId)\n supportCodePaths.forEach((codePath) => require(codePath))\n return supportCodeLibraryBuilder.finalize()\n }\n\n async run(): Promise<ICliRunResult> {\n await validateInstall(this.cwd)\n const configuration = await this.getConfiguration()\n if (configuration.listI18nLanguages) {\n this.stdout.write(I18n.getLanguages())\n return { shouldExitImmediately: true, success: true }\n }\n if (configuration.listI18nKeywordsFor !== '') {\n this.stdout.write(I18n.getKeywords(configuration.listI18nKeywordsFor))\n return { shouldExitImmediately: true, success: true }\n }\n const newId =\n configuration.predictableIds && configuration.parallel <= 1\n ? incrementing()\n : uuid()\n const supportCodeLibrary = this.getSupportCodeLibrary({\n newId,\n supportCodePaths: configuration.supportCodePaths,\n supportCodeRequiredModules: configuration.supportCodeRequiredModules,\n })\n const eventBroadcaster = new EventEmitter()\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n const cleanup = await this.initializeFormatters({\n eventBroadcaster,\n eventDataCollector,\n formatOptions: configuration.formatOptions,\n formats: configuration.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster)\n const gherkinMessageStream = GherkinStreams.fromPaths(\n configuration.featurePaths,\n {\n defaultDialect: configuration.featureDefaultLanguage,\n newId,\n }\n )\n const pickleIds = await parseGherkinMessageStream({\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order: configuration.order,\n pickleFilter: new PickleFilter(configuration.pickleFilterOptions),\n })\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n let success\n if (configuration.parallel > 1) {\n const parallelRuntimeCoordinator = new ParallelRuntimeCoordinator({\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n options: configuration.runtimeOptions,\n pickleIds,\n supportCodeLibrary,\n supportCodePaths: configuration.supportCodePaths,\n supportCodeRequiredModules: configuration.supportCodeRequiredModules,\n })\n await new Promise<void>((resolve) => {\n parallelRuntimeCoordinator.run(configuration.parallel, (s) => {\n success = s\n resolve()\n })\n })\n } else {\n const runtime = new Runtime({\n eventBroadcaster,\n eventDataCollector,\n options: configuration.runtimeOptions,\n newId,\n pickleIds,\n supportCodeLibrary,\n })\n success = await runtime.start()\n }\n await cleanup()\n return {\n shouldExitImmediately: configuration.shouldExitImmediately,\n success,\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyD;AACzD,uCAKkB;AAClB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AA0B,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;SACvE;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC;gBAC1B,gBAAgB;gBAChB,kBAAkB;gBAClB,OAAO,EAAE,aAAa,CAAC,cAAc;gBACrC,KAAK;gBACL,SAAS;gBACT,kBAAkB;aACnB,CAAC,CAAA;YACF,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;SAChC;QACD,MAAM,OAAO,EAAE,CAAA;QACf,OAAO;YACL,qBAAqB,EAAE,aAAa,CAAC,qBAAqB;YAC1D,OAAO;SACR,CAAA;IACH,CAAC;CACF;AA/MD,sBA+MC","sourcesContent":["import { EventDataCollector } from '../formatter/helpers'\nimport {\n emitMetaMessage,\n emitSupportCodeMessages,\n getExpandedArgv,\n parseGherkinMessageStream,\n} from './helpers'\nimport { validateInstall } from './install_validator'\nimport * as I18n from './i18n'\nimport ConfigurationBuilder, {\n IConfiguration,\n IConfigurationFormat,\n} from './configuration_builder'\nimport { EventEmitter } from 'events'\nimport FormatterBuilder from '../formatter/builder'\nimport fs from 'mz/fs'\nimport path from 'path'\nimport PickleFilter from '../pickle_filter'\nimport bluebird from 'bluebird'\nimport ParallelRuntimeCoordinator from '../runtime/parallel/coordinator'\nimport Runtime from '../runtime'\nimport supportCodeLibraryBuilder from '../support_code_library_builder'\nimport { IdGenerator } from '@cucumber/messages'\nimport { IFormatterStream } from '../formatter'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport { doesNotHaveValue } from '../value_checker'\nimport { GherkinStreams } from '@cucumber/gherkin-streams'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { IParsedArgvFormatOptions } from './argv_parser'\nimport HttpStream from '../formatter/http_stream'\nimport { Writable } from 'stream'\n\nconst { incrementing, uuid } = IdGenerator\n\nexport interface ICliRunResult {\n shouldExitImmediately: boolean\n success: boolean\n}\n\ninterface IInitializeFormattersRequest {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n formatOptions: IParsedArgvFormatOptions\n formats: IConfigurationFormat[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\ninterface IGetSupportCodeLibraryRequest {\n newId: IdGenerator.NewId\n supportCodeRequiredModules: string[]\n supportCodePaths: string[]\n}\n\nexport default class Cli {\n private readonly argv: string[]\n private readonly cwd: string\n private readonly stdout: IFormatterStream\n\n constructor({\n argv,\n cwd,\n stdout,\n }: {\n argv: string[]\n cwd: string\n stdout: IFormatterStream\n }) {\n this.argv = argv\n this.cwd = cwd\n this.stdout = stdout\n }\n\n async getConfiguration(): Promise<IConfiguration> {\n const fullArgv = await getExpandedArgv({\n argv: this.argv,\n cwd: this.cwd,\n })\n return await ConfigurationBuilder.build({\n argv: fullArgv,\n cwd: this.cwd,\n })\n }\n\n async initializeFormatters({\n eventBroadcaster,\n eventDataCollector,\n formatOptions,\n formats,\n supportCodeLibrary,\n }: IInitializeFormattersRequest): Promise<() => Promise<void>> {\n const formatters = await bluebird.map(\n formats,\n async ({ type, outputTo }) => {\n let stream: IFormatterStream = this.stdout\n if (outputTo !== '') {\n if (outputTo.match(/^https?:\\/\\//) !== null) {\n const headers: { [key: string]: string } = {}\n if (process.env.CUCUMBER_PUBLISH_TOKEN !== undefined) {\n headers.Authorization = `Bearer ${process.env.CUCUMBER_PUBLISH_TOKEN}`\n }\n\n stream = new HttpStream(outputTo, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n console.error(responseBody)\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n } else {\n const fd = await fs.open(path.resolve(this.cwd, outputTo), 'w')\n stream = fs.createWriteStream(null, { fd })\n }\n }\n\n stream.on('error', (error) => {\n console.error(error.message)\n process.exit(1)\n })\n\n const typeOptions = {\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n log: stream.write.bind(stream),\n parsedArgvOptions: formatOptions,\n stream,\n cleanup:\n stream === this.stdout\n ? async () => await Promise.resolve()\n : bluebird.promisify(stream.end.bind(stream)),\n supportCodeLibrary,\n }\n if (doesNotHaveValue(formatOptions.colorsEnabled)) {\n typeOptions.parsedArgvOptions.colorsEnabled = (\n stream as TtyWriteStream\n ).isTTY\n }\n if (type === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {\n const outputToName = outputTo === '' ? 'stdout' : outputTo\n console.warn(\n `Cannot use 'progress-bar' formatter for output to '${outputToName}' as not a TTY. Switching to 'progress' formatter.`\n )\n type = 'progress'\n }\n return FormatterBuilder.build(type, typeOptions)\n }\n )\n return async function () {\n await bluebird.each(formatters, async (formatter) => {\n await formatter.finished()\n })\n }\n }\n\n getSupportCodeLibrary({\n newId,\n supportCodeRequiredModules,\n supportCodePaths,\n }: IGetSupportCodeLibraryRequest): ISupportCodeLibrary {\n supportCodeRequiredModules.map((module) => require(module))\n supportCodeLibraryBuilder.reset(this.cwd, newId)\n supportCodePaths.forEach((codePath) => {\n try {\n require(codePath)\n } catch (e) {\n console.error(e.stack)\n console.error('codepath: ' + codePath)\n }\n })\n return supportCodeLibraryBuilder.finalize()\n }\n\n async run(): Promise<ICliRunResult> {\n await validateInstall(this.cwd)\n const configuration = await this.getConfiguration()\n if (configuration.listI18nLanguages) {\n this.stdout.write(I18n.getLanguages())\n return { shouldExitImmediately: true, success: true }\n }\n if (configuration.listI18nKeywordsFor !== '') {\n this.stdout.write(I18n.getKeywords(configuration.listI18nKeywordsFor))\n return { shouldExitImmediately: true, success: true }\n }\n const newId =\n configuration.predictableIds && configuration.parallel <= 1\n ? incrementing()\n : uuid()\n const supportCodeLibrary = this.getSupportCodeLibrary({\n newId,\n supportCodePaths: configuration.supportCodePaths,\n supportCodeRequiredModules: configuration.supportCodeRequiredModules,\n })\n const eventBroadcaster = new EventEmitter()\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n const cleanup = await this.initializeFormatters({\n eventBroadcaster,\n eventDataCollector,\n formatOptions: configuration.formatOptions,\n formats: configuration.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster)\n const gherkinMessageStream = GherkinStreams.fromPaths(\n configuration.featurePaths,\n {\n defaultDialect: configuration.featureDefaultLanguage,\n newId,\n relativeTo: this.cwd,\n }\n )\n let pickleIds: string[] = []\n\n if (configuration.featurePaths.length > 0) {\n pickleIds = await parseGherkinMessageStream({\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order: configuration.order,\n pickleFilter: new PickleFilter(configuration.pickleFilterOptions),\n })\n }\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n let success\n if (configuration.parallel > 1) {\n const parallelRuntimeCoordinator = new ParallelRuntimeCoordinator({\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n options: configuration.runtimeOptions,\n newId,\n pickleIds,\n supportCodeLibrary,\n supportCodePaths: configuration.supportCodePaths,\n supportCodeRequiredModules: configuration.supportCodeRequiredModules,\n })\n success = await parallelRuntimeCoordinator.run(configuration.parallel)\n } else {\n const runtime = new Runtime({\n eventBroadcaster,\n eventDataCollector,\n options: configuration.runtimeOptions,\n newId,\n pickleIds,\n supportCodeLibrary,\n })\n success = await runtime.start()\n }\n await cleanup()\n return {\n shouldExitImmediately: configuration.shouldExitImmediately,\n success,\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Dictionary } from 'lodash';
|
|
2
1
|
export default class ProfileLoader {
|
|
3
2
|
private readonly directory;
|
|
4
3
|
constructor(directory: string);
|
|
5
|
-
getDefinitions(): Promise<
|
|
4
|
+
getDefinitions(): Promise<Record<string, string>>;
|
|
6
5
|
getArgv(profiles: string[]): Promise<string[]>;
|
|
7
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile_loader.js","sourceRoot":"","sources":["../../src/cli/profile_loader.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"profile_loader.js","sourceRoot":"","s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C,OAAO,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;CACF;AAjCD,gCAiCC","sourcesContent":["import _ from 'lodash'\nimport fs from 'mz/fs'\nimport path from 'path'\nimport stringArgv from 'string-argv'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\n\nexport default class ProfileLoader {\n private readonly directory: string\n\n constructor(directory: string) {\n this.directory = directory\n }\n\n async getDefinitions(): Promise<Record<string, string>> {\n const definitionsFilePath = path.join(this.directory, 'cucumber.js')\n const exists = await fs.exists(definitionsFilePath)\n if (!exists) {\n return {}\n }\n const definitions = require(definitionsFilePath) // eslint-disable-line @typescript-eslint/no-var-requires\n if (typeof definitions !== 'object') {\n throw new Error(`${definitionsFilePath} does not export an object`)\n }\n return definitions\n }\n\n async getArgv(profiles: string[]): Promise<string[]> {\n const definitions = await this.getDefinitions()\n if (profiles.length === 0 && doesHaveValue(definitions.default)) {\n profiles = ['default']\n }\n const argvs = profiles.map((profile) => {\n if (doesNotHaveValue(definitions[profile])) {\n throw new Error(`Undefined profile: ${profile}`)\n }\n return stringArgv(definitions[profile])\n })\n return _.flatten(argvs)\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TestStepResultStatus } from '@cucumber/messages';
|
|
2
2
|
export declare type IColorFn = (text: string) => string;
|
|
3
3
|
export interface IColorFns {
|
|
4
|
-
forStatus: (status:
|
|
4
|
+
forStatus: (status: TestStepResultStatus) => IColorFn;
|
|
5
5
|
location: IColorFn;
|
|
6
6
|
tag: IColorFn;
|
|
7
7
|
}
|
|
@@ -5,20 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const safe_1 = __importDefault(require("colors/safe"));
|
|
8
|
-
const status_1 = __importDefault(require("../status"));
|
|
9
8
|
safe_1.default.enable();
|
|
10
9
|
function getColorFns(enabled) {
|
|
11
10
|
if (enabled) {
|
|
12
11
|
return {
|
|
13
12
|
forStatus(status) {
|
|
14
13
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
AMBIGUOUS: safe_1.default.red.bind(safe_1.default),
|
|
15
|
+
FAILED: safe_1.default.red.bind(safe_1.default),
|
|
16
|
+
PASSED: safe_1.default.green.bind(safe_1.default),
|
|
17
|
+
PENDING: safe_1.default.yellow.bind(safe_1.default),
|
|
18
|
+
SKIPPED: safe_1.default.cyan.bind(safe_1.default),
|
|
19
|
+
UNDEFINED: safe_1.default.yellow.bind(safe_1.default),
|
|
20
|
+
UNKNOWN: safe_1.default.yellow.bind(safe_1.default),
|
|
22
21
|
}[status];
|
|
23
22
|
},
|
|
24
23
|
location: safe_1.default.gray.bind(safe_1.default),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_color_fns.js","sourceRoot":"","sources":["../../src/formatter/get_color_fns.ts"],"names":[],"mappings":";;;;;AAAA,oDAAsB;AACtB,uDAAgC;
|
|
1
|
+
{"version":3,"file":"get_color_fns.js","sourceRoot":"","sources":["../../src/formatter/get_color_fns.ts"],"names":[],"mappings":";;;;;AAAA,oDAAsB;AACtB,uDAAgC;AAGhC,cAAM,CAAC,MAAM,EAAE,CAAA;AAUf,SAAwB,WAAW,CAAC,OAAgB;IAClD,IAAI,OAAO,EAAE;QACX,OAAO;YACL,SAAS,CAAC,MAA4B;gBACpC,OAAO;oBACL,SAAS,EAAE,cAAM,CAAC,GAAG,CAAC,IAAI,CAAC,cAAM,CAAC;oBAClC,MAAM,EAAE,cAAM,CAAC,GAAG,CAAC,IAAI,CAAC,cAAM,CAAC;oBAC/B,MAAM,EAAE,cAAM,CAAC,KAAK,CAAC,IAAI,CAAC,cAAM,CAAC;oBACjC,OAAO,EAAE,cAAM,CAAC,MAAM,CAAC,IAAI,CAAC,cAAM,CAAC;oBACnC,OAAO,EAAE,cAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAM,CAAC;oBACjC,SAAS,EAAE,cAAM,CAAC,MAAM,CAAC,IAAI,CAAC,cAAM,CAAC;oBACrC,OAAO,EAAE,cAAM,CAAC,MAAM,CAAC,IAAI,CAAC,cAAM,CAAC;iBACpC,CAAC,MAAM,CAAC,CAAA;YACX,CAAC;YACD,QAAQ,EAAE,cAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAM,CAAC;YAClC,GAAG,EAAE,cAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAM,CAAC;SAC9B,CAAA;KACF;SAAM;QACL,OAAO;YACL,SAAS,CAAC,MAA4B;gBACpC,OAAO,gBAAC,CAAC,QAAQ,CAAA;YACnB,CAAC;YACD,QAAQ,EAAE,gBAAC,CAAC,QAAQ;YACpB,GAAG,EAAE,gBAAC,CAAC,QAAQ;SAChB,CAAA;KACF;AACH,CAAC;AA1BD,8BA0BC","sourcesContent":["import _ from 'lodash'\nimport colors from 'colors/safe'\nimport { TestStepResultStatus } from '@cucumber/messages'\n\ncolors.enable()\n\nexport type IColorFn = (text: string) => string\n\nexport interface IColorFns {\n forStatus: (status: TestStepResultStatus) => IColorFn\n location: IColorFn\n tag: IColorFn\n}\n\nexport default function getColorFns(enabled: boolean): IColorFns {\n if (enabled) {\n return {\n forStatus(status: TestStepResultStatus) {\n return {\n AMBIGUOUS: colors.red.bind(colors),\n FAILED: colors.red.bind(colors),\n PASSED: colors.green.bind(colors),\n PENDING: colors.yellow.bind(colors),\n SKIPPED: colors.cyan.bind(colors),\n UNDEFINED: colors.yellow.bind(colors),\n UNKNOWN: colors.yellow.bind(colors),\n }[status]\n },\n location: colors.gray.bind(colors),\n tag: colors.cyan.bind(colors),\n }\n } else {\n return {\n forStatus(status: TestStepResultStatus) {\n return _.identity\n },\n location: _.identity,\n tag: _.identity,\n }\n }\n}\n"]}
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import { messages } from '@cucumber/messages';
|
|
2
|
+
import * as messages from '@cucumber/messages';
|
|
4
3
|
import { EventEmitter } from 'events';
|
|
5
|
-
import { Query } from '@cucumber/query';
|
|
6
4
|
export interface ITestCaseAttempt {
|
|
7
5
|
attempt: number;
|
|
8
|
-
gherkinDocument: messages.
|
|
9
|
-
pickle: messages.
|
|
10
|
-
stepAttachments:
|
|
11
|
-
stepResults:
|
|
12
|
-
testCase: messages.
|
|
13
|
-
worstTestStepResult: messages.
|
|
6
|
+
gherkinDocument: messages.GherkinDocument;
|
|
7
|
+
pickle: messages.Pickle;
|
|
8
|
+
stepAttachments: Record<string, messages.Attachment[]>;
|
|
9
|
+
stepResults: Record<string, messages.TestStepResult>;
|
|
10
|
+
testCase: messages.TestCase;
|
|
11
|
+
worstTestStepResult: messages.TestStepResult;
|
|
14
12
|
}
|
|
15
13
|
export default class EventDataCollector {
|
|
16
14
|
private gherkinDocumentMap;
|
|
17
15
|
private pickleMap;
|
|
18
16
|
private testCaseMap;
|
|
19
17
|
private testCaseAttemptDataMap;
|
|
20
|
-
readonly undefinedParameterTypes: messages.
|
|
21
|
-
readonly query: Query;
|
|
18
|
+
readonly undefinedParameterTypes: messages.UndefinedParameterType[];
|
|
22
19
|
constructor(eventBroadcaster: EventEmitter);
|
|
23
|
-
getGherkinDocument(uri: string): messages.
|
|
24
|
-
getPickle(pickleId: string): messages.
|
|
20
|
+
getGherkinDocument(uri: string): messages.GherkinDocument;
|
|
21
|
+
getPickle(pickleId: string): messages.Pickle;
|
|
25
22
|
getTestCaseAttempts(): ITestCaseAttempt[];
|
|
26
23
|
getTestCaseAttempt(testCaseStartedId: string): ITestCaseAttempt;
|
|
27
24
|
parseEnvelope(envelope: messages.Envelope): void;
|
|
28
|
-
initTestCaseAttempt
|
|
29
|
-
storeAttachment(
|
|
30
|
-
storeTestStepResult({ testCaseStartedId, testStepId, testStepResult, }: messages.
|
|
31
|
-
storeTestCaseResult({ testCaseStartedId }: messages.
|
|
25
|
+
private initTestCaseAttempt;
|
|
26
|
+
storeAttachment(attachment: messages.Attachment): void;
|
|
27
|
+
storeTestStepResult({ testCaseStartedId, testStepId, testStepResult, }: messages.TestStepFinished): void;
|
|
28
|
+
storeTestCaseResult({ testCaseStartedId }: messages.TestCaseFinished): void;
|
|
32
29
|
}
|