@dev-blinq/cucumber-js 1.0.14 → 1.0.16-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 +42 -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/bvt_analysis_formatter.d.ts +3 -3
- package/lib/formatter/bvt_analysis_formatter.js +105 -115
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -1
- package/lib/formatter/feature_data_format.d.ts +10 -1
- package/lib/formatter/feature_data_format.js +58 -2
- package/lib/formatter/feature_data_format.js.map +1 -1
- package/lib/formatter/helpers/formatters.js +1 -3
- package/lib/formatter/helpers/formatters.js.map +1 -1
- package/lib/formatter/helpers/report_generator.d.ts +22 -3
- package/lib/formatter/helpers/report_generator.js +151 -21
- package/lib/formatter/helpers/report_generator.js.map +1 -1
- package/lib/formatter/helpers/upload_serivce.d.ts +5 -1
- package/lib/formatter/helpers/upload_serivce.js +73 -12
- package/lib/formatter/helpers/upload_serivce.js.map +1 -1
- package/lib/formatter/helpers/uploader.d.ts +4 -1
- package/lib/formatter/helpers/uploader.js +62 -10
- package/lib/formatter/helpers/uploader.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 -4
- package/lib/formatter/bvt_formatter.d.ts +0 -6
- package/lib/formatter/bvt_formatter.js +0 -25
- package/lib/formatter/bvt_formatter.js.map +0 -1
package/lib/cli/index.js
CHANGED
|
@@ -3,11 +3,12 @@ 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
|
-
const
|
|
6
|
+
const debug_1 = __importDefault(require("debug"));
|
|
7
7
|
const api_1 = require("../api");
|
|
8
|
+
const configuration_1 = require("../configuration");
|
|
9
|
+
const helpers_1 = require("./helpers");
|
|
8
10
|
const i18n_1 = require("./i18n");
|
|
9
11
|
const install_validator_1 = require("./install_validator");
|
|
10
|
-
const debug_1 = __importDefault(require("debug"));
|
|
11
12
|
class Cli {
|
|
12
13
|
constructor({ argv, cwd, stdout, stderr = process.stderr, env, }) {
|
|
13
14
|
this.argv = argv;
|
|
@@ -22,6 +23,10 @@ class Cli {
|
|
|
22
23
|
await (0, install_validator_1.validateInstall)();
|
|
23
24
|
}
|
|
24
25
|
const { options, configuration: argvConfiguration } = configuration_1.ArgvParser.parse(this.argv);
|
|
26
|
+
argvConfiguration.runName = (0, helpers_1.getRunName)(argvConfiguration);
|
|
27
|
+
if (argvConfiguration.bvtRerun) {
|
|
28
|
+
process.env.BVT_FORMATTER = 'ANALYSIS';
|
|
29
|
+
}
|
|
25
30
|
if (options.i18nLanguages) {
|
|
26
31
|
this.stdout.write((0, i18n_1.getLanguages)());
|
|
27
32
|
return {
|
package/lib/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,gCAAuD;AACvD,oDAA6C;AAE7C,uCAAsC;AACtC,iCAAkD;AAClD,2DAAqD;AAOrD,MAAqB,GAAG;IAOtB,YAAY,EACV,IAAI,EACJ,GAAG,EACH,MAAM,EACN,MAAM,GAAG,OAAO,CAAC,MAAM,EACvB,GAAG,GAOJ;QACC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,YAAY,GAAG,eAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QAC9C,IAAI,YAAY,EAAE;YAChB,MAAM,IAAA,mCAAe,GAAE,CAAA;SACxB;QACD,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,0BAAU,CAAC,KAAK,CACpE,IAAI,CAAC,IAAI,CACV,CAAA;QACD,iBAAiB,CAAC,OAAO,GAAG,IAAA,oBAAU,EAAC,iBAAiB,CAAC,CAAA;QACzD,IAAI,iBAAiB,CAAC,QAAQ,EAAE;YAC9B,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,UAAU,CAAA;SACvC;QACD,IAAI,OAAO,CAAC,aAAa,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,mBAAY,GAAE,CAAC,CAAA;YACjC,OAAO;gBACL,qBAAqB,EAAE,IAAI;gBAC3B,OAAO,EAAE,IAAI;aACd,CAAA;SACF;QACD,IAAI,OAAO,CAAC,YAAY,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,kBAAW,EAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;YACpD,OAAO;gBACL,qBAAqB,EAAE,IAAI;gBAC3B,OAAO,EAAE,IAAI;aACd,CAAA;SACF;QAED,MAAM,WAAW,GAAG;YAClB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,YAAY;SACpB,CAAA;QACD,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,GACzD,MAAM,IAAA,uBAAiB,EACrB;YACE,IAAI,EAAE,OAAO,CAAC,MAAM;YACpB,QAAQ,EAAE,OAAO,CAAC,OAAO;YACzB,QAAQ,EAAE,iBAAiB;SAC5B,EACD,WAAW,CACZ,CAAA;QACH,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,iBAAW,EAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;QACpE,OAAO;YACL,qBAAqB,EAAE,aAAa,CAAC,SAAS;YAC9C,OAAO;SACR,CAAA;IACH,CAAC;CACF;AA5ED,sBA4EC","sourcesContent":["import debug from 'debug'\nimport { loadConfiguration, runCucumber } from '../api'\nimport { ArgvParser } from '../configuration'\nimport { IFormatterStream } from '../formatter'\nimport { getRunName } from './helpers'\nimport { getKeywords, getLanguages } from './i18n'\nimport { validateInstall } from './install_validator'\n\nexport interface ICliRunResult {\n shouldExitImmediately: boolean\n success: boolean\n}\n\nexport default class Cli {\n private readonly argv: string[]\n private readonly cwd: string\n private readonly stdout: IFormatterStream\n private readonly stderr: IFormatterStream\n private readonly env: NodeJS.ProcessEnv\n\n constructor({\n argv,\n cwd,\n stdout,\n stderr = process.stderr,\n env,\n }: {\n argv: string[]\n cwd: string\n stdout: IFormatterStream\n stderr?: IFormatterStream\n env: NodeJS.ProcessEnv\n }) {\n this.argv = argv\n this.cwd = cwd\n this.stdout = stdout\n this.stderr = stderr\n this.env = env\n }\n\n async run(): Promise<ICliRunResult> {\n const debugEnabled = debug.enabled('cucumber')\n if (debugEnabled) {\n await validateInstall()\n }\n const { options, configuration: argvConfiguration } = ArgvParser.parse(\n this.argv\n )\n argvConfiguration.runName = getRunName(argvConfiguration)\n if (argvConfiguration.bvtRerun) {\n process.env.BVT_FORMATTER = 'ANALYSIS'\n }\n if (options.i18nLanguages) {\n this.stdout.write(getLanguages())\n return {\n shouldExitImmediately: true,\n success: true,\n }\n }\n if (options.i18nKeywords) {\n this.stdout.write(getKeywords(options.i18nKeywords))\n return {\n shouldExitImmediately: true,\n success: true,\n }\n }\n\n const environment = {\n cwd: this.cwd,\n stdout: this.stdout,\n stderr: this.stderr,\n env: this.env,\n debug: debugEnabled,\n }\n const { useConfiguration: configuration, runConfiguration } =\n await loadConfiguration(\n {\n file: options.config,\n profiles: options.profile,\n provided: argvConfiguration,\n },\n environment\n )\n const { success } = await runCucumber(runConfiguration, environment)\n return {\n shouldExitImmediately: configuration.forceExit,\n success,\n }\n }\n}\n"]}
|
|
@@ -3,9 +3,9 @@ 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
|
+
const gherkin_1 = require("@cucumber/gherkin");
|
|
6
7
|
const commander_1 = require("commander");
|
|
7
8
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
8
|
-
const gherkin_1 = require("@cucumber/gherkin");
|
|
9
9
|
const formatters_1 = __importDefault(require("../formatter/helpers/formatters"));
|
|
10
10
|
const version_1 = require("../version");
|
|
11
11
|
const ArgvParser = {
|
|
@@ -79,7 +79,9 @@ const ArgvParser = {
|
|
|
79
79
|
.option('--strict', 'fail if there are pending steps')
|
|
80
80
|
.option('--no-strict', 'succeed even if there are pending steps')
|
|
81
81
|
.option('-t, --tags <EXPRESSION>', 'only execute the features or scenarios with tags matching the expression (repeatable)', ArgvParser.mergeTags)
|
|
82
|
-
.option('--world-parameters <JSON>', 'provide parameters that will be passed to the world constructor (repeatable)', ArgvParser.mergeJson('--world-parameters'))
|
|
82
|
+
.option('--world-parameters <JSON>', 'provide parameters that will be passed to the world constructor (repeatable)', ArgvParser.mergeJson('--world-parameters'))
|
|
83
|
+
.option('--run-name <NAME>', 'provide a name for the run')
|
|
84
|
+
.option('--bvt-rerun', 'rerun failed scenarios from the last run');
|
|
83
85
|
program.addHelpText('afterAll', 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md');
|
|
84
86
|
program.parse(argv);
|
|
85
87
|
const { config, i18nKeywords, i18nLanguages, profile, ...regularStuff } = program.opts();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC,+CAA4C;AAC5C,iFAAwD;AACxD,wCAAoC;AAkBpC,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAC/B,IAAI,GAAG,EAAE;YACP,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;SACtB;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC7C,IAAI,GAAW,CAAA;YACf,IAAI;gBACF,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACtB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,GAAU,KAAK,CAAA;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yBAAyB,CAAC,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC,CAAA;aACvE;YACD,IAAI,OAAO,GAAG,KA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DACgD,EAChD,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CAAC,UAAU,EAAE,iCAAiC,CAAC;aACrD,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;aAChE,MAAM,CACL,yBAAyB,EACzB,uFAAuF,EACvF,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CACL,2BAA2B,EAC3B,8EAA8E,EAC9E,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC3C,CAAA;QAEH,OAAO,CAAC,WAAW,CACjB,UAAU,EACV,6FAA6F,CAC9F,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;SACnC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport { dialects } from '@cucumber/gherkin'\nimport Formatters from '../formatter/helpers/formatters'\nimport { version } from '../version'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command('cucumber-js')\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Formatters.buildFormattersDocumentationString(),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\"\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
1
|
+
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,+CAA4C;AAC5C,yCAAmC;AACnC,gEAAgC;AAChC,iFAAwD;AACxD,wCAAoC;AAkBpC,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAC/B,IAAI,GAAG,EAAE;YACP,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;SACtB;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC7C,IAAI,GAAW,CAAA;YACf,IAAI;gBACF,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACtB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,GAAU,KAAK,CAAA;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yBAAyB,CAAC,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC,CAAA;aACvE;YACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACjD,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,sCAAsC,GAAG,EAAE,CAAC,CAAA;aACtE;YACD,OAAO,IAAA,sBAAK,EAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACzB,CAAC,CAAA;IACH,CAAC;IAED,SAAS,CAAC,KAAa,EAAE,IAAa;QACpC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAA;IACvD,CAAC;IAED,mBAAmB,CAAC,KAAa,EAAE,UAAkB;QACnD,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpC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AC,CAAA;QACnB,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;SACnC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { dialects } from '@cucumber/gherkin'\nimport { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport Formatters from '../formatter/helpers/formatters'\nimport { version } from '../version'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command('cucumber-js')\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Formatters.buildFormattersDocumentationString(),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\"\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n .option('--run-name <NAME>', 'provide a name for the run')\n .option('--bvt-rerun', 'rerun failed scenarios from the last run')\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const axiosClient: import("axios").AxiosInstance;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.axiosClient = void 0;
|
|
7
|
+
/* eslint-disable no-console */
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const tunnel_1 = __importDefault(require("tunnel"));
|
|
10
|
+
const getProxy = () => {
|
|
11
|
+
if (!process.env.PROXY) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const proxy = process.env.PROXY;
|
|
15
|
+
const url = new URL(proxy);
|
|
16
|
+
const proxyObject = {
|
|
17
|
+
host: url.hostname,
|
|
18
|
+
port: Number(url.port),
|
|
19
|
+
};
|
|
20
|
+
const { username, password } = url;
|
|
21
|
+
if (username && password) {
|
|
22
|
+
proxyObject.proxyAuth = `${username}:${password}`;
|
|
23
|
+
}
|
|
24
|
+
return tunnel_1.default.httpsOverHttp({ proxy: proxyObject });
|
|
25
|
+
};
|
|
26
|
+
const createAxiosClient = () => {
|
|
27
|
+
try {
|
|
28
|
+
const agent = getProxy();
|
|
29
|
+
return axios_1.default.create({
|
|
30
|
+
httpsAgent: agent,
|
|
31
|
+
proxy: false,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.log(error.message);
|
|
36
|
+
throw new Error(`Error creating axios client ${error instanceof Error ? error.message : error.response.data}`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.axiosClient = createAxiosClient();
|
|
40
|
+
//# sourceMappingURL=axios_client.js.map
|
|
@@ -0,0 +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,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;IAElC,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,WAAW,CAAC,SAAS,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAA;KAClD;IACD,OAAO,gBAAM,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AACrD,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,IAAI;QACF,MAAM,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default_configuration.js","sourceRoot":"","sources":["../../src/configuration/default_configuration.ts"],"names":[],"mappings":";;;AAEa,QAAA,qBAAqB,GAAmB;IACnD,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,EAAE;IACV,aAAa,EAAE,EAAE;IACjB,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,EAAE;IACX,aAAa,EAAE,EAAE;IACjB,KAAK,EAAE,CAAC;IACR,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,EAAE;IACR,eAAe,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"default_configuration.js","sourceRoot":"","sources":["../../src/configuration/default_configuration.ts"],"names":[],"mappings":";;;AAEa,QAAA,qBAAqB,GAAmB;IACnD,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,EAAE;IACV,aAAa,EAAE,EAAE;IACjB,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,EAAE;IACX,aAAa,EAAE,EAAE;IACjB,KAAK,EAAE,CAAC;IACR,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,EAAE;IACR,eAAe,EAAE,EAAE;IACnB,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,KAAK;CAChB,CAAA","sourcesContent":["import { IConfiguration } from './types'\n\nexport const DEFAULT_CONFIGURATION: IConfiguration = {\n backtrace: false,\n dryRun: false,\n forceExit: false,\n failFast: false,\n format: [],\n formatOptions: {},\n import: [],\n language: 'en',\n name: [],\n order: 'defined',\n paths: [],\n parallel: 0,\n publish: false,\n publishQuiet: false,\n require: [],\n requireModule: [],\n retry: 0,\n retryTagFilter: '',\n strict: true,\n tags: '',\n worldParameters: {},\n runName: '',\n bvtRerun: false,\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/configuration/types.ts"],"names":[],"mappings":"","sourcesContent":["import { FormatOptions } from '../formatter'\nimport { PickleOrder } from '../models/pickle_order'\n\nexport interface IConfiguration {\n backtrace: boolean\n dryRun: boolean\n forceExit: boolean\n failFast: boolean\n format: string[]\n formatOptions: FormatOptions\n import: string[]\n language: string\n name: string[]\n order: PickleOrder\n paths: string[]\n parallel: number\n publish: boolean\n /**\n * @deprecated no longer needed; see <https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md>\n */\n publishQuiet: boolean\n require: string[]\n requireModule: string[]\n retry: number\n retryTagFilter: string\n strict: boolean\n tags: string\n worldParameters: any\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/configuration/types.ts"],"names":[],"mappings":"","sourcesContent":["import { FormatOptions } from '../formatter'\nimport { PickleOrder } from '../models/pickle_order'\n\nexport interface IConfiguration {\n backtrace: boolean\n dryRun: boolean\n forceExit: boolean\n failFast: boolean\n format: string[]\n formatOptions: FormatOptions\n import: string[]\n language: string\n name: string[]\n order: PickleOrder\n paths: string[]\n parallel: number\n publish: boolean\n /**\n * @deprecated no longer needed; see <https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md>\n */\n publishQuiet: boolean\n require: string[]\n requireModule: string[]\n retry: number\n retryTagFilter: string\n strict: boolean\n tags: string\n worldParameters: any\n runName: string\n bvtRerun: boolean\n}\n"]}
|
|
@@ -4,15 +4,15 @@ export default class BVTAnalysisFormatter extends Formatter {
|
|
|
4
4
|
private uploader;
|
|
5
5
|
private exit;
|
|
6
6
|
private START;
|
|
7
|
+
private runName;
|
|
7
8
|
constructor(options: IFormatterOptions);
|
|
9
|
+
private uploadReport;
|
|
8
10
|
finished(): Promise<any>;
|
|
9
11
|
private analyzeReport;
|
|
10
12
|
private processTestCases;
|
|
11
13
|
private processTestCase;
|
|
12
|
-
private createFinalResult;
|
|
13
|
-
private createStartTime;
|
|
14
|
-
private createStepResult;
|
|
15
14
|
private uploadFinalReport;
|
|
16
15
|
private retrain;
|
|
17
16
|
private call_cucumber_client;
|
|
17
|
+
private logReportLink;
|
|
18
18
|
}
|
|
@@ -9,6 +9,8 @@ const _1 = __importDefault(require("."));
|
|
|
9
9
|
const value_checker_1 = require("../value_checker");
|
|
10
10
|
const report_generator_1 = __importDefault(require("./helpers/report_generator"));
|
|
11
11
|
const uploader_1 = __importDefault(require("./helpers/uploader"));
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const tmp_promise_1 = require("tmp-promise");
|
|
12
14
|
//User token
|
|
13
15
|
const TOKEN = process.env.TOKEN;
|
|
14
16
|
class BVTAnalysisFormatter extends _1.default {
|
|
@@ -17,19 +19,35 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
17
19
|
this.reportGenerator = new report_generator_1.default();
|
|
18
20
|
this.uploader = new uploader_1.default(this.reportGenerator);
|
|
19
21
|
this.exit = false;
|
|
20
|
-
if (!TOKEN) {
|
|
22
|
+
if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {
|
|
21
23
|
throw new Error('TOKEN must be set');
|
|
22
24
|
}
|
|
23
25
|
options.eventBroadcaster.on('envelope', async (envelope) => {
|
|
24
26
|
this.reportGenerator.handleMessage(envelope);
|
|
27
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.meta) &&
|
|
28
|
+
(0, value_checker_1.doesHaveValue)(envelope.meta.runName)) {
|
|
29
|
+
this.runName = envelope.meta.runName;
|
|
30
|
+
}
|
|
25
31
|
if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
26
32
|
const report = this.reportGenerator.getReport();
|
|
27
33
|
this.START = Date.now();
|
|
28
|
-
|
|
34
|
+
if (process.env.BVT_FORMATTER === 'ANALYSIS') {
|
|
35
|
+
await this.analyzeReport(report);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
await this.uploadReport(report);
|
|
39
|
+
}
|
|
29
40
|
this.exit = true;
|
|
30
41
|
}
|
|
31
42
|
});
|
|
32
43
|
}
|
|
44
|
+
async uploadReport(report) {
|
|
45
|
+
const uploadSuccessful = await this.uploadFinalReport(report);
|
|
46
|
+
if (uploadSuccessful && report.result.status !== 'FAILED') {
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
33
51
|
async finished() {
|
|
34
52
|
await new Promise((resolve) => {
|
|
35
53
|
const checkInterval = setInterval(() => {
|
|
@@ -42,131 +60,82 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
42
60
|
}
|
|
43
61
|
async analyzeReport(report) {
|
|
44
62
|
if (report.result.status === 'PASSED') {
|
|
45
|
-
this.log('
|
|
46
|
-
await this.
|
|
47
|
-
|
|
63
|
+
this.log('No test failed. No need to retrain\n');
|
|
64
|
+
const uploadSuccessful = await this.uploadFinalReport(report);
|
|
65
|
+
if (uploadSuccessful) {
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
process.exit(1);
|
|
48
69
|
}
|
|
49
70
|
//checking if the type of report.result is JsonResultFailed or not
|
|
71
|
+
this.log('Some tests failed, starting the retraining...\n');
|
|
50
72
|
if (!('startTime' in report.result) || !('endTime' in report.result)) {
|
|
51
73
|
this.log('Unknown error occured,not retraining\n');
|
|
52
|
-
await this.
|
|
74
|
+
await this.uploadFinalReport(report);
|
|
53
75
|
return;
|
|
54
76
|
}
|
|
55
77
|
const finalReport = await this.processTestCases(report);
|
|
56
|
-
await this.uploadFinalReport(finalReport);
|
|
78
|
+
const uploadSuccessful = await this.uploadFinalReport(finalReport);
|
|
79
|
+
if (finalReport.result.status !== 'FAILED' && uploadSuccessful) {
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
57
85
|
}
|
|
58
86
|
async processTestCases(report) {
|
|
59
|
-
const
|
|
60
|
-
const finalStepResults = [];
|
|
61
|
-
let isFailing = true;
|
|
87
|
+
const finalTestCases = [];
|
|
62
88
|
for (const testCase of report.testCases) {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
finalStepResults.push(steps);
|
|
66
|
-
//If any of the test case fails, the whole run is considered failed
|
|
67
|
-
if (result.status === 'FAILED') {
|
|
68
|
-
isFailing = false;
|
|
69
|
-
}
|
|
89
|
+
const modifiedTestCase = await this.processTestCase(testCase, report);
|
|
90
|
+
finalTestCases.push(modifiedTestCase);
|
|
70
91
|
}
|
|
92
|
+
const finalResult = finalTestCases.some((tc) => tc.result.status !== 'PASSED')
|
|
93
|
+
? report.result
|
|
94
|
+
: {
|
|
95
|
+
...report.result,
|
|
96
|
+
status: 'PASSED',
|
|
97
|
+
};
|
|
71
98
|
return {
|
|
72
|
-
result:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
startTime: 'startTime' in report.result
|
|
76
|
-
? report.result.startTime
|
|
77
|
-
: this.START,
|
|
78
|
-
endTime: Date.now(),
|
|
79
|
-
}
|
|
80
|
-
: {
|
|
81
|
-
status: 'FAILED',
|
|
82
|
-
startTime: 'startTime' in report.result
|
|
83
|
-
? report.result.startTime
|
|
84
|
-
: Date.now(),
|
|
85
|
-
endTime: Date.now(),
|
|
86
|
-
},
|
|
87
|
-
testCases: report.testCases.map((testCase, i) => {
|
|
88
|
-
return {
|
|
89
|
-
...testCase,
|
|
90
|
-
result: finalResults[i],
|
|
91
|
-
steps: testCase.steps.map((step, j) => {
|
|
92
|
-
return {
|
|
93
|
-
...step,
|
|
94
|
-
result: finalStepResults[i][j],
|
|
95
|
-
};
|
|
96
|
-
}),
|
|
97
|
-
};
|
|
98
|
-
}),
|
|
99
|
+
result: finalResult,
|
|
100
|
+
testCases: finalTestCases,
|
|
101
|
+
env: report.env,
|
|
99
102
|
};
|
|
100
103
|
}
|
|
101
104
|
async processTestCase(testCase, report) {
|
|
102
105
|
if (testCase.result.status === 'PASSED') {
|
|
103
|
-
return
|
|
104
|
-
result: testCase.result,
|
|
105
|
-
steps: testCase.steps.map((step) => {
|
|
106
|
-
return step.result.status === 'PASSED'
|
|
107
|
-
? step.result
|
|
108
|
-
: this.createStepResult(true, step, report);
|
|
109
|
-
}),
|
|
110
|
-
};
|
|
106
|
+
return testCase;
|
|
111
107
|
}
|
|
112
|
-
const
|
|
108
|
+
const failedTestSteps = testCase.steps
|
|
113
109
|
.map((step, i) => (step.result.status !== 'PASSED' ? i : null))
|
|
114
110
|
.filter((i) => i !== null);
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
result: finalResult,
|
|
119
|
-
steps: testCase.steps.map((step) => step.result.status === 'PASSED'
|
|
120
|
-
? { ...step.result }
|
|
121
|
-
: this.createStepResult(success, step, report)),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
createFinalResult(success, testCase, report) {
|
|
125
|
-
const status = success ? 'FIXED_BY_AI' : 'FAILED';
|
|
126
|
-
return {
|
|
127
|
-
status,
|
|
128
|
-
startTime: this.createStartTime(testCase, report),
|
|
129
|
-
endTime: Date.now(),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
createStartTime(testCase, report) {
|
|
133
|
-
let startTime;
|
|
134
|
-
if ('startTime' in testCase.result) {
|
|
135
|
-
startTime = testCase.result.startTime;
|
|
136
|
-
}
|
|
137
|
-
else if ('startTime' in report.result) {
|
|
138
|
-
startTime = report.result.startTime;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
startTime = Date.now();
|
|
111
|
+
const retrainStats = await this.retrain(failedTestSteps, testCase);
|
|
112
|
+
if (!retrainStats) {
|
|
113
|
+
return testCase;
|
|
142
114
|
}
|
|
143
|
-
return startTime;
|
|
144
|
-
}
|
|
145
|
-
createStepResult(success, step, report) {
|
|
146
|
-
const status = success ? 'FIXED_BY_AI' : 'FAILED';
|
|
147
115
|
return {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
? step.result.startTime
|
|
151
|
-
: 'startTime' in report.result
|
|
152
|
-
? report.result.startTime
|
|
153
|
-
: Date.now(),
|
|
154
|
-
endTime: Date.now(),
|
|
116
|
+
...testCase,
|
|
117
|
+
retrainStats,
|
|
155
118
|
};
|
|
156
119
|
}
|
|
157
120
|
async uploadFinalReport(finalReport) {
|
|
121
|
+
let success = true;
|
|
158
122
|
try {
|
|
159
|
-
await this.uploader.uploadRun(finalReport);
|
|
123
|
+
const { projectId, runId } = await this.uploader.uploadRun(finalReport, this.runName);
|
|
124
|
+
this.logReportLink(runId, projectId);
|
|
160
125
|
}
|
|
161
126
|
catch (err) {
|
|
162
127
|
this.log('Error uploading report\n');
|
|
128
|
+
if ('stack' in err) {
|
|
129
|
+
this.log(err.stack);
|
|
130
|
+
}
|
|
131
|
+
success = false;
|
|
163
132
|
}
|
|
164
|
-
this.log(JSON.stringify(finalReport, null, 2))
|
|
133
|
+
//this.log(JSON.stringify(finalReport, null, 2))
|
|
134
|
+
return success;
|
|
165
135
|
}
|
|
166
136
|
async retrain(failedTestCases, testCase) {
|
|
167
137
|
const stepsToRetrain = testCase.steps.map((_, i) => i);
|
|
168
|
-
|
|
169
|
-
return success;
|
|
138
|
+
return await this.call_cucumber_client(stepsToRetrain, testCase);
|
|
170
139
|
}
|
|
171
140
|
async call_cucumber_client(stepsToRetrain, testCase) {
|
|
172
141
|
return new Promise((resolve, reject) => {
|
|
@@ -178,30 +147,51 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
178
147
|
`${stepsToRetrain.join(',')}`,
|
|
179
148
|
];
|
|
180
149
|
if (process.env.BLINQ_ENV) {
|
|
181
|
-
args.push(`--env
|
|
150
|
+
args.push(`--env=${process.env.BLINQ_ENV}`);
|
|
182
151
|
}
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
152
|
+
// const temporaryFileTask = await import('tempy')
|
|
153
|
+
(0, tmp_promise_1.withFile)(async ({ path: tempFile, fd }) => {
|
|
154
|
+
// when this function returns or throws - release the file
|
|
155
|
+
args.push(`--temp-file=${tempFile}`);
|
|
156
|
+
const cucumberClient = (0, child_process_1.spawn)('node', [cucumber_client_path, ...args], {
|
|
157
|
+
env: {
|
|
158
|
+
...process.env,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
cucumberClient.stdout.on('data', (data) => {
|
|
162
|
+
console.log(data.toString());
|
|
163
|
+
});
|
|
164
|
+
cucumberClient.stderr.on('data', (data) => {
|
|
165
|
+
console.error(data.toString());
|
|
166
|
+
});
|
|
167
|
+
cucumberClient.on('close', (code) => {
|
|
168
|
+
if (code === 0) {
|
|
169
|
+
const reportData = (0, fs_1.readFileSync)(tempFile, 'utf-8');
|
|
170
|
+
const retrainStats = JSON.parse(reportData);
|
|
171
|
+
resolve(retrainStats);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.log('Error retraining\n');
|
|
175
|
+
resolve(null);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
202
178
|
});
|
|
203
179
|
});
|
|
204
180
|
}
|
|
181
|
+
logReportLink(runId, projectId) {
|
|
182
|
+
let reportLinkBaseUrl = 'https://www.app.blinq.io';
|
|
183
|
+
if (process.env.NODE_ENV_BLINQ === 'local') {
|
|
184
|
+
reportLinkBaseUrl = 'http://localhost:3000';
|
|
185
|
+
}
|
|
186
|
+
else if (process.env.NODE_ENV_BLINQ === 'dev') {
|
|
187
|
+
reportLinkBaseUrl = 'https://dev.app.blinq.io';
|
|
188
|
+
}
|
|
189
|
+
else if (process.env.NODE_ENV_BLINQ === 'stage') {
|
|
190
|
+
reportLinkBaseUrl = 'https://stage.app.blinq.io';
|
|
191
|
+
}
|
|
192
|
+
const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`;
|
|
193
|
+
this.log(`Report link: ${reportLink}\n`);
|
|
194
|
+
}
|
|
205
195
|
}
|
|
206
196
|
exports.default = BVTAnalysisFormatter;
|
|
207
197
|
//# sourceMappingURL=bvt_analysis_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bvt_analysis_formatter.js","sourceRoot":"","sources":["../../src/formatter/bvt_analysis_formatter.ts"],"names":[],"mappings":";;;;;AACA,iDAAqC;AACrC,gDAAuB;AACvB,yCAAgD;AAChD,oDAAgD;AAChD,kFAQmC;AACnC,kEAA+C;AAC/C,YAAY;AACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;AAC/B,MAAqB,oBAAqB,SAAQ,UAAS;IAKzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QALR,oBAAe,GAAG,IAAI,0BAAe,EAAE,CAAA;QACvC,aAAQ,GAAG,IAAI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I,CAAC,CAAA;iBACd;qBAAM;oBACL,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;oBAC9B,OAAO,CAAC,KAAK,CAAC,CAAA;iBACf;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA1OD,uCA0OC","sourcesContent":["import { Envelope } from '@cucumber/messages'\nimport { spawn } from 'child_process'\nimport path from 'path'\nimport Formatter, { IFormatterOptions } from '.'\nimport { doesHaveValue } from '../value_checker'\nimport ReportGenerator, {\n JsonFixedByAi,\n JsonReport,\n JsonResultFailed,\n JsonResultPassed,\n JsonStep,\n JsonTestProgress,\n JsonTestResult,\n} from './helpers/report_generator'\nimport ReportUploader from './helpers/uploader'\n//User token\nconst TOKEN = process.env.TOKEN\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 constructor(options: IFormatterOptions) {\n super(options)\n if (!TOKEN) {\n throw new Error('TOKEN must be set')\n }\n options.eventBroadcaster.on('envelope', async (envelope: Envelope) => {\n this.reportGenerator.handleMessage(envelope)\n if (doesHaveValue(envelope.testRunFinished)) {\n const report = this.reportGenerator.getReport()\n this.START = Date.now()\n await this.analyzeReport(report)\n this.exit = true\n }\n })\n }\n\n async finished(): Promise<any> {\n await new Promise((resolve) => {\n const checkInterval = setInterval(() => {\n if (this.exit) {\n clearInterval(checkInterval)\n resolve(null)\n }\n }, 100) // check every 100ms\n })\n }\n private async analyzeReport(report: JsonReport) {\n if (report.result.status === 'PASSED') {\n this.log('All tests passed. No need to retrain\\n')\n await this.uploader.uploadRun(report)\n return\n }\n //checking if the type of report.result is JsonResultFailed or not\n if (!('startTime' in report.result) || !('endTime' in report.result)) {\n this.log('Unknown error occured,not retraining\\n')\n await this.uploader.uploadRun(report)\n return\n }\n const finalReport = await this.processTestCases(report)\n await this.uploadFinalReport(finalReport)\n }\n private async processTestCases(report: JsonReport): Promise<JsonReport> {\n const finalResults: JsonTestResult[] = []\n const finalStepResults: JsonTestResult[][] = []\n let isFailing = true\n for (const testCase of report.testCases) {\n const { result, steps } = await this.processTestCase(testCase, report)\n finalResults.push(result)\n finalStepResults.push(steps)\n //If any of the test case fails, the whole run is considered failed\n if (result.status === 'FAILED') {\n isFailing = false\n }\n }\n return {\n result: isFailing\n ? {\n status: 'FIXED_BY_AI',\n startTime:\n 'startTime' in report.result\n ? report.result.startTime\n : this.START,\n endTime: Date.now(),\n }\n : {\n status: 'FAILED',\n startTime:\n 'startTime' in report.result\n ? report.result.startTime\n : Date.now(),\n endTime: Date.now(),\n },\n testCases: report.testCases.map((testCase, i) => {\n return {\n ...testCase,\n result: finalResults[i],\n steps: testCase.steps.map((step, j) => {\n return {\n ...step,\n result: finalStepResults[i][j],\n }\n }),\n }\n }),\n }\n }\n private async processTestCase(\n testCase: JsonTestProgress,\n report: JsonReport\n ): Promise<{\n result: JsonFixedByAi | JsonResultFailed | JsonResultPassed\n steps: (JsonFixedByAi | JsonResultFailed | JsonResultPassed)[]\n }> {\n if (testCase.result.status === 'PASSED') {\n return {\n result: testCase.result,\n steps: testCase.steps.map((step) => {\n return step.result.status === 'PASSED'\n ? step.result\n : this.createStepResult(true, step, report)\n }),\n }\n }\n const failedTestCases = testCase.steps\n .map((step, i) => (step.result.status !== 'PASSED' ? i : null))\n .filter((i) => i !== null)\n const success = await this.retrain(failedTestCases, testCase)\n const finalResult = this.createFinalResult(success, testCase, report)\n\n return {\n result: finalResult,\n steps: testCase.steps.map((step) =>\n step.result.status === 'PASSED'\n ? { ...step.result }\n : this.createStepResult(success, step, report)\n ),\n }\n }\n\n private createFinalResult(\n success: boolean,\n testCase: JsonTestProgress,\n report: JsonReport\n ): JsonFixedByAi | JsonResultFailed {\n const status = success ? 'FIXED_BY_AI' : 'FAILED'\n return {\n status,\n startTime: this.createStartTime(testCase, report),\n endTime: Date.now(),\n }\n }\n private createStartTime(\n testCase: JsonTestProgress,\n report: JsonReport\n ): number {\n let startTime\n\n if ('startTime' in testCase.result) {\n startTime = testCase.result.startTime\n } else if ('startTime' in report.result) {\n startTime = report.result.startTime\n } else {\n startTime = Date.now()\n }\n\n return startTime\n }\n private createStepResult(\n success: boolean,\n step: JsonStep,\n report: JsonReport\n ): JsonFixedByAi | JsonResultFailed {\n const status = success ? 'FIXED_BY_AI' : 'FAILED'\n return {\n status,\n startTime:\n 'startTime' in step.result\n ? step.result.startTime\n : 'startTime' in report.result\n ? report.result.startTime\n : Date.now(),\n endTime: Date.now(),\n }\n }\n private async uploadFinalReport(finalReport: JsonReport) {\n try {\n await this.uploader.uploadRun(finalReport)\n } catch (err) {\n this.log('Error uploading report\\n')\n }\n\n this.log(JSON.stringify(finalReport, null, 2))\n }\n private async retrain(failedTestCases: number[], testCase: JsonTestProgress) {\n const stepsToRetrain = testCase.steps.map((_, i) => i)\n const success = await this.call_cucumber_client(stepsToRetrain, testCase)\n return success\n }\n\n private async call_cucumber_client(\n stepsToRetrain: number[],\n testCase: JsonTestProgress\n ): Promise<boolean> {\n return new Promise((resolve, reject) => {\n const cucumber_client_path = path.resolve(\n process.cwd(),\n 'node_modules',\n '@dev-blinq',\n 'cucumber_client',\n 'bin',\n 'client',\n 'cucumber.js'\n )\n\n const args: string[] = [\n process.cwd(),\n path.join(process.cwd(), testCase.uri),\n `${testCase.scenarioName}`,\n `${stepsToRetrain.join(',')}`,\n ]\n\n if (process.env.BLINQ_ENV) {\n args.push(`--env=\"${process.env.BLINQ_ENV}\"`)\n }\n\n const cucumberClient = spawn('node', [cucumber_client_path, ...args], {\n env: {\n ...process.env,\n },\n })\n\n cucumberClient.stdout.on('data', (data) => {\n console.log(data.toString())\n })\n\n cucumberClient.stderr.on('data', (data) => {\n console.error(data.toString())\n })\n\n cucumberClient.on('close', (code) => {\n if (code === 0) {\n resolve(true)\n } else {\n this.log('Error retraining\\n')\n resolve(false)\n }\n })\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bvt_analysis_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ACjD,iBAAiB,GAAG,4BAA4B,CAAA;SAEjD;QACD,MAAM,UAAU,GAAG,GAAG,iBAAiB,IAAI,SAAS,eAAe,KAAK,EAAE,CAAA;QAC1E,IAAI,CAAC,GAAG,CAAC,gBAAgB,UAAU,IAAI,CAAC,CAAA;IAC1C,CAAC;CACF;AAzND,uCAyNC","sourcesContent":["import { Envelope, Meta } from '@cucumber/messages'\nimport { spawn } from 'child_process'\nimport path from 'path'\nimport Formatter, { IFormatterOptions } from '.'\nimport { doesHaveValue } from '../value_checker'\nimport ReportGenerator, {\n JsonFixedByAi,\n JsonReport,\n JsonResultFailed,\n JsonResultPassed,\n JsonStep,\n JsonTestProgress,\n JsonTestResult,\n RetrainStats,\n} from './helpers/report_generator'\nimport ReportUploader from './helpers/uploader'\nimport { readFileSync } from 'fs'\nimport { withFile } from 'tmp-promise'\n//User token\nconst TOKEN = process.env.TOKEN\ninterface MetaMessage extends Meta {\n runName: string\n}\n\ninterface EnvelopeWithMetaMessage extends Envelope {\n meta: MetaMessage\n}\nexport default class BVTAnalysisFormatter extends Formatter {\n private reportGenerator = new ReportGenerator()\n private uploader = new ReportUploader(this.reportGenerator)\n private exit = false\n private START: number\n private runName: string\n constructor(options: IFormatterOptions) {\n super(options)\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage) => {\n this.reportGenerator.handleMessage(envelope)\n if (\n doesHaveValue(envelope.meta) &&\n doesHaveValue(envelope.meta.runName)\n ) {\n this.runName = envelope.meta.runName\n }\n if (doesHaveValue(envelope.testRunFinished)) {\n const report = this.reportGenerator.getReport()\n this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport(report)\n } else {\n await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private async uploadReport(report: JsonReport) {\n const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful && report.result.status !== 'FAILED') {\n process.exit(0)\n }\n process.exit(1)\n }\n\n async finished(): Promise<any> {\n await new Promise((resolve) => {\n const checkInterval = setInterval(() => {\n if (this.exit) {\n clearInterval(checkInterval)\n resolve(null)\n }\n }, 100) // check every 100ms\n })\n }\n private async analyzeReport(report: JsonReport) {\n if (report.result.status === 'PASSED') {\n this.log('No test failed. No need to retrain\\n')\n const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful) {\n process.exit(0)\n }\n\n process.exit(1)\n }\n //checking if the type of report.result is JsonResultFailed or not\n this.log('Some tests failed, starting the retraining...\\n')\n if (!('startTime' in report.result) || !('endTime' in report.result)) {\n this.log('Unknown error occured,not retraining\\n')\n await this.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 !== 'PASSED' ? 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 this.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 }\n\n //this.log(JSON.stringify(finalReport, null, 2))\n return success\n }\n private async retrain(\n failedTestCases: number[],\n testCase: JsonTestProgress\n ): Promise<RetrainStats | null> {\n const stepsToRetrain = testCase.steps.map((_, i) => i)\n return await this.call_cucumber_client(stepsToRetrain, testCase)\n }\n\n private async call_cucumber_client(\n stepsToRetrain: number[],\n testCase: JsonTestProgress\n ): Promise<RetrainStats | null> {\n return new Promise((resolve, reject) => {\n const cucumber_client_path = path.resolve(\n process.cwd(),\n 'node_modules',\n '@dev-blinq',\n 'cucumber_client',\n 'bin',\n 'client',\n 'cucumber.js'\n )\n\n const args: string[] = [\n process.cwd(),\n path.join(process.cwd(), testCase.uri),\n `${testCase.scenarioName}`,\n `${stepsToRetrain.join(',')}`,\n ]\n\n if (process.env.BLINQ_ENV) {\n args.push(`--env=${process.env.BLINQ_ENV}`)\n }\n // const temporaryFileTask = await import('tempy')\n withFile(async ({ path: tempFile, fd }) => {\n // when this function returns or throws - release the file\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', (code) => {\n if (code === 0) {\n const reportData = readFileSync(tempFile, 'utf-8')\n const retrainStats = JSON.parse(reportData) as RetrainStats\n resolve(retrainStats)\n } else {\n this.log('Error retraining\\n')\n resolve(null)\n }\n })\n })\n })\n }\n private logReportLink(runId: string, projectId: string) {\n let reportLinkBaseUrl = 'https://www.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 }\n const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`\n this.log(`Report link: ${reportLink}\\n`)\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TableCell } from '@cucumber/messages';
|
|
1
2
|
declare const generateTestData: (featureFileContent: string, vars?: any, fakeData?: {
|
|
2
3
|
var: string;
|
|
3
4
|
fake: string;
|
|
@@ -11,4 +12,12 @@ declare const generateTestData: (featureFileContent: string, vars?: any, fakeDat
|
|
|
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, };
|