@dev-blinq/cucumber-js 1.0.128-dev → 1.0.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cucumber.ts +1 -0
- package/bin/download-install.js +22 -2
- package/lib/api/console_logger.js.map +1 -1
- package/lib/cli/run.js +1 -0
- package/lib/cli/run.js.map +1 -1
- package/lib/cli/validate_node_engine_version.js +3 -1
- package/lib/cli/validate_node_engine_version.js.map +1 -1
- package/lib/configuration/axios_client.js +1 -1
- package/lib/configuration/axios_client.js.map +1 -1
- package/lib/formatter/api.js +16 -5
- package/lib/formatter/api.js.map +1 -1
- package/lib/formatter/builder.js +1 -3
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/bvt_analysis_formatter.d.ts +12 -1
- package/lib/formatter/bvt_analysis_formatter.js +161 -55
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -1
- package/lib/formatter/feature_data_format.js +22 -8
- package/lib/formatter/feature_data_format.js.map +1 -1
- package/lib/formatter/helpers/constants.d.ts +50 -0
- package/lib/formatter/helpers/constants.js +60 -0
- package/lib/formatter/helpers/constants.js.map +1 -0
- package/lib/formatter/helpers/report_generator.d.ts +22 -3
- package/lib/formatter/helpers/report_generator.js +336 -27
- package/lib/formatter/helpers/report_generator.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/upload_serivce.d.ts +20 -2
- package/lib/formatter/helpers/upload_serivce.js +210 -17
- package/lib/formatter/helpers/upload_serivce.js.map +1 -1
- package/lib/formatter/helpers/uploader.js +6 -2
- package/lib/formatter/helpers/uploader.js.map +1 -1
- package/lib/formatter/summary_formatter.js +4 -0
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +2 -0
- package/lib/runtime/test_case_runner.js +17 -1
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +6 -3
package/bin/cucumber.ts
CHANGED
package/bin/download-install.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
/* eslint-disable no-undef */
|
|
1
4
|
const { argv } = require('node:process')
|
|
2
5
|
const fs = require('fs')
|
|
3
6
|
const path = require('path')
|
|
@@ -16,8 +19,14 @@ const getSSoUrl = () => {
|
|
|
16
19
|
return 'https://dev.api.blinq.io/api/auth'
|
|
17
20
|
case 'stage':
|
|
18
21
|
return 'https://stage.api.blinq.io/api/auth'
|
|
19
|
-
|
|
22
|
+
case 'prod':
|
|
23
|
+
return 'https://api.blinq.io/api/auth'
|
|
24
|
+
case null:
|
|
25
|
+
return 'https://api.blinq.io/api/auth'
|
|
26
|
+
case undefined:
|
|
20
27
|
return 'https://api.blinq.io/api/auth'
|
|
28
|
+
default:
|
|
29
|
+
return `${process.env.NODE_ENV_BLINQ}/api/auth`
|
|
21
30
|
}
|
|
22
31
|
}
|
|
23
32
|
|
|
@@ -48,8 +57,14 @@ const getWorkSpaceUrl = () => {
|
|
|
48
57
|
return 'https://dev.api.blinq.io/api/workspace'
|
|
49
58
|
case "stage":
|
|
50
59
|
return 'https://stage.api.blinq.io/api/workspace'
|
|
51
|
-
|
|
60
|
+
case 'prod':
|
|
61
|
+
return 'https://api.blinq.io/api/workspace'
|
|
62
|
+
case null:
|
|
52
63
|
return 'https://api.blinq.io/api/workspace'
|
|
64
|
+
case undefined:
|
|
65
|
+
return 'https://api.blinq.io/api/workspace'
|
|
66
|
+
default:
|
|
67
|
+
return `${process.env.NODE_ENV_BLINQ}/api/workspace`
|
|
53
68
|
}
|
|
54
69
|
}
|
|
55
70
|
|
|
@@ -137,6 +152,11 @@ const downloadAndInstall = async (extractPath, token) => {
|
|
|
137
152
|
},
|
|
138
153
|
})
|
|
139
154
|
|
|
155
|
+
if (res.status !== 200) {
|
|
156
|
+
console.error('Error: Unable to fetch workspace')
|
|
157
|
+
process.exit(1)
|
|
158
|
+
}
|
|
159
|
+
|
|
140
160
|
const zip = await JSZip.loadAsync(res.data)
|
|
141
161
|
for (const filename of Object.keys(zip.files)) {
|
|
142
162
|
const fileData = zip.files[filename]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console_logger.js","sourceRoot":"","sources":["../../src/api/console_logger.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAIjC,MAAa,aAAa;IAExB,
|
|
1
|
+
{"version":3,"file":"console_logger.js","sourceRoot":"","sources":["../../src/api/console_logger.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAIjC,MAAa,aAAa;IAExB,YACU,MAAgB,EAChB,YAAqB;QADrB,WAAM,GAAN,MAAM,CAAU;QAChB,iBAAY,GAAZ,YAAY,CAAS;QAHvB,YAAO,GAAY,IAAI,iBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAIhD,CAAC;IAEJ,KAAK,CAAC,GAAG,OAAc;QACrB,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAA;SAC/B;IACH,CAAC;IAED,KAAK,CAAC,GAAG,OAAc;QACrB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,IAAI,CAAC,GAAG,OAAc;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAA;IAC/B,CAAC;CACF;AApBD,sCAoBC","sourcesContent":["import { Console } from 'console'\nimport { Writable } from 'stream'\nimport { ILogger } from '../logger'\n\nexport class ConsoleLogger implements ILogger {\n private console: Console = new Console(this.stream)\n constructor(\n private stream: Writable,\n private debugEnabled: boolean\n ) {}\n\n debug(...content: any[]): void {\n if (this.debugEnabled) {\n this.console.debug(...content)\n }\n }\n\n error(...content: any[]): void {\n this.console.error(...content)\n }\n\n warn(...content: any[]): void {\n this.console.warn(...content)\n }\n}\n"]}
|
package/lib/cli/run.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
/* eslint-disable no-console */
|
|
7
7
|
/* This is one rare place where we're fine to use process/console directly,
|
|
8
8
|
* but other code abstracts those to remain composable and testable. */
|
|
9
|
+
console.log('Loading necessary packages...');
|
|
9
10
|
const _1 = __importDefault(require("./"));
|
|
10
11
|
const verror_1 = __importDefault(require("verror"));
|
|
11
12
|
const validate_node_engine_version_1 = require("./validate_node_engine_version");
|
package/lib/cli/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B;uEACuE;AACvE,0CAAuC;AACvC,oDAA2B;AAC3B,iFAA0E;AAE1E,SAAS,sBAAsB,CAAC,OAAe;IAC7C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAEc,KAAK,UAAU,GAAG;IAC/B,IAAA,wDAAyB,EACvB,OAAO,CAAC,OAAO,EACf,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,EACD,OAAO,CAAC,IAAI,CACb,CAAA;IAED,MAAM,GAAG,GAAG,IAAI,UAAG,CAAC;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAA;IAEF,IAAI,MAAqB,CAAA;IACzB,IAAI;QACF,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,sBAAsB,CAAC,gBAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;KAChD;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,qBAAqB,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KACvB;SAAM;QACL,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;KAC5B;AACH,CAAC;AA/BD,sBA+BC","sourcesContent":["/* eslint-disable no-console */\n/* This is one rare place where we're fine to use process/console directly,\n * but other code abstracts those to remain composable and testable. */\nimport Cli, { ICliRunResult } from './'\nimport VError from 'verror'\nimport { validateNodeEngineVersion } from './validate_node_engine_version'\n\nfunction logErrorMessageAndExit(message: string): void {\n console.error(message)\n process.exit(1)\n}\n\nexport default async function run(): Promise<void> {\n validateNodeEngineVersion(\n process.version,\n (error) => {\n console.error(error)\n process.exit(1)\n },\n console.warn\n )\n\n const cli = new Cli({\n argv: process.argv,\n cwd: process.cwd(),\n stdout: process.stdout,\n stderr: process.stderr,\n env: process.env,\n })\n\n let result: ICliRunResult\n try {\n result = await cli.run()\n } catch (error) {\n logErrorMessageAndExit(VError.fullStack(error))\n }\n\n const exitCode = result.success ? 0 : 1\n if (result.shouldExitImmediately) {\n process.exit(exitCode)\n } else {\n process.exitCode = exitCode\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B;uEACuE;AACvE,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;AAC5C,0CAAuC;AACvC,oDAA2B;AAC3B,iFAA0E;AAE1E,SAAS,sBAAsB,CAAC,OAAe;IAC7C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAEc,KAAK,UAAU,GAAG;IAC/B,IAAA,wDAAyB,EACvB,OAAO,CAAC,OAAO,EACf,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,EACD,OAAO,CAAC,IAAI,CACb,CAAA;IAED,MAAM,GAAG,GAAG,IAAI,UAAG,CAAC;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAA;IAEF,IAAI,MAAqB,CAAA;IACzB,IAAI;QACF,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,sBAAsB,CAAC,gBAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;KAChD;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,qBAAqB,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KACvB;SAAM;QACL,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;KAC5B;AACH,CAAC;AA/BD,sBA+BC","sourcesContent":["/* eslint-disable no-console */\n/* This is one rare place where we're fine to use process/console directly,\n * but other code abstracts those to remain composable and testable. */\nconsole.log('Loading necessary packages...')\nimport Cli, { ICliRunResult } from './'\nimport VError from 'verror'\nimport { validateNodeEngineVersion } from './validate_node_engine_version'\n\nfunction logErrorMessageAndExit(message: string): void {\n console.error(message)\n process.exit(1)\n}\n\nexport default async function run(): Promise<void> {\n validateNodeEngineVersion(\n process.version,\n (error) => {\n console.error(error)\n process.exit(1)\n },\n console.warn\n )\n\n const cli = new Cli({\n argv: process.argv,\n cwd: process.cwd(),\n stdout: process.stdout,\n stderr: process.stderr,\n env: process.env,\n })\n\n let result: ICliRunResult\n try {\n result = await cli.run()\n } catch (error) {\n logErrorMessageAndExit(VError.fullStack(error))\n }\n\n const exitCode = result.success ? 0 : 1\n if (result.shouldExitImmediately) {\n process.exit(exitCode)\n } else {\n process.exitCode = exitCode\n }\n}\n"]}
|
|
@@ -17,7 +17,9 @@ function validateNodeEngineVersion(currentVersion, onError, onWarning, readPacka
|
|
|
17
17
|
onError(`Cucumber can only run on Node.js versions ${requiredVersions}. This Node.js version is ${currentVersion}`);
|
|
18
18
|
}
|
|
19
19
|
else if (!semver_1.default.satisfies(currentVersion, testedVersions)) {
|
|
20
|
-
onWarning(
|
|
20
|
+
// onWarning(
|
|
21
|
+
// `This Node.js version (${currentVersion}) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`
|
|
22
|
+
// )
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
exports.validateNodeEngineVersion = validateNodeEngineVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate_node_engine_version.js","sourceRoot":"","sources":["../../src/cli/validate_node_engine_version.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,oDAA2B;AAO3B,MAAM,qBAAqB,GAAsB,GAAG,EAAE,CACpD,IAAI,CAAC,KAAK,CACR,YAAE;KACC,YAAY,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;KACjE,QAAQ,EAAE,CACd,CAAA;AAEH,SAAgB,yBAAyB,CACvC,cAAsB,EACtB,OAAkC,EAClC,SAAoC,EACpC,kBAAqC,qBAAqB;IAE1D,MAAM,gBAAgB,GAAG,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,CAAA;IACvD,MAAM,cAAc,GAAG,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,CAAA;IAC3D,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAE;QACvD,OAAO,CACL,6CAA6C,gBAAgB,6BAA6B,cAAc,EAAE,CAC3G,CAAA;KACF;SAAM,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE;QAC5D,
|
|
1
|
+
{"version":3,"file":"validate_node_engine_version.js","sourceRoot":"","sources":["../../src/cli/validate_node_engine_version.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,oDAA2B;AAO3B,MAAM,qBAAqB,GAAsB,GAAG,EAAE,CACpD,IAAI,CAAC,KAAK,CACR,YAAE;KACC,YAAY,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;KACjE,QAAQ,EAAE,CACd,CAAA;AAEH,SAAgB,yBAAyB,CACvC,cAAsB,EACtB,OAAkC,EAClC,SAAoC,EACpC,kBAAqC,qBAAqB;IAE1D,MAAM,gBAAgB,GAAG,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,CAAA;IACvD,MAAM,cAAc,GAAG,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,CAAA;IAC3D,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAE;QACvD,OAAO,CACL,6CAA6C,gBAAgB,6BAA6B,cAAc,EAAE,CAC3G,CAAA;KACF;SAAM,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE;QAC5D,aAAa;QACb,qLAAqL;QACrL,IAAI;KACL;AACH,CAAC;AAjBD,8DAiBC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport semver from 'semver'\n\ntype PackageJSON = {\n engines: { node: string }\n enginesTested: { node: string }\n}\n\nconst readActualPackageJSON: () => PackageJSON = () =>\n JSON.parse(\n fs\n .readFileSync(path.resolve(__dirname, '..', '..', 'package.json'))\n .toString()\n )\n\nexport function validateNodeEngineVersion(\n currentVersion: string,\n onError: (message: string) => void,\n onWarning: (message: string) => void,\n readPackageJSON: () => PackageJSON = readActualPackageJSON\n): void {\n const requiredVersions = readPackageJSON().engines.node\n const testedVersions = readPackageJSON().enginesTested.node\n if (!semver.satisfies(currentVersion, requiredVersions)) {\n onError(\n `Cucumber can only run on Node.js versions ${requiredVersions}. This Node.js version is ${currentVersion}`\n )\n } else if (!semver.satisfies(currentVersion, testedVersions)) {\n // onWarning(\n // `This Node.js version (${currentVersion}) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`\n // )\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios_client.js","sourceRoot":"","sources":["../../src/configuration/axios_client.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,kDAAyB;AACzB,oDAA6C;AAG7C,MAAM,QAAQ,GAAG,GAAiB,EAAE;IAClC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE;QACtB,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,KAAK,GAAkB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;IAC9C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,MAAM,WAAW,GAAiB;QAChC,IAAI,EAAE,GAAG,CAAC,QAAQ;QAClB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;KACvB,CAAA;IAED,MAAM,E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AM,KAAK,GAAmB,QAAQ,EAAE,CAAA;QACxC,OAAO,eAAK,CAAC,MAAM,CAAC;YAClB,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE,KAAK;SACb,CAAC,CAAA;KACH;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,MAAM,IAAI,KAAK,CACb,+BACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAC1D,EAAE,CACH,CAAA;KACF;AACH,CAAC,CAAA;AAEY,QAAA,WAAW,GAAG,iBAAiB,EAAE,CAAA","sourcesContent":["/* eslint-disable no-console */\nimport axios from 'axios'\nimport tunnel, { ProxyOptions } from 'tunnel'\nimport { Agent } from 'http'\n\nconst getProxy = (): Agent | null => {\n if (!process.env.PROXY) {\n return null\n }\n\n const proxy: string | null = process.env.PROXY\n const url = new URL(proxy)\n const proxyObject: ProxyOptions = {\n host: url.hostname,\n port: Number(url.port),\n }\n\n const { username, password } = url\n\n if (username && password) {\n proxyObject.proxyAuth = `${username}:${password}`\n }\n return tunnel.httpsOverHttp({ proxy: proxyObject })\n}\n\nconst createAxiosClient = () => {\n try {\n const agent: string | Agent = getProxy()\n return axios.create({\n httpsAgent: agent,\n proxy: false,\n })\n } catch (error) {\n console.log(error.message)\n throw new Error(\n `Error creating axios client ${\n error instanceof Error ? error.message : error.response.data\n }`\n )\n }\n}\n\nexport const axiosClient = createAxiosClient()\n"]}
|
package/lib/formatter/api.js
CHANGED
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getProjectByAccessKey = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
7
|
const tunnel_1 = __importDefault(require("tunnel"));
|
|
8
|
+
const axios_client_1 = require("../configuration/axios_client");
|
|
9
9
|
const getSSoUrl = () => {
|
|
10
10
|
switch (process.env.NODE_ENV_BLINQ) {
|
|
11
11
|
case 'local':
|
|
@@ -14,8 +14,14 @@ const getSSoUrl = () => {
|
|
|
14
14
|
return 'https://dev.api.blinq.io/api/auth';
|
|
15
15
|
case 'stage':
|
|
16
16
|
return 'https://stage.api.blinq.io/api/auth';
|
|
17
|
-
|
|
17
|
+
case 'prod':
|
|
18
|
+
return 'https://api.blinq.io/api/auth';
|
|
19
|
+
case null:
|
|
18
20
|
return 'https://api.blinq.io/api/auth';
|
|
21
|
+
case undefined:
|
|
22
|
+
return 'https://api.blinq.io/api/auth';
|
|
23
|
+
default:
|
|
24
|
+
return `${process.env.NODE_ENV_BLINQ}/api/auth`;
|
|
19
25
|
}
|
|
20
26
|
};
|
|
21
27
|
const getProxy = () => {
|
|
@@ -38,11 +44,16 @@ const getProxy = () => {
|
|
|
38
44
|
const getProjectByAccessKey = async (access_key) => {
|
|
39
45
|
const ssoUrl = getSSoUrl();
|
|
40
46
|
const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`;
|
|
41
|
-
const response = await
|
|
47
|
+
const response = await axios_client_1.axiosClient.post(accessKeyUrl, {
|
|
42
48
|
access_key,
|
|
43
|
-
httpAgent: getProxy(),
|
|
44
|
-
proxy: false,
|
|
45
49
|
});
|
|
50
|
+
/*
|
|
51
|
+
const response = await axios.post(accessKeyUrl, {
|
|
52
|
+
access_key,
|
|
53
|
+
httpAgent: getProxy(),
|
|
54
|
+
proxy: false,
|
|
55
|
+
})
|
|
56
|
+
*/
|
|
46
57
|
if (response.status !== 200) {
|
|
47
58
|
console.error('Error: Invalid access key');
|
|
48
59
|
process.exit(1);
|
package/lib/formatter/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/formatter/api.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"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IACzD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,YAAY,GAAG,GAAG,MAAM,wBAAwB,CAAA;IAEtD,MAAM,QAAQ,GAAG,MAAM,0BAAW,CAAC,IAAI,CAAC,YAAY,EAAE;QACpD,UAAU;KACX,CAAC,CAAA;IAEF;;;;;;MAME;IAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;QAC3B,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IACD,OAAO,QAAQ,CAAC,IAAI,CAAA;AACtB,CAAC,CAAA;AAEQ,sDAAqB","sourcesContent":["import axios from 'axios'\nimport tunnel from 'tunnel'\nimport { axiosClient } from '../configuration/axios_client'\n\nconst getSSoUrl = () => {\n switch (process.env.NODE_ENV_BLINQ) {\n case 'local':\n return 'http://localhost:5000/api/auth'\n case 'dev':\n return 'https://dev.api.blinq.io/api/auth'\n case 'stage':\n return 'https://stage.api.blinq.io/api/auth'\n case 'prod':\n return 'https://api.blinq.io/api/auth'\n case null:\n return 'https://api.blinq.io/api/auth'\n case undefined:\n return 'https://api.blinq.io/api/auth'\n default:\n return `${process.env.NODE_ENV_BLINQ}/api/auth`\n }\n}\nconst getProxy = () => {\n if (!process.env.PROXY) {\n return null\n }\n\n const proxy = process.env.PROXY\n const url = new URL(proxy)\n const proxyObject = {\n host: url.hostname,\n port: Number(url.port),\n }\n\n const { username, password } = url\n\n if (username && password) {\n //@ts-ignore\n proxyObject.proxyAuth = `${username}:${password}`\n }\n return tunnel.httpsOverHttp({ proxy: proxyObject })\n}\n\nconst getProjectByAccessKey = async (access_key: string) => {\n const ssoUrl = getSSoUrl()\n const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`\n\n const response = await axiosClient.post(accessKeyUrl, {\n access_key,\n })\n\n /*\n const response = await axios.post(accessKeyUrl, {\n access_key,\n httpAgent: getProxy(),\n proxy: false,\n })\n */\n\n if (response.status !== 200) {\n console.error('Error: Invalid access key')\n process.exit(1)\n }\n return response.data\n}\n\nexport { getProjectByAccessKey }\n"]}
|
package/lib/formatter/builder.js
CHANGED
|
@@ -69,9 +69,7 @@ const FormatterBuilder = {
|
|
|
69
69
|
let result;
|
|
70
70
|
try {
|
|
71
71
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
72
|
-
result = require(typeof urlOrName === 'string'
|
|
73
|
-
? urlOrName
|
|
74
|
-
: (0, url_1.fileURLToPath)(urlOrName));
|
|
72
|
+
result = require(typeof urlOrName === 'string' ? urlOrName : (0, url_1.fileURLToPath)(urlOrName));
|
|
75
73
|
}
|
|
76
74
|
catch (error) {
|
|
77
75
|
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/formatter/builder.ts"],"names":[],"mappings":";;;;;AAAA,oEAAyC;AACzC,4HAAiG;AACjG,gDAAuB;AACvB,wGAA4E;AAO5E,oDAAkE;AAIlE,qFAAmF;AACnF,6BAAkD;AAClD,sEAA6C;AAC7C,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAqB3C,MAAM,gBAAgB,GAAG;IACvB,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,OAAsB;QAC9C,MAAM,oBAAoB,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CACtE,IAAI,EACJ,OAAO,CAAC,GAAG,CACZ,CAAA;QACD,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAC1B,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,GAAG,EACX,OAAO,CAAC,iBAAiB,CAAC,aAAa,CACxC,CAAA;QACD,MAAM,cAAc,GAClB,MAAM,gBAAgB,CAAC,+BAA+B,CAAC;YACrD,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,gBAAgB,EAAE,OAAO,CAAC,i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AAE;YACtC,OAAO,YAAY,CAAA;SACpB;aAAM,IACL,OAAO,YAAY,KAAK,QAAQ;YAChC,OAAO,YAAY,CAAC,OAAO,KAAK,UAAU,EAC1C;YACA,OAAO,YAAY,CAAC,OAAO,CAAA;SAC5B;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAED,kBAAe,gBAAgB,CAAA","sourcesContent":["import getColorFns from './get_color_fns'\nimport JavascriptSnippetSyntax from './step_definition_snippet_builder/javascript_snippet_syntax'\nimport path from 'path'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport Formatter, {\n FormatOptions,\n IFormatterCleanupFn,\n IFormatterLogFn,\n} from '.'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { EventEmitter } from 'events'\nimport EventDataCollector from './helpers/event_data_collector'\nimport { Writable as WritableStream } from 'stream'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\nimport { fileURLToPath, pathToFileURL } from 'url'\nimport Formatters from './helpers/formatters'\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\ninterface IGetStepDefinitionSnippetBuilderOptions {\n cwd: string\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IBuildOptions {\n env: NodeJS.ProcessEnv\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n stream: WritableStream\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nconst FormatterBuilder = {\n async build(type: string, options: IBuildOptions): Promise<Formatter> {\n const FormatterConstructor = await FormatterBuilder.getConstructorByType(\n type,\n options.cwd\n )\n const colorFns = getColorFns(\n options.stream,\n options.env,\n options.parsedArgvOptions.colorsEnabled\n )\n const snippetBuilder =\n await FormatterBuilder.getStepDefinitionSnippetBuilder({\n cwd: options.cwd,\n snippetInterface: options.parsedArgvOptions.snippetInterface,\n snippetSyntax: options.parsedArgvOptions.snippetSyntax,\n supportCodeLibrary: options.supportCodeLibrary,\n })\n return new FormatterConstructor({\n colorFns,\n snippetBuilder,\n ...options,\n })\n },\n\n async getConstructorByType(\n type: string,\n cwd: string\n ): Promise<typeof Formatter> {\n const formatters: Record<string, typeof Formatter> =\n Formatters.getFormatters()\n\n return formatters[type]\n ? formatters[type]\n : await FormatterBuilder.loadCustomClass('formatter', type, cwd)\n },\n\n async getStepDefinitionSnippetBuilder({\n cwd,\n snippetInterface,\n snippetSyntax,\n supportCodeLibrary,\n }: IGetStepDefinitionSnippetBuilderOptions) {\n if (doesNotHaveValue(snippetInterface)) {\n snippetInterface = SnippetInterface.Synchronous\n }\n let Syntax = JavascriptSnippetSyntax\n if (doesHaveValue(snippetSyntax)) {\n Syntax = await FormatterBuilder.loadCustomClass(\n 'syntax',\n snippetSyntax,\n cwd\n )\n }\n return new StepDefinitionSnippetBuilder({\n snippetSyntax: new Syntax(snippetInterface),\n parameterTypeRegistry: supportCodeLibrary.parameterTypeRegistry,\n })\n },\n\n async loadCustomClass(\n type: 'formatter' | 'syntax',\n descriptor: string,\n cwd: string\n ) {\n let normalized: URL | string = descriptor\n if (descriptor.startsWith('.')) {\n normalized = pathToFileURL(path.resolve(cwd, descriptor))\n } else if (descriptor.startsWith('file://')) {\n normalized = new URL(descriptor)\n }\n let CustomClass = await FormatterBuilder.loadFile(normalized)\n CustomClass = FormatterBuilder.resolveConstructor(CustomClass)\n if (doesHaveValue(CustomClass)) {\n return CustomClass\n } else {\n throw new Error(\n `Custom ${type} (${descriptor}) does not export a function/class`\n )\n }\n },\n\n async loadFile(urlOrName: URL | string) {\n let result\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n result = require(\n typeof urlOrName === 'string' ? urlOrName : fileURLToPath(urlOrName)\n )\n } catch (error) {\n if (error.code === 'ERR_REQUIRE_ESM') {\n result = await importer(urlOrName)\n } else {\n throw error\n }\n }\n return result\n },\n\n resolveConstructor(ImportedCode: any) {\n if (doesNotHaveValue(ImportedCode)) {\n return null\n }\n if (typeof ImportedCode === 'function') {\n return ImportedCode\n } else if (\n typeof ImportedCode === 'object' &&\n typeof ImportedCode.default === 'function'\n ) {\n return ImportedCode.default\n }\n return null\n },\n}\n\nexport default FormatterBuilder\n"]}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import Formatter, { IFormatterOptions } from '.';
|
|
2
|
+
import ReportGenerator, { JsonTestResult } from './helpers/report_generator';
|
|
3
|
+
export declare let globalReportLink: string;
|
|
2
4
|
export default class BVTAnalysisFormatter extends Formatter {
|
|
5
|
+
static reportGenerator: ReportGenerator;
|
|
6
|
+
static reRunFailedStepsIndex: {
|
|
7
|
+
testCaseId: string;
|
|
8
|
+
failedStepIndex: number;
|
|
9
|
+
}[] | null;
|
|
3
10
|
private reportGenerator;
|
|
4
11
|
private uploader;
|
|
5
12
|
private exit;
|
|
6
13
|
private START;
|
|
7
14
|
private runName;
|
|
15
|
+
private failedStepsIndex;
|
|
8
16
|
private summaryFormatter;
|
|
17
|
+
private rootCauseArray;
|
|
9
18
|
constructor(options: IFormatterOptions);
|
|
19
|
+
private sendEvent;
|
|
10
20
|
private uploadReport;
|
|
11
21
|
finished(): Promise<any>;
|
|
12
22
|
private analyzeReport;
|
|
@@ -14,7 +24,8 @@ export default class BVTAnalysisFormatter extends Formatter {
|
|
|
14
24
|
private processTestCase;
|
|
15
25
|
private uploadFinalReport;
|
|
16
26
|
private retrain;
|
|
27
|
+
private rerun;
|
|
17
28
|
private call_cucumber_client;
|
|
18
29
|
private getAppDataDir;
|
|
19
30
|
}
|
|
20
|
-
export declare function logReportLink(runId: string, projectId: string):
|
|
31
|
+
export declare function logReportLink(runId: string, projectId: string, status: JsonTestResult): string;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.logReportLink = void 0;
|
|
6
|
+
exports.logReportLink = exports.globalReportLink = void 0;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const promises_1 = require("fs/promises");
|
|
@@ -16,29 +16,53 @@ const uploader_1 = __importDefault(require("./helpers/uploader"));
|
|
|
16
16
|
const os_1 = __importDefault(require("os"));
|
|
17
17
|
const api_1 = require("./api");
|
|
18
18
|
const summary_formatter_1 = __importDefault(require("./summary_formatter"));
|
|
19
|
+
const constants_1 = require("./helpers/constants");
|
|
20
|
+
const axios_client_1 = require("../configuration/axios_client");
|
|
21
|
+
const util_1 = require("util");
|
|
22
|
+
const child_process_2 = require("child_process");
|
|
19
23
|
//User token
|
|
20
24
|
const TOKEN = process.env.TOKEN;
|
|
25
|
+
exports.globalReportLink = '';
|
|
21
26
|
class BVTAnalysisFormatter extends _1.default {
|
|
22
27
|
constructor(options) {
|
|
23
28
|
super(options);
|
|
24
29
|
this.reportGenerator = new report_generator_1.default();
|
|
25
30
|
this.uploader = new uploader_1.default(this.reportGenerator);
|
|
26
31
|
this.exit = false;
|
|
32
|
+
this.rootCauseArray = [];
|
|
27
33
|
this.summaryFormatter = new summary_formatter_1.default(options);
|
|
34
|
+
BVTAnalysisFormatter.reportGenerator = this.reportGenerator;
|
|
35
|
+
this.rootCauseArray = [];
|
|
36
|
+
this.failedStepsIndex = [];
|
|
37
|
+
BVTAnalysisFormatter.reRunFailedStepsIndex = process.env.RERUN
|
|
38
|
+
? JSON.parse(process.env.RERUN)
|
|
39
|
+
: null;
|
|
28
40
|
if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {
|
|
29
41
|
throw new Error('TOKEN must be set');
|
|
30
42
|
}
|
|
31
|
-
|
|
43
|
+
this.sendEvent(constants_1.ActionEvents.cli_run_tests);
|
|
44
|
+
options.eventBroadcaster.on('envelope', async (envelope, data) => {
|
|
45
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.testCaseFinished) && data) {
|
|
46
|
+
const { rootCause, report } = data;
|
|
47
|
+
if (!rootCause.status) {
|
|
48
|
+
console.error(`Root cause: ${rootCause.failClass}\n, ${rootCause.analysis}\nfailing step: ${rootCause.failedStep}`);
|
|
49
|
+
this.rootCauseArray.push({ rootCause, report });
|
|
50
|
+
this.failedStepsIndex.push({
|
|
51
|
+
testCaseId: report.id,
|
|
52
|
+
failedStepIndex: rootCause.failedStep,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
32
57
|
await this.reportGenerator.handleMessage(envelope);
|
|
33
58
|
if ((0, value_checker_1.doesHaveValue)(envelope.meta) &&
|
|
34
59
|
(0, value_checker_1.doesHaveValue)(envelope.meta.runName)) {
|
|
35
60
|
this.runName = envelope.meta.runName;
|
|
36
61
|
}
|
|
37
62
|
if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
38
|
-
const report = this.reportGenerator.getReport();
|
|
39
63
|
this.START = Date.now();
|
|
40
64
|
if (process.env.BVT_FORMATTER === 'ANALYSIS') {
|
|
41
|
-
await this.analyzeReport(
|
|
65
|
+
await this.analyzeReport();
|
|
42
66
|
}
|
|
43
67
|
else {
|
|
44
68
|
// await this.uploadReport(report)
|
|
@@ -47,6 +71,20 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
47
71
|
}
|
|
48
72
|
});
|
|
49
73
|
}
|
|
74
|
+
sendEvent(event) {
|
|
75
|
+
axios_client_1.axiosClient
|
|
76
|
+
.post(`${constants_1.SERVICES_URI.STORAGE}/event`, {
|
|
77
|
+
event,
|
|
78
|
+
}, {
|
|
79
|
+
headers: {
|
|
80
|
+
Authorization: `Bearer ${TOKEN}`,
|
|
81
|
+
'x-source': 'cucumber_js',
|
|
82
|
+
},
|
|
83
|
+
})
|
|
84
|
+
.catch((err) => {
|
|
85
|
+
// Error with events, ignoring
|
|
86
|
+
});
|
|
87
|
+
}
|
|
50
88
|
async uploadReport(report) {
|
|
51
89
|
const uploadSuccessful = await this.uploadFinalReport(report);
|
|
52
90
|
if (uploadSuccessful && report.result.status !== 'FAILED') {
|
|
@@ -77,10 +115,10 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
77
115
|
}, 100); // check every 100ms
|
|
78
116
|
});
|
|
79
117
|
}
|
|
80
|
-
async analyzeReport(
|
|
81
|
-
if (
|
|
118
|
+
async analyzeReport() {
|
|
119
|
+
if (this.rootCauseArray.length === 0 ||
|
|
82
120
|
process.env.NO_RETRAIN === 'false') {
|
|
83
|
-
if (
|
|
121
|
+
if (this.rootCauseArray.length === 0) {
|
|
84
122
|
this.log('No test failed. No need to retrain\n');
|
|
85
123
|
}
|
|
86
124
|
if (process.env.NO_RETRAIN === 'false') {
|
|
@@ -93,61 +131,44 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
93
131
|
}
|
|
94
132
|
//checking if the type of report.result is JsonResultFailed or not
|
|
95
133
|
this.log('Some tests failed, starting the retraining...\n');
|
|
96
|
-
|
|
97
|
-
this.log('Unknown error occured,not retraining\n');
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
await this.processTestCases(report);
|
|
134
|
+
await this.processTestCases();
|
|
101
135
|
if (this.reportGenerator.getReport().result.status === 'FAILED') {
|
|
102
136
|
process.exit(1);
|
|
103
137
|
}
|
|
104
138
|
process.exit(0);
|
|
105
139
|
}
|
|
106
|
-
async processTestCases(
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
const modifiedTestCase = await this.processTestCase(testCase, report);
|
|
110
|
-
finalTestCases.push(modifiedTestCase);
|
|
140
|
+
async processTestCases() {
|
|
141
|
+
for (const { rootCause, report } of this.rootCauseArray) {
|
|
142
|
+
await this.processTestCase(rootCause, report);
|
|
111
143
|
}
|
|
112
|
-
const finalResult = finalTestCases.some((tc) => tc.result.status !== 'PASSED')
|
|
113
|
-
? report.result
|
|
114
|
-
: {
|
|
115
|
-
...report.result,
|
|
116
|
-
status: 'PASSED',
|
|
117
|
-
};
|
|
118
|
-
return {
|
|
119
|
-
result: finalResult,
|
|
120
|
-
testCases: finalTestCases,
|
|
121
|
-
env: report.env,
|
|
122
|
-
};
|
|
123
144
|
}
|
|
124
|
-
async processTestCase(
|
|
125
|
-
|
|
126
|
-
|
|
145
|
+
async processTestCase(rootCause, report) {
|
|
146
|
+
const failedTestSteps = rootCause.failedStep;
|
|
147
|
+
if (BVTAnalysisFormatter.reRunFailedStepsIndex &&
|
|
148
|
+
BVTAnalysisFormatter.reRunFailedStepsIndex.length > 0) {
|
|
149
|
+
const previousRun = BVTAnalysisFormatter.reRunFailedStepsIndex[0];
|
|
150
|
+
if (previousRun.failedStepIndex === failedTestSteps) {
|
|
151
|
+
console.log('Same step has failed again, skipping retraining');
|
|
152
|
+
BVTAnalysisFormatter.reRunFailedStepsIndex.shift();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
BVTAnalysisFormatter.reRunFailedStepsIndex.shift();
|
|
127
156
|
}
|
|
128
|
-
const
|
|
129
|
-
.map((step, i) => (step.result.status === 'FAILED' ? i : null))
|
|
130
|
-
.filter((i) => i !== null);
|
|
131
|
-
const retrainStats = await this.retrain(failedTestSteps, testCase);
|
|
157
|
+
const retrainStats = await this.retrain(failedTestSteps, report);
|
|
132
158
|
if (!retrainStats) {
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
if (retrainStats.result.status === 'PASSED') {
|
|
136
|
-
await this.uploader.modifyTestCase({
|
|
137
|
-
...testCase,
|
|
138
|
-
retrainStats,
|
|
139
|
-
});
|
|
159
|
+
return;
|
|
140
160
|
}
|
|
141
|
-
|
|
142
|
-
...
|
|
161
|
+
await this.uploader.modifyTestCase({
|
|
162
|
+
...report,
|
|
143
163
|
retrainStats,
|
|
144
|
-
};
|
|
164
|
+
});
|
|
165
|
+
await this.rerun(report);
|
|
145
166
|
}
|
|
146
167
|
async uploadFinalReport(finalReport) {
|
|
147
168
|
let success = true;
|
|
148
169
|
try {
|
|
149
170
|
const { projectId, runId } = await this.uploader.uploadRun(finalReport, this.runName);
|
|
150
|
-
logReportLink(runId, projectId);
|
|
171
|
+
logReportLink(runId, projectId, finalReport.result);
|
|
151
172
|
}
|
|
152
173
|
catch (err) {
|
|
153
174
|
this.log('Error uploading report\n');
|
|
@@ -176,6 +197,49 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
176
197
|
}
|
|
177
198
|
return await this.call_cucumber_client(failedTestCases, testCase);
|
|
178
199
|
}
|
|
200
|
+
async rerun(report) {
|
|
201
|
+
await new Promise((resolve) => {
|
|
202
|
+
// Default to system Node.js
|
|
203
|
+
let node_path = process.argv.shift();
|
|
204
|
+
// Use bundled Node if running from recorder app on macOS or Windows
|
|
205
|
+
const isFromRecorderApp = process.env.FROM_RECORDER_APP === 'true';
|
|
206
|
+
const isSupportedPlatform = process.platform === 'darwin' || process.platform === 'win32';
|
|
207
|
+
if (isFromRecorderApp && isSupportedPlatform) {
|
|
208
|
+
node_path = process.execPath;
|
|
209
|
+
}
|
|
210
|
+
const args = [
|
|
211
|
+
path_1.default.join(process.cwd(), 'node_modules', '@dev-blinq', 'cucumber-js', 'bin', 'cucumber.js'),
|
|
212
|
+
'--name',
|
|
213
|
+
`^${report.scenarioName}$`,
|
|
214
|
+
'--exit',
|
|
215
|
+
'--format',
|
|
216
|
+
'bvt',
|
|
217
|
+
'--run-name',
|
|
218
|
+
`${report.scenarioName}@debug`,
|
|
219
|
+
path_1.default.join(process.cwd(), report.uri),
|
|
220
|
+
];
|
|
221
|
+
const envVars = {
|
|
222
|
+
...process.env,
|
|
223
|
+
RERUN: JSON.stringify(this.failedStepsIndex),
|
|
224
|
+
};
|
|
225
|
+
// Inject Electron node env only if using bundled node
|
|
226
|
+
if (node_path === process.execPath) {
|
|
227
|
+
envVars.ELECTRON_RUN_AS_NODE = '1';
|
|
228
|
+
}
|
|
229
|
+
const cucumberClient = (0, child_process_1.spawn)(node_path, args, {
|
|
230
|
+
env: envVars,
|
|
231
|
+
});
|
|
232
|
+
cucumberClient.stdout.on('data', (data) => {
|
|
233
|
+
console.log(data.toString());
|
|
234
|
+
});
|
|
235
|
+
cucumberClient.stderr.on('data', (data) => {
|
|
236
|
+
console.error(data.toString());
|
|
237
|
+
});
|
|
238
|
+
cucumberClient.on('close', () => {
|
|
239
|
+
resolve();
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
179
243
|
async call_cucumber_client(stepsToRetrain, testCase) {
|
|
180
244
|
return new Promise((resolve, reject) => {
|
|
181
245
|
const cucumber_client_path = path_1.default.resolve(process.cwd(), 'node_modules', '@dev-blinq', 'cucumber_client', 'bin', 'client', 'cucumber.js');
|
|
@@ -184,7 +248,7 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
184
248
|
path_1.default.join(process.cwd(), testCase.uri),
|
|
185
249
|
`${testCase.scenarioName}`,
|
|
186
250
|
'undefined',
|
|
187
|
-
`${stepsToRetrain
|
|
251
|
+
`${stepsToRetrain},`,
|
|
188
252
|
];
|
|
189
253
|
if (process.env.BLINQ_ENV) {
|
|
190
254
|
args.push(`--env=${process.env.BLINQ_ENV}`);
|
|
@@ -197,13 +261,24 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
197
261
|
(0, tmp_1.tmpName)(async (err, name) => {
|
|
198
262
|
const tempFile = path_1.default.join(this.getAppDataDir(), 'blinq.io', '.temp', path_1.default.basename(name));
|
|
199
263
|
console.log('File path: ', tempFile);
|
|
264
|
+
if (!(0, fs_1.existsSync)(path_1.default.dirname(tempFile))) {
|
|
265
|
+
await (0, promises_1.mkdir)(path_1.default.dirname(tempFile), { recursive: true });
|
|
266
|
+
}
|
|
200
267
|
await (0, promises_1.writeFile)(tempFile, '', 'utf-8');
|
|
201
268
|
args.push(`--temp-file=${tempFile}`);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
269
|
+
// Determine node path
|
|
270
|
+
const isFromRecorderApp = process.env.FROM_RECORDER_APP === 'true';
|
|
271
|
+
const isSupportedPlatform = process.platform === 'darwin' || process.platform === 'win32';
|
|
272
|
+
const node_path = isFromRecorderApp && isSupportedPlatform ? process.execPath : 'node';
|
|
273
|
+
const envVars = {
|
|
274
|
+
...process.env,
|
|
275
|
+
TEMP_FILE_PATH: tempFile,
|
|
276
|
+
};
|
|
277
|
+
if (node_path === process.execPath) {
|
|
278
|
+
envVars.ELECTRON_RUN_AS_NODE = '1';
|
|
279
|
+
}
|
|
280
|
+
const cucumberClient = (0, child_process_1.spawn)(node_path, [cucumber_client_path, ...args], {
|
|
281
|
+
env: envVars,
|
|
207
282
|
});
|
|
208
283
|
cucumberClient.stdout.on('data', (data) => {
|
|
209
284
|
console.log(data.toString());
|
|
@@ -220,7 +295,16 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
220
295
|
}
|
|
221
296
|
else {
|
|
222
297
|
this.log('Error retraining\n');
|
|
223
|
-
|
|
298
|
+
try {
|
|
299
|
+
const reportData = (0, fs_1.readFileSync)(tempFile, 'utf-8');
|
|
300
|
+
const retrainStats = JSON.parse(reportData);
|
|
301
|
+
await (0, promises_1.unlink)(tempFile);
|
|
302
|
+
resolve(retrainStats);
|
|
303
|
+
}
|
|
304
|
+
catch (e) {
|
|
305
|
+
this.log('Error reading scenario report\n ' + e);
|
|
306
|
+
resolve(null);
|
|
307
|
+
}
|
|
224
308
|
}
|
|
225
309
|
});
|
|
226
310
|
});
|
|
@@ -246,7 +330,7 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
246
330
|
}
|
|
247
331
|
}
|
|
248
332
|
exports.default = BVTAnalysisFormatter;
|
|
249
|
-
function logReportLink(runId, projectId) {
|
|
333
|
+
function logReportLink(runId, projectId, status) {
|
|
250
334
|
let reportLinkBaseUrl = 'https://app.blinq.io';
|
|
251
335
|
if (process.env.NODE_ENV_BLINQ === 'local') {
|
|
252
336
|
reportLinkBaseUrl = 'http://localhost:3000';
|
|
@@ -257,8 +341,30 @@ function logReportLink(runId, projectId) {
|
|
|
257
341
|
else if (process.env.NODE_ENV_BLINQ === 'stage') {
|
|
258
342
|
reportLinkBaseUrl = 'https://stage.app.blinq.io';
|
|
259
343
|
}
|
|
344
|
+
else if (process.env.NODE_ENV_BLINQ === 'prod') {
|
|
345
|
+
reportLinkBaseUrl = 'https://app.blinq.io';
|
|
346
|
+
}
|
|
347
|
+
else if (!process.env.NODE_ENV_BLINQ) {
|
|
348
|
+
reportLinkBaseUrl = 'https://app.blinq.io';
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
reportLinkBaseUrl = process.env.NODE_ENV_BLINQ.replace('api', 'app');
|
|
352
|
+
}
|
|
260
353
|
const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`;
|
|
261
|
-
|
|
354
|
+
exports.globalReportLink = reportLink;
|
|
355
|
+
try {
|
|
356
|
+
publishReportLinkToGuacServer(reportLink, status.status === 'PASSED');
|
|
357
|
+
}
|
|
358
|
+
catch (err) {
|
|
359
|
+
// Error with events, ignoring
|
|
360
|
+
}
|
|
361
|
+
return reportLink;
|
|
262
362
|
}
|
|
263
363
|
exports.logReportLink = logReportLink;
|
|
364
|
+
function publishReportLinkToGuacServer(reportLink, result) {
|
|
365
|
+
if ((0, fs_1.existsSync)('/tmp/report_publish.sh')) {
|
|
366
|
+
const execAsync = (0, util_1.promisify)(child_process_2.exec);
|
|
367
|
+
execAsync('sh /tmp/report_publish.sh ' + reportLink + ' ' + result);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
264
370
|
//# sourceMappingURL=bvt_analysis_formatter.js.map
|