@dev-blinq/cucumber-js 1.0.123-dev → 1.0.123

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.
Files changed (42) hide show
  1. package/bin/cucumber.ts +1 -0
  2. package/bin/download-install.js +22 -2
  3. package/lib/api/console_logger.js.map +1 -1
  4. package/lib/cli/run.js +1 -0
  5. package/lib/cli/run.js.map +1 -1
  6. package/lib/cli/validate_node_engine_version.js +3 -1
  7. package/lib/cli/validate_node_engine_version.js.map +1 -1
  8. package/lib/configuration/axios_client.js +1 -1
  9. package/lib/configuration/axios_client.js.map +1 -1
  10. package/lib/formatter/api.js +16 -5
  11. package/lib/formatter/api.js.map +1 -1
  12. package/lib/formatter/builder.js +1 -3
  13. package/lib/formatter/builder.js.map +1 -1
  14. package/lib/formatter/bvt_analysis_formatter.d.ts +13 -1
  15. package/lib/formatter/bvt_analysis_formatter.js +163 -55
  16. package/lib/formatter/bvt_analysis_formatter.js.map +1 -1
  17. package/lib/formatter/feature_data_format.js +22 -8
  18. package/lib/formatter/feature_data_format.js.map +1 -1
  19. package/lib/formatter/helpers/constants.d.ts +50 -0
  20. package/lib/formatter/helpers/constants.js +60 -0
  21. package/lib/formatter/helpers/constants.js.map +1 -0
  22. package/lib/formatter/helpers/report_generator.d.ts +21 -3
  23. package/lib/formatter/helpers/report_generator.js +333 -27
  24. package/lib/formatter/helpers/report_generator.js.map +1 -1
  25. package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
  26. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
  27. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
  28. package/lib/formatter/helpers/upload_serivce.d.ts +15 -2
  29. package/lib/formatter/helpers/upload_serivce.js +153 -7
  30. package/lib/formatter/helpers/upload_serivce.js.map +1 -1
  31. package/lib/formatter/helpers/uploader.js +6 -2
  32. package/lib/formatter/helpers/uploader.js.map +1 -1
  33. package/lib/formatter/summary_formatter.js +4 -0
  34. package/lib/formatter/summary_formatter.js.map +1 -1
  35. package/lib/importer.js +0 -1
  36. package/lib/runtime/test_case_runner.d.ts +2 -0
  37. package/lib/runtime/test_case_runner.js +17 -1
  38. package/lib/runtime/test_case_runner.js.map +1 -1
  39. package/lib/version.d.ts +1 -1
  40. package/lib/version.js +1 -1
  41. package/lib/version.js.map +1 -1
  42. package/package.json +6 -3
@@ -1 +1 @@
1
- {"version":3,"file":"upload_serivce.js","sourceRoot":"","sources":["../../../src/formatter/helpers/upload_serivce.ts"],"names":[],"mappings":";;;;;;;AAEA,2BAAiD;AACjD,2DAA4B;AAG5B,mEAA8D;AAC9D,gDAAuB;AACvB,sEAAyD;AAEzD,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,mCAAI,GAAG,CAAA;AAChE,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,oBAAoB,GACxB,MAAA,OAAO,CAAC,GAAG,CAAC,KAAK,mCAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;AACvD,MAAM,gBAAgB;IACpB,YAAoB,cAAsB,EAAU,WAAmB;QAAnD,mBAAc,GAAd,cAAc,CAAQ;QAAU,gBAAW,GAAX,WAAW,CAAQ;IAAG,CAAC;IAC3E,KAAK,CAAC,iBAAiB,CAAC,IAAY;QAClC,IAAI;YACF,MAAM,YAAY,GAAG,MAAM,0BAAW,CAAC,IAAI,CACzC,IAAI,CAAC,cAAc,GAAG,uBAAuB,EAC7C;gBACE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;aAC3B,EACD;gBACE,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;oBAC3C,UAAU,EAAE,aAAa;iBAC1B;aACF,CACF,CAAA;YACD,IAAI,YAAY,CAAC,MAAM,KAAK,GAAG,EAAE;gBAC/B,MAAM,IAAI,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KAAK,CAAC,cAAc,CAClB,KAAa,EACb,SAAiB,EACjB,kBAAoC;QAEpC,IAAI;YACF,MAAM,GAAG,GAAG,MAAM,0BAAW,CAAC,IAAI,CAChC,IAAI,CAAC,cAAc,GAAG,+BAA+B,EACrD;gBACE,KAAK;gBACL,SAAS;gBACT,kBAAkB;aACnB,EACD;gBACE,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;oBAC3C,UAAU,EAAE,aAAa;iBAC1B;aACF,CACF,CAAA;YACD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAA;aACpB;YACD,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;gBAC5B,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAA;aACpB;YACD,IAAA,sCAAa,EAAC,KAAK,EAAE,SAAS,CAAC,CAAA;SAChC;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CACX,mCAAmC,kBAAkB,CAAC,EAAE,IAAI,CAAC,EAAE,CAChE,CAAA;SACF;IACH,CAAC;CACF;AAEQ,4CAAgB","sourcesContent":["/* eslint-disable no-console */\nimport FormData from 'form-data'\nimport { createReadStream, existsSync } from 'fs'\nimport fs from 'fs/promises'\n\nimport { JsonReport, JsonTestProgress } from './report_generator'\nimport { axiosClient } from '../../configuration/axios_client'\nimport path from 'path'\nimport { logReportLink } from '../bvt_analysis_formatter'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\nclass RunUploadService {\n constructor(private runsApiBaseURL: string, private accessToken: string) {}\n async createRunDocument(name: string) {\n try {\n const runDocResult = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/create',\n {\n name: name ? name : 'TEST',\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (runDocResult.status !== 200) {\n throw new Error('Failed to create run document in the server')\n }\n if (runDocResult.data.status !== true) {\n throw new Error('Failed to create run document in the server')\n }\n return runDocResult.data.run\n } catch (error) {\n if (error.response && error.response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot create or upload reports.'\n )\n process.exit(1)\n }\n throw new Error('Failed to create run document in the server: ' + error)\n }\n }\n async upload(formData: FormData) {\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/upload',\n formData,\n {\n headers: {\n ...formData.getHeaders(),\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 401) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to upload run to the server')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to upload run to the server')\n }\n }\n async getPreSignedUrls(fileUris: string[], runId: string) {\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/generateuploadurls',\n {\n fileUris,\n runId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n\n return response.data.uploadUrls\n }\n\n async uploadTestCase(\n testCaseReport: JsonTestProgress,\n runId: string,\n projectId: string,\n reportFolder: string\n ) {\n const fileUris = []\n //iterate over all the files in the JsonCommand.screenshotId and insert them into the fileUris array\n for (const step of testCaseReport.steps) {\n for (const command of step.commands) {\n if (command.screenshotId) {\n fileUris.push(\n 'screenshots' + '/' + String(command.screenshotId) + '.png'\n )\n }\n }\n }\n const preSignedUrls = await this.getPreSignedUrls(fileUris, runId)\n //upload all the files in the fileUris array\n try {\n for (let i = 0; i < fileUris.length; i += BATCH_SIZE) {\n const batch = fileUris.slice(\n i,\n Math.min(i + BATCH_SIZE, fileUris.length)\n )\n await Promise.all(\n batch\n .filter((fileUri) => preSignedUrls[fileUri])\n .map(async (fileUri) => {\n for (let j = 0; j < MAX_RETRIES; j++) {\n const success = await this.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\n }\n console.error('Failed to upload file:', fileUri)\n })\n )\n }\n await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/createNewTestCase',\n {\n runId,\n projectId,\n testProgressReport: testCaseReport,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n logReportLink(runId, projectId)\n } catch (e) {\n console.error(`failed to upload the test case: ${testCaseReport.id} ${e}`)\n }\n }\n async uploadFile(filePath: string, preSignedUrl: string) {\n const fileStream = createReadStream(filePath)\n let success = true\n try {\n const fileStats = await fs.stat(filePath)\n const fileSize = fileStats.size\n\n await axiosClient.put(preSignedUrl, fileStream, {\n headers: {\n 'Content-Type': 'application/octet-stream',\n 'Content-Length': fileSize,\n },\n })\n } catch (error) {\n if (process.env.NODE_ENV_BLINQ === 'dev') {\n console.error('Error uploading file:', error)\n }\n success = false\n } finally {\n fileStream.close()\n }\n return success\n }\n async uploadComplete(runId: string, projectId: string) {\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/uploadCompletion',\n {\n runId,\n projectId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status !== 200) {\n throw new Error('Failed to mark run as complete')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to mark run as complete')\n }\n }\n async modifyTestCase(\n runId: string,\n projectId: string,\n testProgressReport: JsonTestProgress\n ) {\n try {\n const res = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/modifyTestCase',\n {\n runId,\n projectId,\n testProgressReport,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (res.status !== 200) {\n throw new Error('')\n }\n if (res.data.status !== true) {\n throw new Error('')\n }\n logReportLink(runId, projectId)\n } catch (e) {\n console.error(\n `failed to modify the test case: ${testProgressReport.id} ${e}`\n )\n }\n }\n}\n\nexport { RunUploadService }\n"]}
1
+ {"version":3,"file":"upload_serivce.js","sourceRoot":"","sources":["../../../src/formatter/helpers/upload_serivce.ts"],"names":[],"mappings":";;;;;;;AAEA,2BAAuE;AACvE,2DAA4B;AAG5B,mEAA8D;AAC9D,gDAAuB;AACvB,sEAAyD;AACzD,2CAAwD;AAExD,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,mCAAI,GAAG,CAAA;AAChE,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,oBAAoB,GACxB,MAAA,OAAO,CAAC,GAAG,CAAC,KAAK,mCAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;AAevD,MAAM,gBAAgB;IACpB,YAAoB,cAAsB,EAAU,WAAmB;QAAnD,mBAAc,GAAd,cAAc,CAAQ;QAAU,gBAAW,GAAX,WAAW,CAAQ;IAAG,CAAC;IAC3E,KAAK,CAAC,iBAAiB,CAAC,IAAY,EAAE,GAAQ;QAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,OAAO,EAAE;YACzC,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAA;YACtE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EA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,kDAAkD,CAAC,CAAA;SAChE;IACH,CAAC;CACF;AAEQ,4CAAgB","sourcesContent":["/* eslint-disable no-console */\nimport FormData from 'form-data'\nimport { createReadStream, existsSync, write, writeFileSync } from 'fs'\nimport fs from 'fs/promises'\n\nimport { JsonReport, JsonTestProgress } from './report_generator'\nimport { axiosClient } from '../../configuration/axios_client'\nimport path from 'path'\nimport { logReportLink } from '../bvt_analysis_formatter'\nimport { ActionEvents, SERVICES_URI } from './constants'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport interface RootCauseProps {\n status: boolean\n analysis: string\n failedStep: number\n failClass: string\n}\n\nexport interface FinishTestCaseResponse {\n status: true\n rootCause: RootCauseProps\n report: JsonTestProgress\n}\n\nclass RunUploadService {\n constructor(private runsApiBaseURL: string, private accessToken: string) {}\n async createRunDocument(name: string, env: any) {\n if (process.env.UPLOADREPORTS === 'false') {\n console.log('Skipping report upload as UPLOADREPORTS is set to false')\n return { id: 'local-run', projectId: 'local-project' }\n }\n try {\n const runDocResult = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/create',\n {\n name: name ? name : 'TEST',\n branch: process.env.GIT_BRANCH ? process.env.GIT_BRANCH : 'main',\n video_id: process.env.VIDEO_ID,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode:\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local',\n env: { name: env?.name, baseUrl: env?.baseUrl },\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (runDocResult.status !== 200) {\n throw new Error('Failed to create run document in the server')\n }\n if (runDocResult.data.status !== true) {\n throw new Error('Failed to create run document in the server')\n }\n return runDocResult.data.run\n } catch (error) {\n if (error.response && error.response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot create or upload reports.'\n )\n process.exit(1)\n }\n throw new Error('Failed to create run document in the server: ' + error)\n }\n }\n async updateProjectAnalytics(projectId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n try {\n await axiosClient.post(\n this.runsApiBaseURL + '/project/updateAIRecoveryCount',\n {\n projectId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n } catch (error) {\n console.error('Failed to update project metadata:', error)\n }\n }\n async upload(formData: FormData) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/upload',\n formData,\n {\n headers: {\n ...formData.getHeaders(),\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 401) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to upload run to the server')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to upload run to the server')\n }\n }\n async getPreSignedUrls(fileUris: string[], runId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return {}\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/generateuploadurls',\n {\n fileUris,\n runId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n\n return response.data.uploadUrls\n }\n\n async uploadTestCase(\n testCaseReport: JsonTestProgress,\n runId: string,\n projectId: string,\n reportFolder: string,\n rerunId?: string\n ) {\n if (process.env.UPLOADREPORTS === 'false') {\n return null\n }\n const fileUris = []\n //iterate over all the files in the JsonCommand.screenshotId and insert them into the fileUris array\n for (const step of testCaseReport.steps) {\n for (const command of step.commands) {\n if (command.screenshotId) {\n fileUris.push(\n 'screenshots' + '/' + String(command.screenshotId) + '.png'\n )\n }\n }\n if (step.traceFilePath) {\n fileUris.push('trace' + '/' + step.traceFilePath)\n }\n }\n if (testCaseReport.logFileId) {\n fileUris.push(\n 'editorLogs' + '/' + 'testCaseLog_' + testCaseReport.logFileId + '.log'\n )\n }\n // console.log({ fileUris })\n //upload all the files in the fileUris array\n\n try {\n const preSignedUrls = await this.getPreSignedUrls(fileUris, runId)\n for (let i = 0; i < fileUris.length; i += BATCH_SIZE) {\n const batch = fileUris.slice(\n i,\n Math.min(i + BATCH_SIZE, fileUris.length)\n )\n await Promise.all(\n batch\n .filter((fileUri) => preSignedUrls[fileUri])\n .map(async (fileUri) => {\n for (let j = 0; j < MAX_RETRIES; j++) {\n if (existsSync(path.join(reportFolder, fileUri))) {\n const success = await this.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\n }\n const success = await this.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\n }\n console.error('Failed to upload file:', fileUri)\n })\n )\n }\n } catch (error) {\n const errorMessage = error.response ? error.response.data : error.message\n console.error('Error uploading files:', errorMessage)\n }\n\n try {\n // writeFileSync(\"report.json\", JSON.stringify(testCaseReport, null, 2))\n const mode =\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local'\n\n let rerunIdFinal = null\n\n rerunIdFinal = process.env.RETRY_ID || null\n if (rerunId) {\n rerunIdFinal = rerunId.includes(runId) ? rerunId : `${runId}${rerunId}`\n }\n\n if (mode === 'executions') {\n testCaseReport.id = process.env.VIDEO_ID || testCaseReport.id\n }\n\n const { data } = await axiosClient.post<FinishTestCaseResponse>(\n this.runsApiBaseURL + '/cucumber-runs/createNewTestCase',\n {\n runId,\n projectId,\n testProgressReport: testCaseReport,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode,\n rerunId: rerunIdFinal,\n video_id: process.env.VIDEO_ID,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n\n try {\n await axiosClient.post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event: ActionEvents.upload_report,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n 'x-bvt-project-id': projectId,\n },\n }\n )\n } catch (error) {\n // no event tracking\n }\n logReportLink(runId, projectId, testCaseReport.result)\n return data\n } catch (e) {\n const errorMessage = e.response ? e.response.data : e.message\n console.error(\n `failed to upload the test case: ${testCaseReport.id} ${errorMessage}`\n )\n return null\n }\n }\n async uploadFile(filePath: string, preSignedUrl: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return true\n }\n const fileStream = createReadStream(filePath)\n let success = true\n try {\n const fileStats = await fs.stat(filePath)\n const fileSize = fileStats.size\n\n await axiosClient.put(preSignedUrl, fileStream, {\n headers: {\n 'Content-Type': 'application/octet-stream',\n 'Content-Length': fileSize,\n },\n })\n } catch (error) {\n if (process.env.NODE_ENV_BLINQ === 'dev') {\n console.error('Error uploading file:', error)\n }\n success = false\n } finally {\n fileStream.close()\n }\n return success\n }\n async uploadComplete(runId: string, projectId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/uploadCompletion',\n {\n runId,\n projectId,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode:\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local',\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status !== 200) {\n throw new Error('Failed to mark run as complete')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to mark run as complete')\n }\n\n try {\n await axiosClient.post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event: ActionEvents.upload_report,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n 'x-bvt-project-id': projectId,\n },\n }\n )\n } catch (error) {\n // no event tracking\n }\n }\n async modifyTestCase(\n runId: string,\n projectId: string,\n testProgressReport: JsonTestProgress\n ) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n try {\n const res = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/modifyTestCase',\n {\n runId,\n projectId,\n testProgressReport,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (res.status !== 200) {\n throw new Error('')\n }\n if (res.data.status !== true) {\n throw new Error('')\n }\n logReportLink(runId, projectId, testProgressReport.result)\n } catch (e) {\n console.error(\n `failed to modify the test case: ${testProgressReport.id} ${e}`\n )\n }\n }\n async createStatus(status: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n if (!process.env.UUID) {\n return\n }\n\n try {\n await axiosClient.post(\n this.runsApiBaseURL + '/scenarios/status',\n {\n status: { status },\n uuid: process.env.UUID,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n } catch (error) {\n console.log('Failed to send status to the server, ignoring it')\n }\n }\n}\n\nexport { RunUploadService }\n"]}
@@ -38,7 +38,11 @@ const URL = process.env.NODE_ENV_BLINQ === 'dev'
38
38
  ? 'http://localhost:5001/api/runs'
39
39
  : process.env.NODE_ENV_BLINQ === 'stage'
40
40
  ? 'https://stage.api.blinq.io/api/runs'
41
- : 'https://api.blinq.io/api/runs';
41
+ : process.env.NODE_ENV_BLINQ === 'prod'
42
+ ? 'https://api.blinq.io/api/runs'
43
+ : !process.env.NODE_ENV_BLINQ
44
+ ? 'https://api.blinq.io/api/runs'
45
+ : `${process.env.NODE_ENV_BLINQ}/api/runs`;
42
46
  const REPORT_SERVICE_URL = (_a = process.env.REPORT_SERVICE_URL) !== null && _a !== void 0 ? _a : URL;
43
47
  const BATCH_SIZE = 10;
44
48
  const MAX_RETRIES = 3;
@@ -52,7 +56,7 @@ class ReportUploader {
52
56
  this.reportGenerator = reportGenerator;
53
57
  }
54
58
  async uploadRun(report, runName) {
55
- const runDoc = await this.uploadService.createRunDocument(runName);
59
+ const runDoc = await this.uploadService.createRunDocument(runName, report.env);
56
60
  const runDocId = runDoc._id;
57
61
  const reportFolder = this.reportGenerator.reportFolder;
58
62
  if (!fs_1.default.existsSync(reportFolder)) {
@@ -1 +1 @@
1
- {"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../../src/formatter/helpers/uploader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,qDAAmD;AAEnD,0DAAgC;AAChC,yCAAsC;AACtC,kDAAyB;AACzB,gDAAuB;AACvB,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,KAAK;IAClC,CAAC,CAAC,mCAAmC;IACrC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;QACxC,CAAC,CAAC,gCAAgC;QAClC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;YACxC,CAAC,CAAC,qCAAqC;YACvC,CAAC,CAAC,+BAA+B,CAAA;AAErC,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,mCAAI,GAAG,CAAA;AAChE,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,oBAAoB,GACxB,MAAA,OAAO,CAAC,G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AC,YAAY,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAA","sourcesContent":["import axios from 'axios'\nimport ReportGenerator, {\n JsonReport,\n JsonTestProgress,\n} from './report_generator'\nimport { RunUploadService } from './upload_serivce'\n\nimport FormData from 'form-data'\nimport fs, { writeFileSync } from 'fs'\nimport JSZip from 'jszip'\nimport path from 'path'\nconst URL =\n process.env.NODE_ENV_BLINQ === 'dev'\n ? 'https://dev.api.blinq.io/api/runs'\n : process.env.NODE_ENV_BLINQ === 'local'\n ? 'http://localhost:5001/api/runs'\n : process.env.NODE_ENV_BLINQ === 'stage'\n ? 'https://stage.api.blinq.io/api/runs'\n : 'https://api.blinq.io/api/runs'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport default class ReportUploader {\n private uploadService = new RunUploadService(\n REPORT_SERVICE_URL,\n REPORT_SERVICE_TOKEN\n )\n private reportGenerator: ReportGenerator\n constructor(reportGenerator: ReportGenerator) {\n if (!REPORT_SERVICE_URL || !REPORT_SERVICE_TOKEN) {\n throw new Error('REPORT_SERVICE_URL and REPORT_SERVICE_TOKEN must be set')\n }\n this.reportGenerator = reportGenerator\n }\n\n async uploadRun(report: JsonReport, runName: string) {\n const runDoc = await this.uploadService.createRunDocument(runName)\n const runDocId = runDoc._id\n const reportFolder = this.reportGenerator.reportFolder\n if (!fs.existsSync(reportFolder)) {\n fs.mkdirSync(reportFolder)\n }\n writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n if (process.env.NODE_ENV_BLINQ === 'local') {\n const formData = new FormData()\n const zipPath = await this.createZip(reportFolder, report)\n formData.append(runDocId, fs.readFileSync(zipPath), 'report.zip')\n await this.uploadService.upload(formData)\n } else {\n const fileUris = [\n ...getFileUris(reportFolder, 'screenshots'),\n ...getFileUris(reportFolder, 'trace'),\n 'report.json',\n 'network.json',\n ]\n try {\n const preSignedUrls = await this.uploadService.getPreSignedUrls(\n fileUris,\n runDocId\n )\n\n for (let i = 0; i < fileUris.length; i += BATCH_SIZE) {\n const batch = fileUris.slice(\n i,\n Math.min(i + BATCH_SIZE, fileUris.length)\n )\n await Promise.all(\n batch\n .filter((fileUri) => preSignedUrls[fileUri])\n .map(async (fileUri) => {\n for (let j = 0; j < MAX_RETRIES; j++) {\n const success = await this.uploadService.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\n }\n console.error('Failed to upload file:', fileUri)\n })\n )\n }\n await this.uploadService.uploadComplete(runDocId, runDoc.project_id)\n } catch (err) {\n throw new Error('Failed to upload all the files')\n }\n }\n return { runId: runDoc._id, projectId: runDoc.project_id }\n }\n\n async modifyTestCase(testCase: JsonTestProgress) {\n const runId = process.env.RUN_ID\n if (!runId) {\n return\n }\n const projectId = process.env.PROJECT_ID\n if (!projectId) {\n return\n }\n await this.uploadService.modifyTestCase(runId, projectId, testCase)\n }\n async createZip(reportFolder: string | null, report: JsonReport) {\n if (reportFolder === null) {\n console.error('report folder is empty')\n console.error('it is likey that there are no scenarios to run')\n throw new Error('Empty report folder')\n }\n const zip = new JSZip()\n zip.file('report.json', JSON.stringify(report, null, 2))\n const folder = zip.folder('screenshots')\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n files.forEach((file) => {\n folder.file(\n file,\n fs.readFileSync(path.join(reportFolder, 'screenshots', file))\n )\n })\n const zipBuffer = await zip.generateAsync({ type: 'nodebuffer' })\n // save zip file\n const zipPath = path.join(reportFolder, 'report.zip')\n fs.writeFileSync(zipPath, new Uint8Array(zipBuffer))\n fs.writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n return zipPath\n }\n}\n\nconst getFileUrisScreenShotDir = (reportFolder: string) => {\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n\n return files.map((file) => ['screenshots', file].join('/'))\n}\n\nconst getFileUris = (reportFolder: string, targetFolder: string) => {\n const resultFolder = path.join(reportFolder, targetFolder)\n if (!fs.existsSync(resultFolder)) {\n return []\n }\n const files = fs.readdirSync(resultFolder)\n return files.map((file) => [targetFolder, file].join('/'))\n}\n"]}
1
+ {"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../../src/formatter/helpers/uploader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,qDAAmD;AAEnD,0DAAgC;AAChC,yCAAsC;AACtC,kDAAyB;AACzB,gDAAuB;AACvB,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,KAAK;IAClC,CAAC,CAAC,mCAAmC;IACrC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;QACtC,CAAC,CAAC,gCAAgC;QAClC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;YACtC,CAAC,CAAC,qCAAqC;YACvC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM;gBACrC,CAAC,CAAC,+BAA+B;gBACjC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc;oBAC3B,CAAC,CAAC,+BAA+B;oBACjC,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,WAAW,CAAA;AAEtD,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,mCAAI,GAAG,CAAA;AAChE,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,oBAAoB,GACxB,MAAA,OAAO,CAAC,GAAG,CAAC,KAAK,mCAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;AAEvD,MAAqB,cAAc;IAMjC,YAAY,eAA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AC,CAAA","sourcesContent":["import axios from 'axios'\nimport ReportGenerator, {\n JsonReport,\n JsonTestProgress,\n} from './report_generator'\nimport { RunUploadService } from './upload_serivce'\n\nimport FormData from 'form-data'\nimport fs, { writeFileSync } from 'fs'\nimport JSZip from 'jszip'\nimport path from 'path'\nconst URL =\n process.env.NODE_ENV_BLINQ === 'dev'\n ? 'https://dev.api.blinq.io/api/runs'\n : process.env.NODE_ENV_BLINQ === 'local'\n ? 'http://localhost:5001/api/runs'\n : process.env.NODE_ENV_BLINQ === 'stage'\n ? 'https://stage.api.blinq.io/api/runs'\n : process.env.NODE_ENV_BLINQ === 'prod'\n ? 'https://api.blinq.io/api/runs'\n : !process.env.NODE_ENV_BLINQ\n ? 'https://api.blinq.io/api/runs'\n : `${process.env.NODE_ENV_BLINQ}/api/runs`\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport default class ReportUploader {\n private uploadService = new RunUploadService(\n REPORT_SERVICE_URL,\n REPORT_SERVICE_TOKEN\n )\n private reportGenerator: ReportGenerator\n constructor(reportGenerator: ReportGenerator) {\n if (!REPORT_SERVICE_URL || !REPORT_SERVICE_TOKEN) {\n throw new Error('REPORT_SERVICE_URL and REPORT_SERVICE_TOKEN must be set')\n }\n this.reportGenerator = reportGenerator\n }\n\n async uploadRun(report: JsonReport, runName: string) {\n const runDoc = await this.uploadService.createRunDocument(\n runName,\n report.env\n )\n const runDocId = runDoc._id\n const reportFolder = this.reportGenerator.reportFolder\n if (!fs.existsSync(reportFolder)) {\n fs.mkdirSync(reportFolder)\n }\n writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n if (process.env.NODE_ENV_BLINQ === 'local') {\n const formData = new FormData()\n const zipPath = await this.createZip(reportFolder, report)\n formData.append(runDocId, fs.readFileSync(zipPath), 'report.zip')\n await this.uploadService.upload(formData)\n } else {\n const fileUris = [\n ...getFileUris(reportFolder, 'screenshots'),\n ...getFileUris(reportFolder, 'trace'),\n 'report.json',\n 'network.json',\n ]\n try {\n const preSignedUrls = await this.uploadService.getPreSignedUrls(\n fileUris,\n runDocId\n )\n\n for (let i = 0; i < fileUris.length; i += BATCH_SIZE) {\n const batch = fileUris.slice(\n i,\n Math.min(i + BATCH_SIZE, fileUris.length)\n )\n await Promise.all(\n batch\n .filter((fileUri) => preSignedUrls[fileUri])\n .map(async (fileUri) => {\n for (let j = 0; j < MAX_RETRIES; j++) {\n const success = await this.uploadService.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\n }\n console.error('Failed to upload file:', fileUri)\n })\n )\n }\n await this.uploadService.uploadComplete(runDocId, runDoc.project_id)\n } catch (err) {\n throw new Error('Failed to upload all the files')\n }\n }\n return { runId: runDoc._id, projectId: runDoc.project_id }\n }\n\n async modifyTestCase(testCase: JsonTestProgress) {\n const runId = process.env.RUN_ID\n if (!runId) {\n return\n }\n const projectId = process.env.PROJECT_ID\n if (!projectId) {\n return\n }\n await this.uploadService.modifyTestCase(runId, projectId, testCase)\n }\n async createZip(reportFolder: string | null, report: JsonReport) {\n if (reportFolder === null) {\n console.error('report folder is empty')\n console.error('it is likey that there are no scenarios to run')\n throw new Error('Empty report folder')\n }\n const zip = new JSZip()\n zip.file('report.json', JSON.stringify(report, null, 2))\n const folder = zip.folder('screenshots')\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n files.forEach((file) => {\n folder.file(\n file,\n fs.readFileSync(path.join(reportFolder, 'screenshots', file))\n )\n })\n const zipBuffer = await zip.generateAsync({ type: 'nodebuffer' })\n // save zip file\n const zipPath = path.join(reportFolder, 'report.zip')\n fs.writeFileSync(zipPath, new Uint8Array(zipBuffer))\n fs.writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n return zipPath\n }\n}\n\nconst getFileUrisScreenShotDir = (reportFolder: string) => {\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n\n return files.map((file) => ['screenshots', file].join('/'))\n}\n\nconst getFileUris = (reportFolder: string, targetFolder: string) => {\n const resultFolder = path.join(reportFolder, targetFolder)\n if (!fs.existsSync(resultFolder)) {\n return []\n }\n const files = fs.readdirSync(resultFolder)\n return files.map((file) => [targetFolder, file].join('/'))\n}\n"]}
@@ -8,6 +8,7 @@ const _1 = __importDefault(require("./"));
8
8
  const value_checker_1 = require("../value_checker");
9
9
  const issue_helpers_1 = require("./helpers/issue_helpers");
10
10
  const time_1 = require("../time");
11
+ const bvt_analysis_formatter_1 = require("./bvt_analysis_formatter");
11
12
  class SummaryFormatter extends _1.default {
12
13
  constructor(options) {
13
14
  super(options);
@@ -43,6 +44,9 @@ class SummaryFormatter extends _1.default {
43
44
  if (warnings.length > 0) {
44
45
  this.logIssues({ issues: warnings, title: 'Warnings' });
45
46
  }
47
+ if (bvt_analysis_formatter_1.globalReportLink) {
48
+ console.log(`Report link: ${bvt_analysis_formatter_1.globalReportLink}\n`);
49
+ }
46
50
  this.log((0, helpers_1.formatSummary)({
47
51
  colorFns: this.colorFns,
48
52
  testCaseAttempts,
@@ -1 +1 @@
1
- {"version":3,"file":"summary_formatter.js","sourceRoot":"","sources":["../../src/formatter/summary_formatter.ts"],"names":[],"mappings":";;;;;AAAA,uCAA4E;AAC5E,0CAAiD;AACjD,oDAAgD;AAGhD,2DAAuE;AACvE,kCAAmD;AAOnD,MAAqB,gBAAiB,SAAQ,UAAS;IAIrD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,uBAA2C,CAAA;QAC/C,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;gBAC1C,uBAAuB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E;YACvB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAA;SACxD;QACD,IAAI,CAAC,GAAG,CACN,IAAA,uBAAa,EAAC;YACZ,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,gBAAgB;YAChB,eAAe;SAChB,CAAC,CACH,CAAA;IACH,CAAC;IAED,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAqB;QAC5C,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,OAAO,CAAC,CAAA;QACzB,MAAM,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,KAAK,EAAE,EAAE;YACxC,IAAI,CAAC,GAAG,CACN,IAAA,qBAAW,EAAC;gBACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,MAAM,EAAE,KAAK,GAAG,CAAC;gBACjB,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,eAAe;gBACf,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;aACxC,CAAC,CACH,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;;AAhFH,mCAiFC;AAhFwB,8BAAa,GAClC,yCAAyC,CAAA","sourcesContent":["import { formatIssue, formatSummary, isFailure, isWarning } from './helpers'\nimport Formatter, { IFormatterOptions } from './'\nimport { doesHaveValue } from '../value_checker'\nimport * as messages from '@cucumber/messages'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { formatUndefinedParameterTypes } from './helpers/issue_helpers'\nimport { durationBetweenTimestamps } from '../time'\n\ninterface ILogIssuesRequest {\n issues: ITestCaseAttempt[]\n title: string\n}\n\nexport default class SummaryFormatter extends Formatter {\n public static readonly documentation: string =\n 'Summary output of feature and scenarios'\n\n constructor(options: IFormatterOptions) {\n super(options)\n let testRunStartedTimestamp: messages.Timestamp\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunStarted)) {\n testRunStartedTimestamp = envelope.testRunStarted.timestamp\n }\n if (doesHaveValue(envelope.testRunFinished)) {\n const testRunFinishedTimestamp = envelope.testRunFinished.timestamp\n this.logSummary(\n durationBetweenTimestamps(\n testRunStartedTimestamp,\n testRunFinishedTimestamp\n )\n )\n }\n })\n }\n\n logSummary(testRunDuration: messages.Duration): void {\n const failures: ITestCaseAttempt[] = []\n const warnings: ITestCaseAttempt[] = []\n const testCaseAttempts = this.eventDataCollector.getTestCaseAttempts()\n testCaseAttempts.forEach((testCaseAttempt) => {\n if (\n isFailure(\n testCaseAttempt.worstTestStepResult,\n testCaseAttempt.willBeRetried\n )\n ) {\n failures.push(testCaseAttempt)\n } else if (\n isWarning(\n testCaseAttempt.worstTestStepResult,\n testCaseAttempt.willBeRetried\n )\n ) {\n warnings.push(testCaseAttempt)\n }\n })\n if (this.eventDataCollector.undefinedParameterTypes.length > 0) {\n this.log(\n formatUndefinedParameterTypes(\n this.eventDataCollector.undefinedParameterTypes\n )\n )\n }\n if (failures.length > 0) {\n this.logIssues({ issues: failures, title: 'Failures' })\n }\n if (warnings.length > 0) {\n this.logIssues({ issues: warnings, title: 'Warnings' })\n }\n this.log(\n formatSummary({\n colorFns: this.colorFns,\n testCaseAttempts,\n testRunDuration,\n })\n )\n }\n\n logIssues({ issues, title }: ILogIssuesRequest): void {\n this.log(`${title}:\\n\\n`)\n issues.forEach((testCaseAttempt, index) => {\n this.log(\n formatIssue({\n colorFns: this.colorFns,\n number: index + 1,\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n printAttachments: this.printAttachments,\n })\n )\n })\n }\n}\n"]}
1
+ {"version":3,"file":"summary_formatter.js","sourceRoot":"","sources":["../../src/formatter/summary_formatter.ts"],"names":[],"mappings":";;;;;AAAA,uCAA4E;AAC5E,0CAAiD;AACjD,oDAAgD;AAGhD,2DAAuE;AACvE,kCAAmD;AACnD,qEAA2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IFormatterOptions } from './'\nimport { doesHaveValue } from '../value_checker'\nimport * as messages from '@cucumber/messages'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { formatUndefinedParameterTypes } from './helpers/issue_helpers'\nimport { durationBetweenTimestamps } from '../time'\nimport { globalReportLink } from './bvt_analysis_formatter'\n\ninterface ILogIssuesRequest {\n issues: ITestCaseAttempt[]\n title: string\n}\n\nexport default class SummaryFormatter extends Formatter {\n public static readonly documentation: string =\n 'Summary output of feature and scenarios'\n\n constructor(options: IFormatterOptions) {\n super(options)\n let testRunStartedTimestamp: messages.Timestamp\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunStarted)) {\n testRunStartedTimestamp = envelope.testRunStarted.timestamp\n }\n if (doesHaveValue(envelope.testRunFinished)) {\n const testRunFinishedTimestamp = envelope.testRunFinished.timestamp\n this.logSummary(\n durationBetweenTimestamps(\n testRunStartedTimestamp,\n testRunFinishedTimestamp\n )\n )\n }\n })\n }\n\n logSummary(testRunDuration: messages.Duration): void {\n const failures: ITestCaseAttempt[] = []\n const warnings: ITestCaseAttempt[] = []\n const testCaseAttempts = this.eventDataCollector.getTestCaseAttempts()\n testCaseAttempts.forEach((testCaseAttempt) => {\n if (\n isFailure(\n testCaseAttempt.worstTestStepResult,\n testCaseAttempt.willBeRetried\n )\n ) {\n failures.push(testCaseAttempt)\n } else if (\n isWarning(\n testCaseAttempt.worstTestStepResult,\n testCaseAttempt.willBeRetried\n )\n ) {\n warnings.push(testCaseAttempt)\n }\n })\n if (this.eventDataCollector.undefinedParameterTypes.length > 0) {\n this.log(\n formatUndefinedParameterTypes(\n this.eventDataCollector.undefinedParameterTypes\n )\n )\n }\n if (failures.length > 0) {\n this.logIssues({ issues: failures, title: 'Failures' })\n }\n if (warnings.length > 0) {\n this.logIssues({ issues: warnings, title: 'Warnings' })\n }\n if (globalReportLink) {\n console.log(`Report link: ${globalReportLink}\\n`)\n }\n this.log(\n formatSummary({\n colorFns: this.colorFns,\n testCaseAttempts,\n testRunDuration,\n })\n )\n }\n\n logIssues({ issues, title }: ILogIssuesRequest): void {\n this.log(`${title}:\\n\\n`)\n issues.forEach((testCaseAttempt, index) => {\n this.log(\n formatIssue({\n colorFns: this.colorFns,\n number: index + 1,\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n printAttachments: this.printAttachments,\n })\n )\n })\n }\n}\n"]}
package/lib/importer.js CHANGED
@@ -10,5 +10,4 @@ async function importer(descriptor) {
10
10
  return await import(descriptor)
11
11
  }
12
12
 
13
-
14
13
  module.exports = { importer }
@@ -37,6 +37,8 @@ export default class TestCaseRunner {
37
37
  private testStepResults;
38
38
  private world;
39
39
  private readonly worldParameters;
40
+ private retryTestCaseId;
41
+ private reportGenerator;
40
42
  constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries, skip, filterStackTraces, supportCodeLibrary, worldParameters, }: INewTestCaseRunnerOptions);
41
43
  resetTestProgressData(): void;
42
44
  getBeforeStepHookDefinitions(): TestStepHookDefinition[];
@@ -32,6 +32,8 @@ const step_runner_1 = __importDefault(require("./step_runner"));
32
32
  const messages = __importStar(require("@cucumber/messages"));
33
33
  const messages_1 = require("@cucumber/messages");
34
34
  const value_checker_1 = require("../value_checker");
35
+ const report_generator_1 = __importDefault(require("../formatter/helpers/report_generator"));
36
+ const bvt_analysis_formatter_1 = __importDefault(require("../formatter/bvt_analysis_formatter"));
35
37
  class TestCaseRunner {
36
38
  constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries = 0, skip, filterStackTraces, supportCodeLibrary, worldParameters, }) {
37
39
  this.attachmentManager = new attachment_manager_1.default(({ data, media, fileName }) => {
@@ -62,6 +64,7 @@ class TestCaseRunner {
62
64
  this.supportCodeLibrary = supportCodeLibrary;
63
65
  this.worldParameters = worldParameters;
64
66
  this.resetTestProgressData();
67
+ this.reportGenerator = new report_generator_1.default();
65
68
  }
66
69
  resetTestProgressData() {
67
70
  this.world = new this.supportCodeLibrary.World({
@@ -149,9 +152,16 @@ class TestCaseRunner {
149
152
  testCaseId: this.testCase.id,
150
153
  id: this.currentTestCaseStartedId,
151
154
  timestamp: this.stopwatch.timestamp(),
155
+ retryTestCaseId: this.retryTestCaseId,
152
156
  },
153
157
  };
158
+ if (process.env.NODE_ENV === 'test') {
159
+ delete testCaseStarted.testCaseStarted.retryTestCaseId;
160
+ }
154
161
  this.eventBroadcaster.emit('envelope', testCaseStarted);
162
+ if (this.maxAttempts > 1 && attempt === 0) {
163
+ this.retryTestCaseId = this.currentTestCaseStartedId;
164
+ }
155
165
  // used to determine whether a hook is a Before or After
156
166
  let didWeRunStepsYet = false;
157
167
  for (const testStep of this.testCase.testSteps) {
@@ -187,7 +197,13 @@ class TestCaseRunner {
187
197
  willBeRetried,
188
198
  },
189
199
  };
190
- this.eventBroadcaster.emit('envelope', testCaseFinished);
200
+ const rerunId = bvt_analysis_formatter_1.default.reRunFailedStepsIndex
201
+ ? bvt_analysis_formatter_1.default.reRunFailedStepsIndex[0].testCaseId
202
+ : null;
203
+ const data = bvt_analysis_formatter_1.default.reportGenerator
204
+ ? await bvt_analysis_formatter_1.default.reportGenerator.handleMessage(testCaseFinished, rerunId)
205
+ : null;
206
+ this.eventBroadcaster.emit('envelope', testCaseFinished, data);
191
207
  return willBeRetried;
192
208
  }
193
209
  async runHook(hookDefinition, hookParameter, isBeforeHook) {
@@ -1 +1 @@
1
- {"version":3,"file":"test_case_runner.js","sourceRoot":"","sources":["../../src/runtime/test_case_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAqD;AACrD,8EAAoD;AACpD,gEAAsC;AACtC,6DAA8C;AAC9C,iDAAwE;AAUxE,oDAAkE;AAkBlE,MAAqB,cAAc;IAkBjC,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO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Q,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;QACrE,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE;YAChC,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,YAAY,CAClD,aAAa,EACb,MAAM,CAAC,QAAQ,CAChB,CAAA;SACF;QACD,eAAe,CAAC,QAAQ,GAAG,aAAa,CAAA;QACxC,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AAlUD,iCAkUC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO;QACL,GAAG,kBAAkB,CAAC,6BAA6B;QACnD,GAAG,kBAAkB,CAAC,4BAA4B;KACnD,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAC5C,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CACrC,CAAA;AACH,CAAC","sourcesContent":["import { getAmbiguousStepException } from './helpers'\nimport AttachmentManager from './attachment_manager'\nimport StepRunner from './step_runner'\nimport * as messages from '@cucumber/messages'\nimport { getWorstTestStepResult, IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport {\n ISupportCodeLibrary,\n ITestCaseHookParameter,\n ITestStepHookParameter,\n} from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport { IDefinition } from '../models/definition'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { IStopwatch } from './stopwatch'\nimport StepDefinition from '../models/step_definition'\n\nexport interface INewTestCaseRunnerOptions {\n eventBroadcaster: EventEmitter\n stopwatch: IStopwatch\n gherkinDocument: messages.GherkinDocument\n newId: IdGenerator.NewId\n pickle: messages.Pickle\n testCase: messages.TestCase\n retries: number\n skip: boolean\n filterStackTraces: boolean\n supportCodeLibrary: ISupportCodeLibrary\n worldParameters: any\n}\n\nexport default class TestCaseRunner {\n private readonly attachmentManager: AttachmentManager\n private currentTestCaseStartedId: string\n private currentTestStepId: string\n private readonly eventBroadcaster: EventEmitter\n private readonly stopwatch: IStopwatch\n private readonly gherkinDocument: messages.GherkinDocument\n private readonly newId: IdGenerator.NewId\n private readonly pickle: messages.Pickle\n private readonly testCase: messages.TestCase\n private readonly maxAttempts: number\n private readonly skip: boolean\n private readonly filterStackTraces: boolean\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private testStepResults: messages.TestStepResult[]\n private world: any\n private readonly worldParameters: any\n\n constructor({\n eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId,\n pickle,\n testCase,\n retries = 0,\n skip,\n filterStackTraces,\n supportCodeLibrary,\n worldParameters,\n }: INewTestCaseRunnerOptions) {\n this.attachmentManager = new AttachmentManager(\n ({ data, media, fileName }) => {\n if (doesNotHaveValue(this.currentTestStepId)) {\n throw new Error(\n 'Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.'\n )\n }\n const attachment: messages.Envelope = {\n attachment: {\n body: data,\n contentEncoding: media.encoding,\n mediaType: media.contentType,\n fileName,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n },\n }\n this.eventBroadcaster.emit('envelope', attachment)\n }\n )\n this.eventBroadcaster = eventBroadcaster\n this.stopwatch = stopwatch\n this.gherkinDocument = gherkinDocument\n this.maxAttempts = 1 + (skip ? 0 : retries)\n this.newId = newId\n this.pickle = pickle\n this.testCase = testCase\n this.skip = skip\n this.filterStackTraces = filterStackTraces\n this.supportCodeLibrary = supportCodeLibrary\n this.worldParameters = worldParameters\n this.resetTestProgressData()\n }\n\n resetTestProgressData(): void {\n this.world = new this.supportCodeLibrary.World({\n attach: this.attachmentManager.create.bind(this.attachmentManager),\n log: this.attachmentManager.log.bind(this.attachmentManager),\n parameters: this.worldParameters,\n })\n this.testStepResults = []\n }\n\n getBeforeStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter(\n (hookDefinition) => hookDefinition.appliesToTestCase(this.pickle)\n )\n }\n\n getAfterStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.afterTestStepHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle))\n }\n\n getWorstStepResult(): messages.TestStepResult {\n if (this.testStepResults.length === 0) {\n return {\n status: this.skip\n ? messages.TestStepResultStatus.SKIPPED\n : messages.TestStepResultStatus.PASSED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return getWorstTestStepResult(this.testStepResults)\n }\n\n async invokeStep(\n step: messages.PickleStep,\n stepDefinition: IDefinition,\n hookParameter?: any\n ): Promise<messages.TestStepResult> {\n return await StepRunner.run({\n defaultTimeout: this.supportCodeLibrary.defaultTimeout,\n filterStackTraces: this.filterStackTraces,\n hookParameter,\n step,\n stepDefinition,\n world: this.world,\n })\n }\n\n isSkippingSteps(): boolean {\n return (\n this.getWorstStepResult().status !== messages.TestStepResultStatus.PASSED\n )\n }\n\n shouldSkipHook(isBeforeHook: boolean): boolean {\n return this.skip || (this.isSkippingSteps() && isBeforeHook)\n }\n\n async aroundTestStep(\n testStepId: string,\n runStepFn: () => Promise<messages.TestStepResult>\n ): Promise<void> {\n const testStepStarted: messages.Envelope = {\n testStepStarted: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepStarted)\n this.currentTestStepId = testStepId\n const testStepResult = await runStepFn()\n this.currentTestStepId = null\n this.testStepResults.push(testStepResult)\n const testStepFinished: messages.Envelope = {\n testStepFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n testStepResult,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepFinished)\n }\n\n async run(): Promise<messages.TestStepResultStatus> {\n for (let attempt = 0; attempt < this.maxAttempts; attempt++) {\n const moreAttemptsRemaining = attempt + 1 < this.maxAttempts\n\n const willBeRetried = await this.runAttempt(\n attempt,\n moreAttemptsRemaining\n )\n\n if (!willBeRetried) {\n break\n }\n this.resetTestProgressData()\n }\n return this.getWorstStepResult().status\n }\n\n async runAttempt(\n attempt: number,\n moreAttemptsRemaining: boolean\n ): Promise<boolean> {\n this.currentTestCaseStartedId = this.newId()\n const testCaseStarted: messages.Envelope = {\n testCaseStarted: {\n attempt,\n testCaseId: this.testCase.id,\n id: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseStarted)\n // used to determine whether a hook is a Before or After\n let didWeRunStepsYet = false\n for (const testStep of this.testCase.testSteps) {\n await this.aroundTestStep(testStep.id, async () => {\n if (doesHaveValue(testStep.hookId)) {\n const hookParameter: ITestCaseHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n testCaseStartedId: this.currentTestCaseStartedId,\n }\n if (didWeRunStepsYet) {\n hookParameter.result = this.getWorstStepResult()\n hookParameter.willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n }\n return await this.runHook(\n findHookDefinition(testStep.hookId, this.supportCodeLibrary),\n hookParameter,\n !didWeRunStepsYet\n )\n } else {\n const pickleStep = this.pickle.steps.find(\n (pickleStep) => pickleStep.id === testStep.pickleStepId\n )\n const testStepResult = await this.runStep(pickleStep, testStep)\n didWeRunStepsYet = true\n return testStepResult\n }\n })\n }\n\n const willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n const testCaseFinished: messages.Envelope = {\n testCaseFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n willBeRetried,\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseFinished)\n\n return willBeRetried\n }\n\n async runHook(\n hookDefinition: TestCaseHookDefinition,\n hookParameter: ITestCaseHookParameter,\n isBeforeHook: boolean\n ): Promise<messages.TestStepResult> {\n if (this.shouldSkipHook(isBeforeHook)) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return await this.invokeStep(null, hookDefinition, hookParameter)\n }\n\n async runStepHooks(\n stepHooks: TestStepHookDefinition[],\n pickleStep: messages.PickleStep,\n stepResult?: messages.TestStepResult\n ): Promise<messages.TestStepResult[]> {\n const stepHooksResult = []\n const hookParameter: ITestStepHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n pickleStep,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n result: stepResult,\n }\n for (const stepHookDefinition of stepHooks) {\n stepHooksResult.push(\n await this.invokeStep(null, stepHookDefinition, hookParameter)\n )\n }\n return stepHooksResult\n }\n\n async runStep(\n pickleStep: messages.PickleStep,\n testStep: messages.TestStep\n ): Promise<messages.TestStepResult> {\n const stepDefinitions = testStep.stepDefinitionIds.map(\n (stepDefinitionId) => {\n return findStepDefinition(stepDefinitionId, this.supportCodeLibrary)\n }\n )\n if (stepDefinitions.length === 0) {\n return {\n status: messages.TestStepResultStatus.UNDEFINED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (stepDefinitions.length > 1) {\n return {\n message: getAmbiguousStepException(stepDefinitions),\n status: messages.TestStepResultStatus.AMBIGUOUS,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (this.isSkippingSteps()) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n\n let stepResult\n let stepResults = await this.runStepHooks(\n this.getBeforeStepHookDefinitions(),\n pickleStep\n )\n if (\n getWorstTestStepResult(stepResults).status !==\n messages.TestStepResultStatus.FAILED\n ) {\n stepResult = await this.invokeStep(pickleStep, stepDefinitions[0])\n stepResults.push(stepResult)\n }\n const afterStepHookResults = await this.runStepHooks(\n this.getAfterStepHookDefinitions(),\n pickleStep,\n stepResult\n )\n stepResults = stepResults.concat(afterStepHookResults)\n\n const finalStepResult = getWorstTestStepResult(stepResults)\n let finalDuration = messages.TimeConversion.millisecondsToDuration(0)\n for (const result of stepResults) {\n finalDuration = messages.TimeConversion.addDurations(\n finalDuration,\n result.duration\n )\n }\n finalStepResult.duration = finalDuration\n return finalStepResult\n }\n}\n\nfunction findHookDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): TestCaseHookDefinition {\n return [\n ...supportCodeLibrary.beforeTestCaseHookDefinitions,\n ...supportCodeLibrary.afterTestCaseHookDefinitions,\n ].find((definition) => definition.id === id)\n}\n\nfunction findStepDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): StepDefinition {\n return supportCodeLibrary.stepDefinitions.find(\n (definition) => definition.id === id\n )\n}\n"]}
1
+ {"version":3,"file":"test_case_runner.js","sourceRoot":"","sources":["../../src/runtime/test_case_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAqD;AACrD,8EAAoD;AACpD,gEAAsC;AACtC,6DAA8C;AAC9C,iDAAwE;AAUxE,oDAAkE;AAGlE,6FAAmE;AACnE,iGAAsE;AAgBtE,MAAqB,cAAc;IAoBjC,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,IAAI,EACJ,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GACW;QAC1B,IAAI,CAAC,iBAAiB,GAAG,IAAI,4BAAiB,CAC5C,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC5B,IAAI,IAAA,gCAAgB,EAAC,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C,oBAAoB,CAAC,MAAM,EACpC;YACA,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;YAClE,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SAC7B;QACD,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,YAAY,CAClD,IAAI,CAAC,2BAA2B,EAAE,EAClC,UAAU,EACV,UAAU,CACX,CAAA;QACD,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;QAEtD,MAAM,eAAe,GAAG,IAAA,iCAAsB,EAAC,WAAW,CAAC,CAAA;QAC3D,IAAI,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;QACrE,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE;YAChC,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,YAAY,CAClD,aAAa,EACb,MAAM,CAAC,QAAQ,CAChB,CAAA;SACF;QACD,eAAe,CAAC,QAAQ,GAAG,aAAa,CAAA;QACxC,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AA5VD,iCA4VC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO;QACL,GAAG,kBAAkB,CAAC,6BAA6B;QACnD,GAAG,kBAAkB,CAAC,4BAA4B;KACnD,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAC5C,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CACrC,CAAA;AACH,CAAC","sourcesContent":["import { getAmbiguousStepException } from './helpers'\nimport AttachmentManager from './attachment_manager'\nimport StepRunner from './step_runner'\nimport * as messages from '@cucumber/messages'\nimport { getWorstTestStepResult, IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport {\n ISupportCodeLibrary,\n ITestCaseHookParameter,\n ITestStepHookParameter,\n} from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport { IDefinition } from '../models/definition'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { IStopwatch } from './stopwatch'\nimport StepDefinition from '../models/step_definition'\nimport ReportGenerator from '../formatter/helpers/report_generator'\nimport BVTAnalysisFormatter from '../formatter/bvt_analysis_formatter'\n\nexport interface INewTestCaseRunnerOptions {\n eventBroadcaster: EventEmitter\n stopwatch: IStopwatch\n gherkinDocument: messages.GherkinDocument\n newId: IdGenerator.NewId\n pickle: messages.Pickle\n testCase: messages.TestCase\n retries: number\n skip: boolean\n filterStackTraces: boolean\n supportCodeLibrary: ISupportCodeLibrary\n worldParameters: any\n}\n\nexport default class TestCaseRunner {\n private readonly attachmentManager: AttachmentManager\n private currentTestCaseStartedId: string\n private currentTestStepId: string\n private readonly eventBroadcaster: EventEmitter\n private readonly stopwatch: IStopwatch\n private readonly gherkinDocument: messages.GherkinDocument\n private readonly newId: IdGenerator.NewId\n private readonly pickle: messages.Pickle\n private readonly testCase: messages.TestCase\n private readonly maxAttempts: number\n private readonly skip: boolean\n private readonly filterStackTraces: boolean\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private testStepResults: messages.TestStepResult[]\n private world: any\n private readonly worldParameters: any\n private retryTestCaseId: string\n private reportGenerator: ReportGenerator\n\n constructor({\n eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId,\n pickle,\n testCase,\n retries = 0,\n skip,\n filterStackTraces,\n supportCodeLibrary,\n worldParameters,\n }: INewTestCaseRunnerOptions) {\n this.attachmentManager = new AttachmentManager(\n ({ data, media, fileName }) => {\n if (doesNotHaveValue(this.currentTestStepId)) {\n throw new Error(\n 'Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.'\n )\n }\n const attachment: messages.Envelope = {\n attachment: {\n body: data,\n contentEncoding: media.encoding,\n mediaType: media.contentType,\n fileName,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n },\n }\n this.eventBroadcaster.emit('envelope', attachment)\n }\n )\n this.eventBroadcaster = eventBroadcaster\n this.stopwatch = stopwatch\n this.gherkinDocument = gherkinDocument\n this.maxAttempts = 1 + (skip ? 0 : retries)\n this.newId = newId\n this.pickle = pickle\n this.testCase = testCase\n this.skip = skip\n this.filterStackTraces = filterStackTraces\n this.supportCodeLibrary = supportCodeLibrary\n this.worldParameters = worldParameters\n this.resetTestProgressData()\n this.reportGenerator = new ReportGenerator()\n }\n\n resetTestProgressData(): void {\n this.world = new this.supportCodeLibrary.World({\n attach: this.attachmentManager.create.bind(this.attachmentManager),\n log: this.attachmentManager.log.bind(this.attachmentManager),\n parameters: this.worldParameters,\n })\n this.testStepResults = []\n }\n\n getBeforeStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter(\n (hookDefinition) => hookDefinition.appliesToTestCase(this.pickle)\n )\n }\n\n getAfterStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.afterTestStepHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle))\n }\n\n getWorstStepResult(): messages.TestStepResult {\n if (this.testStepResults.length === 0) {\n return {\n status: this.skip\n ? messages.TestStepResultStatus.SKIPPED\n : messages.TestStepResultStatus.PASSED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return getWorstTestStepResult(this.testStepResults)\n }\n\n async invokeStep(\n step: messages.PickleStep,\n stepDefinition: IDefinition,\n hookParameter?: any\n ): Promise<messages.TestStepResult> {\n return await StepRunner.run({\n defaultTimeout: this.supportCodeLibrary.defaultTimeout,\n filterStackTraces: this.filterStackTraces,\n hookParameter,\n step,\n stepDefinition,\n world: this.world,\n })\n }\n\n isSkippingSteps(): boolean {\n return (\n this.getWorstStepResult().status !== messages.TestStepResultStatus.PASSED\n )\n }\n\n shouldSkipHook(isBeforeHook: boolean): boolean {\n return this.skip || (this.isSkippingSteps() && isBeforeHook)\n }\n\n async aroundTestStep(\n testStepId: string,\n runStepFn: () => Promise<messages.TestStepResult>\n ): Promise<void> {\n const testStepStarted: messages.Envelope = {\n testStepStarted: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepStarted)\n this.currentTestStepId = testStepId\n const testStepResult = await runStepFn()\n this.currentTestStepId = null\n this.testStepResults.push(testStepResult)\n const testStepFinished: messages.Envelope = {\n testStepFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n testStepResult,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepFinished)\n }\n\n async run(): Promise<messages.TestStepResultStatus> {\n for (let attempt = 0; attempt < this.maxAttempts; attempt++) {\n const moreAttemptsRemaining = attempt + 1 < this.maxAttempts\n\n const willBeRetried = await this.runAttempt(\n attempt,\n moreAttemptsRemaining\n )\n\n if (!willBeRetried) {\n break\n }\n this.resetTestProgressData()\n }\n return this.getWorstStepResult().status\n }\n\n async runAttempt(\n attempt: number,\n moreAttemptsRemaining: boolean\n ): Promise<boolean> {\n this.currentTestCaseStartedId = this.newId()\n const testCaseStarted = {\n testCaseStarted: {\n attempt,\n testCaseId: this.testCase.id,\n id: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n retryTestCaseId: this.retryTestCaseId,\n },\n } as messages.Envelope & { retryTestCaseId?: string }\n\n if (process.env.NODE_ENV === 'test') {\n delete (testCaseStarted as any).testCaseStarted.retryTestCaseId\n }\n\n this.eventBroadcaster.emit('envelope', testCaseStarted)\n\n if (this.maxAttempts > 1 && attempt === 0) {\n this.retryTestCaseId = this.currentTestCaseStartedId\n }\n\n // used to determine whether a hook is a Before or After\n let didWeRunStepsYet = false\n for (const testStep of this.testCase.testSteps) {\n await this.aroundTestStep(testStep.id, async () => {\n if (doesHaveValue(testStep.hookId)) {\n const hookParameter: ITestCaseHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n testCaseStartedId: this.currentTestCaseStartedId,\n }\n if (didWeRunStepsYet) {\n hookParameter.result = this.getWorstStepResult()\n hookParameter.willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n }\n return await this.runHook(\n findHookDefinition(testStep.hookId, this.supportCodeLibrary),\n hookParameter,\n !didWeRunStepsYet\n )\n } else {\n const pickleStep = this.pickle.steps.find(\n (pickleStep) => pickleStep.id === testStep.pickleStepId\n )\n const testStepResult = await this.runStep(pickleStep, testStep)\n didWeRunStepsYet = true\n return testStepResult\n }\n })\n }\n\n const willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n const testCaseFinished: messages.Envelope = {\n testCaseFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n willBeRetried,\n },\n }\n\n const rerunId = BVTAnalysisFormatter.reRunFailedStepsIndex\n ? BVTAnalysisFormatter.reRunFailedStepsIndex[0].testCaseId\n : null\n\n const data = BVTAnalysisFormatter.reportGenerator\n ? await BVTAnalysisFormatter.reportGenerator.handleMessage(\n testCaseFinished,\n rerunId\n )\n : null\n\n this.eventBroadcaster.emit('envelope', testCaseFinished, data)\n\n return willBeRetried\n }\n\n async runHook(\n hookDefinition: TestCaseHookDefinition,\n hookParameter: ITestCaseHookParameter,\n isBeforeHook: boolean\n ): Promise<messages.TestStepResult> {\n if (this.shouldSkipHook(isBeforeHook)) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return await this.invokeStep(null, hookDefinition, hookParameter)\n }\n\n async runStepHooks(\n stepHooks: TestStepHookDefinition[],\n pickleStep: messages.PickleStep,\n stepResult?: messages.TestStepResult\n ): Promise<messages.TestStepResult[]> {\n const stepHooksResult = []\n const hookParameter: ITestStepHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n pickleStep,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n result: stepResult,\n }\n for (const stepHookDefinition of stepHooks) {\n stepHooksResult.push(\n await this.invokeStep(null, stepHookDefinition, hookParameter)\n )\n }\n return stepHooksResult\n }\n\n async runStep(\n pickleStep: messages.PickleStep,\n testStep: messages.TestStep\n ): Promise<messages.TestStepResult> {\n const stepDefinitions = testStep.stepDefinitionIds.map(\n (stepDefinitionId) => {\n return findStepDefinition(stepDefinitionId, this.supportCodeLibrary)\n }\n )\n if (stepDefinitions.length === 0) {\n return {\n status: messages.TestStepResultStatus.UNDEFINED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (stepDefinitions.length > 1) {\n return {\n message: getAmbiguousStepException(stepDefinitions),\n status: messages.TestStepResultStatus.AMBIGUOUS,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (this.isSkippingSteps()) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n\n let stepResult\n let stepResults = await this.runStepHooks(\n this.getBeforeStepHookDefinitions(),\n pickleStep\n )\n if (\n getWorstTestStepResult(stepResults).status !==\n messages.TestStepResultStatus.FAILED\n ) {\n stepResult = await this.invokeStep(pickleStep, stepDefinitions[0])\n stepResults.push(stepResult)\n }\n const afterStepHookResults = await this.runStepHooks(\n this.getAfterStepHookDefinitions(),\n pickleStep,\n stepResult\n )\n stepResults = stepResults.concat(afterStepHookResults)\n\n const finalStepResult = getWorstTestStepResult(stepResults)\n let finalDuration = messages.TimeConversion.millisecondsToDuration(0)\n for (const result of stepResults) {\n finalDuration = messages.TimeConversion.addDurations(\n finalDuration,\n result.duration\n )\n }\n finalStepResult.duration = finalDuration\n return finalStepResult\n }\n}\n\nfunction findHookDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): TestCaseHookDefinition {\n return [\n ...supportCodeLibrary.beforeTestCaseHookDefinitions,\n ...supportCodeLibrary.afterTestCaseHookDefinitions,\n ].find((definition) => definition.id === id)\n}\n\nfunction findStepDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): StepDefinition {\n return supportCodeLibrary.stepDefinitions.find(\n (definition) => definition.id === id\n )\n}\n"]}
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.0.123-dev";
1
+ export declare const version = "1.0.123";
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.123-dev';
5
+ exports.version = '1.0.123';
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,aAAa,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.123-dev'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,SAAS,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.123'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber-js",
3
- "description": "The official JavaScript implementation of Cucumber.",
3
+ "description": "",
4
4
  "keywords": [
5
5
  "testing",
6
6
  "bdd",
@@ -8,7 +8,7 @@
8
8
  "gherkin",
9
9
  "tests"
10
10
  ],
11
- "version": "1.0.123-dev",
11
+ "version": "1.0.123",
12
12
  "homepage": "https://github.com/blinq-io/cucumber-js",
13
13
  "author": "blinq.io",
14
14
  "contributors": [
@@ -60,6 +60,7 @@
60
60
  "@cucumber/messages": "22.0.0",
61
61
  "@cucumber/tag-expressions": "5.0.1",
62
62
  "@faker-js/faker": "^8.0.2",
63
+ "@types/object-path": "^0.11.4",
63
64
  "@types/tunnel": "^0.0.7",
64
65
  "assertion-error-formatter": "^3.0.0",
65
66
  "axios": "^1.6.2",
@@ -83,6 +84,7 @@
83
84
  "luxon": "3.2.1",
84
85
  "mkdirp": "^2.1.5",
85
86
  "mz": "^2.7.0",
87
+ "object-path": "^0.11.8",
86
88
  "progress": "^2.0.3",
87
89
  "resolve-pkg": "^2.0.0",
88
90
  "semver": "7.5.3",
@@ -161,10 +163,11 @@
161
163
  },
162
164
  "scripts": {
163
165
  "build-local": "genversion --es6 src/version.ts && tsc --build tsconfig.node.json && shx cp src/importer.js lib/ && shx cp src/wrapper.mjs lib/ && shx cp src/api/wrapper.mjs lib/api/",
166
+ "build:watch": "genversion --es6 src/version.ts && tsc --build tsconfig.node.json --watch && shx cp src/importer.js lib/ && shx cp src/wrapper.mjs lib/ && shx cp src/api/wrapper.mjs lib/api/",
164
167
  "cck-test": "mocha 'compatibility/**/*_spec.ts'",
165
168
  "docs:ci": "api-extractor run --verbose",
166
169
  "docs:local": "api-extractor run --verbose --local && api-documenter markdown --input-folder ./tmp/api-extractor --output-folder ./docs/api",
167
- "feature-test": "node bin/cucumber.js",
170
+ "feature-test": "npx cross-env NODE_ENV=test node bin/cucumber.js",
168
171
  "lint-code-autofix": "eslint --fix \"{compatibility,example,features,scripts,src,test}/**/*.ts\"",
169
172
  "lint-code": "eslint \"{compatibility,example,features,scripts,src,test}/**/*.ts\"",
170
173
  "lint-dependencies": "dependency-lint",