@dev-blinq/cucumber-js 1.0.37 → 1.0.38-stage
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/download-install.js +167 -0
- package/lib/api/convert_configuration.js +1 -0
- package/lib/api/convert_configuration.js.map +1 -1
- package/lib/api/gherkin.js +47 -1
- package/lib/api/gherkin.js.map +1 -1
- package/lib/api/run_cucumber.d.ts +1 -1
- package/lib/api/run_cucumber.js +10 -10
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/api/types.d.ts +5 -3
- package/lib/api/types.js.map +1 -1
- package/lib/cli/helpers.d.ts +8 -6
- package/lib/cli/helpers.js +27 -6
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/index.js +7 -2
- package/lib/cli/index.js.map +1 -1
- package/lib/configuration/argv_parser.js +4 -2
- package/lib/configuration/argv_parser.js.map +1 -1
- package/lib/configuration/axios_client.d.ts +1 -0
- package/lib/configuration/axios_client.js +40 -0
- package/lib/configuration/axios_client.js.map +1 -0
- package/lib/configuration/default_configuration.js +2 -0
- package/lib/configuration/default_configuration.js.map +1 -1
- package/lib/configuration/types.d.ts +2 -0
- package/lib/configuration/types.js.map +1 -1
- package/lib/formatter/api.d.ts +2 -0
- package/lib/formatter/api.js +53 -0
- package/lib/formatter/api.js.map +1 -0
- package/lib/formatter/bvt_analysis_formatter.d.ts +19 -0
- package/lib/formatter/bvt_analysis_formatter.js +244 -0
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -0
- package/lib/formatter/feature_data_format.d.ts +12 -3
- package/lib/formatter/feature_data_format.js +106 -8
- package/lib/formatter/feature_data_format.js.map +1 -1
- package/lib/formatter/helpers/formatters.js +2 -2
- package/lib/formatter/helpers/formatters.js.map +1 -1
- package/lib/formatter/helpers/report_generator.d.ts +48 -8
- package/lib/formatter/helpers/report_generator.js +127 -4
- package/lib/formatter/helpers/report_generator.js.map +1 -1
- package/lib/formatter/helpers/upload_serivce.d.ts +6 -1
- package/lib/formatter/helpers/upload_serivce.js +142 -17
- package/lib/formatter/helpers/upload_serivce.js.map +1 -1
- package/lib/formatter/helpers/uploader.d.ts +11 -0
- package/lib/formatter/helpers/uploader.js +140 -0
- package/lib/formatter/helpers/uploader.js.map +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +7 -2
- package/lib/formatter/bvt_formatter.d.ts +0 -9
- package/lib/formatter/bvt_formatter.js +0 -62
- package/lib/formatter/bvt_formatter.js.map +0 -1
|
@@ -0,0 +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,YAAY;AACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;AAQ/B,MAAqB,oBAAqB,SAAQ,UAAS;IAMzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QANR,oBAAe,GAAG,IAAI,0BAAe,EAAE,CAAA;QACvC,aAAQ,GAAG,IAAI,kBAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACnD,SAAI,GAAG,KAAK,CAAA;QAKlB,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,UAAU,EAAE;YACtD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;SACrC;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CACzB,UAAU,EACV,KAAK,EAAE,QAAiC,EAAE,EAAE;YAC1C,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;YAClD,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C;IAEO,aAAa;QACnB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;YACjC,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;SACrC;QAED,IAAI,UAAkB,CAAA;QAEtB,QAAQ,OAAO,CAAC,QAAQ,EAAE;YACxB,KAAK,OAAO;gBACV,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAA;gBACjC,MAAK;YACP,KAAK,QAAQ;gBACX,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,qBAAqB,CAAC,CAAA;gBACtE,MAAK;YACP;gBACE,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;gBAC/C,MAAK;SACR;QACD,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AAzQD,uCAyQC;AAED,SAAgB,aAAa,CAAC,KAAa,EAAE,SAAiB;IAC5D,IAAI,iBAAiB,GAAG,sBAAsB,CAAA;IAC9C,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO,EAAE;QAC1C,iBAAiB,GAAG,uBAAuB,CAAA;KAC5C;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,KAAK,EAAE;QAC/C,iBAAiB,GAAG,0BAA0B,CAAA;KAC/C;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO,EAAE;QACjD,iBAAiB,GAAG,4BAA4B,CAAA;KACjD;IACD,MAAM,UAAU,GAAG,GAAG,iBAAiB,IAAI,SAAS,eAAe,KAAK,EAAE,CAAA;IAC1E,OAAO,CAAC,GAAG,CAAC,gBAAgB,UAAU,IAAI,CAAC,CAAA;AAC7C,CAAC;AAXD,sCAWC","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'\n//User token\nconst TOKEN = process.env.TOKEN\ninterface MetaMessage extends Meta {\n runName: string\n}\n\ninterface EnvelopeWithMetaMessage extends Envelope {\n meta: MetaMessage\n}\nexport default class BVTAnalysisFormatter extends Formatter {\n private reportGenerator = new ReportGenerator()\n private uploader = new ReportUploader(this.reportGenerator)\n private exit = false\n private START: number\n private runName: string\n constructor(options: IFormatterOptions) {\n super(options)\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage) => {\n await this.reportGenerator.handleMessage(envelope)\n if (\n doesHaveValue(envelope.meta) &&\n doesHaveValue(envelope.meta.runName)\n ) {\n this.runName = envelope.meta.runName\n }\n if (doesHaveValue(envelope.testRunFinished)) {\n const report = this.reportGenerator.getReport()\n this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport(report)\n } else {\n // await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private async uploadReport(report: JsonReport) {\n const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful && report.result.status !== 'FAILED') {\n process.exit(0)\n }\n process.exit(1)\n }\n\n async finished(): Promise<any> {\n await new Promise((resolve) => {\n const checkInterval = setInterval(() => {\n if (this.exit) {\n clearInterval(checkInterval)\n resolve(null)\n }\n }, 100) // check every 100ms\n })\n }\n private async analyzeReport(report: JsonReport) {\n if (\n report.result.status === 'PASSED' ||\n process.env.NO_RETRAIN === 'false'\n ) {\n if (report.result.status === 'PASSED') {\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 }\n\n //checking if the type of report.result is JsonResultFailed or not\n this.log('Some tests failed, starting the retraining...\\n')\n if (!('startTime' in report.result) || !('endTime' in report.result)) {\n this.log('Unknown error occured,not retraining\\n')\n await this.uploadFinalReport(report)\n return\n }\n const finalReport = await this.processTestCases(report)\n const uploadSuccessful = await this.uploadFinalReport(finalReport)\n if (finalReport.result.status !== 'FAILED' && uploadSuccessful) {\n process.exit(0)\n } else {\n process.exit(1)\n }\n }\n private async processTestCases(report: JsonReport): Promise<JsonReport> {\n const finalTestCases = []\n for (const testCase of report.testCases) {\n const modifiedTestCase = await this.processTestCase(testCase, report)\n\n finalTestCases.push(modifiedTestCase)\n }\n const finalResult = finalTestCases.some(\n (tc) => tc.result.status !== 'PASSED'\n )\n ? report.result\n : ({\n ...report.result,\n status: 'PASSED',\n } as JsonTestResult)\n return {\n result: finalResult,\n testCases: finalTestCases,\n env: report.env,\n }\n }\n private async processTestCase(\n testCase: JsonTestProgress,\n report: JsonReport\n ): Promise<JsonTestProgress> {\n if (testCase.result.status === 'PASSED') {\n return testCase\n }\n const failedTestSteps = testCase.steps\n .map((step, i) => (step.result.status === 'FAILED' ? i : null))\n .filter((i) => i !== null)\n const retrainStats = await this.retrain(failedTestSteps, testCase)\n\n if (!retrainStats) {\n return testCase\n }\n\n return {\n ...testCase,\n retrainStats,\n }\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)\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 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.join(',')}`,\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 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 },\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 resolve(null)\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) {\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 }\n const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`\n console.log(`Report link: ${reportLink}\\n`)\n}\n"]}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
+
import { TableCell } from '@cucumber/messages';
|
|
1
2
|
declare const generateTestData: (featureFileContent: string, vars?: any, fakeData?: {
|
|
2
3
|
var: string;
|
|
3
4
|
fake: string;
|
|
4
|
-
}[]) => {
|
|
5
|
+
}[], projectDir?: string) => {
|
|
5
6
|
newContent: string;
|
|
6
7
|
variables: any;
|
|
7
8
|
otherFakeData: {
|
|
8
9
|
var: string;
|
|
9
|
-
fake:
|
|
10
|
+
fake: any;
|
|
10
11
|
}[];
|
|
11
12
|
changed: boolean;
|
|
12
13
|
fakeIndex: number;
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
declare const generateExamplesFromFunction: (data: string, feature_path: string, functionName: string, functionFile: string) => {
|
|
16
|
+
newData: string;
|
|
17
|
+
mjsData: any;
|
|
18
|
+
};
|
|
19
|
+
declare const generateExamplesFromFunctionGherkin: (headers: readonly TableCell[], values: readonly TableCell[], mjsData: any) => {
|
|
20
|
+
header: string;
|
|
21
|
+
value: any;
|
|
22
|
+
}[];
|
|
23
|
+
export { generateTestData, generateExamplesFromFunction, generateExamplesFromFunctionGherkin, };
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateTestData = void 0;
|
|
6
|
+
exports.generateExamplesFromFunctionGherkin = exports.generateExamplesFromFunction = exports.generateTestData = void 0;
|
|
4
7
|
const faker_1 = require("@faker-js/faker");
|
|
5
|
-
const
|
|
6
|
-
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const json5_1 = __importDefault(require("json5"));
|
|
11
|
+
const generateTestData = (featureFileContent, vars, fakeData, projectDir) => {
|
|
12
|
+
const regexp = /\{\{([^}]*\([^)]*\))\}\}/g;
|
|
7
13
|
const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g;
|
|
8
14
|
let newContent = featureFileContent;
|
|
9
15
|
let match;
|
|
16
|
+
if (!projectDir) {
|
|
17
|
+
projectDir = process.cwd();
|
|
18
|
+
}
|
|
19
|
+
const namespacePath = path_1.default.join(projectDir, 'features', 'step_definitions', 'namespaces.json');
|
|
20
|
+
let namespaces = fs_1.default.existsSync(namespacePath)
|
|
21
|
+
? JSON.parse(fs_1.default.readFileSync(namespacePath, 'utf-8'))
|
|
22
|
+
: [];
|
|
23
|
+
if (!Array.isArray(namespaces)) {
|
|
24
|
+
namespaces = [];
|
|
25
|
+
}
|
|
10
26
|
const matches = [];
|
|
11
27
|
// collect all matches
|
|
12
28
|
while ((match = regexp.exec(featureFileContent)) !== null) {
|
|
13
|
-
|
|
29
|
+
// match[0] is the full match, match[1] is the first capturing group
|
|
30
|
+
// Eg:- match[0] = {{name}}, match[1] = name
|
|
31
|
+
if (!namespaces.includes(match[1].split('.')[0]))
|
|
32
|
+
matches.push(match);
|
|
14
33
|
}
|
|
15
34
|
// find all variables in the matches
|
|
16
35
|
const variables = { ...vars };
|
|
@@ -43,7 +62,7 @@ const generateTestData = (featureFileContent, vars, fakeData) => {
|
|
|
43
62
|
}
|
|
44
63
|
for (const key in variables) {
|
|
45
64
|
const variable = variables[key];
|
|
46
|
-
const fake =
|
|
65
|
+
const fake = getFakeString(variable.toFake.substring(2, variable.toFake.length - 2));
|
|
47
66
|
newContent = newContent.replaceAll(`{{${variable.var}}}`, fake);
|
|
48
67
|
variables[key].fake = fake;
|
|
49
68
|
}
|
|
@@ -53,10 +72,14 @@ const generateTestData = (featureFileContent, vars, fakeData) => {
|
|
|
53
72
|
const duplicateFakeData = fakeData ? [...fakeData] : [];
|
|
54
73
|
let fakeIndex = 0;
|
|
55
74
|
while ((match = regexp.exec(featureFileContent)) !== null) {
|
|
75
|
+
if (namespaces.includes(match[1].split('.')[0]))
|
|
76
|
+
continue;
|
|
56
77
|
try {
|
|
57
|
-
const fake = duplicateFakeData &&
|
|
78
|
+
const fake = duplicateFakeData &&
|
|
79
|
+
duplicateFakeData.length > 0 &&
|
|
80
|
+
duplicateFakeData[0].var === match[0]
|
|
58
81
|
? duplicateFakeData.shift().fake
|
|
59
|
-
:
|
|
82
|
+
: getFakeString(match[0].substring(2, match[0].length - 2));
|
|
60
83
|
otherFakeData.push({
|
|
61
84
|
var: match[0],
|
|
62
85
|
fake,
|
|
@@ -66,7 +89,7 @@ const generateTestData = (featureFileContent, vars, fakeData) => {
|
|
|
66
89
|
}
|
|
67
90
|
catch (err) {
|
|
68
91
|
// eslint-disable-next-line no-console
|
|
69
|
-
console.log('unknown faker variable:' + match[0])
|
|
92
|
+
//console.log('unknown faker variable:' + match[0])
|
|
70
93
|
}
|
|
71
94
|
}
|
|
72
95
|
return {
|
|
@@ -78,4 +101,79 @@ const generateTestData = (featureFileContent, vars, fakeData) => {
|
|
|
78
101
|
};
|
|
79
102
|
};
|
|
80
103
|
exports.generateTestData = generateTestData;
|
|
104
|
+
const getFakeString = (content) => {
|
|
105
|
+
// content example: helpers.fromRegExp('#{2,9}')
|
|
106
|
+
const faking = content.split('(')[0].split('.');
|
|
107
|
+
// faking example: ['helpers', 'fromRegExp']
|
|
108
|
+
const argument = content.substring(content.indexOf('(') + 1, content.lastIndexOf(')'));
|
|
109
|
+
// argument example: '#{2,9}'
|
|
110
|
+
let fakeFunc = faker_1.faker;
|
|
111
|
+
faking.forEach((f) => {
|
|
112
|
+
fakeFunc = fakeFunc[f];
|
|
113
|
+
});
|
|
114
|
+
let regexpParam = false;
|
|
115
|
+
if (faking.length === 2 && faking[1] === 'fromRegExp') {
|
|
116
|
+
regexpParam = true;
|
|
117
|
+
}
|
|
118
|
+
if (regexpParam) {
|
|
119
|
+
return fakeFunc(new RegExp(argument));
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
return fakeFunc(json5_1.default.parse(argument));
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
return fakeFunc(argument);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const getDefinitionFunction = (feature_path, functionName, functionFile) => {
|
|
129
|
+
const mjsFiles = fs_1.default
|
|
130
|
+
.readdirSync(path_1.default.join(feature_path, '../step_definitions'))
|
|
131
|
+
.filter((file) => file === `${functionFile}.js`);
|
|
132
|
+
if (mjsFiles.length === 0) {
|
|
133
|
+
throw new Error(`File ${functionFile} not found in step_definitions folder`);
|
|
134
|
+
}
|
|
135
|
+
const [mjsData] = mjsFiles.map((file) => {
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
137
|
+
const { [functionName]: func } = require(path_1.default.join(feature_path, '../step_definitions', file));
|
|
138
|
+
if (!func)
|
|
139
|
+
throw new Error(`Function ${functionName} not found in file ${file}`);
|
|
140
|
+
return func();
|
|
141
|
+
});
|
|
142
|
+
return mjsData;
|
|
143
|
+
};
|
|
144
|
+
const generateExamplesFromFunction = (data, feature_path, functionName, functionFile) => {
|
|
145
|
+
const examples = data.split('Examples:')[1].split('\n').slice(1);
|
|
146
|
+
const headers = examples[0]
|
|
147
|
+
.split('|')
|
|
148
|
+
.map((header) => header.trim())
|
|
149
|
+
.filter((header) => header !== '');
|
|
150
|
+
const values = examples[1]
|
|
151
|
+
.split('|')
|
|
152
|
+
.map((value) => value.trim())
|
|
153
|
+
.filter((header) => header !== '');
|
|
154
|
+
const mjsData = getDefinitionFunction(feature_path, functionName, functionFile);
|
|
155
|
+
const newExamples = headers.map((header) => {
|
|
156
|
+
if (mjsData[header]) {
|
|
157
|
+
return mjsData[header];
|
|
158
|
+
}
|
|
159
|
+
return values[headers.indexOf(header)];
|
|
160
|
+
});
|
|
161
|
+
let newExamplesString = data.split('Examples:')[1];
|
|
162
|
+
newExamples.forEach((example, index) => {
|
|
163
|
+
newExamplesString = newExamplesString.replace(values[index], example);
|
|
164
|
+
});
|
|
165
|
+
const newData = data.replace(data.split('Examples:')[1], newExamplesString);
|
|
166
|
+
return { newData, mjsData };
|
|
167
|
+
};
|
|
168
|
+
exports.generateExamplesFromFunction = generateExamplesFromFunction;
|
|
169
|
+
const generateExamplesFromFunctionGherkin = (headers, values, mjsData) => {
|
|
170
|
+
const newExamples = headers.map(({ value: header }, index) => {
|
|
171
|
+
if (mjsData[header]) {
|
|
172
|
+
return { header, value: mjsData[header] };
|
|
173
|
+
}
|
|
174
|
+
return { header, value: values[index].value };
|
|
175
|
+
});
|
|
176
|
+
return newExamples;
|
|
177
|
+
};
|
|
178
|
+
exports.generateExamplesFromFunctionGherkin = generateExamplesFromFunctionGherkin;
|
|
81
179
|
//# sourceMappingURL=feature_data_format.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature_data_format.js","sourceRoot":"","sources":["../../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CAAA;IAEjB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,KAAK,IAAI,EAAE;QACzD,IAAI;YACF,MAAM,IAAI,GACR,iBAAiB,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC;gBAC/C,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,IAAI;gBAChC,CAAC,CAAC,aAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YAClC,aAAa,CAAC,IAAI,CAAC;gBACjB,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;gBACb,IAAI;aACL,CAAC,CAAA;YACF,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;YAC/C,SAAS,EAAE,CAAA;SACZ;QAAC,OAAO,GAAG,EAAE;YACZ,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;SAClD;KACF;IAED,OAAO;QACL,UAAU;QACV,SAAS;QACT,aAAa;QACb,OAAO,EAAE,UAAU,KAAK,kBAAkB;QAC1C,SAAS;KACV,CAAA;AACH,CAAC,CAAA;AAIQ,4CAAgB","sourcesContent":["import { faker } from '@faker-js/faker'\n\nconst generateTestData = (\n featureFileContent: string,\n vars?: any,\n fakeData?: {\n var: string\n fake: string\n }[]\n) => {\n const regexp = /\\{\\{([^}]+)\\}\\}/g\n const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g\n let newContent = featureFileContent\n let match: RegExpExecArray\n const matches = []\n // collect all matches\n while ((match = regexp.exec(featureFileContent)) !== null) {\n matches.push(match)\n }\n // find all variables in the matches\n const variables: any = { ...vars }\n\n if (Object.keys(variables).length > 0) {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n newContent = newContent.replaceAll(`{{${variable.var}}}`, variable.fake)\n }\n } else {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n variables[variableMatch[1]] = {\n var: variableMatch[1],\n toFake: variableMatch[2],\n }\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n const fake = faker.helpers.fake(`{{${variable.toFake}}}`)\n newContent = newContent.replaceAll(`{{${variable.var}}}`, fake)\n variables[key].fake = fake\n }\n }\n\n regexp.lastIndex = 0\n const otherFakeData = []\n const duplicateFakeData = fakeData ? [...fakeData] : []\n let fakeIndex = 0\n\n while ((match = regexp.exec(featureFileContent)) !== null) {\n try {\n const fake =\n duplicateFakeData && duplicateFakeData.length > 0\n ? duplicateFakeData.shift().fake\n : faker.helpers.fake(match[0])\n otherFakeData.push({\n var: match[0],\n fake,\n })\n newContent = newContent.replace(match[0], fake)\n fakeIndex++\n } catch (err) {\n // eslint-disable-next-line no-console\n console.log('unknown faker variable:' + match[0])\n }\n }\n\n return {\n newContent,\n variables,\n otherFakeData,\n changed: newContent !== featureFileContent,\n fakeIndex,\n }\n}\n\n//let result = generateTestData(\"/Users/guyarieli/Documents/GitHub/ai-qa/cucumber_demo/features/create_issues.feature\");\n//console.log(result.newContent);\nexport { generateTestData }\n"]}
|
|
1
|
+
{"version":3,"file":"feature_data_format.js","sourceRoot":"","sources":["../../src/formatter/feature_data_format.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAuC;AACvC,4CAAmB;AACnB,gDAAuB;AAEvB,kDAAyB;AAEzB,MAAM,gBAAgB,GAAG,CACvB,kBAA0B,EAC1B,IAAU,EACV,QAGG,EACH,UAAmB,EACnB,EAAE;IACF,MAAM,MAAM,GA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5B,OAAY,EACZ,EAAE;IACF,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE;QAC3D,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;YACnB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;SAC1C;QACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAA;IAC/C,CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAKC,kFAAmC","sourcesContent":["import { faker } from '@faker-js/faker'\nimport fs from 'fs'\nimport path from 'path'\nimport { TableCell } from '@cucumber/messages'\nimport JSON5 from 'json5'\n\nconst generateTestData = (\n featureFileContent: string,\n vars?: any,\n fakeData?: {\n var: string\n fake: string\n }[],\n projectDir?: string\n) => {\n const regexp = /\\{\\{([^}]*\\([^)]*\\))\\}\\}/g\n const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g\n let newContent = featureFileContent\n let match: RegExpExecArray\n if (!projectDir) {\n projectDir = process.cwd()\n }\n const namespacePath = path.join(\n projectDir,\n 'features',\n 'step_definitions',\n 'namespaces.json'\n )\n let namespaces: string[] = fs.existsSync(namespacePath)\n ? JSON.parse(fs.readFileSync(namespacePath, 'utf-8'))\n : []\n if (!Array.isArray(namespaces)) {\n namespaces = []\n }\n const matches = []\n // collect all matches\n while ((match = regexp.exec(featureFileContent)) !== null) {\n // match[0] is the full match, match[1] is the first capturing group\n // Eg:- match[0] = {{name}}, match[1] = name\n if (!namespaces.includes(match[1].split('.')[0])) matches.push(match)\n }\n // find all variables in the matches\n const variables: any = { ...vars }\n\n if (Object.keys(variables).length > 0) {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n newContent = newContent.replaceAll(`{{${variable.var}}}`, variable.fake)\n }\n } else {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n variables[variableMatch[1]] = {\n var: variableMatch[1],\n toFake: variableMatch[2],\n }\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n const fake = getFakeString(\n variable.toFake.substring(2, variable.toFake.length - 2)\n )\n newContent = newContent.replaceAll(`{{${variable.var}}}`, fake)\n variables[key].fake = fake\n }\n }\n\n regexp.lastIndex = 0\n const otherFakeData = []\n const duplicateFakeData = fakeData ? [...fakeData] : []\n let fakeIndex = 0\n while ((match = regexp.exec(featureFileContent)) !== null) {\n if (namespaces.includes(match[1].split('.')[0])) continue\n try {\n const fake =\n duplicateFakeData &&\n duplicateFakeData.length > 0 &&\n duplicateFakeData[0].var === match[0]\n ? duplicateFakeData.shift().fake\n : getFakeString(match[0].substring(2, match[0].length - 2))\n otherFakeData.push({\n var: match[0],\n fake,\n })\n newContent = newContent.replace(match[0], fake)\n fakeIndex++\n } catch (err) {\n // eslint-disable-next-line no-console\n //console.log('unknown faker variable:' + match[0])\n }\n }\n\n return {\n newContent,\n variables,\n otherFakeData,\n changed: newContent !== featureFileContent,\n fakeIndex,\n }\n}\n\nconst getFakeString = (content: string) => {\n // content example: helpers.fromRegExp('#{2,9}')\n const faking = content.split('(')[0].split('.')\n // faking example: ['helpers', 'fromRegExp']\n const argument = content.substring(\n content.indexOf('(') + 1,\n content.lastIndexOf(')')\n )\n // argument example: '#{2,9}'\n\n let fakeFunc: any = faker\n faking.forEach((f: string) => {\n fakeFunc = fakeFunc[f]\n })\n let regexpParam = false\n if (faking.length === 2 && faking[1] === 'fromRegExp') {\n regexpParam = true\n }\n if (regexpParam) {\n return fakeFunc(new RegExp(argument))\n }\n try {\n return fakeFunc(JSON5.parse(argument))\n } catch (error) {\n return fakeFunc(argument)\n }\n}\n\nconst getDefinitionFunction = (\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const mjsFiles = fs\n .readdirSync(path.join(feature_path, '../step_definitions'))\n .filter((file) => file === `${functionFile}.js`)\n\n if (mjsFiles.length === 0) {\n throw new Error(`File ${functionFile} not found in step_definitions folder`)\n }\n\n const [mjsData] = mjsFiles.map((file) => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { [functionName]: func } = require(path.join(\n feature_path,\n '../step_definitions',\n file\n ))\n if (!func)\n throw new Error(`Function ${functionName} not found in file ${file}`)\n\n return func()\n })\n\n return mjsData\n}\n\nconst generateExamplesFromFunction = (\n data: string,\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const examples = data.split('Examples:')[1].split('\\n').slice(1)\n const headers = examples[0]\n .split('|')\n .map((header) => header.trim())\n .filter((header) => header !== '')\n const values = examples[1]\n .split('|')\n .map((value) => value.trim())\n .filter((header) => header !== '')\n\n const mjsData = getDefinitionFunction(\n feature_path,\n functionName,\n functionFile\n )\n\n const newExamples = headers.map((header) => {\n if (mjsData[header]) {\n return mjsData[header]\n }\n return values[headers.indexOf(header)]\n })\n\n let newExamplesString = data.split('Examples:')[1]\n newExamples.forEach((example, index) => {\n newExamplesString = newExamplesString.replace(values[index], example)\n })\n\n const newData = data.replace(data.split('Examples:')[1], newExamplesString)\n\n return { newData, mjsData }\n}\n\nconst generateExamplesFromFunctionGherkin = (\n headers: readonly TableCell[],\n values: readonly TableCell[],\n mjsData: any\n) => {\n const newExamples = headers.map(({ value: header }, index) => {\n if (mjsData[header]) {\n return { header, value: mjsData[header] }\n }\n return { header, value: values[index].value }\n })\n\n return newExamples\n}\n\nexport {\n generateTestData,\n generateExamplesFromFunction,\n generateExamplesFromFunctionGherkin,\n}\n"]}
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const json_formatter_1 = __importDefault(require("../json_formatter"));
|
|
7
|
-
const bvt_formatter_1 = __importDefault(require("../bvt_formatter"));
|
|
8
7
|
const message_formatter_1 = __importDefault(require("../message_formatter"));
|
|
9
8
|
const progress_bar_formatter_1 = __importDefault(require("../progress_bar_formatter"));
|
|
10
9
|
const progress_formatter_1 = __importDefault(require("../progress_formatter"));
|
|
@@ -15,11 +14,11 @@ const usage_formatter_1 = __importDefault(require("../usage_formatter"));
|
|
|
15
14
|
const usage_json_formatter_1 = __importDefault(require("../usage_json_formatter"));
|
|
16
15
|
const html_formatter_1 = __importDefault(require("../html_formatter"));
|
|
17
16
|
const junit_formatter_1 = __importDefault(require("../junit_formatter"));
|
|
17
|
+
const bvt_analysis_formatter_1 = __importDefault(require("../bvt_analysis_formatter"));
|
|
18
18
|
const Formatters = {
|
|
19
19
|
getFormatters() {
|
|
20
20
|
return {
|
|
21
21
|
json: json_formatter_1.default,
|
|
22
|
-
bvt: bvt_formatter_1.default,
|
|
23
22
|
message: message_formatter_1.default,
|
|
24
23
|
html: html_formatter_1.default,
|
|
25
24
|
progress: progress_formatter_1.default,
|
|
@@ -30,6 +29,7 @@ const Formatters = {
|
|
|
30
29
|
usage: usage_formatter_1.default,
|
|
31
30
|
'usage-json': usage_json_formatter_1.default,
|
|
32
31
|
junit: junit_formatter_1.default,
|
|
32
|
+
bvt: bvt_analysis_formatter_1.default,
|
|
33
33
|
};
|
|
34
34
|
},
|
|
35
35
|
buildFormattersDocumentationString() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/formatter/helpers/formatters.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/formatter/helpers/formatters.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,6EAAmD;AACnD,uFAA4D;AAC5D,+EAAqD;AACrD,yEAA+C;AAC/C,+EAAqD;AACrD,6EAAmD;AACnD,yEAA+C;AAC/C,mFAAwD;AACxD,uEAA6C;AAC7C,yEAA+C;AAC/C,uFAA4D;AAC5D,MAAM,UAAU,GAAG;IACjB,aAAa;QACX,OAAO;YACL,IAAI,EAAE,wBAAa;YACnB,OAAO,EAAE,2BAAgB;YACzB,IAAI,EAAE,wBAAa;YACnB,QAAQ,EAAE,4BAAiB;YAC3B,cAAc,EAAE,gCAAoB;YACpC,KAAK,EAAE,yBAAc;YACrB,QAAQ,EAAE,4BAAiB;YAC3B,OAAO,EAAE,2BAAgB;YACzB,KAAK,EAAE,yBAAc;YACrB,YAAY,EAAE,8BAAkB;YAChC,KAAK,EAAE,yBAAc;YACrB,GAAG,EAAE,gCAAoB;SAC1B,CAAA;IACH,CAAC;IACD,kCAAkC;QAChC,IAAI,mCAAmC,GAAW,EAAE,CAAA;QACpD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QACvC,KAAK,MAAM,aAAa,IAAI,UAAU,EAAE;YACtC,mCAAmC,IAAI,OAAO,aAAa,KAAK,UAAU,CAAC,aAAa,CAAC,CAAC,aAAa,IAAI,CAAA;SAC5G;QAED,OAAO,mCAAmC,CAAA;IAC5C,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import Formatter from '../.'\nimport JsonFormatter from '../json_formatter'\nimport MessageFormatter from '../message_formatter'\nimport ProgressBarFormatter from '../progress_bar_formatter'\nimport ProgressFormatter from '../progress_formatter'\nimport RerunFormatter from '../rerun_formatter'\nimport SnippetsFormatter from '../snippets_formatter'\nimport SummaryFormatter from '../summary_formatter'\nimport UsageFormatter from '../usage_formatter'\nimport UsageJsonFormatter from '../usage_json_formatter'\nimport HtmlFormatter from '../html_formatter'\nimport JunitFormatter from '../junit_formatter'\nimport BVTAnalysisFormatter from '../bvt_analysis_formatter'\nconst Formatters = {\n getFormatters(): Record<string, typeof Formatter> {\n return {\n json: JsonFormatter,\n message: MessageFormatter,\n html: HtmlFormatter,\n progress: ProgressFormatter,\n 'progress-bar': ProgressBarFormatter,\n rerun: RerunFormatter,\n snippets: SnippetsFormatter,\n summary: SummaryFormatter,\n usage: UsageFormatter,\n 'usage-json': UsageJsonFormatter,\n junit: JunitFormatter,\n bvt: BVTAnalysisFormatter,\n }\n },\n buildFormattersDocumentationString(): string {\n let concatanatedFormattersDocumentation: string = ''\n const formatters = this.getFormatters()\n for (const formatterName in formatters) {\n concatanatedFormattersDocumentation += ` ${formatterName}: ${formatters[formatterName].documentation}\\n`\n }\n\n return concatanatedFormattersDocumentation\n },\n}\n\nexport default Formatters\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as messages from '@cucumber/messages';
|
|
2
2
|
type JsonTimestamp = number;
|
|
3
3
|
type JsonStepType = 'Unknown' | 'Context' | 'Action' | 'Outcome' | 'Conjunction';
|
|
4
|
-
type JsonResultUnknown = {
|
|
4
|
+
export type JsonResultUnknown = {
|
|
5
5
|
status: 'UNKNOWN';
|
|
6
6
|
};
|
|
7
7
|
type JsonResultSkipped = {
|
|
@@ -13,7 +13,7 @@ type JsonResultUndefined = {
|
|
|
13
13
|
type JsonResultAmbiguous = {
|
|
14
14
|
status: 'AMBIGUOUS';
|
|
15
15
|
};
|
|
16
|
-
type JsonResultStarted = {
|
|
16
|
+
export type JsonResultStarted = {
|
|
17
17
|
status: 'STARTED';
|
|
18
18
|
startTime: JsonTimestamp;
|
|
19
19
|
};
|
|
@@ -22,20 +22,25 @@ type JsonResultPending = {
|
|
|
22
22
|
startTime: JsonTimestamp;
|
|
23
23
|
endTime: JsonTimestamp;
|
|
24
24
|
};
|
|
25
|
-
type JsonResultPassed = {
|
|
25
|
+
export type JsonResultPassed = {
|
|
26
26
|
status: 'PASSED';
|
|
27
27
|
startTime: JsonTimestamp;
|
|
28
28
|
endTime: JsonTimestamp;
|
|
29
29
|
};
|
|
30
|
-
type JsonResultFailed = {
|
|
30
|
+
export type JsonResultFailed = {
|
|
31
31
|
status: 'FAILED';
|
|
32
32
|
startTime: JsonTimestamp;
|
|
33
33
|
endTime: JsonTimestamp;
|
|
34
34
|
message?: string;
|
|
35
35
|
};
|
|
36
|
+
export type JsonFixedByAi = {
|
|
37
|
+
status: 'FIXED_BY_AI';
|
|
38
|
+
startTime: JsonTimestamp;
|
|
39
|
+
endTime: JsonTimestamp;
|
|
40
|
+
};
|
|
36
41
|
type JsonCommandResult = JsonResultPassed | JsonResultFailed;
|
|
37
|
-
type JsonStepResult = JsonResultUnknown | JsonResultSkipped | JsonResultUndefined | JsonResultAmbiguous | JsonResultStarted | JsonResultPending | JsonResultPassed | JsonResultFailed;
|
|
38
|
-
type JsonTestResult = JsonResultUnknown | JsonResultStarted | JsonResultPassed | JsonResultFailed;
|
|
42
|
+
type JsonStepResult = JsonResultUnknown | JsonResultSkipped | JsonResultUndefined | JsonResultAmbiguous | JsonResultStarted | JsonResultPending | JsonResultPassed | JsonResultFailed | JsonFixedByAi;
|
|
43
|
+
export type JsonTestResult = JsonResultUnknown | JsonResultStarted | JsonResultPassed | JsonResultFailed | JsonFixedByAi;
|
|
39
44
|
type JsonReportResult = JsonTestResult;
|
|
40
45
|
type JsonCommand = {
|
|
41
46
|
type: string;
|
|
@@ -43,6 +48,14 @@ type JsonCommand = {
|
|
|
43
48
|
text: string;
|
|
44
49
|
screenshotId?: string;
|
|
45
50
|
result: JsonCommandResult;
|
|
51
|
+
webLog?: webLog[];
|
|
52
|
+
netWorkLog?: any[];
|
|
53
|
+
};
|
|
54
|
+
type webLog = {
|
|
55
|
+
type: string;
|
|
56
|
+
text: string;
|
|
57
|
+
location: string;
|
|
58
|
+
time: string;
|
|
46
59
|
};
|
|
47
60
|
export type JsonStep = {
|
|
48
61
|
keyword: string;
|
|
@@ -50,8 +63,15 @@ export type JsonStep = {
|
|
|
50
63
|
text: string;
|
|
51
64
|
commands: JsonCommand[];
|
|
52
65
|
result: JsonStepResult;
|
|
66
|
+
data?: any;
|
|
67
|
+
};
|
|
68
|
+
export type RetrainStats = {
|
|
69
|
+
result: JsonTestResult;
|
|
70
|
+
totalSteps: number;
|
|
71
|
+
upload_id: string;
|
|
72
|
+
local_id: number;
|
|
53
73
|
};
|
|
54
|
-
type JsonTestProgress = {
|
|
74
|
+
export type JsonTestProgress = {
|
|
55
75
|
id: string;
|
|
56
76
|
featureName: string;
|
|
57
77
|
uri: string;
|
|
@@ -59,11 +79,24 @@ type JsonTestProgress = {
|
|
|
59
79
|
parameters: Record<string, string>;
|
|
60
80
|
steps: JsonStep[];
|
|
61
81
|
result: JsonTestResult;
|
|
82
|
+
retrainStats?: RetrainStats;
|
|
83
|
+
webLog: any;
|
|
84
|
+
networkLog: any;
|
|
62
85
|
};
|
|
63
86
|
export type JsonReport = {
|
|
64
87
|
testCases: JsonTestProgress[];
|
|
65
88
|
result: JsonReportResult;
|
|
89
|
+
env: {
|
|
90
|
+
name: string;
|
|
91
|
+
baseUrl: string;
|
|
92
|
+
};
|
|
66
93
|
};
|
|
94
|
+
interface MetaMessage extends messages.Meta {
|
|
95
|
+
runName: string;
|
|
96
|
+
}
|
|
97
|
+
interface EnvelopeWithMetaMessage extends messages.Envelope {
|
|
98
|
+
meta: MetaMessage;
|
|
99
|
+
}
|
|
67
100
|
export default class ReportGenerator {
|
|
68
101
|
private report;
|
|
69
102
|
private gherkinDocumentMap;
|
|
@@ -73,8 +106,13 @@ export default class ReportGenerator {
|
|
|
73
106
|
private testStepMap;
|
|
74
107
|
private stepReportMap;
|
|
75
108
|
private testCaseReportMap;
|
|
109
|
+
private scenarioIterationCountMap;
|
|
110
|
+
private logs;
|
|
111
|
+
private networkLog;
|
|
112
|
+
private runName;
|
|
76
113
|
reportFolder: null | string;
|
|
77
|
-
|
|
114
|
+
private uploadService;
|
|
115
|
+
handleMessage(envelope: EnvelopeWithMetaMessage): Promise<void>;
|
|
78
116
|
getReport(): JsonReport;
|
|
79
117
|
private handleParseError;
|
|
80
118
|
private onGherkinDocument;
|
|
@@ -88,8 +126,10 @@ export default class ReportGenerator {
|
|
|
88
126
|
private onTestStepStarted;
|
|
89
127
|
private onAttachment;
|
|
90
128
|
private onTestStepFinished;
|
|
129
|
+
getLogFileContent(): any;
|
|
91
130
|
private getTestCaseResult;
|
|
92
131
|
private onTestCaseFinished;
|
|
132
|
+
private uploadTestCase;
|
|
93
133
|
private onTestRunFinished;
|
|
94
134
|
}
|
|
95
135
|
export {};
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a, _b;
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const upload_serivce_1 = require("./upload_serivce");
|
|
10
|
+
const URL = process.env.NODE_ENV_BLINQ === 'dev'
|
|
11
|
+
? 'https://dev.api.blinq.io/api/runs'
|
|
12
|
+
: process.env.NODE_ENV_BLINQ === 'local'
|
|
13
|
+
? 'http://localhost:5001/api/runs'
|
|
14
|
+
: process.env.NODE_ENV_BLINQ === 'stage'
|
|
15
|
+
? 'https://stage.api.blinq.io/api/runs'
|
|
16
|
+
: 'https://api.blinq.io/api/runs';
|
|
17
|
+
const REPORT_SERVICE_URL = (_a = process.env.REPORT_SERVICE_URL) !== null && _a !== void 0 ? _a : URL;
|
|
18
|
+
const BATCH_SIZE = 10;
|
|
19
|
+
const MAX_RETRIES = 3;
|
|
20
|
+
const REPORT_SERVICE_TOKEN = (_b = process.env.TOKEN) !== null && _b !== void 0 ? _b : process.env.REPORT_SERVICE_TOKEN;
|
|
3
21
|
class ReportGenerator {
|
|
4
22
|
constructor() {
|
|
5
23
|
this.report = {
|
|
@@ -7,6 +25,10 @@ class ReportGenerator {
|
|
|
7
25
|
status: 'UNKNOWN',
|
|
8
26
|
},
|
|
9
27
|
testCases: [],
|
|
28
|
+
env: {
|
|
29
|
+
name: '',
|
|
30
|
+
baseUrl: '',
|
|
31
|
+
},
|
|
10
32
|
};
|
|
11
33
|
this.gherkinDocumentMap = new Map();
|
|
12
34
|
this.stepMap = new Map();
|
|
@@ -15,9 +37,17 @@ class ReportGenerator {
|
|
|
15
37
|
this.testStepMap = new Map();
|
|
16
38
|
this.stepReportMap = new Map();
|
|
17
39
|
this.testCaseReportMap = new Map();
|
|
40
|
+
this.scenarioIterationCountMap = new Map();
|
|
41
|
+
this.logs = [];
|
|
42
|
+
this.networkLog = [];
|
|
43
|
+
this.runName = '';
|
|
18
44
|
this.reportFolder = null;
|
|
45
|
+
this.uploadService = new upload_serivce_1.RunUploadService(REPORT_SERVICE_URL, REPORT_SERVICE_TOKEN);
|
|
19
46
|
}
|
|
20
|
-
handleMessage(envelope) {
|
|
47
|
+
async handleMessage(envelope) {
|
|
48
|
+
if (envelope.meta && envelope.meta.runName) {
|
|
49
|
+
this.runName = envelope.meta.runName;
|
|
50
|
+
}
|
|
21
51
|
const type = Object.keys(envelope)[0];
|
|
22
52
|
switch (type) {
|
|
23
53
|
// case "meta": { break}
|
|
@@ -71,7 +101,7 @@ class ReportGenerator {
|
|
|
71
101
|
}
|
|
72
102
|
case 'testCaseFinished': {
|
|
73
103
|
const testCaseFinished = envelope[type];
|
|
74
|
-
this.onTestCaseFinished(testCaseFinished);
|
|
104
|
+
await this.onTestCaseFinished(testCaseFinished);
|
|
75
105
|
break;
|
|
76
106
|
}
|
|
77
107
|
// case "hook": { break} // After Hook
|
|
@@ -190,7 +220,13 @@ class ReportGenerator {
|
|
|
190
220
|
const scenarioId = pickle.astNodeIds[0];
|
|
191
221
|
const scenario = this._findScenario(doc, scenarioId);
|
|
192
222
|
const scenarioName = scenario.name;
|
|
223
|
+
if (!this.scenarioIterationCountMap.has(scenarioId)) {
|
|
224
|
+
this.scenarioIterationCountMap.set(scenarioId, 1);
|
|
225
|
+
}
|
|
193
226
|
const parameters = this._getParameters(scenario, pickle.astNodeIds[1]);
|
|
227
|
+
console.log(`Running scenario ${scenarioName} iteration ${this.scenarioIterationCountMap.get(scenarioId)} with parameters:\n${JSON.stringify(parameters, null, 4)}\n
|
|
228
|
+
`);
|
|
229
|
+
this.scenarioIterationCountMap.set(scenarioId, this.scenarioIterationCountMap.get(scenarioId) + 1);
|
|
194
230
|
const steps = pickle.steps.map((pickleStep) => {
|
|
195
231
|
const stepId = pickleStep.astNodeIds[0];
|
|
196
232
|
const step = this.stepMap.get(stepId);
|
|
@@ -216,6 +252,8 @@ class ReportGenerator {
|
|
|
216
252
|
status: 'STARTED',
|
|
217
253
|
startTime: this.getTimeStamp(timestamp),
|
|
218
254
|
},
|
|
255
|
+
webLog: [],
|
|
256
|
+
networkLog: [],
|
|
219
257
|
});
|
|
220
258
|
this.report.testCases.push(this.testCaseReportMap.get(id));
|
|
221
259
|
}
|
|
@@ -236,6 +274,21 @@ class ReportGenerator {
|
|
|
236
274
|
const { testStepId, body, mediaType } = attachment;
|
|
237
275
|
if (mediaType === 'text/plain') {
|
|
238
276
|
this.reportFolder = body.replaceAll('\\', '/');
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (mediaType === 'application/json+env') {
|
|
280
|
+
const data = JSON.parse(body);
|
|
281
|
+
this.report.env = data;
|
|
282
|
+
}
|
|
283
|
+
if (mediaType === 'application/json+log') {
|
|
284
|
+
const log = JSON.parse(body);
|
|
285
|
+
if (this.logs.length < 1000)
|
|
286
|
+
this.logs.push(log);
|
|
287
|
+
}
|
|
288
|
+
if (mediaType === 'application/json+network') {
|
|
289
|
+
const networkLog = JSON.parse(body);
|
|
290
|
+
if (this.networkLog.length < 1000)
|
|
291
|
+
this.networkLog.push(networkLog);
|
|
239
292
|
}
|
|
240
293
|
const testStep = this.testStepMap.get(testStepId);
|
|
241
294
|
if (testStep.pickleStepId === undefined)
|
|
@@ -249,10 +302,27 @@ class ReportGenerator {
|
|
|
249
302
|
onTestStepFinished(testStepFinished) {
|
|
250
303
|
const { testStepId, testStepResult, timestamp } = testStepFinished;
|
|
251
304
|
const testStep = this.testStepMap.get(testStepId);
|
|
252
|
-
if (testStep.pickleStepId === undefined)
|
|
305
|
+
if (testStep.pickleStepId === undefined) {
|
|
306
|
+
if (testStepResult.status === 'FAILED') {
|
|
307
|
+
console.error(`Before/After hook failed with message: ${testStepResult.message}`);
|
|
308
|
+
}
|
|
253
309
|
return;
|
|
310
|
+
}
|
|
254
311
|
const stepProgess = this.stepReportMap.get(testStep.pickleStepId);
|
|
255
312
|
const prevStepResult = stepProgess.result;
|
|
313
|
+
let data = {};
|
|
314
|
+
const reportFolder = this.reportFolder;
|
|
315
|
+
if (reportFolder === null) {
|
|
316
|
+
throw new Error('"reportFolder" is "null". Failed to run BVT hooks. Please retry after running "Generate All" or "Record Scenario" ');
|
|
317
|
+
}
|
|
318
|
+
try {
|
|
319
|
+
if (fs_1.default.existsSync(path_1.default.join(reportFolder, 'data.json'))) {
|
|
320
|
+
data = JSON.parse(fs_1.default.readFileSync(path_1.default.join(reportFolder, 'data.json'), 'utf8'));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
console.log('Error reading data.json');
|
|
325
|
+
}
|
|
256
326
|
stepProgess.result = {
|
|
257
327
|
status: testStepResult.status,
|
|
258
328
|
startTime: prevStepResult.startTime,
|
|
@@ -260,6 +330,33 @@ class ReportGenerator {
|
|
|
260
330
|
message: testStepResult.message,
|
|
261
331
|
// exception: testStepResult.exception,
|
|
262
332
|
};
|
|
333
|
+
if (Object.keys(data).length > 0) {
|
|
334
|
+
stepProgess.data = data;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
getLogFileContent() {
|
|
338
|
+
let projectPath = process.cwd();
|
|
339
|
+
if (process.env.PROJECT_PATH) {
|
|
340
|
+
projectPath = process.env.PROJECT_PATH;
|
|
341
|
+
}
|
|
342
|
+
const logFolder = path_1.default.join(projectPath, 'logs', 'web');
|
|
343
|
+
if (!fs_1.default.existsSync(logFolder)) {
|
|
344
|
+
return [];
|
|
345
|
+
}
|
|
346
|
+
let nextId = 1;
|
|
347
|
+
while (fs_1.default.existsSync(path_1.default.join(logFolder, `${nextId}.json`))) {
|
|
348
|
+
nextId++;
|
|
349
|
+
}
|
|
350
|
+
if (nextId === 1) {
|
|
351
|
+
return [];
|
|
352
|
+
}
|
|
353
|
+
try {
|
|
354
|
+
const logFileContent = fs_1.default.readFileSync(path_1.default.join(logFolder, `${nextId - 1}.json`), 'utf8');
|
|
355
|
+
return JSON.parse(logFileContent);
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
return [];
|
|
359
|
+
}
|
|
263
360
|
}
|
|
264
361
|
getTestCaseResult(steps) {
|
|
265
362
|
for (const step of steps) {
|
|
@@ -283,7 +380,7 @@ class ReportGenerator {
|
|
|
283
380
|
status: 'PASSED',
|
|
284
381
|
};
|
|
285
382
|
}
|
|
286
|
-
onTestCaseFinished(testCaseFinished) {
|
|
383
|
+
async onTestCaseFinished(testCaseFinished) {
|
|
287
384
|
const { testCaseStartedId, timestamp } = testCaseFinished;
|
|
288
385
|
const testProgress = this.testCaseReportMap.get(testCaseStartedId);
|
|
289
386
|
const prevResult = testProgress.result;
|
|
@@ -294,6 +391,32 @@ class ReportGenerator {
|
|
|
294
391
|
startTime: prevResult.startTime,
|
|
295
392
|
endTime: this.getTimeStamp(timestamp),
|
|
296
393
|
};
|
|
394
|
+
testProgress.webLog = this.logs;
|
|
395
|
+
testProgress.networkLog = this.networkLog;
|
|
396
|
+
this.networkLog = [];
|
|
397
|
+
this.logs = [];
|
|
398
|
+
await this.uploadTestCase(testProgress);
|
|
399
|
+
}
|
|
400
|
+
async uploadTestCase(testCase) {
|
|
401
|
+
let runId = '';
|
|
402
|
+
let projectId = '';
|
|
403
|
+
try {
|
|
404
|
+
if (process.env.RUN_ID && process.env.PROJECT_ID) {
|
|
405
|
+
runId = process.env.RUN_ID;
|
|
406
|
+
projectId = process.env.PROJECT_ID;
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
const runDoc = await this.uploadService.createRunDocument(this.runName);
|
|
410
|
+
runId = runDoc._id;
|
|
411
|
+
projectId = runDoc.project_id;
|
|
412
|
+
process.env.RUN_ID = runId;
|
|
413
|
+
process.env.PROJECT_ID = projectId;
|
|
414
|
+
}
|
|
415
|
+
await this.uploadService.uploadTestCase(testCase, runId, projectId, this.reportFolder);
|
|
416
|
+
}
|
|
417
|
+
catch (e) {
|
|
418
|
+
console.error('Error uploading test case:', e);
|
|
419
|
+
}
|
|
297
420
|
}
|
|
298
421
|
onTestRunFinished(testRunFinished) {
|
|
299
422
|
const { timestamp, success, message } = testRunFinished;
|