@cucumber/cucumber 7.3.2 → 8.0.0-rc.3
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 +88 -51
- package/api/index.d.ts +6 -0
- package/lib/api/convert_configuration.d.ts +4 -0
- package/lib/api/convert_configuration.js +64 -0
- package/lib/api/convert_configuration.js.map +1 -0
- package/lib/api/environment.d.ts +2 -0
- package/lib/api/environment.js +13 -0
- package/lib/api/environment.js.map +1 -0
- package/lib/api/formatters.d.ts +16 -0
- package/lib/api/formatters.js +72 -0
- package/lib/api/formatters.js.map +1 -0
- package/lib/api/gherkin.d.ts +21 -0
- package/lib/api/gherkin.js +65 -0
- package/lib/api/gherkin.js.map +1 -0
- package/lib/api/index.d.ts +11 -0
- package/lib/api/index.js +24 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/load_configuration.d.ts +9 -0
- package/lib/api/load_configuration.js +32 -0
- package/lib/api/load_configuration.js.map +1 -0
- package/lib/api/load_sources.d.ts +9 -0
- package/lib/api/load_sources.js +53 -0
- package/lib/api/load_sources.js.map +1 -0
- package/lib/api/load_support.d.ts +10 -0
- package/lib/api/load_support.js +28 -0
- package/lib/api/load_support.js.map +1 -0
- package/lib/api/paths.d.ts +7 -0
- package/lib/api/paths.js +99 -0
- package/lib/api/paths.js.map +1 -0
- package/lib/api/run_cucumber.d.ts +11 -0
- package/lib/api/run_cucumber.js +108 -0
- package/lib/api/run_cucumber.js.map +1 -0
- package/lib/api/runtime.d.ts +20 -0
- package/lib/api/runtime.js +36 -0
- package/lib/api/runtime.js.map +1 -0
- package/lib/api/support.d.ts +9 -0
- package/lib/api/support.js +21 -0
- package/lib/api/support.js.map +1 -0
- package/lib/api/types.d.ts +168 -0
- package/lib/api/types.js +3 -0
- package/lib/api/types.js.map +1 -0
- package/lib/api/wrapper.mjs +6 -0
- package/lib/cli/helpers.d.ts +16 -9
- package/lib/cli/helpers.js +49 -32
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/i18n.js +7 -7
- package/lib/cli/i18n.js.map +1 -1
- package/lib/cli/index.d.ts +6 -23
- package/lib/cli/index.js +38 -197
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/install_validator.js +1 -1
- package/lib/cli/install_validator.js.map +1 -1
- package/lib/cli/publish_banner.js +6 -6
- package/lib/cli/publish_banner.js.map +1 -1
- package/lib/cli/run.js +15 -7
- package/lib/cli/run.js.map +1 -1
- package/lib/cli/validate_node_engine_version.d.ts +7 -0
- package/lib/cli/validate_node_engine_version.js +20 -0
- package/lib/cli/validate_node_engine_version.js.map +1 -0
- package/lib/configuration/argv_parser.d.ts +20 -0
- package/lib/{cli → configuration}/argv_parser.js +52 -53
- package/lib/configuration/argv_parser.js.map +1 -0
- package/lib/configuration/check_schema.d.ts +2 -0
- package/lib/configuration/check_schema.js +56 -0
- package/lib/configuration/check_schema.js.map +1 -0
- package/lib/configuration/default_configuration.d.ts +2 -0
- package/lib/configuration/default_configuration.js +27 -0
- package/lib/configuration/default_configuration.js.map +1 -0
- package/lib/configuration/from_file.d.ts +2 -0
- package/lib/configuration/from_file.js +68 -0
- package/lib/configuration/from_file.js.map +1 -0
- package/lib/configuration/helpers.d.ts +1 -0
- package/lib/configuration/helpers.js +11 -0
- package/lib/configuration/helpers.js.map +1 -0
- package/lib/configuration/index.d.ts +7 -0
- package/lib/configuration/index.js +25 -0
- package/lib/configuration/index.js.map +1 -0
- package/lib/configuration/locate_file.d.ts +1 -0
- package/lib/configuration/locate_file.js +19 -0
- package/lib/configuration/locate_file.js.map +1 -0
- package/lib/configuration/merge_configurations.d.ts +2 -0
- package/lib/configuration/merge_configurations.js +48 -0
- package/lib/configuration/merge_configurations.js.map +1 -0
- package/lib/configuration/option_splitter.d.ts +3 -0
- package/lib/{cli → configuration}/option_splitter.js +3 -2
- package/lib/configuration/option_splitter.js.map +1 -0
- package/lib/configuration/types.d.ts +25 -0
- package/lib/configuration/types.js +3 -0
- package/lib/configuration/types.js.map +1 -0
- package/lib/configuration/validate_configuration.d.ts +2 -0
- package/lib/configuration/validate_configuration.js +10 -0
- package/lib/configuration/validate_configuration.js.map +1 -0
- package/lib/formatter/builder.d.ts +7 -7
- package/lib/formatter/builder.js +48 -55
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/get_color_fns.js +15 -16
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +2 -1
- package/lib/formatter/helpers/event_data_collector.js +16 -15
- 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.js +29 -42
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +4 -4
- package/lib/formatter/helpers/issue_helpers.js +8 -9
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/keyword_type.js +2 -6
- package/lib/formatter/helpers/keyword_type.js.map +1 -1
- package/lib/formatter/helpers/location_helpers.js +1 -1
- package/lib/formatter/helpers/location_helpers.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.js +9 -18
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.js +8 -7
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +2 -2
- package/lib/formatter/helpers/test_case_attempt_formatter.js +20 -19
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -2
- package/lib/formatter/helpers/test_case_attempt_parser.js +18 -21
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.d.ts +1 -2
- package/lib/formatter/helpers/usage_helpers/index.js +29 -43
- 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 +5 -4
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/http_stream.js +7 -7
- package/lib/formatter/http_stream.js.map +1 -1
- package/lib/formatter/index.d.ts +15 -2
- package/lib/formatter/index.js +2 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +1 -0
- package/lib/formatter/json_formatter.js +25 -20
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.d.ts +1 -0
- package/lib/formatter/message_formatter.js +1 -0
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +1 -0
- package/lib/formatter/progress_bar_formatter.js +18 -17
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +1 -0
- package/lib/formatter/progress_formatter.js +3 -2
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/publish.d.ts +1 -0
- package/lib/formatter/publish.js +5 -0
- package/lib/formatter/publish.js.map +1 -0
- package/lib/formatter/rerun_formatter.d.ts +1 -0
- package/lib/formatter/rerun_formatter.js +15 -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 +3 -3
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.js +2 -2
- 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 +1 -0
- package/lib/formatter/summary_formatter.js +11 -11
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.d.ts +1 -0
- package/lib/formatter/usage_formatter.js +9 -10
- 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 +3 -3
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/importer.js +13 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +9 -1
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.js +9 -7
- package/lib/models/data_table.js.map +1 -1
- package/lib/models/pickle_order.d.ts +1 -0
- package/lib/models/pickle_order.js +3 -0
- package/lib/models/pickle_order.js.map +1 -0
- package/lib/models/step_definition.js +4 -5
- package/lib/models/step_definition.js.map +1 -1
- package/lib/pickle_filter.js +13 -13
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/assemble_test_cases.js +3 -3
- package/lib/runtime/assemble_test_cases.js.map +1 -1
- package/lib/runtime/attachment_manager/index.js +4 -4
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/helpers.d.ts +1 -0
- package/lib/runtime/helpers.js +42 -4
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +7 -7
- package/lib/runtime/index.js +12 -65
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/command_types.d.ts +3 -2
- package/lib/runtime/parallel/command_types.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +32 -12
- package/lib/runtime/parallel/coordinator.js +82 -38
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/run_worker.js +1 -1
- package/lib/runtime/parallel/run_worker.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -4
- package/lib/runtime/parallel/worker.js +18 -33
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/run_test_run_hooks.d.ts +3 -0
- package/lib/runtime/run_test_run_hooks.js +28 -0
- package/lib/runtime/run_test_run_hooks.js.map +1 -0
- package/lib/runtime/step_runner.js +5 -7
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.js +4 -4
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +3 -3
- package/lib/runtime/test_case_runner.js +19 -28
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/stack_trace_filter.js +6 -7
- package/lib/stack_trace_filter.js.map +1 -1
- package/lib/step_arguments.js +2 -2
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/{build_helpers.d.ts → build_parameter_type.d.ts} +0 -2
- package/lib/support_code_library_builder/build_parameter_type.js +13 -0
- package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js +30 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
- package/lib/support_code_library_builder/index.d.ts +4 -2
- package/lib/support_code_library_builder/index.js +43 -34
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
- package/lib/support_code_library_builder/types.d.ts +10 -0
- 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/time.d.ts +1 -0
- package/lib/time.js +17 -2
- package/lib/time.js.map +1 -1
- package/lib/user_code_runner.js +10 -17
- 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/version.d.ts +1 -0
- package/lib/version.js +6 -0
- package/lib/version.js.map +1 -0
- package/lib/wrapper.mjs +42 -0
- package/package.json +98 -70
- package/lib/cli/argv_parser.d.ts +0 -51
- package/lib/cli/argv_parser.js.map +0 -1
- package/lib/cli/configuration_builder.d.ts +0 -46
- package/lib/cli/configuration_builder.js +0 -161
- package/lib/cli/configuration_builder.js.map +0 -1
- package/lib/cli/option_splitter.d.ts +0 -4
- package/lib/cli/option_splitter.js.map +0 -1
- package/lib/cli/profile_loader.d.ts +0 -6
- package/lib/cli/profile_loader.js +0 -42
- package/lib/cli/profile_loader.js.map +0 -1
- package/lib/support_code_library_builder/build_helpers.js +0 -41
- package/lib/support_code_library_builder/build_helpers.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
|
@@ -31,7 +31,7 @@ class HttpStream extends stream_1.Transform {
|
|
|
31
31
|
_write(chunk, encoding, callback) {
|
|
32
32
|
if (this.tempFile === undefined) {
|
|
33
33
|
tmp_1.default.file((err, name, fd) => {
|
|
34
|
-
if (value_checker_1.doesHaveValue(err))
|
|
34
|
+
if ((0, value_checker_1.doesHaveValue)(err))
|
|
35
35
|
return callback(err);
|
|
36
36
|
this.tempFilePath = name;
|
|
37
37
|
this.tempFile = fs_1.default.createWriteStream(name, { fd });
|
|
@@ -45,14 +45,14 @@ class HttpStream extends stream_1.Transform {
|
|
|
45
45
|
_final(callback) {
|
|
46
46
|
this.tempFile.end(() => {
|
|
47
47
|
this.sendHttpRequest(this.url, this.method, this.headers, (err1, res1) => {
|
|
48
|
-
if (value_checker_1.doesHaveValue(err1))
|
|
48
|
+
if ((0, value_checker_1.doesHaveValue)(err1))
|
|
49
49
|
return callback(err1);
|
|
50
50
|
this.pushResponseBody(res1, () => {
|
|
51
51
|
this.emitErrorUnlessHttp2xx(res1, this.url, this.method);
|
|
52
52
|
if (res1.statusCode === 202 &&
|
|
53
53
|
res1.headers.location !== undefined) {
|
|
54
54
|
this.sendHttpRequest(res1.headers.location, 'PUT', {}, (err2, res2) => {
|
|
55
|
-
if (value_checker_1.doesHaveValue(err2))
|
|
55
|
+
if ((0, value_checker_1.doesHaveValue)(err2))
|
|
56
56
|
return callback(err2);
|
|
57
57
|
this.emitErrorUnlessHttp2xx(res2, this.url, this.method);
|
|
58
58
|
callback();
|
|
@@ -80,13 +80,13 @@ class HttpStream extends stream_1.Transform {
|
|
|
80
80
|
this.emit('error', new Error(`Unexpected http status ${res.statusCode} from ${method} ${url}`));
|
|
81
81
|
}
|
|
82
82
|
sendHttpRequest(url, method, headers, callback) {
|
|
83
|
-
const httpx = value_checker_1.doesHaveValue(url.match(/^https:/)) ? https_1.default : http_1.default;
|
|
83
|
+
const httpx = (0, value_checker_1.doesHaveValue)(url.match(/^https:/)) ? https_1.default : http_1.default;
|
|
84
84
|
const additionalHttpHeaders = {};
|
|
85
85
|
const upload = method === 'PUT' || method === 'POST';
|
|
86
86
|
if (upload) {
|
|
87
87
|
additionalHttpHeaders['Content-Length'] = fs_1.default.statSync(this.tempFilePath).size;
|
|
88
88
|
}
|
|
89
|
-
const allHeaders =
|
|
89
|
+
const allHeaders = { ...headers, ...additionalHttpHeaders };
|
|
90
90
|
const req = httpx.request(url, {
|
|
91
91
|
method,
|
|
92
92
|
headers: allHeaders,
|
|
@@ -97,8 +97,8 @@ class HttpStream extends stream_1.Transform {
|
|
|
97
97
|
callback(null, res);
|
|
98
98
|
});
|
|
99
99
|
if (upload) {
|
|
100
|
-
stream_1.pipeline(fs_1.default.createReadStream(this.tempFilePath), req, (err) => {
|
|
101
|
-
if (value_checker_1.doesHaveValue(err)) {
|
|
100
|
+
(0, stream_1.pipeline)(fs_1.default.createReadStream(this.tempFilePath), req, (err) => {
|
|
101
|
+
if ((0, value_checker_1.doesHaveValue)(err)) {
|
|
102
102
|
this.emit('error', err);
|
|
103
103
|
}
|
|
104
104
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http_stream.js","sourceRoot":"","sources":["../../src/formatter/http_stream.ts"],"names":[],"mappings":";;;;;AAAA,mCAAsD;AACtD,8CAAqB;AACrB,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AACzB,oDAAgD;AAIhD;;;;;;;;;GASG;AACH,MAAqB,UAAW,SAAQ,kBAAS;IAI/C,YACmB,GAAW,EACX,MAAkB,EAClB,OAAiC;QAElD,KAAK,CAAC;YACJ,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAA;QANe,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAY;QAClB,YAAO,GAAP,OAAO,CAA0B;IAKpD,CAAC;IAED,MAAM,CACJ,KAAU,EACV,QAAwB,EACxB,QAAsC;QAEtC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,aAAG,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBACzB,IAAI,6BAAa,
|
|
1
|
+
{"version":3,"file":"http_stream.js","sourceRoot":"","sources":["../../src/formatter/http_stream.ts"],"names":[],"mappings":";;;;;AAAA,mCAAsD;AACtD,8CAAqB;AACrB,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AACzB,oDAAgD;AAIhD;;;;;;;;;GASG;AACH,MAAqB,UAAW,SAAQ,kBAAS;IAI/C,YACmB,GAAW,EACX,MAAkB,EAClB,OAAiC;QAElD,KAAK,CAAC;YACJ,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAA;QANe,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAY;QAClB,YAAO,GAAP,OAAO,CAA0B;IAKpD,CAAC;IAED,MAAM,CACJ,KAAU,EACV,QAAwB,EACxB,QAAsC;QAEtC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,aAAG,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBACzB,IAAI,IA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http'\nimport https from 'https'\nimport { doesHaveValue } from '../value_checker'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT'\n\n/**\n * This Writable writes data to a HTTP/HTTPS URL.\n *\n * It has special handling for https://reports.cucumber.io/\n * which uses an API where the first request is a `GET`,\n * and if the response is 202 with a Location header, issues\n * a PUT request to that URL.\n *\n * 3xx redirects are not currently followed.\n */\nexport default class HttpStream extends Transform {\n private tempFilePath: string\n private tempFile: Writable\n\n constructor(\n private readonly url: string,\n private readonly method: HttpMethod,\n private readonly headers: http.OutgoingHttpHeaders\n ) {\n super({\n readableObjectMode: true,\n })\n }\n\n _write(\n chunk: any,\n encoding: BufferEncoding,\n callback: (err?: Error | null) => void\n ): void {\n if (this.tempFile === undefined) {\n tmp.file((err, name, fd) => {\n if (doesHaveValue(err)) return callback(err)\n this.tempFilePath = name\n this.tempFile = fs.createWriteStream(name, { fd })\n this.tempFile.write(chunk, encoding, callback)\n })\n } else {\n this.tempFile.write(chunk, encoding, callback)\n }\n }\n\n _final(callback: (error?: Error | null) => void): void {\n this.tempFile.end(() => {\n this.sendHttpRequest(\n this.url,\n this.method,\n this.headers,\n (err1, res1) => {\n if (doesHaveValue(err1)) return callback(err1)\n this.pushResponseBody(res1, () => {\n this.emitErrorUnlessHttp2xx(res1, this.url, this.method)\n if (\n res1.statusCode === 202 &&\n res1.headers.location !== undefined\n ) {\n this.sendHttpRequest(\n res1.headers.location,\n 'PUT',\n {},\n (err2, res2) => {\n if (doesHaveValue(err2)) return callback(err2)\n this.emitErrorUnlessHttp2xx(res2, this.url, this.method)\n callback()\n }\n )\n } else {\n callback()\n }\n })\n }\n )\n })\n }\n\n private pushResponseBody(res: http.IncomingMessage, done: () => void): void {\n let body = Buffer.alloc(0)\n res.on('data', (chunk) => {\n body = Buffer.concat([body, chunk])\n })\n res.on('end', () => {\n this.push(body.toString('utf-8'))\n done()\n })\n }\n\n private emitErrorUnlessHttp2xx(\n res: http.IncomingMessage,\n url: string,\n method: string\n ): void {\n if (res.statusCode >= 300)\n this.emit(\n 'error',\n new Error(\n `Unexpected http status ${res.statusCode} from ${method} ${url}`\n )\n )\n }\n\n private sendHttpRequest(\n url: string,\n method: HttpMethod,\n headers: http.OutgoingHttpHeaders,\n callback: (err?: Error | null, res?: http.IncomingMessage) => void\n ): void {\n const httpx = doesHaveValue(url.match(/^https:/)) ? https : http\n const additionalHttpHeaders: http.OutgoingHttpHeaders = {}\n\n const upload = method === 'PUT' || method === 'POST'\n if (upload) {\n additionalHttpHeaders['Content-Length'] = fs.statSync(\n this.tempFilePath\n ).size\n }\n\n const allHeaders = { ...headers, ...additionalHttpHeaders }\n const req = httpx.request(url, {\n method,\n headers: allHeaders,\n })\n req.on('error', (err) => this.emit('error', err))\n req.on('response', (res) => {\n res.on('error', (err) => this.emit('error', err))\n callback(null, res)\n })\n\n if (upload) {\n pipeline(fs.createReadStream(this.tempFilePath), req, (err) => {\n if (doesHaveValue(err)) {\n this.emit('error', err)\n }\n })\n } else {\n req.end()\n }\n }\n}\n"]}
|
package/lib/formatter/index.d.ts
CHANGED
|
@@ -7,8 +7,19 @@ import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
|
7
7
|
import { WriteStream as FsWriteStream } from 'fs';
|
|
8
8
|
import { WriteStream as TtyWriteStream } from 'tty';
|
|
9
9
|
import { EventEmitter } from 'events';
|
|
10
|
-
import { IParsedArgvFormatOptions } from '../cli/argv_parser';
|
|
11
10
|
import HttpStream from './http_stream';
|
|
11
|
+
import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax';
|
|
12
|
+
export interface FormatRerunOptions {
|
|
13
|
+
separator?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FormatOptions {
|
|
16
|
+
colorsEnabled?: boolean;
|
|
17
|
+
rerun?: FormatRerunOptions;
|
|
18
|
+
snippetInterface?: SnippetInterface;
|
|
19
|
+
snippetSyntax?: string;
|
|
20
|
+
printAttachments?: boolean;
|
|
21
|
+
[customKey: string]: any;
|
|
22
|
+
}
|
|
12
23
|
export declare type IFormatterStream = FsWriteStream | TtyWriteStream | PassThrough | HttpStream;
|
|
13
24
|
export declare type IFormatterLogFn = (buffer: string | Uint8Array) => void;
|
|
14
25
|
export declare type IFormatterCleanupFn = () => Promise<any>;
|
|
@@ -18,7 +29,7 @@ export interface IFormatterOptions {
|
|
|
18
29
|
eventBroadcaster: EventEmitter;
|
|
19
30
|
eventDataCollector: EventDataCollector;
|
|
20
31
|
log: IFormatterLogFn;
|
|
21
|
-
parsedArgvOptions:
|
|
32
|
+
parsedArgvOptions: FormatOptions;
|
|
22
33
|
snippetBuilder: StepDefinitionSnippetBuilder;
|
|
23
34
|
stream: WritableStream;
|
|
24
35
|
cleanup: IFormatterCleanupFn;
|
|
@@ -32,7 +43,9 @@ export default class Formatter {
|
|
|
32
43
|
protected snippetBuilder: StepDefinitionSnippetBuilder;
|
|
33
44
|
protected stream: WritableStream;
|
|
34
45
|
protected supportCodeLibrary: ISupportCodeLibrary;
|
|
46
|
+
protected printAttachments: boolean;
|
|
35
47
|
private readonly cleanup;
|
|
48
|
+
static readonly documentation: string;
|
|
36
49
|
constructor(options: IFormatterOptions);
|
|
37
50
|
finished(): Promise<void>;
|
|
38
51
|
}
|
package/lib/formatter/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const value_checker_1 = require("../value_checker");
|
|
3
4
|
class Formatter {
|
|
4
5
|
constructor(options) {
|
|
5
6
|
this.colorFns = options.colorFns;
|
|
@@ -10,6 +11,7 @@ class Formatter {
|
|
|
10
11
|
this.stream = options.stream;
|
|
11
12
|
this.supportCodeLibrary = options.supportCodeLibrary;
|
|
12
13
|
this.cleanup = options.cleanup;
|
|
14
|
+
this.printAttachments = (0, value_checker_1.valueOrDefault)(options.parsedArgvOptions.printAttachments, true);
|
|
13
15
|
}
|
|
14
16
|
async finished() {
|
|
15
17
|
await this.cleanup();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;AASA,oDAAiD;AAqCjD,MAAqB,SAAS;IAY5B,YAAY,OAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAc,EACpC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,EAC1C,IAAI,CACL,CAAA;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;IACtB,CAAC;CACF;AA9BD,4BA8BC","sourcesContent":["import { IColorFns } from './get_color_fns'\nimport { EventDataCollector } from './helpers'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { PassThrough, Writable as WritableStream } from 'stream'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { WriteStream as FsWriteStream } from 'fs'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport { EventEmitter } from 'events'\nimport HttpStream from './http_stream'\nimport { valueOrDefault } from '../value_checker'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\n\nexport interface FormatRerunOptions {\n separator?: string\n}\n\nexport interface FormatOptions {\n colorsEnabled?: boolean\n rerun?: FormatRerunOptions\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n printAttachments?: boolean\n [customKey: string]: any\n}\n\nexport type IFormatterStream =\n | FsWriteStream\n | TtyWriteStream\n | PassThrough\n | HttpStream\nexport type IFormatterLogFn = (buffer: string | Uint8Array) => void\nexport type IFormatterCleanupFn = () => Promise<any>\n\nexport interface IFormatterOptions {\n colorFns: IColorFns\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n snippetBuilder: StepDefinitionSnippetBuilder\n stream: WritableStream\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport default class Formatter {\n protected colorFns: IColorFns\n protected cwd: string\n protected eventDataCollector: EventDataCollector\n protected log: IFormatterLogFn\n protected snippetBuilder: StepDefinitionSnippetBuilder\n protected stream: WritableStream\n protected supportCodeLibrary: ISupportCodeLibrary\n protected printAttachments: boolean\n private readonly cleanup: IFormatterCleanupFn\n static readonly documentation: string\n\n constructor(options: IFormatterOptions) {\n this.colorFns = options.colorFns\n this.cwd = options.cwd\n this.eventDataCollector = options.eventDataCollector\n this.log = options.log\n this.snippetBuilder = options.snippetBuilder\n this.stream = options.stream\n this.supportCodeLibrary = options.supportCodeLibrary\n this.cleanup = options.cleanup\n this.printAttachments = valueOrDefault(\n options.parsedArgvOptions.printAttachments,\n true\n )\n }\n\n async finished(): Promise<void> {\n await this.cleanup()\n }\n}\n"]}
|
|
@@ -56,6 +56,7 @@ interface IBuildJsonStepOptions {
|
|
|
56
56
|
testStepResult: messages.TestStepResult;
|
|
57
57
|
}
|
|
58
58
|
export default class JsonFormatter extends Formatter {
|
|
59
|
+
static readonly documentation: string;
|
|
59
60
|
constructor(options: IFormatterOptions);
|
|
60
61
|
convertNameToId(obj: messages.Feature | messages.Pickle): string;
|
|
61
62
|
formatDataTable(dataTable: messages.PickleTable): any;
|
|
@@ -22,7 +22,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
26
25
|
const _1 = __importDefault(require("./"));
|
|
27
26
|
const helpers_1 = require("./helpers");
|
|
28
27
|
const messages = __importStar(require("@cucumber/messages"));
|
|
@@ -35,7 +34,7 @@ class JsonFormatter extends _1.default {
|
|
|
35
34
|
constructor(options) {
|
|
36
35
|
super(options);
|
|
37
36
|
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
38
|
-
if (value_checker_1.doesHaveValue(envelope.testRunFinished)) {
|
|
37
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
39
38
|
this.onTestRunFinished();
|
|
40
39
|
}
|
|
41
40
|
});
|
|
@@ -45,7 +44,9 @@ class JsonFormatter extends _1.default {
|
|
|
45
44
|
}
|
|
46
45
|
formatDataTable(dataTable) {
|
|
47
46
|
return {
|
|
48
|
-
rows: dataTable.rows.map((row) => ({
|
|
47
|
+
rows: dataTable.rows.map((row) => ({
|
|
48
|
+
cells: row.cells.map((x) => x.value),
|
|
49
|
+
})),
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
formatDocString(docString, gherkinStep) {
|
|
@@ -55,11 +56,11 @@ class JsonFormatter extends _1.default {
|
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
formatStepArgument(stepArgument, gherkinStep) {
|
|
58
|
-
if (value_checker_1.doesNotHaveValue(stepArgument)) {
|
|
59
|
+
if ((0, value_checker_1.doesNotHaveValue)(stepArgument)) {
|
|
59
60
|
return [];
|
|
60
61
|
}
|
|
61
62
|
return [
|
|
62
|
-
step_arguments_1.parseStepArgument(stepArgument, {
|
|
63
|
+
(0, step_arguments_1.parseStepArgument)(stepArgument, {
|
|
63
64
|
dataTable: (dataTable) => this.formatDataTable(dataTable),
|
|
64
65
|
docString: (docString) => this.formatDocString(docString, gherkinStep),
|
|
65
66
|
}),
|
|
@@ -67,27 +68,30 @@ class JsonFormatter extends _1.default {
|
|
|
67
68
|
}
|
|
68
69
|
onTestRunFinished() {
|
|
69
70
|
const groupedTestCaseAttempts = {};
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
this.eventDataCollector
|
|
72
|
+
.getTestCaseAttempts()
|
|
73
|
+
.forEach((testCaseAttempt) => {
|
|
74
|
+
if (!testCaseAttempt.willBeRetried) {
|
|
72
75
|
const uri = testCaseAttempt.pickle.uri;
|
|
73
|
-
if (value_checker_1.doesNotHaveValue(groupedTestCaseAttempts[uri])) {
|
|
76
|
+
if ((0, value_checker_1.doesNotHaveValue)(groupedTestCaseAttempts[uri])) {
|
|
74
77
|
groupedTestCaseAttempts[uri] = [];
|
|
75
78
|
}
|
|
76
79
|
groupedTestCaseAttempts[uri].push(testCaseAttempt);
|
|
77
80
|
}
|
|
78
81
|
});
|
|
79
|
-
const features =
|
|
82
|
+
const features = Object.keys(groupedTestCaseAttempts).map((uri) => {
|
|
83
|
+
const group = groupedTestCaseAttempts[uri];
|
|
80
84
|
const { gherkinDocument } = group[0];
|
|
81
85
|
const gherkinStepMap = getGherkinStepMap(gherkinDocument);
|
|
82
86
|
const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument);
|
|
83
|
-
const gherkinExampleRuleMap = gherkin_document_parser_1.getGherkinExampleRuleMap(gherkinDocument);
|
|
84
|
-
const gherkinScenarioLocationMap = gherkin_document_parser_1.getGherkinScenarioLocationMap(gherkinDocument);
|
|
87
|
+
const gherkinExampleRuleMap = (0, gherkin_document_parser_1.getGherkinExampleRuleMap)(gherkinDocument);
|
|
88
|
+
const gherkinScenarioLocationMap = (0, gherkin_document_parser_1.getGherkinScenarioLocationMap)(gherkinDocument);
|
|
85
89
|
const elements = group.map((testCaseAttempt) => {
|
|
86
90
|
const { pickle } = testCaseAttempt;
|
|
87
91
|
const pickleStepMap = getPickleStepMap(pickle);
|
|
88
92
|
let isBeforeHook = true;
|
|
89
93
|
const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {
|
|
90
|
-
isBeforeHook = isBeforeHook && !value_checker_1.doesHaveValue(testStep.pickleStepId);
|
|
94
|
+
isBeforeHook = isBeforeHook && !(0, value_checker_1.doesHaveValue)(testStep.pickleStepId);
|
|
91
95
|
return this.getStepData({
|
|
92
96
|
isBeforeHook,
|
|
93
97
|
gherkinStepMap,
|
|
@@ -145,7 +149,7 @@ class JsonFormatter extends _1.default {
|
|
|
145
149
|
formatScenarioId({ feature, pickle, gherkinExampleRuleMap, }) {
|
|
146
150
|
let parts;
|
|
147
151
|
const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]];
|
|
148
|
-
if (value_checker_1.doesHaveValue(rule)) {
|
|
152
|
+
if ((0, value_checker_1.doesHaveValue)(rule)) {
|
|
149
153
|
parts = [feature, rule, pickle];
|
|
150
154
|
}
|
|
151
155
|
else {
|
|
@@ -155,7 +159,7 @@ class JsonFormatter extends _1.default {
|
|
|
155
159
|
}
|
|
156
160
|
getStepData({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult, }) {
|
|
157
161
|
const data = {};
|
|
158
|
-
if (value_checker_1.doesHaveValue(testStep.pickleStepId)) {
|
|
162
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId)) {
|
|
159
163
|
const pickleStep = pickleStepMap[testStep.pickleStepId];
|
|
160
164
|
data.arguments = this.formatStepArgument(pickleStep.argument, gherkinStepMap[pickleStep.astNodeIds[0]]);
|
|
161
165
|
data.keyword = getStepKeyword({ pickleStep, gherkinStepMap });
|
|
@@ -166,24 +170,24 @@ class JsonFormatter extends _1.default {
|
|
|
166
170
|
data.keyword = isBeforeHook ? 'Before' : 'After';
|
|
167
171
|
data.hidden = true;
|
|
168
172
|
}
|
|
169
|
-
if (value_checker_1.doesHaveValue(testStep.stepDefinitionIds) &&
|
|
173
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.stepDefinitionIds) &&
|
|
170
174
|
testStep.stepDefinitionIds.length === 1) {
|
|
171
175
|
const stepDefinition = this.supportCodeLibrary.stepDefinitions.find((s) => s.id === testStep.stepDefinitionIds[0]);
|
|
172
|
-
data.match = { location: helpers_1.formatLocation(stepDefinition) };
|
|
176
|
+
data.match = { location: (0, helpers_1.formatLocation)(stepDefinition) };
|
|
173
177
|
}
|
|
174
178
|
const { message, status } = testStepResult;
|
|
175
179
|
data.result = {
|
|
176
180
|
status: messages.TestStepResultStatus[status].toLowerCase(),
|
|
177
181
|
};
|
|
178
|
-
if (value_checker_1.doesHaveValue(testStepResult.duration)) {
|
|
182
|
+
if ((0, value_checker_1.doesHaveValue)(testStepResult.duration)) {
|
|
179
183
|
data.result.duration =
|
|
180
184
|
messages.TimeConversion.durationToMilliseconds(testStepResult.duration) * 1000000;
|
|
181
185
|
}
|
|
182
186
|
if (status === messages.TestStepResultStatus.FAILED &&
|
|
183
|
-
value_checker_1.doesHaveValue(message)) {
|
|
187
|
+
(0, value_checker_1.doesHaveValue)(message)) {
|
|
184
188
|
data.result.error_message = message;
|
|
185
189
|
}
|
|
186
|
-
if (
|
|
190
|
+
if ((testStepAttachments === null || testStepAttachments === void 0 ? void 0 : testStepAttachments.length) > 0) {
|
|
187
191
|
data.embeddings = testStepAttachments.map((attachment) => ({
|
|
188
192
|
data: attachment.body,
|
|
189
193
|
mime_type: attachment.mediaType,
|
|
@@ -192,7 +196,7 @@ class JsonFormatter extends _1.default {
|
|
|
192
196
|
return data;
|
|
193
197
|
}
|
|
194
198
|
getFeatureTags(feature) {
|
|
195
|
-
return
|
|
199
|
+
return feature.tags.map((tagData) => ({
|
|
196
200
|
name: tagData.name,
|
|
197
201
|
line: tagData.location.line,
|
|
198
202
|
}));
|
|
@@ -218,4 +222,5 @@ class JsonFormatter extends _1.default {
|
|
|
218
222
|
}
|
|
219
223
|
}
|
|
220
224
|
exports.default = JsonFormatter;
|
|
225
|
+
JsonFormatter.documentation = 'Prints the feature as JSON. The JSON format is in maintenance mode. Please consider using the message formatter with the standalone json-formatter (https://github.com/cucumber/cucumber/tree/master/json-formatter).';
|
|
221
226
|
//# sourceMappingURL=json_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json_formatter.js","sourceRoot":"","sources":["../../src/formatter/json_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsB;AACtB,0CAAiD;AACjD,uCAA+E;AAC/E,6DAA8C;AAC9C,+EAG0C;AAE1C,oDAAkE;AAClE,sDAAqD;AAErD,MAAM,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,GAAG,+BAAqB,CAAA;AAE1E,MAAM,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAChE,sBAAY,CAAA;AAoEd,MAAqB,aAAc,SAAQ,UAAS;IAClD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,6BAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,iBAAiB,EAAE,CAAA;aACzB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,eAAe,CAAC,GAAuC;QACrD,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;IAClD,CAAC;IAED,eAAe,CAAC,SAA+B;QAC7C,OAAO;YACL,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAC,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC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CAAE,QAAQ,0CAAE,IAAI;SAC1B,CAAA;IACH,CAAC;CACF;AAxQD,gCAwQC","sourcesContent":["import _ from 'lodash'\nimport Formatter, { IFormatterOptions } from './'\nimport { formatLocation, GherkinDocumentParser, PickleParser } from './helpers'\nimport * as messages from '@cucumber/messages'\nimport {\n getGherkinExampleRuleMap,\n getGherkinScenarioLocationMap,\n} from './helpers/gherkin_document_parser'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { parseStepArgument } from '../step_arguments'\n\nconst { getGherkinStepMap, getGherkinScenarioMap } = GherkinDocumentParser\n\nconst { getScenarioDescription, getPickleStepMap, getStepKeyword } =\n PickleParser\n\nexport interface IJsonFeature {\n description: string\n elements: IJsonScenario[]\n id: string\n keyword: string\n line: number\n name: string\n tags: IJsonTag[]\n uri: string\n}\n\nexport interface IJsonScenario {\n description: string\n id: string\n keyword: string\n line: number\n name: string\n steps: IJsonStep[]\n tags: IJsonTag[]\n type: string\n}\n\nexport interface IJsonStep {\n arguments?: any // TODO\n embeddings?: any // TODO\n hidden?: boolean\n keyword?: string // TODO, not optional\n line?: number\n match?: any // TODO\n name?: string\n result?: any // TODO\n}\n\nexport interface IJsonTag {\n name: string\n line: number\n}\n\ninterface IBuildJsonFeatureOptions {\n feature: messages.Feature\n elements: IJsonScenario[]\n uri: string\n}\n\ninterface IBuildJsonScenarioOptions {\n feature: messages.Feature\n gherkinScenarioMap: Record<string, messages.Scenario>\n gherkinExampleRuleMap: Record<string, messages.Rule>\n gherkinScenarioLocationMap: Record<string, messages.Location>\n pickle: messages.Pickle\n steps: IJsonStep[]\n}\n\ninterface IBuildJsonStepOptions {\n isBeforeHook: boolean\n gherkinStepMap: Record<string, messages.Step>\n pickleStepMap: Record<string, messages.PickleStep>\n testStep: messages.TestStep\n testStepAttachments: messages.Attachment[]\n testStepResult: messages.TestStepResult\n}\n\ninterface UriToTestCaseAttemptsMap {\n [uri: string]: ITestCaseAttempt[]\n}\n\nexport default class JsonFormatter extends Formatter {\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n convertNameToId(obj: messages.Feature | messages.Pickle): string {\n return obj.name.replace(/ /g, '-').toLowerCase()\n }\n\n formatDataTable(dataTable: messages.PickleTable): any {\n return {\n rows: dataTable.rows.map((row) => ({ cells: _.map(row.cells, 'value') })),\n }\n }\n\n formatDocString(\n docString: messages.PickleDocString,\n gherkinStep: messages.Step\n ): any {\n return {\n content: docString.content,\n line: gherkinStep.docString.location.line,\n }\n }\n\n formatStepArgument(\n stepArgument: messages.PickleStepArgument,\n gherkinStep: messages.Step\n ): any {\n if (doesNotHaveValue(stepArgument)) {\n return []\n }\n return [\n parseStepArgument<any>(stepArgument, {\n dataTable: (dataTable) => this.formatDataTable(dataTable),\n docString: (docString) => this.formatDocString(docString, gherkinStep),\n }),\n ]\n }\n\n onTestRunFinished(): void {\n const groupedTestCaseAttempts: UriToTestCaseAttemptsMap = {}\n _.each(\n this.eventDataCollector.getTestCaseAttempts(),\n (testCaseAttempt: ITestCaseAttempt) => {\n if (!testCaseAttempt.worstTestStepResult.willBeRetried) {\n const uri = testCaseAttempt.pickle.uri\n if (doesNotHaveValue(groupedTestCaseAttempts[uri])) {\n groupedTestCaseAttempts[uri] = []\n }\n groupedTestCaseAttempts[uri].push(testCaseAttempt)\n }\n }\n )\n const features = _.map(groupedTestCaseAttempts, (group, uri) => {\n const { gherkinDocument } = group[0]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument)\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const gherkinScenarioLocationMap =\n getGherkinScenarioLocationMap(gherkinDocument)\n const elements = group.map((testCaseAttempt: ITestCaseAttempt) => {\n const { pickle } = testCaseAttempt\n const pickleStepMap = getPickleStepMap(pickle)\n let isBeforeHook = true\n const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {\n isBeforeHook = isBeforeHook && !doesHaveValue(testStep.pickleStepId)\n return this.getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n return this.getScenarioData({\n feature: gherkinDocument.feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n })\n })\n return this.getFeatureData({\n feature: gherkinDocument.feature,\n elements,\n uri,\n })\n })\n this.log(JSON.stringify(features, null, 2))\n }\n\n getFeatureData({\n feature,\n elements,\n uri,\n }: IBuildJsonFeatureOptions): IJsonFeature {\n return {\n description: feature.description,\n elements,\n id: this.convertNameToId(feature),\n line: feature.location.line,\n keyword: feature.keyword,\n name: feature.name,\n tags: this.getFeatureTags(feature),\n uri,\n }\n }\n\n getScenarioData({\n feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n }: IBuildJsonScenarioOptions): IJsonScenario {\n const description = getScenarioDescription({\n pickle,\n gherkinScenarioMap,\n })\n return {\n description,\n id: this.formatScenarioId({ feature, pickle, gherkinExampleRuleMap }),\n keyword: gherkinScenarioMap[pickle.astNodeIds[0]].keyword,\n line: gherkinScenarioLocationMap[pickle.astNodeIds[0]].line,\n name: pickle.name,\n steps,\n tags: this.getScenarioTags({ feature, pickle, gherkinScenarioMap }),\n type: 'scenario',\n }\n }\n\n private formatScenarioId({\n feature,\n pickle,\n gherkinExampleRuleMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinExampleRuleMap: Record<string, messages.Rule>\n }): string {\n let parts: any[]\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n if (doesHaveValue(rule)) {\n parts = [feature, rule, pickle]\n } else {\n parts = [feature, pickle]\n }\n return parts.map((part) => this.convertNameToId(part)).join(';')\n }\n\n getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJsonStepOptions): IJsonStep {\n const data: IJsonStep = {}\n if (doesHaveValue(testStep.pickleStepId)) {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\n data.arguments = this.formatStepArgument(\n pickleStep.argument,\n gherkinStepMap[pickleStep.astNodeIds[0]]\n )\n data.keyword = getStepKeyword({ pickleStep, gherkinStepMap })\n data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line\n data.name = pickleStep.text\n } else {\n data.keyword = isBeforeHook ? 'Before' : 'After'\n data.hidden = true\n }\n if (\n doesHaveValue(testStep.stepDefinitionIds) &&\n testStep.stepDefinitionIds.length === 1\n ) {\n const stepDefinition = this.supportCodeLibrary.stepDefinitions.find(\n (s) => s.id === testStep.stepDefinitionIds[0]\n )\n data.match = { location: formatLocation(stepDefinition) }\n }\n const { message, status } = testStepResult\n data.result = {\n status: messages.TestStepResultStatus[status].toLowerCase(),\n }\n if (doesHaveValue(testStepResult.duration)) {\n data.result.duration =\n messages.TimeConversion.durationToMilliseconds(\n testStepResult.duration\n ) * 1000000\n }\n if (\n status === messages.TestStepResultStatus.FAILED &&\n doesHaveValue(message)\n ) {\n data.result.error_message = message\n }\n if (_.size(testStepAttachments) > 0) {\n data.embeddings = testStepAttachments.map((attachment) => ({\n data: attachment.body,\n mime_type: attachment.mediaType,\n }))\n }\n return data\n }\n\n getFeatureTags(feature: messages.Feature): IJsonTag[] {\n return _.map(feature.tags, (tagData) => ({\n name: tagData.name,\n line: tagData.location.line,\n }))\n }\n\n getScenarioTags({\n feature,\n pickle,\n gherkinScenarioMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinScenarioMap: Record<string, messages.Scenario>\n }): IJsonTag[] {\n const scenario = gherkinScenarioMap[pickle.astNodeIds[0]]\n\n return pickle.tags.map(\n (tagData: messages.PickleTag): IJsonTag =>\n this.getScenarioTag(tagData, feature, scenario)\n )\n }\n\n private getScenarioTag(\n tagData: messages.PickleTag,\n feature: messages.Feature,\n scenario: messages.Scenario\n ): IJsonTag {\n const byAstNodeId = (tag: messages.Tag): Boolean =>\n tag.id === tagData.astNodeId\n const flatten = (\n acc: messages.Tag[],\n val: messages.Tag[]\n ): messages.Tag[] => acc.concat(val)\n\n const tag =\n feature.tags.find(byAstNodeId) ||\n scenario.tags.find(byAstNodeId) ||\n scenario.examples\n .map((e) => e.tags)\n .reduce(flatten, [])\n .find(byAstNodeId)\n\n return {\n name: tagData.name,\n line: tag?.location?.line,\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"json_formatter.js","sourceRoot":"","sources":["../../src/formatter/json_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAiD;AACjD,uCAA+E;AAC/E,6DAA8C;AAC9C,+EAG0C;AAE1C,oDAAkE;AAClE,sDAAqD;AAErD,MAAM,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,GAAG,+BAAqB,CAAA;AAE1E,MAAM,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAChE,sBAAY,CAAA;AAoEd,MAAqB,aAAc,SAAQ,UAAS;IAIlD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,iBAAiB,EAAE,CAAA;aACzB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,eAAe,CAAC,GAAuC;QACrD,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;IAClD,CAAC;IAED,eAAe,CAAC,SA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YAC9B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC/B,QAAQ,CAAC,QAAQ;iBACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAClB,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;iBACnB,IAAI,CAAC,WAAW,CAAC,CAAA;QAEtB,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,0CAAE,IAAI;SAC1B,CAAA;IACH,CAAC;;AA5QH,gCA6QC;AA5QwB,2BAAa,GAClC,uNAAuN,CAAA","sourcesContent":["import Formatter, { IFormatterOptions } from './'\nimport { formatLocation, GherkinDocumentParser, PickleParser } from './helpers'\nimport * as messages from '@cucumber/messages'\nimport {\n getGherkinExampleRuleMap,\n getGherkinScenarioLocationMap,\n} from './helpers/gherkin_document_parser'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { parseStepArgument } from '../step_arguments'\n\nconst { getGherkinStepMap, getGherkinScenarioMap } = GherkinDocumentParser\n\nconst { getScenarioDescription, getPickleStepMap, getStepKeyword } =\n PickleParser\n\nexport interface IJsonFeature {\n description: string\n elements: IJsonScenario[]\n id: string\n keyword: string\n line: number\n name: string\n tags: IJsonTag[]\n uri: string\n}\n\nexport interface IJsonScenario {\n description: string\n id: string\n keyword: string\n line: number\n name: string\n steps: IJsonStep[]\n tags: IJsonTag[]\n type: string\n}\n\nexport interface IJsonStep {\n arguments?: any // TODO\n embeddings?: any // TODO\n hidden?: boolean\n keyword?: string // TODO, not optional\n line?: number\n match?: any // TODO\n name?: string\n result?: any // TODO\n}\n\nexport interface IJsonTag {\n name: string\n line: number\n}\n\ninterface IBuildJsonFeatureOptions {\n feature: messages.Feature\n elements: IJsonScenario[]\n uri: string\n}\n\ninterface IBuildJsonScenarioOptions {\n feature: messages.Feature\n gherkinScenarioMap: Record<string, messages.Scenario>\n gherkinExampleRuleMap: Record<string, messages.Rule>\n gherkinScenarioLocationMap: Record<string, messages.Location>\n pickle: messages.Pickle\n steps: IJsonStep[]\n}\n\ninterface IBuildJsonStepOptions {\n isBeforeHook: boolean\n gherkinStepMap: Record<string, messages.Step>\n pickleStepMap: Record<string, messages.PickleStep>\n testStep: messages.TestStep\n testStepAttachments: messages.Attachment[]\n testStepResult: messages.TestStepResult\n}\n\ninterface UriToTestCaseAttemptsMap {\n [uri: string]: ITestCaseAttempt[]\n}\n\nexport default class JsonFormatter extends Formatter {\n public static readonly documentation: string =\n 'Prints the feature as JSON. The JSON format is in maintenance mode. Please consider using the message formatter with the standalone json-formatter (https://github.com/cucumber/cucumber/tree/master/json-formatter).'\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n convertNameToId(obj: messages.Feature | messages.Pickle): string {\n return obj.name.replace(/ /g, '-').toLowerCase()\n }\n\n formatDataTable(dataTable: messages.PickleTable): any {\n return {\n rows: dataTable.rows.map((row) => ({\n cells: row.cells.map((x) => x.value),\n })),\n }\n }\n\n formatDocString(\n docString: messages.PickleDocString,\n gherkinStep: messages.Step\n ): any {\n return {\n content: docString.content,\n line: gherkinStep.docString.location.line,\n }\n }\n\n formatStepArgument(\n stepArgument: messages.PickleStepArgument,\n gherkinStep: messages.Step\n ): any {\n if (doesNotHaveValue(stepArgument)) {\n return []\n }\n return [\n parseStepArgument<any>(stepArgument, {\n dataTable: (dataTable) => this.formatDataTable(dataTable),\n docString: (docString) => this.formatDocString(docString, gherkinStep),\n }),\n ]\n }\n\n onTestRunFinished(): void {\n const groupedTestCaseAttempts: UriToTestCaseAttemptsMap = {}\n this.eventDataCollector\n .getTestCaseAttempts()\n .forEach((testCaseAttempt: ITestCaseAttempt) => {\n if (!testCaseAttempt.willBeRetried) {\n const uri = testCaseAttempt.pickle.uri\n if (doesNotHaveValue(groupedTestCaseAttempts[uri])) {\n groupedTestCaseAttempts[uri] = []\n }\n groupedTestCaseAttempts[uri].push(testCaseAttempt)\n }\n })\n const features = Object.keys(groupedTestCaseAttempts).map((uri) => {\n const group = groupedTestCaseAttempts[uri]\n const { gherkinDocument } = group[0]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument)\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const gherkinScenarioLocationMap =\n getGherkinScenarioLocationMap(gherkinDocument)\n const elements = group.map((testCaseAttempt: ITestCaseAttempt) => {\n const { pickle } = testCaseAttempt\n const pickleStepMap = getPickleStepMap(pickle)\n let isBeforeHook = true\n const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {\n isBeforeHook = isBeforeHook && !doesHaveValue(testStep.pickleStepId)\n return this.getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n return this.getScenarioData({\n feature: gherkinDocument.feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n })\n })\n return this.getFeatureData({\n feature: gherkinDocument.feature,\n elements,\n uri,\n })\n })\n this.log(JSON.stringify(features, null, 2))\n }\n\n getFeatureData({\n feature,\n elements,\n uri,\n }: IBuildJsonFeatureOptions): IJsonFeature {\n return {\n description: feature.description,\n elements,\n id: this.convertNameToId(feature),\n line: feature.location.line,\n keyword: feature.keyword,\n name: feature.name,\n tags: this.getFeatureTags(feature),\n uri,\n }\n }\n\n getScenarioData({\n feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n }: IBuildJsonScenarioOptions): IJsonScenario {\n const description = getScenarioDescription({\n pickle,\n gherkinScenarioMap,\n })\n return {\n description,\n id: this.formatScenarioId({ feature, pickle, gherkinExampleRuleMap }),\n keyword: gherkinScenarioMap[pickle.astNodeIds[0]].keyword,\n line: gherkinScenarioLocationMap[pickle.astNodeIds[0]].line,\n name: pickle.name,\n steps,\n tags: this.getScenarioTags({ feature, pickle, gherkinScenarioMap }),\n type: 'scenario',\n }\n }\n\n private formatScenarioId({\n feature,\n pickle,\n gherkinExampleRuleMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinExampleRuleMap: Record<string, messages.Rule>\n }): string {\n let parts: any[]\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n if (doesHaveValue(rule)) {\n parts = [feature, rule, pickle]\n } else {\n parts = [feature, pickle]\n }\n return parts.map((part) => this.convertNameToId(part)).join(';')\n }\n\n getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJsonStepOptions): IJsonStep {\n const data: IJsonStep = {}\n if (doesHaveValue(testStep.pickleStepId)) {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\n data.arguments = this.formatStepArgument(\n pickleStep.argument,\n gherkinStepMap[pickleStep.astNodeIds[0]]\n )\n data.keyword = getStepKeyword({ pickleStep, gherkinStepMap })\n data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line\n data.name = pickleStep.text\n } else {\n data.keyword = isBeforeHook ? 'Before' : 'After'\n data.hidden = true\n }\n if (\n doesHaveValue(testStep.stepDefinitionIds) &&\n testStep.stepDefinitionIds.length === 1\n ) {\n const stepDefinition = this.supportCodeLibrary.stepDefinitions.find(\n (s) => s.id === testStep.stepDefinitionIds[0]\n )\n data.match = { location: formatLocation(stepDefinition) }\n }\n const { message, status } = testStepResult\n data.result = {\n status: messages.TestStepResultStatus[status].toLowerCase(),\n }\n if (doesHaveValue(testStepResult.duration)) {\n data.result.duration =\n messages.TimeConversion.durationToMilliseconds(\n testStepResult.duration\n ) * 1000000\n }\n if (\n status === messages.TestStepResultStatus.FAILED &&\n doesHaveValue(message)\n ) {\n data.result.error_message = message\n }\n if (testStepAttachments?.length > 0) {\n data.embeddings = testStepAttachments.map((attachment) => ({\n data: attachment.body,\n mime_type: attachment.mediaType,\n }))\n }\n return data\n }\n\n getFeatureTags(feature: messages.Feature): IJsonTag[] {\n return feature.tags.map((tagData) => ({\n name: tagData.name,\n line: tagData.location.line,\n }))\n }\n\n getScenarioTags({\n feature,\n pickle,\n gherkinScenarioMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinScenarioMap: Record<string, messages.Scenario>\n }): IJsonTag[] {\n const scenario = gherkinScenarioMap[pickle.astNodeIds[0]]\n\n return pickle.tags.map(\n (tagData: messages.PickleTag): IJsonTag =>\n this.getScenarioTag(tagData, feature, scenario)\n )\n }\n\n private getScenarioTag(\n tagData: messages.PickleTag,\n feature: messages.Feature,\n scenario: messages.Scenario\n ): IJsonTag {\n const byAstNodeId = (tag: messages.Tag): boolean =>\n tag.id === tagData.astNodeId\n const flatten = (\n acc: messages.Tag[],\n val: messages.Tag[]\n ): messages.Tag[] => acc.concat(val)\n\n const tag =\n feature.tags.find(byAstNodeId) ||\n scenario.tags.find(byAstNodeId) ||\n scenario.examples\n .map((e) => e.tags)\n .reduce(flatten, [])\n .find(byAstNodeId)\n\n return {\n name: tagData.name,\n line: tag?.location?.line,\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_formatter.js","sourceRoot":"","sources":["../../src/formatter/message_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAGhD,MAAqB,gBAAiB,SAAQ,UAAS;
|
|
1
|
+
{"version":3,"file":"message_formatter.js","sourceRoot":"","sources":["../../src/formatter/message_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAGhD,MAAqB,gBAAiB,SAAQ,UAAS;IAErD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE,CACtE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAC1C,CAAA;IACH,CAAC;;AAPH,mCAQC;AAPwB,8BAAa,GAAW,2BAA2B,CAAA","sourcesContent":["import Formatter, { IFormatterOptions } from '.'\nimport * as messages from '@cucumber/messages'\n\nexport default class MessageFormatter extends Formatter {\n public static readonly documentation: string = 'Outputs protobuf messages'\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) =>\n this.log(JSON.stringify(envelope) + '\\n')\n )\n }\n}\n"]}
|
|
@@ -6,6 +6,7 @@ export default class ProgressBarFormatter extends Formatter {
|
|
|
6
6
|
private testRunStarted;
|
|
7
7
|
private issueCount;
|
|
8
8
|
progressBar: ProgressBar;
|
|
9
|
+
static readonly documentation: string;
|
|
9
10
|
constructor(options: IFormatterOptions);
|
|
10
11
|
incrementStepCount(pickleId: string): void;
|
|
11
12
|
initializeProgressBar(): void;
|
|
@@ -22,7 +22,7 @@ class ProgressBarFormatter extends _1.default {
|
|
|
22
22
|
this.numberOfSteps += pickle.steps.length;
|
|
23
23
|
}
|
|
24
24
|
initializeProgressBar() {
|
|
25
|
-
if (value_checker_1.doesHaveValue(this.progressBar)) {
|
|
25
|
+
if ((0, value_checker_1.doesHaveValue)(this.progressBar)) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
this.progressBar = new progress_1.default(':current/:total steps [:bar] ', {
|
|
@@ -30,69 +30,70 @@ class ProgressBarFormatter extends _1.default {
|
|
|
30
30
|
incomplete: ' ',
|
|
31
31
|
stream: this.stream,
|
|
32
32
|
total: this.numberOfSteps,
|
|
33
|
-
width: value_checker_1.valueOrDefault(this.stream.columns, 80),
|
|
33
|
+
width: (0, value_checker_1.valueOrDefault)(this.stream.columns, 80),
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
logProgress({ testStepId, testCaseStartedId, }) {
|
|
37
37
|
const { testCase } = this.eventDataCollector.getTestCaseAttempt(testCaseStartedId);
|
|
38
38
|
const testStep = testCase.testSteps.find((s) => s.id === testStepId);
|
|
39
|
-
if (value_checker_1.doesHaveValue(testStep.pickleStepId)) {
|
|
39
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId)) {
|
|
40
40
|
this.progressBar.tick();
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
logUndefinedParametertype(parameterType) {
|
|
44
|
-
this.log(`Undefined parameter type: ${issue_helpers_1.formatUndefinedParameterType(parameterType)}\n`);
|
|
44
|
+
this.log(`Undefined parameter type: ${(0, issue_helpers_1.formatUndefinedParameterType)(parameterType)}\n`);
|
|
45
45
|
}
|
|
46
46
|
logErrorIfNeeded(testCaseFinished) {
|
|
47
47
|
const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(testCaseFinished.testCaseStartedId);
|
|
48
|
-
if (helpers_1.isIssue(worstTestStepResult)) {
|
|
48
|
+
if ((0, helpers_1.isIssue)(worstTestStepResult)) {
|
|
49
49
|
this.issueCount += 1;
|
|
50
50
|
const testCaseAttempt = this.eventDataCollector.getTestCaseAttempt(testCaseFinished.testCaseStartedId);
|
|
51
|
-
this.progressBar.interrupt(helpers_1.formatIssue({
|
|
51
|
+
this.progressBar.interrupt((0, helpers_1.formatIssue)({
|
|
52
52
|
colorFns: this.colorFns,
|
|
53
|
-
cwd: this.cwd,
|
|
54
53
|
number: this.issueCount,
|
|
55
54
|
snippetBuilder: this.snippetBuilder,
|
|
56
55
|
supportCodeLibrary: this.supportCodeLibrary,
|
|
57
56
|
testCaseAttempt,
|
|
57
|
+
printAttachments: this.printAttachments,
|
|
58
58
|
}));
|
|
59
|
-
if (
|
|
59
|
+
if (testCaseFinished.willBeRetried) {
|
|
60
60
|
const stepsToRetry = testCaseAttempt.pickle.steps.length;
|
|
61
61
|
this.progressBar.tick(-stepsToRetry);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
logSummary(testRunFinished) {
|
|
66
|
-
const testRunDuration = time_1.durationBetweenTimestamps(this.testRunStarted.timestamp, testRunFinished.timestamp);
|
|
67
|
-
this.log(helpers_1.formatSummary({
|
|
66
|
+
const testRunDuration = (0, time_1.durationBetweenTimestamps)(this.testRunStarted.timestamp, testRunFinished.timestamp);
|
|
67
|
+
this.log((0, helpers_1.formatSummary)({
|
|
68
68
|
colorFns: this.colorFns,
|
|
69
69
|
testCaseAttempts: this.eventDataCollector.getTestCaseAttempts(),
|
|
70
70
|
testRunDuration,
|
|
71
71
|
}));
|
|
72
72
|
}
|
|
73
73
|
parseEnvelope(envelope) {
|
|
74
|
-
if (value_checker_1.doesHaveValue(envelope.undefinedParameterType)) {
|
|
74
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.undefinedParameterType)) {
|
|
75
75
|
this.logUndefinedParametertype(envelope.undefinedParameterType);
|
|
76
76
|
}
|
|
77
|
-
else if (value_checker_1.doesHaveValue(envelope.testCase)) {
|
|
77
|
+
else if ((0, value_checker_1.doesHaveValue)(envelope.testCase)) {
|
|
78
78
|
this.incrementStepCount(envelope.testCase.pickleId);
|
|
79
79
|
}
|
|
80
|
-
else if (value_checker_1.doesHaveValue(envelope.testStepStarted)) {
|
|
80
|
+
else if ((0, value_checker_1.doesHaveValue)(envelope.testStepStarted)) {
|
|
81
81
|
this.initializeProgressBar();
|
|
82
82
|
}
|
|
83
|
-
else if (value_checker_1.doesHaveValue(envelope.testStepFinished)) {
|
|
83
|
+
else if ((0, value_checker_1.doesHaveValue)(envelope.testStepFinished)) {
|
|
84
84
|
this.logProgress(envelope.testStepFinished);
|
|
85
85
|
}
|
|
86
|
-
else if (value_checker_1.doesHaveValue(envelope.testCaseFinished)) {
|
|
86
|
+
else if ((0, value_checker_1.doesHaveValue)(envelope.testCaseFinished)) {
|
|
87
87
|
this.logErrorIfNeeded(envelope.testCaseFinished);
|
|
88
88
|
}
|
|
89
|
-
else if (value_checker_1.doesHaveValue(envelope.testRunStarted)) {
|
|
89
|
+
else if ((0, value_checker_1.doesHaveValue)(envelope.testRunStarted)) {
|
|
90
90
|
this.testRunStarted = envelope.testRunStarted;
|
|
91
91
|
}
|
|
92
|
-
else if (value_checker_1.doesHaveValue(envelope.testRunFinished)) {
|
|
92
|
+
else if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
93
93
|
this.logSummary(envelope.testRunFinished);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
exports.default = ProgressBarFormatter;
|
|
98
|
+
ProgressBarFormatter.documentation = 'Similar to the Progress Formatter, but provides a real-time updating progress bar based on the total number of steps to be executed in the test run';
|
|
98
99
|
//# sourceMappingURL=progress_bar_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress_bar_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_bar_formatter.ts"],"names":[],"mappings":";;;;;AAAA,uCAA+D;AAC/D,0CAAiD;AACjD,wDAAkC;AAGlC,oDAAgE;AAChE,2DAAsE;AACtE,kCAAmD;AAEnD,qGAAqG;AACrG,MAAqB,oBAAqB,SAAQ,UAAS;
|
|
1
|
+
{"version":3,"file":"progress_bar_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_bar_formatter.ts"],"names":[],"mappings":";;;;;AAAA,uCAA+D;AAC/D,0CAAiD;AACjD,wDAAkC;AAGlC,oDAAgE;AAChE,2DAAsE;AACtE,kCAAmD;AAEnD,qGAAqG;AACrG,MAAqB,oBAAqB,SAAQ,UAAS;IAQzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;Q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AI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAA;SAChE;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC3C,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;SACpD;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;YAClD,IAAI,CAAC,qBAAqB,EAAE,CAAA;SAC7B;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;YACnD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAA;SAC5C;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;YACnD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAA;SACjD;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;YACjD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAA;SAC9C;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;YAClD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;SAC1C;IACH,CAAC;;AA/GH,uCAgHC;AA3GwB,kCAAa,GAClC,qJAAqJ,CAAA","sourcesContent":["import { formatIssue, formatSummary, isIssue } from './helpers'\nimport Formatter, { IFormatterOptions } from './'\nimport ProgressBar from 'progress'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport { formatUndefinedParameterType } from './helpers/issue_helpers'\nimport { durationBetweenTimestamps } from '../time'\n\n// Inspired by https://github.com/thekompanee/fuubar and https://github.com/martinciu/fuubar-cucumber\nexport default class ProgressBarFormatter extends Formatter {\n private numberOfSteps: number\n private testRunStarted: messages.TestRunStarted\n private issueCount: number\n public progressBar: ProgressBar\n public static readonly documentation: string =\n 'Similar to the Progress Formatter, but provides a real-time updating progress bar based on the total number of steps to be executed in the test run'\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', this.parseEnvelope.bind(this))\n this.numberOfSteps = 0\n this.issueCount = 0\n }\n\n incrementStepCount(pickleId: string): void {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n this.numberOfSteps += pickle.steps.length\n }\n\n initializeProgressBar(): void {\n if (doesHaveValue(this.progressBar)) {\n return\n }\n this.progressBar = new ProgressBar(':current/:total steps [:bar] ', {\n clear: true,\n incomplete: ' ',\n stream: this.stream,\n total: this.numberOfSteps,\n width: valueOrDefault((this.stream as TtyWriteStream).columns, 80),\n })\n }\n\n logProgress({\n testStepId,\n testCaseStartedId,\n }: messages.TestStepFinished): void {\n const { testCase } =\n this.eventDataCollector.getTestCaseAttempt(testCaseStartedId)\n const testStep = testCase.testSteps.find((s) => s.id === testStepId)\n if (doesHaveValue(testStep.pickleStepId)) {\n this.progressBar.tick()\n }\n }\n\n logUndefinedParametertype(\n parameterType: messages.UndefinedParameterType\n ): void {\n this.log(\n `Undefined parameter type: ${formatUndefinedParameterType(\n parameterType\n )}\\n`\n )\n }\n\n logErrorIfNeeded(testCaseFinished: messages.TestCaseFinished): void {\n const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n if (isIssue(worstTestStepResult)) {\n this.issueCount += 1\n const testCaseAttempt = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n this.progressBar.interrupt(\n formatIssue({\n colorFns: this.colorFns,\n number: this.issueCount,\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n printAttachments: this.printAttachments,\n })\n )\n if (testCaseFinished.willBeRetried) {\n const stepsToRetry = testCaseAttempt.pickle.steps.length\n this.progressBar.tick(-stepsToRetry)\n }\n }\n }\n\n logSummary(testRunFinished: messages.TestRunFinished): void {\n const testRunDuration = durationBetweenTimestamps(\n this.testRunStarted.timestamp,\n testRunFinished.timestamp\n )\n this.log(\n formatSummary({\n colorFns: this.colorFns,\n testCaseAttempts: this.eventDataCollector.getTestCaseAttempts(),\n testRunDuration,\n })\n )\n }\n\n parseEnvelope(envelope: messages.Envelope): void {\n if (doesHaveValue(envelope.undefinedParameterType)) {\n this.logUndefinedParametertype(envelope.undefinedParameterType)\n } else if (doesHaveValue(envelope.testCase)) {\n this.incrementStepCount(envelope.testCase.pickleId)\n } else if (doesHaveValue(envelope.testStepStarted)) {\n this.initializeProgressBar()\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.logProgress(envelope.testStepFinished)\n } else if (doesHaveValue(envelope.testCaseFinished)) {\n this.logErrorIfNeeded(envelope.testCaseFinished)\n } else if (doesHaveValue(envelope.testRunStarted)) {\n this.testRunStarted = envelope.testRunStarted\n } else if (doesHaveValue(envelope.testRunFinished)) {\n this.logSummary(envelope.testRunFinished)\n }\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { IFormatterOptions } from './index';
|
|
|
3
3
|
import * as messages from '@cucumber/messages';
|
|
4
4
|
import ITestStepFinished = messages.TestStepFinished;
|
|
5
5
|
export default class ProgressFormatter extends SummaryFormatter {
|
|
6
|
+
static readonly documentation: string;
|
|
6
7
|
constructor(options: IFormatterOptions);
|
|
7
8
|
logProgress({ testStepResult: { status } }: ITestStepFinished): void;
|
|
8
9
|
}
|
|
@@ -36,10 +36,10 @@ const STATUS_CHARACTER_MAPPING = new Map([
|
|
|
36
36
|
class ProgressFormatter extends summary_formatter_1.default {
|
|
37
37
|
constructor(options) {
|
|
38
38
|
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
39
|
-
if (value_checker_1.doesHaveValue(envelope.testRunFinished)) {
|
|
39
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
40
40
|
this.log('\n\n');
|
|
41
41
|
}
|
|
42
|
-
else if (value_checker_1.doesHaveValue(envelope.testStepFinished)) {
|
|
42
|
+
else if ((0, value_checker_1.doesHaveValue)(envelope.testStepFinished)) {
|
|
43
43
|
this.logProgress(envelope.testStepFinished);
|
|
44
44
|
}
|
|
45
45
|
});
|
|
@@ -51,4 +51,5 @@ class ProgressFormatter extends summary_formatter_1.default {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
exports.default = ProgressFormatter;
|
|
54
|
+
ProgressFormatter.documentation = 'Prints one character per scenario.';
|
|
54
55
|
//# sourceMappingURL=progress_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAkD;AAClD,oDAAgD;AAEhD,6DAA8C;AAI9C,MAAM,wBAAwB,GAC5B,IAAI,GAAG,CAAC;IACN,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;IAC9C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;CAC/C,CAAC,CAAA;AAEJ,MAAqB,iBAAkB,SAAQ,2BAAgB;
|
|
1
|
+
{"version":3,"file":"progress_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAkD;AAClD,oDAAgD;AAEh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AA","sourcesContent":["import SummaryFormatter from './summary_formatter'\nimport { doesHaveValue } from '../value_checker'\nimport { IFormatterOptions } from './index'\nimport * as messages from '@cucumber/messages'\nimport IEnvelope = messages.Envelope\nimport ITestStepFinished = messages.TestStepFinished\n\nconst STATUS_CHARACTER_MAPPING: Map<messages.TestStepResultStatus, string> =\n new Map([\n [messages.TestStepResultStatus.AMBIGUOUS, 'A'],\n [messages.TestStepResultStatus.FAILED, 'F'],\n [messages.TestStepResultStatus.PASSED, '.'],\n [messages.TestStepResultStatus.PENDING, 'P'],\n [messages.TestStepResultStatus.SKIPPED, '-'],\n [messages.TestStepResultStatus.UNDEFINED, 'U'],\n ])\n\nexport default class ProgressFormatter extends SummaryFormatter {\n public static readonly documentation: string =\n 'Prints one character per scenario.'\n\n constructor(options: IFormatterOptions) {\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.log('\\n\\n')\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.logProgress(envelope.testStepFinished)\n }\n })\n super(options)\n }\n\n logProgress({ testStepResult: { status } }: ITestStepFinished): void {\n const character = this.colorFns.forStatus(status)(\n STATUS_CHARACTER_MAPPING.get(status)\n )\n this.log(character)\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_CUCUMBER_PUBLISH_URL = "https://messages.cucumber.io/api/reports";
|