@dev-blinq/cucumber-js 1.0.19 → 1.0.20

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.
@@ -11,9 +11,6 @@ export default class BVTAnalysisFormatter extends Formatter {
11
11
  private analyzeReport;
12
12
  private processTestCases;
13
13
  private processTestCase;
14
- private createFinalResult;
15
- private createStartTime;
16
- private createStepResult;
17
14
  private uploadFinalReport;
18
15
  private retrain;
19
16
  private call_cucumber_client;
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -9,6 +32,8 @@ const _1 = __importDefault(require("."));
9
32
  const value_checker_1 = require("../value_checker");
10
33
  const report_generator_1 = __importDefault(require("./helpers/report_generator"));
11
34
  const uploader_1 = __importDefault(require("./helpers/uploader"));
35
+ // import { temporaryFileTask } from 'tempy'
36
+ const fs_1 = require("fs");
12
37
  //User token
13
38
  const TOKEN = process.env.TOKEN;
14
39
  class BVTAnalysisFormatter extends _1.default {
@@ -66,7 +91,7 @@ class BVTAnalysisFormatter extends _1.default {
66
91
  process.exit(1);
67
92
  }
68
93
  //checking if the type of report.result is JsonResultFailed or not
69
- this.log('Some tests failed,starting the retraining...\n');
94
+ this.log('Some tests failed, starting the retraining...\n');
70
95
  if (!('startTime' in report.result) || !('endTime' in report.result)) {
71
96
  this.log('Unknown error occured,not retraining\n');
72
97
  await this.uploader.uploadRun(report, this.runName);
@@ -82,104 +107,140 @@ class BVTAnalysisFormatter extends _1.default {
82
107
  }
83
108
  }
84
109
  async processTestCases(report) {
85
- const finalResults = [];
86
- const finalStepResults = [];
87
- let isFailing = true;
110
+ // const finalResults: JsonTestResult[] = []
111
+ // const finalStepResults: JsonTestResult[][] = []
112
+ // let isFailing = true
113
+ const finalTestCases = [];
88
114
  for (const testCase of report.testCases) {
89
- const { result, steps } = await this.processTestCase(testCase, report);
90
- finalResults.push(result);
91
- finalStepResults.push(steps);
92
- //If any of the test case fails, the whole run is considered failed
93
- if (result.status === 'FAILED') {
94
- isFailing = false;
95
- }
115
+ const modifiedTestCase = await this.processTestCase(testCase, report);
116
+ // finalResults.push(result)
117
+ // finalStepResults.push(steps)
118
+ // //If any of the test case fails, the whole run is considered failed
119
+ // if (result.status === 'FAILED') {
120
+ // isFailing = false
121
+ // }
122
+ finalTestCases.push(modifiedTestCase);
96
123
  }
124
+ const finalResult = finalTestCases.some((tc) => tc.result.status !== 'PASSED')
125
+ ? report.result
126
+ : {
127
+ ...report.result,
128
+ status: 'PASSED',
129
+ };
97
130
  return {
98
- result: isFailing
99
- ? {
100
- status: 'FIXED_BY_AI',
101
- startTime: 'startTime' in report.result
102
- ? report.result.startTime
103
- : this.START,
104
- endTime: Date.now(),
105
- }
106
- : {
107
- status: 'FAILED',
108
- startTime: 'startTime' in report.result
109
- ? report.result.startTime
110
- : Date.now(),
111
- endTime: Date.now(),
112
- },
113
- testCases: report.testCases.map((testCase, i) => {
114
- return {
115
- ...testCase,
116
- result: finalResults[i],
117
- steps: testCase.steps.map((step, j) => {
118
- return {
119
- ...step,
120
- result: finalStepResults[i][j],
121
- };
122
- }),
123
- };
124
- }),
131
+ result: finalResult,
132
+ testCases: finalTestCases,
125
133
  };
134
+ // return {
135
+ // result: isFailing
136
+ // ? {
137
+ // status: 'FIXED_BY_AI',
138
+ // startTime:
139
+ // 'startTime' in report.result
140
+ // ? report.result.startTime
141
+ // : this.START,
142
+ // endTime: Date.now(),
143
+ // }
144
+ // : {
145
+ // status: 'FAILED',
146
+ // startTime:
147
+ // 'startTime' in report.result
148
+ // ? report.result.startTime
149
+ // : Date.now(),
150
+ // endTime: Date.now(),
151
+ // },
152
+ // testCases: report.testCases.map((testCase, i) => {
153
+ // return {
154
+ // ...testCase,
155
+ // result: finalResults[i],
156
+ // steps: testCase.steps.map((step, j) => {
157
+ // return {
158
+ // ...step,
159
+ // result: finalStepResults[i][j],
160
+ // }
161
+ // }),
162
+ // }
163
+ // }),
164
+ // }
126
165
  }
127
166
  async processTestCase(testCase, report) {
128
167
  if (testCase.result.status === 'PASSED') {
129
- return {
130
- result: testCase.result,
131
- steps: testCase.steps.map((step) => {
132
- return step.result.status === 'PASSED'
133
- ? step.result
134
- : this.createStepResult(true, step, report);
135
- }),
136
- };
168
+ return testCase;
137
169
  }
138
- const failedTestCases = testCase.steps
170
+ const failedTestSteps = testCase.steps
139
171
  .map((step, i) => (step.result.status !== 'PASSED' ? i : null))
140
172
  .filter((i) => i !== null);
141
- const success = await this.retrain(failedTestCases, testCase);
142
- const finalResult = this.createFinalResult(success, testCase, report);
143
- return {
144
- result: finalResult,
145
- steps: testCase.steps.map((step) => step.result.status === 'PASSED'
146
- ? { ...step.result }
147
- : this.createStepResult(success, step, report)),
148
- };
149
- }
150
- createFinalResult(success, testCase, report) {
151
- const status = success ? 'FIXED_BY_AI' : 'FAILED';
152
- return {
153
- status,
154
- startTime: this.createStartTime(testCase, report),
155
- endTime: Date.now(),
156
- };
157
- }
158
- createStartTime(testCase, report) {
159
- let startTime;
160
- if ('startTime' in testCase.result) {
161
- startTime = testCase.result.startTime;
162
- }
163
- else if ('startTime' in report.result) {
164
- startTime = report.result.startTime;
165
- }
166
- else {
167
- startTime = Date.now();
173
+ const retrainStats = await this.retrain(failedTestSteps, testCase);
174
+ // if(newTestCase.result.status === "PASSED") {
175
+ // newTestCase.result.status = "FIXED"
176
+ // }
177
+ if (!retrainStats) {
178
+ return testCase;
168
179
  }
169
- return startTime;
170
- }
171
- createStepResult(success, step, report) {
172
- const status = success ? 'FIXED_BY_AI' : 'FAILED';
180
+ // const newResult: JsonTestResult =
181
+ // retrainStats.result.status === 'PASSED'
182
+ // ? {
183
+ // ...retrainStats.result,
184
+ // status: 'FIXED_BY_AI',
185
+ // }
186
+ // : retrainStats.result
187
+ // const finalResult = this.createFinalResult(success, testCase, report)
173
188
  return {
174
- status,
175
- startTime: 'startTime' in step.result
176
- ? step.result.startTime
177
- : 'startTime' in report.result
178
- ? report.result.startTime
179
- : Date.now(),
180
- endTime: Date.now(),
189
+ ...testCase,
190
+ retrainStats,
181
191
  };
192
+ // return {
193
+ // result: finalResult,
194
+ // steps: testCase.steps.map((step) =>
195
+ // step.result.status === 'PASSED'
196
+ // ? { ...step.result }
197
+ // : this.createStepResult(success, step, report)
198
+ // ),
199
+ // }
182
200
  }
201
+ // private createFinalResult(
202
+ // success: boolean,
203
+ // testCase: JsonTestProgress,
204
+ // report: JsonReport
205
+ // ): JsonFixedByAi | JsonResultFailed {
206
+ // const status = success ? 'FIXED_BY_AI' : 'FAILED'
207
+ // return {
208
+ // status,
209
+ // startTime: this.createStartTime(testCase, report),
210
+ // endTime: Date.now(),
211
+ // }
212
+ // }
213
+ // private createStartTime(
214
+ // testCase: JsonTestProgress,
215
+ // report: JsonReport
216
+ // ): number {
217
+ // let startTime
218
+ // if ('startTime' in testCase.result) {
219
+ // startTime = testCase.result.startTime
220
+ // } else if ('startTime' in report.result) {
221
+ // startTime = report.result.startTime
222
+ // } else {
223
+ // startTime = Date.now()
224
+ // }
225
+ // return startTime
226
+ // }
227
+ // private createStepResult(
228
+ // success: boolean,
229
+ // step: JsonStep,
230
+ // report: JsonReport
231
+ // ): JsonFixedByAi | JsonResultFailed {
232
+ // const status = success ? 'FIXED_BY_AI' : 'FAILED'
233
+ // return {
234
+ // status,
235
+ // startTime:
236
+ // 'startTime' in step.result
237
+ // ? step.result.startTime
238
+ // : 'startTime' in report.result
239
+ // ? report.result.startTime
240
+ // : Date.now(),
241
+ // endTime: Date.now(),
242
+ // }
243
+ // }
183
244
  async uploadFinalReport(finalReport) {
184
245
  let success = true;
185
246
  try {
@@ -197,8 +258,9 @@ class BVTAnalysisFormatter extends _1.default {
197
258
  }
198
259
  async retrain(failedTestCases, testCase) {
199
260
  const stepsToRetrain = testCase.steps.map((_, i) => i);
200
- const success = await this.call_cucumber_client(stepsToRetrain, testCase);
201
- return success;
261
+ return await this.call_cucumber_client(stepsToRetrain, testCase);
262
+ // const success = await this.call_cucumber_client(stepsToRetrain, testCase)
263
+ // return success
202
264
  }
203
265
  async call_cucumber_client(stepsToRetrain, testCase) {
204
266
  return new Promise((resolve, reject) => {
@@ -212,25 +274,33 @@ class BVTAnalysisFormatter extends _1.default {
212
274
  if (process.env.BLINQ_ENV) {
213
275
  args.push(`--env=${process.env.BLINQ_ENV}`);
214
276
  }
215
- const cucumberClient = (0, child_process_1.spawn)('node', [cucumber_client_path, ...args], {
216
- env: {
217
- ...process.env,
218
- },
219
- });
220
- cucumberClient.stdout.on('data', (data) => {
221
- console.log(data.toString());
222
- });
223
- cucumberClient.stderr.on('data', (data) => {
224
- console.error(data.toString());
225
- });
226
- cucumberClient.on('close', (code) => {
227
- if (code === 0) {
228
- resolve(true);
229
- }
230
- else {
231
- this.log('Error retraining\n');
232
- resolve(false);
233
- }
277
+ // const temporaryFileTask = await import('tempy')
278
+ Promise.resolve().then(() => __importStar(require('tempy'))).then(({ temporaryFileTask }) => {
279
+ temporaryFileTask((tempFile) => {
280
+ args.push(`--temp-file=${tempFile}`);
281
+ const cucumberClient = (0, child_process_1.spawn)('node', [cucumber_client_path, ...args], {
282
+ env: {
283
+ ...process.env,
284
+ },
285
+ });
286
+ cucumberClient.stdout.on('data', (data) => {
287
+ console.log(data.toString());
288
+ });
289
+ cucumberClient.stderr.on('data', (data) => {
290
+ console.error(data.toString());
291
+ });
292
+ cucumberClient.on('close', (code) => {
293
+ if (code === 0) {
294
+ const reportData = (0, fs_1.readFileSync)(tempFile, 'utf-8');
295
+ const retrainStats = JSON.parse(reportData);
296
+ resolve(retrainStats);
297
+ }
298
+ else {
299
+ this.log('Error retraining\n');
300
+ resolve(null);
301
+ }
302
+ });
303
+ });
234
304
  });
235
305
  });
236
306
  }
@@ -1 +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;AAQ/B,MAAqB,oBAAqB,SAAQ,UAAS;IAMzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QANR,oBAAe,GAAG,IAAI,0BAAe,EAAE,CAAA;QACvC,aAAQ,GAAG,IAAI,kBAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACnD,SAAI,GAAG,KAAK,CAAA;QAKlB,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,UAAU,EAAE;YACtD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;SACrC;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CACzB,UAAU,EACV,KAAK,EAAE,QAAiC,EAAE,EAAE;Y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import { Envelope, Meta } 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\ninterface MetaMessage extends Meta {\n runName: string\n}\n\ninterface EnvelopeWithMetaMessage extends Envelope {\n meta: MetaMessage\n}\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 private runName: string\n constructor(options: IFormatterOptions) {\n super(options)\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage) => {\n this.reportGenerator.handleMessage(envelope)\n if (\n doesHaveValue(envelope.meta) &&\n doesHaveValue(envelope.meta.runName)\n ) {\n this.runName = envelope.meta.runName\n }\n if (doesHaveValue(envelope.testRunFinished)) {\n const report = this.reportGenerator.getReport()\n this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport(report)\n } else {\n await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private async uploadReport(report: JsonReport) {\n const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful && report.result.status !== 'FAILED') {\n process.exit(0)\n }\n process.exit(1)\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 const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful) {\n process.exit(0)\n }\n\n process.exit(1)\n }\n //checking if the type of report.result is JsonResultFailed or not\n this.log('Some tests failed,starting the retraining...\\n')\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, this.runName)\n return\n }\n const finalReport = await this.processTestCases(report)\n const uploadSuccessful = await this.uploadFinalReport(finalReport)\n if (finalReport.result.status !== 'FAILED' && uploadSuccessful) {\n process.exit(0)\n } else {\n process.exit(1)\n }\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 let success = true\n try {\n await this.uploader.uploadRun(finalReport, this.runName)\n } catch (err) {\n this.log('Error uploading report\\n')\n if ('stack' in err) {\n this.log(err.stack)\n }\n success = false\n }\n\n this.log(JSON.stringify(finalReport, null, 2))\n return success\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
+ {"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,kFASmC;AACnC,kEAA+C;AAC/C,4CAA4C;AAC5C,2BAAiC;AACjC,YAAY;AACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;AAQ/B,MAAqB,oBAAqB,SAAQ,UAAS;IAMzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QANR,oBAAe,GAAG,IAAI,0BAAe,EAAE,CAAA;QACvC,aAAQ,GAAG,IAAI,kBAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACnD,SAAI,GAAG,KAAK,CAAA;QAKlB,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,UAAU,EAAE;YACtD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;SACrC;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CACzB,UAAU,EACV,KAAK,EAAE,QAAiC,EAAE,EAAE;YAC1C,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;YAC5C,IACE,IAAA,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,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAiB,CAAA;4BAC3D,OAAO,CAAC,YAAY,CAAC,CAAA;yBACtB;6BAAM;4BACL,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;4BAC9B,OAAO,CAAC,IAAI,CAAC,CAAA;yBACd;oBACH,CAAC,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAnTD,uCAmTC","sourcesContent":["import { Envelope, Meta } 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 RetrainStats,\n} from './helpers/report_generator'\nimport ReportUploader from './helpers/uploader'\n// import { temporaryFileTask } from 'tempy'\nimport { readFileSync } from 'fs'\n//User token\nconst TOKEN = process.env.TOKEN\ninterface MetaMessage extends Meta {\n runName: string\n}\n\ninterface EnvelopeWithMetaMessage extends Envelope {\n meta: MetaMessage\n}\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 private runName: string\n constructor(options: IFormatterOptions) {\n super(options)\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage) => {\n this.reportGenerator.handleMessage(envelope)\n if (\n doesHaveValue(envelope.meta) &&\n doesHaveValue(envelope.meta.runName)\n ) {\n this.runName = envelope.meta.runName\n }\n if (doesHaveValue(envelope.testRunFinished)) {\n const report = this.reportGenerator.getReport()\n this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport(report)\n } else {\n await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private async uploadReport(report: JsonReport) {\n const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful && report.result.status !== 'FAILED') {\n process.exit(0)\n }\n process.exit(1)\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 const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful) {\n process.exit(0)\n }\n\n process.exit(1)\n }\n //checking if the type of report.result is JsonResultFailed or not\n this.log('Some tests failed, starting the retraining...\\n')\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, this.runName)\n return\n }\n const finalReport = await this.processTestCases(report)\n const uploadSuccessful = await this.uploadFinalReport(finalReport)\n if (finalReport.result.status !== 'FAILED' && uploadSuccessful) {\n process.exit(0)\n } else {\n process.exit(1)\n }\n }\n private async processTestCases(report: JsonReport): Promise<JsonReport> {\n // const finalResults: JsonTestResult[] = []\n // const finalStepResults: JsonTestResult[][] = []\n // let isFailing = true\n const finalTestCases = []\n for (const testCase of report.testCases) {\n const modifiedTestCase = 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 finalTestCases.push(modifiedTestCase)\n }\n const finalResult = finalTestCases.some(\n (tc) => tc.result.status !== 'PASSED'\n )\n ? report.result\n : ({\n ...report.result,\n status: 'PASSED',\n } as JsonTestResult)\n return {\n result: finalResult,\n testCases: finalTestCases,\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<JsonTestProgress> {\n if (testCase.result.status === 'PASSED') {\n return testCase\n }\n const failedTestSteps = testCase.steps\n .map((step, i) => (step.result.status !== 'PASSED' ? i : null))\n .filter((i) => i !== null)\n const retrainStats = await this.retrain(failedTestSteps, testCase)\n // if(newTestCase.result.status === \"PASSED\") {\n // newTestCase.result.status = \"FIXED\"\n // }\n if (!retrainStats) {\n return testCase\n }\n // const newResult: JsonTestResult =\n // retrainStats.result.status === 'PASSED'\n // ? {\n // ...retrainStats.result,\n // status: 'FIXED_BY_AI',\n // }\n // : retrainStats.result\n // const finalResult = this.createFinalResult(success, testCase, report)\n return {\n ...testCase,\n retrainStats,\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 let success = true\n try {\n await this.uploader.uploadRun(finalReport, this.runName)\n } catch (err) {\n this.log('Error uploading report\\n')\n if ('stack' in err) {\n this.log(err.stack)\n }\n success = false\n }\n\n this.log(JSON.stringify(finalReport, null, 2))\n return success\n }\n private async retrain(\n failedTestCases: number[],\n testCase: JsonTestProgress\n ): Promise<RetrainStats | null> {\n const stepsToRetrain = testCase.steps.map((_, i) => i)\n return await this.call_cucumber_client(stepsToRetrain, testCase)\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<RetrainStats | null> {\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 // const temporaryFileTask = await import('tempy')\n import('tempy').then(({ temporaryFileTask }) => {\n temporaryFileTask((tempFile) => {\n args.push(`--temp-file=${tempFile}`)\n const cucumberClient = spawn(\n 'node',\n [cucumber_client_path, ...args],\n {\n env: {\n ...process.env,\n },\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 const reportData = readFileSync(tempFile, 'utf-8')\n const retrainStats = JSON.parse(reportData) as RetrainStats\n resolve(retrainStats)\n } else {\n this.log('Error retraining\\n')\n resolve(null)\n }\n })\n })\n })\n })\n }\n}\n"]}
@@ -55,6 +55,12 @@ export type JsonStep = {
55
55
  commands: JsonCommand[];
56
56
  result: JsonStepResult;
57
57
  };
58
+ export type RetrainStats = {
59
+ result: JsonTestResult;
60
+ totalSteps: number;
61
+ upload_id: string;
62
+ local_id: number;
63
+ };
58
64
  export type JsonTestProgress = {
59
65
  id: string;
60
66
  featureName: string;
@@ -63,6 +69,7 @@ export type JsonTestProgress = {
63
69
  parameters: Record<string, string>;
64
70
  steps: JsonStep[];
65
71
  result: JsonTestResult;
72
+ retrainStats?: RetrainStats;
66
73
  };
67
74
  export type JsonReport = {
68
75
  testCases: JsonTestProgress[];
@@ -1 +1 @@
1
- {"version":3,"file":"report_generator.js","sourceRoot":"","sources":["../../../src/formatter/helpers/report_generator.ts"],"names":[],"mappings":";;AA6FA,MAAqB,eAAe;IAApC;QACU,WAAM,GAAe;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,SAAS;aAClB;YACD,SAAS,EAAE,EAAwB;SACpC,CAAA;QACO,uBAAkB,GAAG,IAAI,GAAG,EAAoC,CAAA;QAChE,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAA;QAC9C,gBAAW,GAAG,IAAI,GAAG,EAA6B,CAAA;QAClD,gBAAW,GAAG,IAAI,GAAG,EAA6B,CAAA;QAClD,oBAAe,GAAG,IAAI,GAAG,EAAoB,CAAA;QAC7C,oBAAe,GAAG,IAAI,GAAG,EAA4B,CAAA;QAE7D,iBAAY,GAAkB,IAAI,CAAA;IAyPpC,CAAC;IAvPC,aAAa,CAAC,QAA2B;QACvC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAA4B,CAAA;QAChE,QAAQ,IAAI,EAAE;YACZ,wBAAwB;Y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Y,CAAC,KAAK,CAAC,CAAA;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;QAC5C,YAAY,CAAC,MAAM,GAAG;YACpB,GAAG,MAAM;YACT,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;SACtC,CAAA;IACH,CAAC;IACO,iBAAiB,CAAC,eAAyC;QACjE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,eAAe,CAAA;QAClE,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAG9B,CAAA;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG;YACnB,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;YACrC,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;YACrC,OAAO;YACP,aAAa;SACd,CAAA;IACH,CAAC;CACF;AAvQD,kCAuQC","sourcesContent":["import * as messages from '@cucumber/messages'\n\n// type JsonException = messages.Exception\ntype JsonTimestamp = number //messages.Timestamp\ntype JsonStepType = 'Unknown' | 'Context' | 'Action' | 'Outcome'\n\nexport type JsonResultUnknown = {\n status: 'UNKNOWN'\n}\ntype JsonResultSkipped = {\n status: 'SKIPPED'\n}\ntype JsonResultUndefined = {\n status: 'UNDEFINED'\n}\ntype JsonResultAmbiguous = {\n status: 'AMBIGUOUS'\n}\nexport type JsonResultStarted = {\n status: 'STARTED'\n startTime: JsonTimestamp\n}\ntype JsonResultPending = {\n status: 'PENDING'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\nexport type JsonResultPassed = {\n status: 'PASSED'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\nexport type JsonResultFailed = {\n status: 'FAILED'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n message?: string\n // exception?: JsonException\n}\nexport type JsonFixedByAi = {\n status: 'FIXED_BY_AI'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\n\ntype JsonCommandResult = JsonResultPassed | JsonResultFailed\ntype JsonStepResult =\n | JsonResultUnknown\n | JsonResultSkipped\n | JsonResultUndefined\n | JsonResultAmbiguous\n | JsonResultStarted\n | JsonResultPending\n | JsonResultPassed\n | JsonResultFailed\n | JsonFixedByAi\nexport type JsonTestResult =\n | JsonResultUnknown\n | JsonResultStarted\n | JsonResultPassed\n | JsonResultFailed\n | JsonFixedByAi\ntype JsonReportResult = JsonTestResult\n\ntype JsonCommand = {\n type: string\n value?: string\n text: string\n screenshotId?: string\n result: JsonCommandResult\n}\nexport type JsonStep = {\n type: JsonStepType\n text: string\n commands: JsonCommand[]\n result: JsonStepResult\n}\n\nexport type JsonTestProgress = {\n id: string\n featureName: string\n uri: string\n scenarioName: string\n parameters: Record<string, string>\n steps: JsonStep[]\n result: JsonTestResult\n}\n\nexport type JsonReport = {\n testCases: JsonTestProgress[]\n result: JsonReportResult\n}\n\nexport default class ReportGenerator {\n private report: JsonReport = {\n result: {\n status: 'UNKNOWN',\n },\n testCases: [] as JsonTestProgress[],\n }\n private gherkinDocumentMap = new Map<string, messages.GherkinDocument>()\n private pickleMap = new Map<string, messages.Pickle>()\n private testCaseMap = new Map<string, messages.TestCase>()\n private testStepMap = new Map<string, messages.TestStep>()\n private stepProgressMap = new Map<string, JsonStep>()\n private testProgressMap = new Map<string, JsonTestProgress>()\n\n reportFolder: null | string = null\n\n handleMessage(envelope: messages.Envelope) {\n const type = Object.keys(envelope)[0] as keyof messages.Envelope\n switch (type) {\n // case \"meta\": { break}\n // case \"source\": { break}\n case 'parseError': {\n const parseError = envelope[type]\n this.handleParseError(parseError)\n break\n }\n case 'gherkinDocument': {\n const doc = envelope[type]\n this.onGherkinDocument(doc)\n break\n }\n case 'pickle': {\n const pickle = envelope[type]\n this.onPickle(pickle)\n break\n }\n // case \"stepDefinition\": { break}\n // case \"hook\": { break} // Before Hook\n case 'testRunStarted': {\n const testRunStarted = envelope[type]\n this.onTestRunStarted(testRunStarted)\n break\n }\n case 'testCase': {\n const testCase = envelope[type]\n this.onTestCase(testCase)\n break\n }\n case 'testCaseStarted': {\n const testCaseStarted = envelope[type]\n this.onTestCaseStarted(testCaseStarted)\n break\n }\n case 'testStepStarted': {\n const testStepStarted = envelope[type]\n this.onTestStepStarted(testStepStarted)\n break\n }\n case 'attachment': {\n const attachment = envelope[type]\n this.onAttachment(attachment)\n break\n }\n case 'testStepFinished': {\n const testStepFinished = envelope[type]\n this.onTestStepFinished(testStepFinished)\n break\n }\n case 'testCaseFinished': {\n const testCaseFinished = envelope[type]\n this.onTestCaseFinished(testCaseFinished)\n break\n }\n // case \"hook\": { break} // After Hook\n case 'testRunFinished': {\n const testRunFinished = envelope[type]\n this.onTestRunFinished(testRunFinished)\n break\n }\n // case \"parameterType\" : { break}\n // case \"undefinedParameterType\": { break}\n }\n }\n getReport() {\n return this.report\n }\n private handleParseError(parseError: messages.ParseError) {\n const { message, source } = parseError\n const timestamp = new Date().getTime()\n this.report.result = {\n status: 'FAILED',\n startTime: timestamp,\n endTime: timestamp,\n message: message,\n }\n }\n private onGherkinDocument(doc: messages.GherkinDocument) {\n this.gherkinDocumentMap.set(doc.uri, doc)\n }\n private onPickle(pickle: messages.Pickle) {\n this.pickleMap.set(pickle.id, pickle)\n }\n private getTimeStamp(timestamp: messages.Timestamp) {\n return timestamp.seconds * 1000 + timestamp.nanos / 1000000\n }\n private onTestRunStarted(testRunStarted: messages.TestRunStarted) {\n this.report.result = {\n status: 'STARTED',\n startTime: this.getTimeStamp(testRunStarted.timestamp),\n }\n }\n private onTestCase(testCase: messages.TestCase) {\n this.testCaseMap.set(testCase.id, testCase)\n testCase.testSteps.forEach((testStep) => {\n this.testStepMap.set(testStep.id, testStep)\n })\n }\n private onTestCaseStarted(testCaseStarted: messages.TestCaseStarted) {\n const { testCaseId, id, timestamp } = testCaseStarted\n const testCase = this.testCaseMap.get(testCaseId)\n if (testCase === undefined)\n throw new Error(`testCase with id ${testCaseId} not found`)\n const pickle = this.pickleMap.get(testCase.pickleId)\n if (pickle === undefined)\n throw new Error(`pickle with id ${testCase.pickleId} not found`)\n\n const doc = this.gherkinDocumentMap.get(pickle.uri)\n if (doc === undefined)\n throw new Error(`gherkinDocument with uri ${pickle.uri} not found`)\n const featureName = doc.feature.name\n\n const scenarioName = pickle.name\n\n const steps: JsonStep[] = pickle.steps.map((step) => {\n this.stepProgressMap.set(step.id, {\n type: step.type,\n text: step.text,\n commands: [],\n result: {\n status: 'UNKNOWN',\n },\n })\n return this.stepProgressMap.get(step.id)\n })\n this.testProgressMap.set(id, {\n id,\n uri: pickle.uri,\n featureName,\n scenarioName,\n // TODO: compute parameters\n parameters: {},\n steps,\n result: {\n status: 'STARTED',\n startTime: this.getTimeStamp(timestamp),\n },\n })\n this.report.testCases.push(this.testProgressMap.get(id))\n }\n private onTestStepStarted(testStepStarted: messages.TestStepStarted) {\n const { testStepId, timestamp, testCaseStartedId } = testStepStarted\n const testStep = this.testStepMap.get(testStepId)\n if (testStep === undefined)\n throw new Error(`testStep with id ${testStepId} not found`)\n if (testStep.pickleStepId === undefined) return\n const stepProgess = this.stepProgressMap.get(testStep.pickleStepId)\n stepProgess.result = {\n status: 'STARTED',\n startTime: this.getTimeStamp(timestamp),\n }\n }\n private onAttachment(attachment: messages.Attachment) {\n const {\n testCaseStartedId,\n testStepId,\n body,\n mediaType,\n contentEncoding,\n fileName,\n source,\n url,\n } = attachment\n if (mediaType === 'text/plain') {\n this.reportFolder = body.replaceAll('\\\\', '/')\n }\n const testStep = this.testStepMap.get(testStepId)\n if (testStep.pickleStepId === undefined) return\n\n const stepProgess = this.stepProgressMap.get(testStep.pickleStepId)\n if (mediaType === 'application/json') {\n const command: JsonCommand = JSON.parse(body)\n stepProgess.commands.push(command)\n }\n }\n private onTestStepFinished(testStepFinished: messages.TestStepFinished) {\n const { testStepId, testCaseStartedId, testStepResult, timestamp } =\n testStepFinished\n const testStep = this.testStepMap.get(testStepId)\n if (testStep.pickleStepId === undefined) return\n const stepProgess = this.stepProgressMap.get(testStep.pickleStepId)\n const prevStepResult = stepProgess.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n stepProgess.result = {\n status: testStepResult.status,\n startTime: prevStepResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n message: testStepResult.message,\n // exception: testStepResult.exception,\n }\n }\n private getTestCaseResult(steps: JsonStep[]) {\n for (const step of steps) {\n switch (step.result.status) {\n case 'FAILED':\n return {\n status: step.result.status,\n message: step.result.message,\n // exception: step.result.exception,\n } as const\n case 'AMBIGUOUS':\n case 'UNDEFINED':\n case 'PENDING':\n return {\n status: 'FAILED',\n message: `step \"${step.text}\" is ${step.result.status}`,\n } as const\n }\n }\n return {\n status: 'PASSED',\n } as const\n }\n private onTestCaseFinished(testCaseFinished: messages.TestCaseFinished) {\n const { testCaseStartedId, timestamp } = testCaseFinished\n const testProgress = this.testProgressMap.get(testCaseStartedId)\n const prevResult = testProgress.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n const steps = Object.values(testProgress.steps)\n const result = this.getTestCaseResult(steps)\n testProgress.result = {\n ...result,\n startTime: prevResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n }\n }\n private onTestRunFinished(testRunFinished: messages.TestRunFinished) {\n const { timestamp, success, exception, message } = testRunFinished\n const prevResult = this.report.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n this.report.result = {\n status: success ? 'PASSED' : 'FAILED',\n startTime: prevResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n message,\n // exception,\n }\n }\n}\n"]}
1
+ {"version":3,"file":"report_generator.js","sourceRoot":"","sources":["../../../src/formatter/helpers/report_generator.ts"],"names":[],"mappings":";;AAmGA,MAAqB,eAAe;IAApC;QACU,WAAM,GAAe;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,SAAS;aAClB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umber/messages'\n\n// type JsonException = messages.Exception\ntype JsonTimestamp = number //messages.Timestamp\ntype JsonStepType = 'Unknown' | 'Context' | 'Action' | 'Outcome'\n\nexport type JsonResultUnknown = {\n status: 'UNKNOWN'\n}\ntype JsonResultSkipped = {\n status: 'SKIPPED'\n}\ntype JsonResultUndefined = {\n status: 'UNDEFINED'\n}\ntype JsonResultAmbiguous = {\n status: 'AMBIGUOUS'\n}\nexport type JsonResultStarted = {\n status: 'STARTED'\n startTime: JsonTimestamp\n}\ntype JsonResultPending = {\n status: 'PENDING'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\nexport type JsonResultPassed = {\n status: 'PASSED'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\nexport type JsonResultFailed = {\n status: 'FAILED'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n message?: string\n // exception?: JsonException\n}\nexport type JsonFixedByAi = {\n status: 'FIXED_BY_AI'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\n\ntype JsonCommandResult = JsonResultPassed | JsonResultFailed\ntype JsonStepResult =\n | JsonResultUnknown\n | JsonResultSkipped\n | JsonResultUndefined\n | JsonResultAmbiguous\n | JsonResultStarted\n | JsonResultPending\n | JsonResultPassed\n | JsonResultFailed\n | JsonFixedByAi\nexport type JsonTestResult =\n | JsonResultUnknown\n | JsonResultStarted\n | JsonResultPassed\n | JsonResultFailed\n | JsonFixedByAi\ntype JsonReportResult = JsonTestResult\n\ntype JsonCommand = {\n type: string\n value?: string\n text: string\n screenshotId?: string\n result: JsonCommandResult\n}\nexport type JsonStep = {\n type: JsonStepType\n text: string\n commands: JsonCommand[]\n result: JsonStepResult\n}\nexport type RetrainStats = {\n result: JsonTestResult\n totalSteps: number\n upload_id: string\n local_id: number\n}\nexport type JsonTestProgress = {\n id: string\n featureName: string\n uri: string\n scenarioName: string\n parameters: Record<string, string>\n steps: JsonStep[]\n result: JsonTestResult\n retrainStats?: RetrainStats\n}\n\nexport type JsonReport = {\n testCases: JsonTestProgress[]\n result: JsonReportResult\n}\n\nexport default class ReportGenerator {\n private report: JsonReport = {\n result: {\n status: 'UNKNOWN',\n },\n testCases: [] as JsonTestProgress[],\n }\n private gherkinDocumentMap = new Map<string, messages.GherkinDocument>()\n private pickleMap = new Map<string, messages.Pickle>()\n private testCaseMap = new Map<string, messages.TestCase>()\n private testStepMap = new Map<string, messages.TestStep>()\n private stepProgressMap = new Map<string, JsonStep>()\n private testProgressMap = new Map<string, JsonTestProgress>()\n\n reportFolder: null | string = null\n\n handleMessage(envelope: messages.Envelope) {\n const type = Object.keys(envelope)[0] as keyof messages.Envelope\n switch (type) {\n // case \"meta\": { break}\n // case \"source\": { break}\n case 'parseError': {\n const parseError = envelope[type]\n this.handleParseError(parseError)\n break\n }\n case 'gherkinDocument': {\n const doc = envelope[type]\n this.onGherkinDocument(doc)\n break\n }\n case 'pickle': {\n const pickle = envelope[type]\n this.onPickle(pickle)\n break\n }\n // case \"stepDefinition\": { break}\n // case \"hook\": { break} // Before Hook\n case 'testRunStarted': {\n const testRunStarted = envelope[type]\n this.onTestRunStarted(testRunStarted)\n break\n }\n case 'testCase': {\n const testCase = envelope[type]\n this.onTestCase(testCase)\n break\n }\n case 'testCaseStarted': {\n const testCaseStarted = envelope[type]\n this.onTestCaseStarted(testCaseStarted)\n break\n }\n case 'testStepStarted': {\n const testStepStarted = envelope[type]\n this.onTestStepStarted(testStepStarted)\n break\n }\n case 'attachment': {\n const attachment = envelope[type]\n this.onAttachment(attachment)\n break\n }\n case 'testStepFinished': {\n const testStepFinished = envelope[type]\n this.onTestStepFinished(testStepFinished)\n break\n }\n case 'testCaseFinished': {\n const testCaseFinished = envelope[type]\n this.onTestCaseFinished(testCaseFinished)\n break\n }\n // case \"hook\": { break} // After Hook\n case 'testRunFinished': {\n const testRunFinished = envelope[type]\n this.onTestRunFinished(testRunFinished)\n break\n }\n // case \"parameterType\" : { break}\n // case \"undefinedParameterType\": { break}\n }\n }\n getReport() {\n return this.report\n }\n private handleParseError(parseError: messages.ParseError) {\n const { message, source } = parseError\n const timestamp = new Date().getTime()\n this.report.result = {\n status: 'FAILED',\n startTime: timestamp,\n endTime: timestamp,\n message: message,\n }\n }\n private onGherkinDocument(doc: messages.GherkinDocument) {\n this.gherkinDocumentMap.set(doc.uri, doc)\n }\n private onPickle(pickle: messages.Pickle) {\n this.pickleMap.set(pickle.id, pickle)\n }\n private getTimeStamp(timestamp: messages.Timestamp) {\n return timestamp.seconds * 1000 + timestamp.nanos / 1000000\n }\n private onTestRunStarted(testRunStarted: messages.TestRunStarted) {\n this.report.result = {\n status: 'STARTED',\n startTime: this.getTimeStamp(testRunStarted.timestamp),\n }\n }\n private onTestCase(testCase: messages.TestCase) {\n this.testCaseMap.set(testCase.id, testCase)\n testCase.testSteps.forEach((testStep) => {\n this.testStepMap.set(testStep.id, testStep)\n })\n }\n private onTestCaseStarted(testCaseStarted: messages.TestCaseStarted) {\n const { testCaseId, id, timestamp } = testCaseStarted\n const testCase = this.testCaseMap.get(testCaseId)\n if (testCase === undefined)\n throw new Error(`testCase with id ${testCaseId} not found`)\n const pickle = this.pickleMap.get(testCase.pickleId)\n if (pickle === undefined)\n throw new Error(`pickle with id ${testCase.pickleId} not found`)\n\n const doc = this.gherkinDocumentMap.get(pickle.uri)\n if (doc === undefined)\n throw new Error(`gherkinDocument with uri ${pickle.uri} not found`)\n const featureName = doc.feature.name\n\n const scenarioName = pickle.name\n\n const steps: JsonStep[] = pickle.steps.map((step) => {\n this.stepProgressMap.set(step.id, {\n type: step.type,\n text: step.text,\n commands: [],\n result: {\n status: 'UNKNOWN',\n },\n })\n return this.stepProgressMap.get(step.id)\n })\n this.testProgressMap.set(id, {\n id,\n uri: pickle.uri,\n featureName,\n scenarioName,\n // TODO: compute parameters\n parameters: {},\n steps,\n result: {\n status: 'STARTED',\n startTime: this.getTimeStamp(timestamp),\n },\n })\n this.report.testCases.push(this.testProgressMap.get(id))\n }\n private onTestStepStarted(testStepStarted: messages.TestStepStarted) {\n const { testStepId, timestamp, testCaseStartedId } = testStepStarted\n const testStep = this.testStepMap.get(testStepId)\n if (testStep === undefined)\n throw new Error(`testStep with id ${testStepId} not found`)\n if (testStep.pickleStepId === undefined) return\n const stepProgess = this.stepProgressMap.get(testStep.pickleStepId)\n stepProgess.result = {\n status: 'STARTED',\n startTime: this.getTimeStamp(timestamp),\n }\n }\n private onAttachment(attachment: messages.Attachment) {\n const {\n testCaseStartedId,\n testStepId,\n body,\n mediaType,\n contentEncoding,\n fileName,\n source,\n url,\n } = attachment\n if (mediaType === 'text/plain') {\n this.reportFolder = body.replaceAll('\\\\', '/')\n }\n const testStep = this.testStepMap.get(testStepId)\n if (testStep.pickleStepId === undefined) return\n\n const stepProgess = this.stepProgressMap.get(testStep.pickleStepId)\n if (mediaType === 'application/json') {\n const command: JsonCommand = JSON.parse(body)\n stepProgess.commands.push(command)\n }\n }\n private onTestStepFinished(testStepFinished: messages.TestStepFinished) {\n const { testStepId, testCaseStartedId, testStepResult, timestamp } =\n testStepFinished\n const testStep = this.testStepMap.get(testStepId)\n if (testStep.pickleStepId === undefined) return\n const stepProgess = this.stepProgressMap.get(testStep.pickleStepId)\n const prevStepResult = stepProgess.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n stepProgess.result = {\n status: testStepResult.status,\n startTime: prevStepResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n message: testStepResult.message,\n // exception: testStepResult.exception,\n }\n }\n private getTestCaseResult(steps: JsonStep[]) {\n for (const step of steps) {\n switch (step.result.status) {\n case 'FAILED':\n return {\n status: step.result.status,\n message: step.result.message,\n // exception: step.result.exception,\n } as const\n case 'AMBIGUOUS':\n case 'UNDEFINED':\n case 'PENDING':\n return {\n status: 'FAILED',\n message: `step \"${step.text}\" is ${step.result.status}`,\n } as const\n }\n }\n return {\n status: 'PASSED',\n } as const\n }\n private onTestCaseFinished(testCaseFinished: messages.TestCaseFinished) {\n const { testCaseStartedId, timestamp } = testCaseFinished\n const testProgress = this.testProgressMap.get(testCaseStartedId)\n const prevResult = testProgress.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n const steps = Object.values(testProgress.steps)\n const result = this.getTestCaseResult(steps)\n testProgress.result = {\n ...result,\n startTime: prevResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n }\n }\n private onTestRunFinished(testRunFinished: messages.TestRunFinished) {\n const { timestamp, success, exception, message } = testRunFinished\n const prevResult = this.report.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n this.report.result = {\n status: success ? 'PASSED' : 'FAILED',\n startTime: prevResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n message,\n // exception,\n }\n }\n}\n"]}
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.0.19";
1
+ export declare const version = "1.0.20";
package/lib/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = '1.0.19';
5
+ exports.version = '1.0.20';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.19'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.20'\n"]}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "gherkin",
9
9
  "tests"
10
10
  ],
11
- "version": "1.0.19",
11
+ "version": "1.0.20",
12
12
  "homepage": "https://github.com/blinq-io/cucumber-js",
13
13
  "author": "blinq.io",
14
14
  "contributors": [
@@ -87,6 +87,7 @@
87
87
  "string-argv": "^0.3.1",
88
88
  "strip-ansi": "6.0.1",
89
89
  "supports-color": "^8.1.1",
90
+ "tempy": "^3.1.0",
90
91
  "tmp": "^0.2.1",
91
92
  "util-arity": "^1.1.0",
92
93
  "verror": "^1.10.0",