@dev-blinq/cucumber-js 1.0.11 → 1.0.14
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/bin/cucumber-js +0 -0
- package/bin/cucumber.js +0 -0
- package/lib/api/console_logger.d.ts +12 -12
- package/lib/api/console_logger.js +23 -23
- package/lib/api/convert_configuration.d.ts +4 -4
- package/lib/api/convert_configuration.js +64 -64
- package/lib/api/environment.d.ts +2 -2
- package/lib/api/environment.js +13 -13
- package/lib/api/formatters.d.ts +20 -20
- package/lib/api/formatters.js +60 -60
- package/lib/api/gherkin.d.ts +21 -21
- package/lib/api/gherkin.js +99 -99
- package/lib/api/index.d.ts +12 -12
- package/lib/api/index.js +27 -27
- package/lib/api/load_configuration.d.ts +9 -9
- package/lib/api/load_configuration.js +40 -40
- package/lib/api/load_sources.d.ts +9 -9
- package/lib/api/load_sources.js +52 -52
- package/lib/api/load_support.d.ts +10 -10
- package/lib/api/load_support.js +29 -29
- package/lib/api/paths.d.ts +8 -8
- package/lib/api/paths.js +101 -101
- package/lib/api/plugins.d.ts +4 -4
- package/lib/api/plugins.js +18 -18
- package/lib/api/run_cucumber.d.ts +11 -11
- package/lib/api/run_cucumber.js +114 -114
- package/lib/api/runtime.d.ts +21 -21
- package/lib/api/runtime.js +35 -35
- package/lib/api/support.d.ts +9 -9
- package/lib/api/support.js +25 -25
- package/lib/api/test_helpers.d.ts +3 -3
- package/lib/api/test_helpers.js +30 -30
- package/lib/api/types.d.ts +175 -175
- package/lib/api/types.js +2 -2
- package/lib/cli/helpers.d.ts +37 -37
- package/lib/cli/helpers.js +202 -202
- package/lib/cli/i18n.d.ts +2 -2
- package/lib/cli/i18n.js +69 -69
- package/lib/cli/index.d.ts +21 -21
- package/lib/cli/index.js +58 -58
- package/lib/cli/install_validator.d.ts +1 -1
- package/lib/cli/install_validator.js +13 -13
- package/lib/cli/run.d.ts +1 -1
- package/lib/cli/run.js +43 -43
- package/lib/cli/validate_node_engine_version.d.ts +10 -10
- package/lib/cli/validate_node_engine_version.js +23 -23
- package/lib/configuration/argv_parser.d.ts +20 -20
- package/lib/configuration/argv_parser.js +100 -100
- package/lib/configuration/check_schema.d.ts +2 -2
- package/lib/configuration/check_schema.js +59 -59
- package/lib/configuration/default_configuration.d.ts +2 -2
- package/lib/configuration/default_configuration.js +26 -26
- package/lib/configuration/from_file.d.ts +3 -3
- package/lib/configuration/from_file.js +84 -84
- package/lib/configuration/helpers.d.ts +1 -1
- package/lib/configuration/helpers.js +10 -10
- package/lib/configuration/index.d.ts +7 -7
- package/lib/configuration/index.js +28 -28
- package/lib/configuration/locate_file.d.ts +1 -1
- package/lib/configuration/locate_file.js +20 -20
- package/lib/configuration/merge_configurations.d.ts +2 -2
- package/lib/configuration/merge_configurations.js +47 -47
- package/lib/configuration/option_splitter.d.ts +3 -3
- package/lib/configuration/option_splitter.js +22 -22
- package/lib/configuration/types.d.ts +28 -28
- package/lib/configuration/types.js +2 -2
- package/lib/configuration/validate_configuration.d.ts +3 -3
- package/lib/configuration/validate_configuration.js +12 -12
- package/lib/filter_stack_trace.d.ts +3 -3
- package/lib/filter_stack_trace.js +37 -37
- package/lib/formatter/builder.d.ts +37 -37
- package/lib/formatter/builder.js +100 -100
- package/lib/formatter/bvt_analysis_formatter.d.ts +18 -0
- package/lib/formatter/bvt_analysis_formatter.js +207 -0
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -0
- package/lib/formatter/bvt_formatter.d.ts +6 -9
- package/lib/formatter/bvt_formatter.js +24 -62
- package/lib/formatter/bvt_formatter.js.map +1 -1
- package/lib/formatter/feature_data_format.d.ts +14 -14
- package/lib/formatter/feature_data_format.js +80 -80
- package/lib/formatter/fixtures/typescript.d.ts +2 -2
- package/lib/formatter/fixtures/typescript.js +5 -5
- package/lib/formatter/get_color_fns.d.ts +15 -15
- package/lib/formatter/get_color_fns.js +55 -55
- package/lib/formatter/helpers/duration_helpers.d.ts +2 -2
- package/lib/formatter/helpers/duration_helpers.js +8 -8
- package/lib/formatter/helpers/event_data_collector.d.ts +30 -30
- package/lib/formatter/helpers/event_data_collector.js +125 -125
- package/lib/formatter/helpers/formatters.d.ts +6 -6
- package/lib/formatter/helpers/formatters.js +46 -44
- package/lib/formatter/helpers/formatters.js.map +1 -1
- package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -5
- package/lib/formatter/helpers/gherkin_document_parser.js +65 -65
- package/lib/formatter/helpers/index.d.ts +10 -10
- package/lib/formatter/helpers/index.js +51 -51
- package/lib/formatter/helpers/issue_helpers.d.ts +19 -19
- package/lib/formatter/helpers/issue_helpers.js +58 -58
- package/lib/formatter/helpers/keyword_type.d.ts +11 -11
- package/lib/formatter/helpers/keyword_type.js +31 -31
- package/lib/formatter/helpers/location_helpers.d.ts +2 -2
- package/lib/formatter/helpers/location_helpers.js +16 -16
- package/lib/formatter/helpers/pickle_parser.d.ts +17 -17
- package/lib/formatter/helpers/pickle_parser.js +27 -27
- package/lib/formatter/helpers/report_generator.d.ts +96 -91
- package/lib/formatter/helpers/report_generator.js +247 -247
- package/lib/formatter/helpers/report_generator.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -2
- package/lib/formatter/helpers/step_argument_formatter.js +47 -47
- package/lib/formatter/helpers/summary_helpers.d.ts +9 -9
- package/lib/formatter/helpers/summary_helpers.js +95 -95
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +12 -12
- package/lib/formatter/helpers/test_case_attempt_formatter.js +113 -113
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +32 -32
- package/lib/formatter/helpers/test_case_attempt_parser.js +134 -134
- package/lib/formatter/helpers/upload_serivce.d.ts +9 -9
- package/lib/formatter/helpers/upload_serivce.js +46 -46
- package/lib/formatter/helpers/upload_serivce.js.map +1 -1
- package/lib/formatter/helpers/uploader.d.ts +8 -0
- package/lib/formatter/helpers/uploader.js +51 -0
- package/lib/formatter/helpers/uploader.js.map +1 -0
- package/lib/formatter/helpers/usage_helpers/index.d.ts +23 -23
- package/lib/formatter/helpers/usage_helpers/index.js +110 -110
- package/lib/formatter/html_formatter.d.ts +7 -7
- package/lib/formatter/html_formatter.js +29 -29
- package/lib/formatter/index.d.ts +53 -53
- package/lib/formatter/index.js +20 -20
- package/lib/formatter/json_formatter.d.ts +78 -78
- package/lib/formatter/json_formatter.js +229 -229
- package/lib/formatter/junit_formatter.d.ts +17 -17
- package/lib/formatter/junit_formatter.js +180 -180
- package/lib/formatter/message_formatter.d.ts +5 -5
- package/lib/formatter/message_formatter.js +14 -14
- package/lib/formatter/progress_bar_formatter.d.ts +18 -18
- package/lib/formatter/progress_bar_formatter.js +98 -98
- package/lib/formatter/progress_formatter.d.ts +9 -9
- package/lib/formatter/progress_formatter.js +58 -58
- package/lib/formatter/rerun_formatter.d.ts +13 -13
- package/lib/formatter/rerun_formatter.js +79 -79
- package/lib/formatter/snippets_formatter.d.ts +6 -6
- package/lib/formatter/snippets_formatter.js +60 -60
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +20 -20
- package/lib/formatter/step_definition_snippet_builder/index.js +45 -45
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.d.ts +7 -7
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +45 -45
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +16 -16
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js +10 -10
- package/lib/formatter/summary_formatter.d.ts +14 -14
- package/lib/formatter/summary_formatter.js +67 -67
- package/lib/formatter/usage_formatter.d.ts +6 -6
- package/lib/formatter/usage_formatter.js +97 -97
- package/lib/formatter/usage_json_formatter.d.ts +7 -7
- package/lib/formatter/usage_json_formatter.js +33 -33
- package/lib/index.d.ts +58 -58
- package/lib/index.js +108 -108
- package/lib/logger.d.ts +5 -5
- package/lib/logger.js +2 -2
- package/lib/models/data_table.d.ts +10 -10
- package/lib/models/data_table.js +45 -45
- package/lib/models/definition.d.ts +55 -55
- package/lib/models/definition.js +21 -21
- package/lib/models/gherkin_step_keyword.d.ts +1 -1
- package/lib/models/gherkin_step_keyword.js +2 -2
- package/lib/models/pickle_order.d.ts +1 -1
- package/lib/models/pickle_order.js +2 -2
- package/lib/models/step_definition.d.ts +11 -11
- package/lib/models/step_definition.js +36 -36
- package/lib/models/test_case_hook_definition.d.ts +10 -10
- package/lib/models/test_case_hook_definition.js +26 -26
- package/lib/models/test_run_hook_definition.d.ts +3 -3
- package/lib/models/test_run_hook_definition.js +9 -9
- package/lib/models/test_step_hook_definition.d.ts +9 -9
- package/lib/models/test_step_hook_definition.js +25 -25
- package/lib/pickle_filter.d.ts +42 -42
- package/lib/pickle_filter.js +98 -98
- package/lib/plugin/index.d.ts +2 -2
- package/lib/plugin/index.js +18 -18
- package/lib/plugin/plugin_manager.d.ts +13 -13
- package/lib/plugin/plugin_manager.js +35 -35
- package/lib/plugin/types.d.ts +14 -14
- package/lib/plugin/types.js +2 -2
- package/lib/publish/http_stream.d.ts +30 -30
- package/lib/publish/http_stream.js +111 -111
- package/lib/publish/index.d.ts +2 -2
- package/lib/publish/index.js +4 -4
- package/lib/publish/publish_plugin.d.ts +2 -2
- package/lib/publish/publish_plugin.js +47 -47
- package/lib/runtime/assemble_test_cases.d.ts +13 -13
- package/lib/runtime/assemble_test_cases.js +87 -87
- package/lib/runtime/attachment_manager/index.d.ts +33 -33
- package/lib/runtime/attachment_manager/index.js +118 -118
- package/lib/runtime/format_error.d.ts +2 -2
- package/lib/runtime/format_error.js +35 -35
- package/lib/runtime/helpers.d.ts +6 -6
- package/lib/runtime/helpers.js +100 -100
- package/lib/runtime/index.d.ts +40 -40
- package/lib/runtime/index.js +75 -75
- package/lib/runtime/parallel/command_types.d.ts +32 -32
- package/lib/runtime/parallel/command_types.js +2 -2
- package/lib/runtime/parallel/coordinator.d.ts +72 -72
- package/lib/runtime/parallel/coordinator.js +221 -221
- package/lib/runtime/parallel/run_worker.d.ts +1 -1
- package/lib/runtime/parallel/run_worker.js +28 -28
- package/lib/runtime/parallel/worker.d.ts +26 -26
- package/lib/runtime/parallel/worker.js +86 -86
- package/lib/runtime/run_test_run_hooks.d.ts +3 -3
- package/lib/runtime/run_test_run_hooks.js +27 -27
- package/lib/runtime/step_runner.d.ts +16 -16
- package/lib/runtime/step_runner.js +87 -87
- package/lib/runtime/stopwatch.d.ts +12 -12
- package/lib/runtime/stopwatch.js +33 -33
- package/lib/runtime/test_case_runner.d.ts +54 -54
- package/lib/runtime/test_case_runner.js +267 -267
- package/lib/step_arguments.d.ts +6 -6
- package/lib/step_arguments.js +18 -18
- package/lib/support_code_library_builder/build_parameter_type.d.ts +3 -3
- package/lib/support_code_library_builder/build_parameter_type.js +12 -12
- package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -3
- package/lib/support_code_library_builder/get_definition_line_and_uri.js +28 -28
- package/lib/support_code_library_builder/index.d.ts +74 -74
- package/lib/support_code_library_builder/index.js +296 -296
- package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -2
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js +15 -15
- package/lib/support_code_library_builder/sourced_parameter_type_registry.d.ts +7 -7
- package/lib/support_code_library_builder/sourced_parameter_type_registry.js +18 -18
- package/lib/support_code_library_builder/types.d.ts +88 -88
- package/lib/support_code_library_builder/types.js +2 -2
- package/lib/support_code_library_builder/validate_arguments.d.ts +12 -12
- package/lib/support_code_library_builder/validate_arguments.js +72 -72
- package/lib/support_code_library_builder/world.d.ts +18 -18
- package/lib/support_code_library_builder/world.js +10 -10
- package/lib/time.d.ts +18 -18
- package/lib/time.js +60 -60
- package/lib/try_require.d.ts +7 -7
- package/lib/try_require.js +22 -22
- package/lib/types/index.d.ts +4 -4
- package/lib/types/index.js +2 -2
- package/lib/uncaught_exception_manager.d.ts +7 -7
- package/lib/uncaught_exception_manager.js +11 -11
- package/lib/user_code_runner.d.ts +14 -14
- package/lib/user_code_runner.js +81 -81
- package/lib/value_checker.d.ts +3 -3
- package/lib/value_checker.js +18 -18
- package/lib/version.d.ts +1 -1
- package/lib/version.js +5 -5
- package/lib/version.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const _1 = __importDefault(require("."));
|
|
9
|
+
const value_checker_1 = require("../value_checker");
|
|
10
|
+
const report_generator_1 = __importDefault(require("./helpers/report_generator"));
|
|
11
|
+
const uploader_1 = __importDefault(require("./helpers/uploader"));
|
|
12
|
+
//User token
|
|
13
|
+
const TOKEN = process.env.TOKEN;
|
|
14
|
+
class BVTAnalysisFormatter extends _1.default {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
super(options);
|
|
17
|
+
this.reportGenerator = new report_generator_1.default();
|
|
18
|
+
this.uploader = new uploader_1.default(this.reportGenerator);
|
|
19
|
+
this.exit = false;
|
|
20
|
+
if (!TOKEN) {
|
|
21
|
+
throw new Error('TOKEN must be set');
|
|
22
|
+
}
|
|
23
|
+
options.eventBroadcaster.on('envelope', async (envelope) => {
|
|
24
|
+
this.reportGenerator.handleMessage(envelope);
|
|
25
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
26
|
+
const report = this.reportGenerator.getReport();
|
|
27
|
+
this.START = Date.now();
|
|
28
|
+
await this.analyzeReport(report);
|
|
29
|
+
this.exit = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async finished() {
|
|
34
|
+
await new Promise((resolve) => {
|
|
35
|
+
const checkInterval = setInterval(() => {
|
|
36
|
+
if (this.exit) {
|
|
37
|
+
clearInterval(checkInterval);
|
|
38
|
+
resolve(null);
|
|
39
|
+
}
|
|
40
|
+
}, 100); // check every 100ms
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async analyzeReport(report) {
|
|
44
|
+
if (report.result.status === 'PASSED') {
|
|
45
|
+
this.log('All tests passed. No need to retrain\n');
|
|
46
|
+
await this.uploader.uploadRun(report);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
//checking if the type of report.result is JsonResultFailed or not
|
|
50
|
+
if (!('startTime' in report.result) || !('endTime' in report.result)) {
|
|
51
|
+
this.log('Unknown error occured,not retraining\n');
|
|
52
|
+
await this.uploader.uploadRun(report);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const finalReport = await this.processTestCases(report);
|
|
56
|
+
await this.uploadFinalReport(finalReport);
|
|
57
|
+
}
|
|
58
|
+
async processTestCases(report) {
|
|
59
|
+
const finalResults = [];
|
|
60
|
+
const finalStepResults = [];
|
|
61
|
+
let isFailing = true;
|
|
62
|
+
for (const testCase of report.testCases) {
|
|
63
|
+
const { result, steps } = await this.processTestCase(testCase, report);
|
|
64
|
+
finalResults.push(result);
|
|
65
|
+
finalStepResults.push(steps);
|
|
66
|
+
//If any of the test case fails, the whole run is considered failed
|
|
67
|
+
if (result.status === 'FAILED') {
|
|
68
|
+
isFailing = false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
result: isFailing
|
|
73
|
+
? {
|
|
74
|
+
status: 'FIXED_BY_AI',
|
|
75
|
+
startTime: 'startTime' in report.result
|
|
76
|
+
? report.result.startTime
|
|
77
|
+
: this.START,
|
|
78
|
+
endTime: Date.now(),
|
|
79
|
+
}
|
|
80
|
+
: {
|
|
81
|
+
status: 'FAILED',
|
|
82
|
+
startTime: 'startTime' in report.result
|
|
83
|
+
? report.result.startTime
|
|
84
|
+
: Date.now(),
|
|
85
|
+
endTime: Date.now(),
|
|
86
|
+
},
|
|
87
|
+
testCases: report.testCases.map((testCase, i) => {
|
|
88
|
+
return {
|
|
89
|
+
...testCase,
|
|
90
|
+
result: finalResults[i],
|
|
91
|
+
steps: testCase.steps.map((step, j) => {
|
|
92
|
+
return {
|
|
93
|
+
...step,
|
|
94
|
+
result: finalStepResults[i][j],
|
|
95
|
+
};
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async processTestCase(testCase, report) {
|
|
102
|
+
if (testCase.result.status === 'PASSED') {
|
|
103
|
+
return {
|
|
104
|
+
result: testCase.result,
|
|
105
|
+
steps: testCase.steps.map((step) => {
|
|
106
|
+
return step.result.status === 'PASSED'
|
|
107
|
+
? step.result
|
|
108
|
+
: this.createStepResult(true, step, report);
|
|
109
|
+
}),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const failedTestCases = testCase.steps
|
|
113
|
+
.map((step, i) => (step.result.status !== 'PASSED' ? i : null))
|
|
114
|
+
.filter((i) => i !== null);
|
|
115
|
+
const success = await this.retrain(failedTestCases, testCase);
|
|
116
|
+
const finalResult = this.createFinalResult(success, testCase, report);
|
|
117
|
+
return {
|
|
118
|
+
result: finalResult,
|
|
119
|
+
steps: testCase.steps.map((step) => step.result.status === 'PASSED'
|
|
120
|
+
? { ...step.result }
|
|
121
|
+
: this.createStepResult(success, step, report)),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
createFinalResult(success, testCase, report) {
|
|
125
|
+
const status = success ? 'FIXED_BY_AI' : 'FAILED';
|
|
126
|
+
return {
|
|
127
|
+
status,
|
|
128
|
+
startTime: this.createStartTime(testCase, report),
|
|
129
|
+
endTime: Date.now(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
createStartTime(testCase, report) {
|
|
133
|
+
let startTime;
|
|
134
|
+
if ('startTime' in testCase.result) {
|
|
135
|
+
startTime = testCase.result.startTime;
|
|
136
|
+
}
|
|
137
|
+
else if ('startTime' in report.result) {
|
|
138
|
+
startTime = report.result.startTime;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
startTime = Date.now();
|
|
142
|
+
}
|
|
143
|
+
return startTime;
|
|
144
|
+
}
|
|
145
|
+
createStepResult(success, step, report) {
|
|
146
|
+
const status = success ? 'FIXED_BY_AI' : 'FAILED';
|
|
147
|
+
return {
|
|
148
|
+
status,
|
|
149
|
+
startTime: 'startTime' in step.result
|
|
150
|
+
? step.result.startTime
|
|
151
|
+
: 'startTime' in report.result
|
|
152
|
+
? report.result.startTime
|
|
153
|
+
: Date.now(),
|
|
154
|
+
endTime: Date.now(),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
async uploadFinalReport(finalReport) {
|
|
158
|
+
try {
|
|
159
|
+
await this.uploader.uploadRun(finalReport);
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
this.log('Error uploading report\n');
|
|
163
|
+
}
|
|
164
|
+
this.log(JSON.stringify(finalReport, null, 2));
|
|
165
|
+
}
|
|
166
|
+
async retrain(failedTestCases, testCase) {
|
|
167
|
+
const stepsToRetrain = testCase.steps.map((_, i) => i);
|
|
168
|
+
const success = await this.call_cucumber_client(stepsToRetrain, testCase);
|
|
169
|
+
return success;
|
|
170
|
+
}
|
|
171
|
+
async call_cucumber_client(stepsToRetrain, testCase) {
|
|
172
|
+
return new Promise((resolve, reject) => {
|
|
173
|
+
const cucumber_client_path = path_1.default.resolve(process.cwd(), 'node_modules', '@dev-blinq', 'cucumber_client', 'bin', 'client', 'cucumber.js');
|
|
174
|
+
const args = [
|
|
175
|
+
process.cwd(),
|
|
176
|
+
path_1.default.join(process.cwd(), testCase.uri),
|
|
177
|
+
`${testCase.scenarioName}`,
|
|
178
|
+
`${stepsToRetrain.join(',')}`,
|
|
179
|
+
];
|
|
180
|
+
if (process.env.BLINQ_ENV) {
|
|
181
|
+
args.push(`--env="${process.env.BLINQ_ENV}"`);
|
|
182
|
+
}
|
|
183
|
+
const cucumberClient = (0, child_process_1.spawn)('node', [cucumber_client_path, ...args], {
|
|
184
|
+
env: {
|
|
185
|
+
...process.env,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
cucumberClient.stdout.on('data', (data) => {
|
|
189
|
+
console.log(data.toString());
|
|
190
|
+
});
|
|
191
|
+
cucumberClient.stderr.on('data', (data) => {
|
|
192
|
+
console.error(data.toString());
|
|
193
|
+
});
|
|
194
|
+
cucumberClient.on('close', (code) => {
|
|
195
|
+
if (code === 0) {
|
|
196
|
+
resolve(true);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
this.log('Error retraining\n');
|
|
200
|
+
resolve(false);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.default = BVTAnalysisFormatter;
|
|
207
|
+
//# sourceMappingURL=bvt_analysis_formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bvt_analysis_formatter.js","sourceRoot":"","sources":["../../src/formatter/bvt_analysis_formatter.ts"],"names":[],"mappings":";;;;;AACA,iDAAqC;AACrC,gDAAuB;AACvB,yCAAgD;AAChD,oDAAgD;AAChD,kFAQmC;AACnC,kEAA+C;AAC/C,YAAY;AACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;AAC/B,MAAqB,oBAAqB,SAAQ,UAAS;IAKzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QALR,oBAAe,GAAG,IAAI,0BAAe,EAAE,CAAA;QACvC,aAAQ,GAAG,IAAI,kBAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACnD,SAAI,GAAG,KAAK,CAAA;QAIlB,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;SACrC;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,QAAkB,EAAE,EAAE;YACnE,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC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,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,GAAG,CAAC;gBACtC,GAAG,QAAQ,CAAC,YAAY,EAAE;gBAC1B,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;aAC9B,CAAA;YAED,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE;gBACzB,IAAI,CAAC,IAAI,CAAC,UAAU,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAA;aAC9C;YAED,MAAM,cAAc,GAAG,IAAA,qBAAK,EAAC,MAAM,EAAE,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,EAAE;gBACpE,GAAG,EAAE;oBACH,GAAG,OAAO,CAAC,GAAG;iBACf;aACF,CAAC,CAAA;YAEF,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBACxC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;YAC9B,CAAC,CAAC,CAAA;YAEF,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBACxC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;YAChC,CAAC,CAAC,CAAA;YAEF,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAClC,IAAI,IAAI,KAAK,CAAC,EAAE;oBACd,OAAO,CAAC,IAAI,CAAC,CAAA;iBACd;qBAAM;oBACL,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;oBAC9B,OAAO,CAAC,KAAK,CAAC,CAAA;iBACf;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA1OD,uCA0OC","sourcesContent":["import { Envelope } from '@cucumber/messages'\nimport { spawn } from 'child_process'\nimport path from 'path'\nimport Formatter, { IFormatterOptions } from '.'\nimport { doesHaveValue } from '../value_checker'\nimport ReportGenerator, {\n JsonFixedByAi,\n JsonReport,\n JsonResultFailed,\n JsonResultPassed,\n JsonStep,\n JsonTestProgress,\n JsonTestResult,\n} from './helpers/report_generator'\nimport ReportUploader from './helpers/uploader'\n//User token\nconst TOKEN = process.env.TOKEN\nexport default class BVTAnalysisFormatter extends Formatter {\n private reportGenerator = new ReportGenerator()\n private uploader = new ReportUploader(this.reportGenerator)\n private exit = false\n private START: number\n constructor(options: IFormatterOptions) {\n super(options)\n if (!TOKEN) {\n throw new Error('TOKEN must be set')\n }\n options.eventBroadcaster.on('envelope', async (envelope: Envelope) => {\n this.reportGenerator.handleMessage(envelope)\n if (doesHaveValue(envelope.testRunFinished)) {\n const report = this.reportGenerator.getReport()\n this.START = Date.now()\n await this.analyzeReport(report)\n this.exit = true\n }\n })\n }\n\n async finished(): Promise<any> {\n await new Promise((resolve) => {\n const checkInterval = setInterval(() => {\n if (this.exit) {\n clearInterval(checkInterval)\n resolve(null)\n }\n }, 100) // check every 100ms\n })\n }\n private async analyzeReport(report: JsonReport) {\n if (report.result.status === 'PASSED') {\n this.log('All tests passed. No need to retrain\\n')\n await this.uploader.uploadRun(report)\n return\n }\n //checking if the type of report.result is JsonResultFailed or not\n if (!('startTime' in report.result) || !('endTime' in report.result)) {\n this.log('Unknown error occured,not retraining\\n')\n await this.uploader.uploadRun(report)\n return\n }\n const finalReport = await this.processTestCases(report)\n await this.uploadFinalReport(finalReport)\n }\n private async processTestCases(report: JsonReport): Promise<JsonReport> {\n const finalResults: JsonTestResult[] = []\n const finalStepResults: JsonTestResult[][] = []\n let isFailing = true\n for (const testCase of report.testCases) {\n const { result, steps } = await this.processTestCase(testCase, report)\n finalResults.push(result)\n finalStepResults.push(steps)\n //If any of the test case fails, the whole run is considered failed\n if (result.status === 'FAILED') {\n isFailing = false\n }\n }\n return {\n result: isFailing\n ? {\n status: 'FIXED_BY_AI',\n startTime:\n 'startTime' in report.result\n ? report.result.startTime\n : this.START,\n endTime: Date.now(),\n }\n : {\n status: 'FAILED',\n startTime:\n 'startTime' in report.result\n ? report.result.startTime\n : Date.now(),\n endTime: Date.now(),\n },\n testCases: report.testCases.map((testCase, i) => {\n return {\n ...testCase,\n result: finalResults[i],\n steps: testCase.steps.map((step, j) => {\n return {\n ...step,\n result: finalStepResults[i][j],\n }\n }),\n }\n }),\n }\n }\n private async processTestCase(\n testCase: JsonTestProgress,\n report: JsonReport\n ): Promise<{\n result: JsonFixedByAi | JsonResultFailed | JsonResultPassed\n steps: (JsonFixedByAi | JsonResultFailed | JsonResultPassed)[]\n }> {\n if (testCase.result.status === 'PASSED') {\n return {\n result: testCase.result,\n steps: testCase.steps.map((step) => {\n return step.result.status === 'PASSED'\n ? step.result\n : this.createStepResult(true, step, report)\n }),\n }\n }\n const failedTestCases = testCase.steps\n .map((step, i) => (step.result.status !== 'PASSED' ? i : null))\n .filter((i) => i !== null)\n const success = await this.retrain(failedTestCases, testCase)\n const finalResult = this.createFinalResult(success, testCase, report)\n\n return {\n result: finalResult,\n steps: testCase.steps.map((step) =>\n step.result.status === 'PASSED'\n ? { ...step.result }\n : this.createStepResult(success, step, report)\n ),\n }\n }\n\n private createFinalResult(\n success: boolean,\n testCase: JsonTestProgress,\n report: JsonReport\n ): JsonFixedByAi | JsonResultFailed {\n const status = success ? 'FIXED_BY_AI' : 'FAILED'\n return {\n status,\n startTime: this.createStartTime(testCase, report),\n endTime: Date.now(),\n }\n }\n private createStartTime(\n testCase: JsonTestProgress,\n report: JsonReport\n ): number {\n let startTime\n\n if ('startTime' in testCase.result) {\n startTime = testCase.result.startTime\n } else if ('startTime' in report.result) {\n startTime = report.result.startTime\n } else {\n startTime = Date.now()\n }\n\n return startTime\n }\n private createStepResult(\n success: boolean,\n step: JsonStep,\n report: JsonReport\n ): JsonFixedByAi | JsonResultFailed {\n const status = success ? 'FIXED_BY_AI' : 'FAILED'\n return {\n status,\n startTime:\n 'startTime' in step.result\n ? step.result.startTime\n : 'startTime' in report.result\n ? report.result.startTime\n : Date.now(),\n endTime: Date.now(),\n }\n }\n private async uploadFinalReport(finalReport: JsonReport) {\n try {\n await this.uploader.uploadRun(finalReport)\n } catch (err) {\n this.log('Error uploading report\\n')\n }\n\n this.log(JSON.stringify(finalReport, null, 2))\n }\n private async retrain(failedTestCases: number[], testCase: JsonTestProgress) {\n const stepsToRetrain = testCase.steps.map((_, i) => i)\n const success = await this.call_cucumber_client(stepsToRetrain, testCase)\n return success\n }\n\n private async call_cucumber_client(\n stepsToRetrain: number[],\n testCase: JsonTestProgress\n ): Promise<boolean> {\n return new Promise((resolve, reject) => {\n const cucumber_client_path = path.resolve(\n process.cwd(),\n 'node_modules',\n '@dev-blinq',\n 'cucumber_client',\n 'bin',\n 'client',\n 'cucumber.js'\n )\n\n const args: string[] = [\n process.cwd(),\n path.join(process.cwd(), testCase.uri),\n `${testCase.scenarioName}`,\n `${stepsToRetrain.join(',')}`,\n ]\n\n if (process.env.BLINQ_ENV) {\n args.push(`--env=\"${process.env.BLINQ_ENV}\"`)\n }\n\n const cucumberClient = spawn('node', [cucumber_client_path, ...args], {\n env: {\n ...process.env,\n },\n })\n\n cucumberClient.stdout.on('data', (data) => {\n console.log(data.toString())\n })\n\n cucumberClient.stderr.on('data', (data) => {\n console.error(data.toString())\n })\n\n cucumberClient.on('close', (code) => {\n if (code === 0) {\n resolve(true)\n } else {\n this.log('Error retraining\\n')\n resolve(false)\n }\n })\n })\n }\n}\n"]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import Formatter, { IFormatterOptions } from '.';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
private
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
uploadRun(report: JsonReport): Promise<void>;
|
|
8
|
-
createZip(reportFolder: string | null, report: JsonReport): Promise<string>;
|
|
9
|
-
}
|
|
1
|
+
import Formatter, { IFormatterOptions } from '.';
|
|
2
|
+
export default class BVTFormatter extends Formatter {
|
|
3
|
+
private reportGenerator;
|
|
4
|
+
private uploader;
|
|
5
|
+
constructor(options: IFormatterOptions);
|
|
6
|
+
}
|
|
@@ -1,63 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const _1 = __importDefault(require("."));
|
|
7
|
-
const report_generator_1 = __importDefault(require("./helpers/report_generator"));
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (envelope.testRunFinished) {
|
|
26
|
-
const report = this.reportGenerator.getReport();
|
|
27
|
-
// this.log(JSON.stringify(report, null, 2))
|
|
28
|
-
await this.uploadRun(report);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
async uploadRun(report) {
|
|
33
|
-
const runDoc = await this.uploadService.createRunDocument("test");
|
|
34
|
-
const runDocId = runDoc._id;
|
|
35
|
-
const formData = new form_data_1.default();
|
|
36
|
-
const reportFolder = this.reportGenerator.reportFolder;
|
|
37
|
-
if (!fs_1.default.existsSync(reportFolder)) {
|
|
38
|
-
fs_1.default.mkdirSync(reportFolder);
|
|
39
|
-
}
|
|
40
|
-
const zipPath = await this.createZip(reportFolder, report);
|
|
41
|
-
console.log(zipPath);
|
|
42
|
-
formData.append(runDocId, fs_1.default.readFileSync(zipPath), "report.zip");
|
|
43
|
-
await this.uploadService.upload(formData);
|
|
44
|
-
process.exit(0);
|
|
45
|
-
}
|
|
46
|
-
async createZip(reportFolder, report) {
|
|
47
|
-
const zip = new jszip_1.default();
|
|
48
|
-
zip.file("report.json", JSON.stringify(report, null, 2));
|
|
49
|
-
const folder = zip.folder("screenshots");
|
|
50
|
-
const files = fs_1.default.readdirSync(path_1.default.join(reportFolder, 'screenshots'));
|
|
51
|
-
files.forEach((file) => {
|
|
52
|
-
folder.file(file, fs_1.default.readFileSync(path_1.default.join(reportFolder, file)));
|
|
53
|
-
});
|
|
54
|
-
const zipBuffer = await zip.generateAsync({ type: "nodebuffer" });
|
|
55
|
-
// save zip file
|
|
56
|
-
const zipPath = path_1.default.join(reportFolder, 'report.zip');
|
|
57
|
-
fs_1.default.writeFileSync(zipPath, zipBuffer);
|
|
58
|
-
fs_1.default.writeFileSync(path_1.default.join(reportFolder, 'report.json'), JSON.stringify(report, null, 2));
|
|
59
|
-
return zipPath;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.default = BVTFormatter;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const _1 = __importDefault(require("."));
|
|
7
|
+
const report_generator_1 = __importDefault(require("./helpers/report_generator"));
|
|
8
|
+
const uploader_1 = __importDefault(require("./helpers/uploader"));
|
|
9
|
+
class BVTFormatter extends _1.default {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super(options);
|
|
12
|
+
this.reportGenerator = new report_generator_1.default();
|
|
13
|
+
this.uploader = new uploader_1.default(this.reportGenerator);
|
|
14
|
+
options.eventBroadcaster.on('envelope', async (envelope) => {
|
|
15
|
+
this.reportGenerator.handleMessage(envelope);
|
|
16
|
+
if (envelope.testRunFinished) {
|
|
17
|
+
const report = this.reportGenerator.getReport();
|
|
18
|
+
// this.log(JSON.stringify(report, null, 2))
|
|
19
|
+
await this.uploader.uploadRun(report);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = BVTFormatter;
|
|
63
25
|
//# sourceMappingURL=bvt_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bvt_formatter.js","sourceRoot":"","sources":["../../src/formatter/bvt_formatter.ts"],"names":[],"mappings":";;;;;AACA,yCAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"bvt_formatter.js","sourceRoot":"","sources":["../../src/formatter/bvt_formatter.ts"],"names":[],"mappings":";;;;;AACA,yCAAgD;AAChD,kFAAwD;AACxD,kEAA+C;AAE/C,MAAqB,YAAa,SAAQ,UAAS;IAGjD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QAHR,oBAAe,GAAG,IAAI,0BAAe,EAAE,CAAA;QACvC,aAAQ,GAAG,IAAI,kBAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QAGzD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CACzB,UAAU,EACV,KAAK,EAAE,QAA2B,EAAE,EAAE;YACpC,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;YAC5C,IAAI,QAAQ,CAAC,eAAe,EAAE;gBAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAA;gBAC/C,4CAA4C;gBAE5C,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;aACtC;QACH,CAAC,CACF,CAAA;IACH,CAAC;CACF;AAlBD,+BAkBC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport Formatter, { IFormatterOptions } from '.'\nimport ReportGenerator from './helpers/report_generator'\nimport ReportUploader from './helpers/uploader'\n\nexport default class BVTFormatter extends Formatter {\n private reportGenerator = new ReportGenerator()\n private uploader = new ReportUploader(this.reportGenerator)\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: messages.Envelope) => {\n this.reportGenerator.handleMessage(envelope)\n if (envelope.testRunFinished) {\n const report = this.reportGenerator.getReport()\n // this.log(JSON.stringify(report, null, 2))\n\n await this.uploader.uploadRun(report)\n }\n }\n )\n }\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
declare const generateTestData: (featureFileContent: string, vars?: any, fakeData?: {
|
|
2
|
-
var: string;
|
|
3
|
-
fake: string;
|
|
4
|
-
}[]) => {
|
|
5
|
-
newContent: string;
|
|
6
|
-
variables: any;
|
|
7
|
-
otherFakeData: {
|
|
8
|
-
var: string;
|
|
9
|
-
fake: string;
|
|
10
|
-
}[];
|
|
11
|
-
changed: boolean;
|
|
12
|
-
fakeIndex: number;
|
|
13
|
-
};
|
|
14
|
-
export { generateTestData };
|
|
1
|
+
declare const generateTestData: (featureFileContent: string, vars?: any, fakeData?: {
|
|
2
|
+
var: string;
|
|
3
|
+
fake: string;
|
|
4
|
+
}[]) => {
|
|
5
|
+
newContent: string;
|
|
6
|
+
variables: any;
|
|
7
|
+
otherFakeData: {
|
|
8
|
+
var: string;
|
|
9
|
+
fake: string;
|
|
10
|
+
}[];
|
|
11
|
+
changed: boolean;
|
|
12
|
+
fakeIndex: number;
|
|
13
|
+
};
|
|
14
|
+
export { generateTestData };
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateTestData = void 0;
|
|
4
|
-
const faker_1 = require("@faker-js/faker");
|
|
5
|
-
const generateTestData = (featureFileContent, vars, fakeData) => {
|
|
6
|
-
const regexp = /\{\{([^}]+)\}\}/g;
|
|
7
|
-
const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g;
|
|
8
|
-
let newContent = featureFileContent;
|
|
9
|
-
let match;
|
|
10
|
-
const matches = [];
|
|
11
|
-
// collect all matches
|
|
12
|
-
while ((match = regexp.exec(featureFileContent)) !== null) {
|
|
13
|
-
matches.push(match);
|
|
14
|
-
}
|
|
15
|
-
// find all variables in the matches
|
|
16
|
-
const variables = { ...vars };
|
|
17
|
-
if (Object.keys(variables).length > 0) {
|
|
18
|
-
for (let i = 0; i < matches.length; i++) {
|
|
19
|
-
const _match = matches[i];
|
|
20
|
-
const value = _match[1];
|
|
21
|
-
const variableMatch = variableRegex.exec(value);
|
|
22
|
-
if (variableMatch !== null) {
|
|
23
|
-
newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
for (const key in variables) {
|
|
27
|
-
const variable = variables[key];
|
|
28
|
-
newContent = newContent.replaceAll(`{{${variable.var}}}`, variable.fake);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
for (let i = 0; i < matches.length; i++) {
|
|
33
|
-
const _match = matches[i];
|
|
34
|
-
const value = _match[1];
|
|
35
|
-
const variableMatch = variableRegex.exec(value);
|
|
36
|
-
if (variableMatch !== null) {
|
|
37
|
-
variables[variableMatch[1]] = {
|
|
38
|
-
var: variableMatch[1],
|
|
39
|
-
toFake: variableMatch[2],
|
|
40
|
-
};
|
|
41
|
-
newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
for (const key in variables) {
|
|
45
|
-
const variable = variables[key];
|
|
46
|
-
const fake = faker_1.faker.helpers.fake(`{{${variable.toFake}}}`);
|
|
47
|
-
newContent = newContent.replaceAll(`{{${variable.var}}}`, fake);
|
|
48
|
-
variables[key].fake = fake;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
regexp.lastIndex = 0;
|
|
52
|
-
const otherFakeData = [];
|
|
53
|
-
const duplicateFakeData = fakeData ? [...fakeData] : [];
|
|
54
|
-
let fakeIndex = 0;
|
|
55
|
-
while ((match = regexp.exec(featureFileContent)) !== null) {
|
|
56
|
-
try {
|
|
57
|
-
const fake = duplicateFakeData && duplicateFakeData.length > 0
|
|
58
|
-
? duplicateFakeData.shift().fake
|
|
59
|
-
: faker_1.faker.helpers.fake(match[0]);
|
|
60
|
-
otherFakeData.push({
|
|
61
|
-
var: match[0],
|
|
62
|
-
fake,
|
|
63
|
-
});
|
|
64
|
-
newContent = newContent.replace(match[0], fake);
|
|
65
|
-
fakeIndex++;
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
// eslint-disable-next-line no-console
|
|
69
|
-
console.log('unknown faker variable:' + match[0]);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
newContent,
|
|
74
|
-
variables,
|
|
75
|
-
otherFakeData,
|
|
76
|
-
changed: newContent !== featureFileContent,
|
|
77
|
-
fakeIndex,
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
exports.generateTestData = generateTestData;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateTestData = void 0;
|
|
4
|
+
const faker_1 = require("@faker-js/faker");
|
|
5
|
+
const generateTestData = (featureFileContent, vars, fakeData) => {
|
|
6
|
+
const regexp = /\{\{([^}]+)\}\}/g;
|
|
7
|
+
const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g;
|
|
8
|
+
let newContent = featureFileContent;
|
|
9
|
+
let match;
|
|
10
|
+
const matches = [];
|
|
11
|
+
// collect all matches
|
|
12
|
+
while ((match = regexp.exec(featureFileContent)) !== null) {
|
|
13
|
+
matches.push(match);
|
|
14
|
+
}
|
|
15
|
+
// find all variables in the matches
|
|
16
|
+
const variables = { ...vars };
|
|
17
|
+
if (Object.keys(variables).length > 0) {
|
|
18
|
+
for (let i = 0; i < matches.length; i++) {
|
|
19
|
+
const _match = matches[i];
|
|
20
|
+
const value = _match[1];
|
|
21
|
+
const variableMatch = variableRegex.exec(value);
|
|
22
|
+
if (variableMatch !== null) {
|
|
23
|
+
newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
for (const key in variables) {
|
|
27
|
+
const variable = variables[key];
|
|
28
|
+
newContent = newContent.replaceAll(`{{${variable.var}}}`, variable.fake);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
for (let i = 0; i < matches.length; i++) {
|
|
33
|
+
const _match = matches[i];
|
|
34
|
+
const value = _match[1];
|
|
35
|
+
const variableMatch = variableRegex.exec(value);
|
|
36
|
+
if (variableMatch !== null) {
|
|
37
|
+
variables[variableMatch[1]] = {
|
|
38
|
+
var: variableMatch[1],
|
|
39
|
+
toFake: variableMatch[2],
|
|
40
|
+
};
|
|
41
|
+
newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
for (const key in variables) {
|
|
45
|
+
const variable = variables[key];
|
|
46
|
+
const fake = faker_1.faker.helpers.fake(`{{${variable.toFake}}}`);
|
|
47
|
+
newContent = newContent.replaceAll(`{{${variable.var}}}`, fake);
|
|
48
|
+
variables[key].fake = fake;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
regexp.lastIndex = 0;
|
|
52
|
+
const otherFakeData = [];
|
|
53
|
+
const duplicateFakeData = fakeData ? [...fakeData] : [];
|
|
54
|
+
let fakeIndex = 0;
|
|
55
|
+
while ((match = regexp.exec(featureFileContent)) !== null) {
|
|
56
|
+
try {
|
|
57
|
+
const fake = duplicateFakeData && duplicateFakeData.length > 0
|
|
58
|
+
? duplicateFakeData.shift().fake
|
|
59
|
+
: faker_1.faker.helpers.fake(match[0]);
|
|
60
|
+
otherFakeData.push({
|
|
61
|
+
var: match[0],
|
|
62
|
+
fake,
|
|
63
|
+
});
|
|
64
|
+
newContent = newContent.replace(match[0], fake);
|
|
65
|
+
fakeIndex++;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
// eslint-disable-next-line no-console
|
|
69
|
+
console.log('unknown faker variable:' + match[0]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
newContent,
|
|
74
|
+
variables,
|
|
75
|
+
otherFakeData,
|
|
76
|
+
changed: newContent !== featureFileContent,
|
|
77
|
+
fakeIndex,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
exports.generateTestData = generateTestData;
|
|
81
81
|
//# sourceMappingURL=feature_data_format.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default class Formatter {
|
|
2
|
-
}
|
|
1
|
+
export default class Formatter {
|
|
2
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class Formatter {
|
|
4
|
-
}
|
|
5
|
-
exports.default = Formatter;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Formatter {
|
|
4
|
+
}
|
|
5
|
+
exports.default = Formatter;
|
|
6
6
|
//# sourceMappingURL=typescript.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { TestStepResultStatus } from '@cucumber/messages';
|
|
4
|
-
import { Writable } from 'stream';
|
|
5
|
-
export type IColorFn = (text: string) => string;
|
|
6
|
-
export interface IColorFns {
|
|
7
|
-
forStatus: (status: TestStepResultStatus) => IColorFn;
|
|
8
|
-
location: IColorFn;
|
|
9
|
-
tag: IColorFn;
|
|
10
|
-
diffAdded: IColorFn;
|
|
11
|
-
diffRemoved: IColorFn;
|
|
12
|
-
errorMessage: IColorFn;
|
|
13
|
-
errorStack: IColorFn;
|
|
14
|
-
}
|
|
15
|
-
export default function getColorFns(stream: Writable, env: NodeJS.ProcessEnv, enabled?: boolean): IColorFns;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { TestStepResultStatus } from '@cucumber/messages';
|
|
4
|
+
import { Writable } from 'stream';
|
|
5
|
+
export type IColorFn = (text: string) => string;
|
|
6
|
+
export interface IColorFns {
|
|
7
|
+
forStatus: (status: TestStepResultStatus) => IColorFn;
|
|
8
|
+
location: IColorFn;
|
|
9
|
+
tag: IColorFn;
|
|
10
|
+
diffAdded: IColorFn;
|
|
11
|
+
diffRemoved: IColorFn;
|
|
12
|
+
errorMessage: IColorFn;
|
|
13
|
+
errorStack: IColorFn;
|
|
14
|
+
}
|
|
15
|
+
export default function getColorFns(stream: Writable, env: NodeJS.ProcessEnv, enabled?: boolean): IColorFns;
|