@dev-blinq/cucumber-js 1.0.180-dev → 1.0.182-dev
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.
|
@@ -199,91 +199,112 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
199
199
|
}
|
|
200
200
|
async rerun(report) {
|
|
201
201
|
await new Promise((resolve) => {
|
|
202
|
-
|
|
202
|
+
// Default to system Node.js
|
|
203
|
+
let node_path = process.argv.shift();
|
|
204
|
+
// Use bundled Node if running from recorder app on macOS or Windows
|
|
205
|
+
const isFromRecorderApp = process.env.FROM_RECORDER_APP === "true";
|
|
206
|
+
const isSupportedPlatform = process.platform === "darwin" || process.platform === "win32";
|
|
207
|
+
if (isFromRecorderApp && isSupportedPlatform) {
|
|
208
|
+
node_path = process.execPath;
|
|
209
|
+
}
|
|
203
210
|
const args = [
|
|
204
|
-
path_1.default.join(process.cwd(),
|
|
205
|
-
|
|
211
|
+
path_1.default.join(process.cwd(), "node_modules", "@dev-blinq", "cucumber-js", "bin", "cucumber.js"),
|
|
212
|
+
"--name",
|
|
206
213
|
`^${report.scenarioName}$`,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
214
|
+
"--exit",
|
|
215
|
+
"--format",
|
|
216
|
+
"bvt",
|
|
217
|
+
"--run-name",
|
|
211
218
|
`${report.scenarioName}@debug`,
|
|
212
|
-
path_1.default.join(process.cwd(),
|
|
219
|
+
path_1.default.join(process.cwd(), report.uri),
|
|
213
220
|
];
|
|
221
|
+
const envVars = {
|
|
222
|
+
...process.env,
|
|
223
|
+
RERUN: JSON.stringify(this.failedStepsIndex),
|
|
224
|
+
};
|
|
225
|
+
// Inject Electron node env only if using bundled node
|
|
226
|
+
if (node_path === process.execPath) {
|
|
227
|
+
envVars.ELECTRON_RUN_AS_NODE = "1";
|
|
228
|
+
}
|
|
214
229
|
const cucumberClient = (0, child_process_1.spawn)(node_path, args, {
|
|
215
|
-
env:
|
|
216
|
-
...process.env,
|
|
217
|
-
RERUN: JSON.stringify(this.failedStepsIndex),
|
|
218
|
-
},
|
|
230
|
+
env: envVars,
|
|
219
231
|
});
|
|
220
|
-
cucumberClient.stdout.on(
|
|
232
|
+
cucumberClient.stdout.on("data", (data) => {
|
|
221
233
|
console.log(data.toString());
|
|
222
234
|
});
|
|
223
|
-
cucumberClient.stderr.on(
|
|
235
|
+
cucumberClient.stderr.on("data", (data) => {
|
|
224
236
|
console.error(data.toString());
|
|
225
237
|
});
|
|
226
|
-
cucumberClient.on(
|
|
238
|
+
cucumberClient.on("close", () => {
|
|
227
239
|
resolve();
|
|
228
240
|
});
|
|
229
241
|
});
|
|
230
242
|
}
|
|
231
243
|
async call_cucumber_client(stepsToRetrain, testCase) {
|
|
232
244
|
return new Promise((resolve, reject) => {
|
|
233
|
-
const cucumber_client_path = path_1.default.resolve(process.cwd(),
|
|
245
|
+
const cucumber_client_path = path_1.default.resolve(process.cwd(), "node_modules", "@dev-blinq", "cucumber_client", "bin", "client", "cucumber.js");
|
|
234
246
|
const args = [
|
|
235
247
|
process.cwd(),
|
|
236
248
|
path_1.default.join(process.cwd(), testCase.uri),
|
|
237
249
|
`${testCase.scenarioName}`,
|
|
238
|
-
|
|
250
|
+
"undefined",
|
|
239
251
|
`${stepsToRetrain},`,
|
|
240
252
|
];
|
|
241
253
|
if (process.env.BLINQ_ENV) {
|
|
242
254
|
args.push(`--env=${process.env.BLINQ_ENV}`);
|
|
243
255
|
}
|
|
244
|
-
if (!(0, fs_1.existsSync)(path_1.default.join(this.getAppDataDir(),
|
|
245
|
-
(0, promises_1.mkdir)(path_1.default.join(this.getAppDataDir(),
|
|
256
|
+
if (!(0, fs_1.existsSync)(path_1.default.join(this.getAppDataDir(), "blinq.io", ".temp"))) {
|
|
257
|
+
(0, promises_1.mkdir)(path_1.default.join(this.getAppDataDir(), "blinq.io", ".temp"), {
|
|
246
258
|
recursive: true,
|
|
247
259
|
});
|
|
248
260
|
}
|
|
249
261
|
(0, tmp_1.tmpName)(async (err, name) => {
|
|
250
|
-
const tempFile = path_1.default.join(this.getAppDataDir(),
|
|
251
|
-
console.log(
|
|
252
|
-
// check if the file directory exists, if not create it
|
|
262
|
+
const tempFile = path_1.default.join(this.getAppDataDir(), "blinq.io", ".temp", path_1.default.basename(name));
|
|
263
|
+
console.log("File path: ", tempFile);
|
|
253
264
|
if (!(0, fs_1.existsSync)(path_1.default.dirname(tempFile))) {
|
|
254
265
|
await (0, promises_1.mkdir)(path_1.default.dirname(tempFile), { recursive: true });
|
|
255
266
|
}
|
|
256
|
-
await (0, promises_1.writeFile)(tempFile,
|
|
267
|
+
await (0, promises_1.writeFile)(tempFile, "", "utf-8");
|
|
257
268
|
args.push(`--temp-file=${tempFile}`);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
269
|
+
// Determine node path
|
|
270
|
+
const isFromRecorderApp = process.env.FROM_RECORDER_APP === "true";
|
|
271
|
+
const isSupportedPlatform = process.platform === "darwin" || process.platform === "win32";
|
|
272
|
+
const node_path = isFromRecorderApp && isSupportedPlatform
|
|
273
|
+
? process.execPath
|
|
274
|
+
: "node";
|
|
275
|
+
const envVars = {
|
|
276
|
+
...process.env,
|
|
277
|
+
TEMP_FILE_PATH: tempFile,
|
|
278
|
+
};
|
|
279
|
+
if (node_path === process.execPath) {
|
|
280
|
+
envVars.ELECTRON_RUN_AS_NODE = "1";
|
|
281
|
+
}
|
|
282
|
+
const cucumberClient = (0, child_process_1.spawn)(node_path, [cucumber_client_path, ...args], {
|
|
283
|
+
env: envVars,
|
|
263
284
|
});
|
|
264
|
-
cucumberClient.stdout.on(
|
|
285
|
+
cucumberClient.stdout.on("data", (data) => {
|
|
265
286
|
console.log(data.toString());
|
|
266
287
|
});
|
|
267
|
-
cucumberClient.stderr.on(
|
|
288
|
+
cucumberClient.stderr.on("data", (data) => {
|
|
268
289
|
console.error(data.toString());
|
|
269
290
|
});
|
|
270
|
-
cucumberClient.on(
|
|
291
|
+
cucumberClient.on("close", async (code) => {
|
|
271
292
|
if (code === 0) {
|
|
272
|
-
const reportData = (0, fs_1.readFileSync)(tempFile,
|
|
293
|
+
const reportData = (0, fs_1.readFileSync)(tempFile, "utf-8");
|
|
273
294
|
const retrainStats = JSON.parse(reportData);
|
|
274
295
|
await (0, promises_1.unlink)(tempFile);
|
|
275
296
|
resolve(retrainStats);
|
|
276
297
|
}
|
|
277
298
|
else {
|
|
278
|
-
this.log(
|
|
299
|
+
this.log("Error retraining\n");
|
|
279
300
|
try {
|
|
280
|
-
const reportData = (0, fs_1.readFileSync)(tempFile,
|
|
301
|
+
const reportData = (0, fs_1.readFileSync)(tempFile, "utf-8");
|
|
281
302
|
const retrainStats = JSON.parse(reportData);
|
|
282
303
|
await (0, promises_1.unlink)(tempFile);
|
|
283
304
|
resolve(retrainStats);
|
|
284
305
|
}
|
|
285
306
|
catch (e) {
|
|
286
|
-
this.log(
|
|
307
|
+
this.log("Error reading scenario report\n " + e);
|
|
287
308
|
resolve(null);
|
|
288
309
|
}
|
|
289
310
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bvt_analysis_formatter.js","sourceRoot":"","sources":["../../src/formatter/bvt_analysis_formatter.ts"],"names":[],"mappings":";;;;;;AACA,iDAAqC;AACrC,2BAA4D;AAC5D,0CAAsD;AACtD,gDAAuB;AACvB,6BAA6B;AAC7B,yCAAgD;AAChD,oDAAgD;AAChD,kFAKmC;AACnC,kEAA+C;AAC/C,4CAAmB;AACnB,+BAA6C;AAC7C,4EAAkD;AAClD,mDAAgE;AAChE,gEAA2D;AAK3D,+BAAgC;AAChC,iDAAoC;AAGpC,YAAY;AACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;AAQpB,QAAA,gBAAgB,GAAG,EAAE,CAAC;AACjC,MAAqB,oBAAqB,SAAQ,UAAS;IAiBzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC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,CAAC;AAvBD,sCAuBC;AAED,SAAS,6BAA6B,CAAC,UAAkB,EAAE,MAAe;IACxE,IAAI,IAAA,eAAU,EAAC,wBAAwB,CAAC,EAAE;QACxC,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAA;QACjC,SAAS,CAAC,4BAA4B,GAAG,UAAU,GAAG,GAAG,GAAG,MAAM,CAAC,CAAA;KACpE;AACH,CAAC","sourcesContent":["import { Envelope, Meta } from '@cucumber/messages'\nimport { spawn } from 'child_process'\nimport { readFileSync, existsSync, writeFileSync } from 'fs'\nimport { mkdir, unlink, writeFile } from 'fs/promises'\nimport path from 'path'\nimport { tmpName } from 'tmp'\nimport Formatter, { IFormatterOptions } from '.'\nimport { doesHaveValue } from '../value_checker'\nimport ReportGenerator, {\n JsonReport,\n JsonTestProgress,\n JsonTestResult,\n RetrainStats,\n} from './helpers/report_generator'\nimport ReportUploader from './helpers/uploader'\nimport os from 'os'\nimport { getProjectByAccessKey } from './api'\nimport SummaryFormatter from './summary_formatter'\nimport { ActionEvents, SERVICES_URI } from './helpers/constants'\nimport { axiosClient } from '../configuration/axios_client'\nimport {\n FinishTestCaseResponse,\n RootCauseProps,\n} from './helpers/upload_serivce'\nimport { promisify } from 'util'\nimport { exec } from 'child_process'\nimport { isCloudRecorder } from './helpers/isCloudRecorder'\n\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 let globalReportLink = '';\nexport default class BVTAnalysisFormatter extends Formatter {\n static reportGenerator: ReportGenerator\n static reRunFailedStepsIndex:\n | { testCaseId: string; failedStepIndex: number }[]\n | null\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 private failedStepsIndex: { testCaseId: string; failedStepIndex: number }[]\n private summaryFormatter: SummaryFormatter\n private rootCauseArray: {\n rootCause: RootCauseProps\n report: JsonTestProgress\n }[] = []\n\n constructor(options: IFormatterOptions) {\n super(options)\n this.summaryFormatter = new SummaryFormatter(options)\n BVTAnalysisFormatter.reportGenerator = this.reportGenerator\n this.rootCauseArray = []\n this.failedStepsIndex = []\n BVTAnalysisFormatter.reRunFailedStepsIndex = process.env.RERUN\n ? JSON.parse(process.env.RERUN)\n : null\n\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n this.sendEvent(ActionEvents.cli_run_tests)\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage, data?: any) => {\n if (doesHaveValue(envelope.testCaseFinished) && data) {\n const { rootCause, report } = data as FinishTestCaseResponse\n\n if (!rootCause.status) {\n console.error(\n `Root cause: ${rootCause.failClass}\\n, ${rootCause.analysis}\\nfailing step: ${rootCause.failedStep}`\n )\n this.rootCauseArray.push({ rootCause, report })\n this.failedStepsIndex.push({\n testCaseId: report.id,\n failedStepIndex: rootCause.failedStep,\n })\n }\n return\n }\n await this.reportGenerator.handleMessage(envelope)\n\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 this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport()\n } else {\n // await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private sendEvent(event: ActionEvents) {\n axiosClient\n .post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event,\n },\n {\n headers: {\n Authorization: `Bearer ${TOKEN}`,\n 'x-source': 'cucumber_js',\n },\n }\n )\n .catch((err) => {\n // Error with events, ignoring\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 let anyRem\n if (process.env.UPLOADING_TEST_CASE) {\n anyRem = JSON.parse(process.env.UPLOADING_TEST_CASE) as string[]\n } else {\n anyRem = undefined\n }\n\n if (this.exit && (!anyRem || anyRem.length === 0)) {\n // clearInterval(checkInterval)\n // resolve(null)\n if (this.reportGenerator.getReport().result.status === 'FAILED') {\n process.exit(1)\n } else {\n process.exit(0)\n }\n }\n }, 100) // check every 100ms\n })\n }\n private async analyzeReport() {\n if (\n this.rootCauseArray.length === 0 ||\n process.env.NO_RETRAIN === 'false'\n ) {\n if (this.rootCauseArray.length === 0) {\n this.log('No test failed. No need to retrain\\n')\n }\n if (process.env.NO_RETRAIN === 'false') {\n this.log(\n 'Retraining is skipped since the failed step contains an API request\\n'\n )\n }\n // const uploadSuccessful = await this.uploadFinalReport(report)\n // process.exit(0)\n this.exit = true\n return\n }\n\n //checking if the type of report.result is JsonResultFailed or not\n\n this.log('Some tests failed, starting the retraining...\\n')\n await this.processTestCases()\n if (this.reportGenerator.getReport().result.status === 'FAILED') {\n process.exit(1)\n }\n process.exit(0)\n }\n private async processTestCases() {\n for (const { rootCause, report } of this.rootCauseArray) {\n await this.processTestCase(rootCause, report)\n }\n }\n private async processTestCase(\n rootCause: RootCauseProps,\n report: JsonTestProgress\n ) {\n const failedTestSteps = rootCause.failedStep\n\n if (\n BVTAnalysisFormatter.reRunFailedStepsIndex &&\n BVTAnalysisFormatter.reRunFailedStepsIndex.length > 0\n ) {\n const previousRun = BVTAnalysisFormatter.reRunFailedStepsIndex[0]\n if (previousRun.failedStepIndex === failedTestSteps) {\n console.log('Same step has failed again, skipping retraining')\n BVTAnalysisFormatter.reRunFailedStepsIndex.shift()\n return\n }\n BVTAnalysisFormatter.reRunFailedStepsIndex.shift()\n }\n\n const retrainStats = await this.retrain(failedTestSteps, report)\n\n if (!retrainStats) {\n return\n }\n\n await this.uploader.modifyTestCase({\n ...report,\n retrainStats,\n })\n\n await this.rerun(report)\n }\n\n private async uploadFinalReport(finalReport: JsonReport) {\n let success = true\n try {\n const { projectId, runId } = await this.uploader.uploadRun(\n finalReport,\n this.runName\n )\n logReportLink(runId, projectId, finalReport.result)\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 } finally {\n try {\n writeFileSync(\n path.join(this.reportGenerator.reportFolder, 'report.json'),\n JSON.stringify(finalReport, null, 2),\n 'utf-8'\n )\n } catch (e) {\n console.error('failed to write report.json to local disk')\n }\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 data = await getProjectByAccessKey(TOKEN)\n const currentTimestampInSeconds = Math.floor(Date.now() / 1000)\n if (data.project.expriration_date < currentTimestampInSeconds) {\n console.log(\n 'Warning: Your project has expired, retraining is restricted. Please contact sales.'\n )\n process.exit(1)\n }\n return await this.call_cucumber_client(failedTestCases, testCase)\n }\n\n private async rerun(report: JsonTestProgress) {\n await new Promise<void>((resolve) => {\n const node_path = process.argv.shift()\n const args = [\n path.join(\n process.cwd(),\n 'node_modules',\n '@dev-blinq',\n 'cucumber-js',\n 'bin',\n 'cucumber.js'\n ),\n '--name',\n `^${report.scenarioName}$`,\n '--exit',\n '--format',\n 'bvt',\n '--run-name',\n `${report.scenarioName}@debug`,\n path.join(process.cwd(), 'features', `${report.featureName}.feature`),\n ]\n const cucumberClient = spawn(node_path, args, {\n env: {\n ...process.env,\n RERUN: JSON.stringify(this.failedStepsIndex),\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', () => {\n resolve()\n })\n })\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 'undefined',\n `${stepsToRetrain},`,\n ]\n\n if (process.env.BLINQ_ENV) {\n args.push(`--env=${process.env.BLINQ_ENV}`)\n }\n\n if (!existsSync(path.join(this.getAppDataDir(), 'blinq.io', '.temp'))) {\n mkdir(path.join(this.getAppDataDir(), 'blinq.io', '.temp'), {\n recursive: true,\n })\n }\n\n tmpName(async (err, name) => {\n const tempFile = path.join(\n this.getAppDataDir(),\n 'blinq.io',\n '.temp',\n path.basename(name)\n )\n console.log('File path: ', tempFile)\n // check if the file directory exists, if not create it\n if (!existsSync(path.dirname(tempFile))) {\n await mkdir(path.dirname(tempFile), { recursive: true })\n }\n await writeFile(tempFile, '', 'utf-8')\n\n args.push(`--temp-file=${tempFile}`)\n const cucumberClient = spawn('node', [cucumber_client_path, ...args], {\n env: {\n ...process.env,\n TEMP_FILE_PATH: tempFile,\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', async (code) => {\n if (code === 0) {\n const reportData = readFileSync(tempFile, 'utf-8')\n const retrainStats = JSON.parse(reportData) as RetrainStats\n await unlink(tempFile)\n resolve(retrainStats)\n } else {\n this.log('Error retraining\\n')\n try {\n const reportData = readFileSync(tempFile, 'utf-8')\n const retrainStats = JSON.parse(reportData) as RetrainStats\n await unlink(tempFile)\n resolve(retrainStats)\n } catch (e) {\n this.log('Error reading scenario report\\n ' + e)\n resolve(null)\n }\n }\n })\n })\n })\n }\n\n private getAppDataDir() {\n if (process.env.BLINQ_APPDATA_DIR) {\n return process.env.BLINQ_APPDATA_DIR\n }\n\n let appDataDir: string\n\n switch (process.platform) {\n case 'win32':\n appDataDir = process.env.APPDATA!\n break\n case 'darwin':\n appDataDir = path.join(os.homedir(), 'Library', 'Application Support')\n break\n default:\n appDataDir = path.join(os.homedir(), '.config')\n break\n }\n return appDataDir\n }\n}\n\nexport function logReportLink(runId: string, projectId: string, status: JsonTestResult) {\n let reportLinkBaseUrl = 'https://app.blinq.io'\n if (process.env.NODE_ENV_BLINQ === 'local') {\n reportLinkBaseUrl = 'http://localhost:3000'\n } else if (process.env.NODE_ENV_BLINQ === 'dev') {\n reportLinkBaseUrl = 'https://dev.app.blinq.io'\n } else if (process.env.NODE_ENV_BLINQ === 'stage') {\n reportLinkBaseUrl = 'https://stage.app.blinq.io'\n } else if (process.env.NODE_ENV_BLINQ === 'prod') {\n reportLinkBaseUrl = 'https://app.blinq.io'\n } else if (!process.env.NODE_ENV_BLINQ) {\n reportLinkBaseUrl = 'https://app.blinq.io'\n } else {\n reportLinkBaseUrl = process.env.NODE_ENV_BLINQ.replace('api', 'app')\n }\n const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`\n globalReportLink = reportLink;\n try {\n publishReportLinkToGuacServer(reportLink, status.status === \"PASSED\")\n } catch (err) {\n // Error with events, ignoring\n }\n return reportLink;\n}\n\nfunction publishReportLinkToGuacServer(reportLink: string, result: boolean) {\n if (existsSync('/tmp/report_publish.sh')) {\n const execAsync = promisify(exec)\n execAsync('sh /tmp/report_publish.sh ' + reportLink + ' ' + result)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bvt_analysis_formatter.js","sourceRoot":"","sources":["../../src/formatter/bvt_analysis_formatter.ts"],"names":[],"mappings":";;;;;;AACA,iDAAqC;AACrC,2BAA4D;AAC5D,0CAAsD;AACtD,gDAAuB;AACvB,6BAA6B;AAC7B,yCAAgD;AAChD,oDAAgD;AAChD,kFAKmC;AACnC,kEAA+C;AAC/C,4CAAmB;AACnB,+BAA6C;AAC7C,4EAAkD;AAClD,mDAAgE;AAChE,gEAA2D;AAK3D,+BAAgC;AAChC,iDAAoC;AAGpC,YAAY;AACZ,MAAM,KAAK,GAA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AAC,4BAA4B,GAAG,UAAU,GAAG,GAAG,GAAG,MAAM,CAAC,CAAA;KACpE;AACH,CAAC","sourcesContent":["import { Envelope, Meta } from '@cucumber/messages'\nimport { spawn } from 'child_process'\nimport { readFileSync, existsSync, writeFileSync } from 'fs'\nimport { mkdir, unlink, writeFile } from 'fs/promises'\nimport path from 'path'\nimport { tmpName } from 'tmp'\nimport Formatter, { IFormatterOptions } from '.'\nimport { doesHaveValue } from '../value_checker'\nimport ReportGenerator, {\n JsonReport,\n JsonTestProgress,\n JsonTestResult,\n RetrainStats,\n} from './helpers/report_generator'\nimport ReportUploader from './helpers/uploader'\nimport os from 'os'\nimport { getProjectByAccessKey } from './api'\nimport SummaryFormatter from './summary_formatter'\nimport { ActionEvents, SERVICES_URI } from './helpers/constants'\nimport { axiosClient } from '../configuration/axios_client'\nimport {\n FinishTestCaseResponse,\n RootCauseProps,\n} from './helpers/upload_serivce'\nimport { promisify } from 'util'\nimport { exec } from 'child_process'\nimport { isCloudRecorder } from './helpers/isCloudRecorder'\n\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 let globalReportLink = '';\nexport default class BVTAnalysisFormatter extends Formatter {\n static reportGenerator: ReportGenerator\n static reRunFailedStepsIndex:\n | { testCaseId: string; failedStepIndex: number }[]\n | null\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 private failedStepsIndex: { testCaseId: string; failedStepIndex: number }[]\n private summaryFormatter: SummaryFormatter\n private rootCauseArray: {\n rootCause: RootCauseProps\n report: JsonTestProgress\n }[] = []\n\n constructor(options: IFormatterOptions) {\n super(options)\n this.summaryFormatter = new SummaryFormatter(options)\n BVTAnalysisFormatter.reportGenerator = this.reportGenerator\n this.rootCauseArray = []\n this.failedStepsIndex = []\n BVTAnalysisFormatter.reRunFailedStepsIndex = process.env.RERUN\n ? JSON.parse(process.env.RERUN)\n : null\n\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n this.sendEvent(ActionEvents.cli_run_tests)\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage, data?: any) => {\n if (doesHaveValue(envelope.testCaseFinished) && data) {\n const { rootCause, report } = data as FinishTestCaseResponse\n\n if (!rootCause.status) {\n console.error(\n `Root cause: ${rootCause.failClass}\\n, ${rootCause.analysis}\\nfailing step: ${rootCause.failedStep}`\n )\n this.rootCauseArray.push({ rootCause, report })\n this.failedStepsIndex.push({\n testCaseId: report.id,\n failedStepIndex: rootCause.failedStep,\n })\n }\n return\n }\n await this.reportGenerator.handleMessage(envelope)\n\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 this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport()\n } else {\n // await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private sendEvent(event: ActionEvents) {\n axiosClient\n .post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event,\n },\n {\n headers: {\n Authorization: `Bearer ${TOKEN}`,\n 'x-source': 'cucumber_js',\n },\n }\n )\n .catch((err) => {\n // Error with events, ignoring\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 let anyRem\n if (process.env.UPLOADING_TEST_CASE) {\n anyRem = JSON.parse(process.env.UPLOADING_TEST_CASE) as string[]\n } else {\n anyRem = undefined\n }\n\n if (this.exit && (!anyRem || anyRem.length === 0)) {\n // clearInterval(checkInterval)\n // resolve(null)\n if (this.reportGenerator.getReport().result.status === 'FAILED') {\n process.exit(1)\n } else {\n process.exit(0)\n }\n }\n }, 100) // check every 100ms\n })\n }\n private async analyzeReport() {\n if (\n this.rootCauseArray.length === 0 ||\n process.env.NO_RETRAIN === 'false'\n ) {\n if (this.rootCauseArray.length === 0) {\n this.log('No test failed. No need to retrain\\n')\n }\n if (process.env.NO_RETRAIN === 'false') {\n this.log(\n 'Retraining is skipped since the failed step contains an API request\\n'\n )\n }\n // const uploadSuccessful = await this.uploadFinalReport(report)\n // process.exit(0)\n this.exit = true\n return\n }\n\n //checking if the type of report.result is JsonResultFailed or not\n\n this.log('Some tests failed, starting the retraining...\\n')\n await this.processTestCases()\n if (this.reportGenerator.getReport().result.status === 'FAILED') {\n process.exit(1)\n }\n process.exit(0)\n }\n private async processTestCases() {\n for (const { rootCause, report } of this.rootCauseArray) {\n await this.processTestCase(rootCause, report)\n }\n }\n private async processTestCase(\n rootCause: RootCauseProps,\n report: JsonTestProgress\n ) {\n const failedTestSteps = rootCause.failedStep\n\n if (\n BVTAnalysisFormatter.reRunFailedStepsIndex &&\n BVTAnalysisFormatter.reRunFailedStepsIndex.length > 0\n ) {\n const previousRun = BVTAnalysisFormatter.reRunFailedStepsIndex[0]\n if (previousRun.failedStepIndex === failedTestSteps) {\n console.log('Same step has failed again, skipping retraining')\n BVTAnalysisFormatter.reRunFailedStepsIndex.shift()\n return\n }\n BVTAnalysisFormatter.reRunFailedStepsIndex.shift()\n }\n\n const retrainStats = await this.retrain(failedTestSteps, report)\n\n if (!retrainStats) {\n return\n }\n\n await this.uploader.modifyTestCase({\n ...report,\n retrainStats,\n })\n\n await this.rerun(report)\n }\n\n private async uploadFinalReport(finalReport: JsonReport) {\n let success = true\n try {\n const { projectId, runId } = await this.uploader.uploadRun(\n finalReport,\n this.runName\n )\n logReportLink(runId, projectId, finalReport.result)\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 } finally {\n try {\n writeFileSync(\n path.join(this.reportGenerator.reportFolder, 'report.json'),\n JSON.stringify(finalReport, null, 2),\n 'utf-8'\n )\n } catch (e) {\n console.error('failed to write report.json to local disk')\n }\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 data = await getProjectByAccessKey(TOKEN)\n const currentTimestampInSeconds = Math.floor(Date.now() / 1000)\n if (data.project.expriration_date < currentTimestampInSeconds) {\n console.log(\n 'Warning: Your project has expired, retraining is restricted. Please contact sales.'\n )\n process.exit(1)\n }\n return await this.call_cucumber_client(failedTestCases, testCase)\n }\n\n private async rerun(report: JsonTestProgress) {\n await new Promise<void>((resolve) => {\n // Default to system Node.js\n let node_path = process.argv.shift();\n \n // Use bundled Node if running from recorder app on macOS or Windows\n const isFromRecorderApp = process.env.FROM_RECORDER_APP === \"true\";\n const isSupportedPlatform = process.platform === \"darwin\" || process.platform === \"win32\";\n \n if (isFromRecorderApp && isSupportedPlatform) {\n node_path = process.execPath;\n }\n \n const args = [\n path.join(\n process.cwd(),\n \"node_modules\",\n \"@dev-blinq\",\n \"cucumber-js\",\n \"bin\",\n \"cucumber.js\"\n ),\n \"--name\",\n `^${report.scenarioName}$`,\n \"--exit\",\n \"--format\",\n \"bvt\",\n \"--run-name\",\n `${report.scenarioName}@debug`,\n path.join(process.cwd(), report.uri),\n ];\n \n const envVars: NodeJS.ProcessEnv = {\n ...process.env,\n RERUN: JSON.stringify(this.failedStepsIndex),\n };\n \n // Inject Electron node env only if using bundled node\n if (node_path === process.execPath) {\n envVars.ELECTRON_RUN_AS_NODE = \"1\";\n }\n \n const cucumberClient = spawn(node_path!, args, {\n env: envVars,\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\", () => {\n resolve();\n });\n });\n }\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 \"undefined\",\n `${stepsToRetrain},`,\n ];\n \n if (process.env.BLINQ_ENV) {\n args.push(`--env=${process.env.BLINQ_ENV}`);\n }\n \n if (!existsSync(path.join(this.getAppDataDir(), \"blinq.io\", \".temp\"))) {\n mkdir(path.join(this.getAppDataDir(), \"blinq.io\", \".temp\"), {\n recursive: true,\n });\n }\n \n tmpName(async (err, name) => {\n const tempFile = path.join(\n this.getAppDataDir(),\n \"blinq.io\",\n \".temp\",\n path.basename(name)\n );\n console.log(\"File path: \", tempFile);\n \n if (!existsSync(path.dirname(tempFile))) {\n await mkdir(path.dirname(tempFile), { recursive: true });\n }\n await writeFile(tempFile, \"\", \"utf-8\");\n \n args.push(`--temp-file=${tempFile}`);\n \n // Determine node path\n const isFromRecorderApp = process.env.FROM_RECORDER_APP === \"true\";\n const isSupportedPlatform =\n process.platform === \"darwin\" || process.platform === \"win32\";\n const node_path =\n isFromRecorderApp && isSupportedPlatform\n ? process.execPath\n : \"node\";\n \n const envVars: NodeJS.ProcessEnv = {\n ...process.env,\n TEMP_FILE_PATH: tempFile,\n };\n \n if (node_path === process.execPath) {\n envVars.ELECTRON_RUN_AS_NODE = \"1\";\n }\n \n const cucumberClient = spawn(node_path, [cucumber_client_path, ...args], {\n env: envVars,\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\", async (code) => {\n if (code === 0) {\n const reportData = readFileSync(tempFile, \"utf-8\");\n const retrainStats = JSON.parse(reportData) as RetrainStats;\n await unlink(tempFile);\n resolve(retrainStats);\n } else {\n this.log(\"Error retraining\\n\");\n try {\n const reportData = readFileSync(tempFile, \"utf-8\");\n const retrainStats = JSON.parse(reportData) as RetrainStats;\n await unlink(tempFile);\n resolve(retrainStats);\n } catch (e) {\n this.log(\"Error reading scenario report\\n \" + e);\n resolve(null);\n }\n }\n });\n });\n });\n }\n \n\n private getAppDataDir() {\n if (process.env.BLINQ_APPDATA_DIR) {\n return process.env.BLINQ_APPDATA_DIR\n }\n\n let appDataDir: string\n\n switch (process.platform) {\n case 'win32':\n appDataDir = process.env.APPDATA!\n break\n case 'darwin':\n appDataDir = path.join(os.homedir(), 'Library', 'Application Support')\n break\n default:\n appDataDir = path.join(os.homedir(), '.config')\n break\n }\n return appDataDir\n }\n}\n\nexport function logReportLink(runId: string, projectId: string, status: JsonTestResult) {\n let reportLinkBaseUrl = 'https://app.blinq.io'\n if (process.env.NODE_ENV_BLINQ === 'local') {\n reportLinkBaseUrl = 'http://localhost:3000'\n } else if (process.env.NODE_ENV_BLINQ === 'dev') {\n reportLinkBaseUrl = 'https://dev.app.blinq.io'\n } else if (process.env.NODE_ENV_BLINQ === 'stage') {\n reportLinkBaseUrl = 'https://stage.app.blinq.io'\n } else if (process.env.NODE_ENV_BLINQ === 'prod') {\n reportLinkBaseUrl = 'https://app.blinq.io'\n } else if (!process.env.NODE_ENV_BLINQ) {\n reportLinkBaseUrl = 'https://app.blinq.io'\n } else {\n reportLinkBaseUrl = process.env.NODE_ENV_BLINQ.replace('api', 'app')\n }\n const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`\n globalReportLink = reportLink;\n try {\n publishReportLinkToGuacServer(reportLink, status.status === \"PASSED\")\n } catch (err) {\n // Error with events, ignoring\n }\n return reportLink;\n}\n\nfunction publishReportLinkToGuacServer(reportLink: string, result: boolean) {\n if (existsSync('/tmp/report_publish.sh')) {\n const execAsync = promisify(exec)\n execAsync('sh /tmp/report_publish.sh ' + reportLink + ' ' + result)\n }\n}\n"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.0.182-dev";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,aAAa,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,aAAa,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.182-dev'\n"]}
|