@dev-blinq/cucumber-js 1.0.114 → 1.0.115-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/cucumber.ts +1 -0
- 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/formatter/api.js +9 -4
- 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/feature_data_format.js +22 -7
- package/lib/formatter/feature_data_format.js.map +1 -1
- package/lib/formatter/helpers/constants.js.map +1 -1
- package/lib/formatter/helpers/report_generator.d.ts +3 -1
- package/lib/formatter/helpers/report_generator.js +49 -7
- package/lib/formatter/helpers/report_generator.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/upload_serivce.d.ts +1 -1
- package/lib/formatter/helpers/upload_serivce.js +62 -4
- package/lib/formatter/helpers/upload_serivce.js.map +1 -1
- package/lib/formatter/helpers/uploader.js +1 -1
- package/lib/formatter/helpers/uploader.js.map +1 -1
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +1 -0
- package/lib/runtime/test_case_runner.js +7 -0
- 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 +3 -2
package/bin/cucumber.ts
CHANGED
|
@@ -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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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"]}
|
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':
|
|
@@ -44,11 +44,16 @@ const getProxy = () => {
|
|
|
44
44
|
const getProjectByAccessKey = async (access_key) => {
|
|
45
45
|
const ssoUrl = getSSoUrl();
|
|
46
46
|
const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`;
|
|
47
|
-
const response = await
|
|
47
|
+
const response = await axios_client_1.axiosClient.post(accessKeyUrl, {
|
|
48
48
|
access_key,
|
|
49
|
-
httpAgent: getProxy(),
|
|
50
|
-
proxy: false,
|
|
51
49
|
});
|
|
50
|
+
/*
|
|
51
|
+
const response = await axios.post(accessKeyUrl, {
|
|
52
|
+
access_key,
|
|
53
|
+
httpAgent: getProxy(),
|
|
54
|
+
proxy: false,
|
|
55
|
+
})
|
|
56
|
+
*/
|
|
52
57
|
if (response.status !== 200) {
|
|
53
58
|
console.error('Error: Invalid access key');
|
|
54
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":"api.js","sourceRoot":"","sources":["../../src/formatter/api.ts"],"names":[],"mappings":";;;;;;AACA,oDAA2B;AAC3B,gEAA2D;AAE3D,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAClC,KAAK,OAAO;YACV,OAAO,gCAAgC,CAAA;QACzC,KAAK,KAAK;YACR,OAA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AAK,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,iBAAiB,CAAC,gBAAgB;YAC5D,aAAa,EAAE,OAAO,CAAC,iBAAiB,CAAC,aAAa;YACtD,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;SAC/C,CAAC,CAAA;QACJ,OAAO,IAAI,oBAAoB,CAAC;YAC9B,QAAQ;YACR,cAAc;YACd,GAAG,OAAO;SACX,CAAC,CAAA;IACJ,CAAC;IAED,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["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"]}
|
|
@@ -4,10 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.generateExamplesFromFunctionGherkin = exports.generateExamplesFromFunction = exports.generateTestData = void 0;
|
|
7
|
-
|
|
7
|
+
// import { faker } from '@faker-js/faker' // it is taking more time to load the module
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const json5_1 = __importDefault(require("json5"));
|
|
11
|
+
const try_require_1 = __importDefault(require("../try_require"));
|
|
11
12
|
const generateTestData = (featureFileContent, vars, fakeData, projectDir) => {
|
|
12
13
|
const regexp = /\{\{([^}]*\([^)]*\))\}\}/g;
|
|
13
14
|
const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g;
|
|
@@ -75,11 +76,19 @@ const generateTestData = (featureFileContent, vars, fakeData, projectDir) => {
|
|
|
75
76
|
if (namespaces.includes(match[1].split('.')[0]))
|
|
76
77
|
continue;
|
|
77
78
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
let fake;
|
|
80
|
+
if (!duplicateFakeData || duplicateFakeData.length === 0) {
|
|
81
|
+
fake = getFakeString(match[0].substring(2, match[0].length - 2));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const foundDuplicate = duplicateFakeData.find((item) => item.var === match[0]);
|
|
85
|
+
if (foundDuplicate) {
|
|
86
|
+
fake = foundDuplicate.fake;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
fake = getFakeString(match[0].substring(2, match[0].length - 2));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
83
92
|
otherFakeData.push({
|
|
84
93
|
var: match[0],
|
|
85
94
|
fake,
|
|
@@ -100,13 +109,19 @@ const generateTestData = (featureFileContent, vars, fakeData, projectDir) => {
|
|
|
100
109
|
};
|
|
101
110
|
};
|
|
102
111
|
exports.generateTestData = generateTestData;
|
|
112
|
+
let globalFaker = null;
|
|
103
113
|
const getFakeString = (content) => {
|
|
104
114
|
// content example: helpers.fromRegExp('#{2,9}')
|
|
105
115
|
const faking = content.split('(')[0].split('.');
|
|
106
116
|
// faking example: ['helpers', 'fromRegExp']
|
|
107
117
|
const argument = content.substring(content.indexOf('(') + 1, content.lastIndexOf(')'));
|
|
108
118
|
// argument example: '#{2,9}'
|
|
109
|
-
let
|
|
119
|
+
let faker = globalFaker;
|
|
120
|
+
if (!faker) {
|
|
121
|
+
faker = (0, try_require_1.default)('@faker-js/faker/locale/en_US').faker;
|
|
122
|
+
globalFaker = faker;
|
|
123
|
+
}
|
|
124
|
+
let fakeFunc = faker;
|
|
110
125
|
faking.forEach((f) => {
|
|
111
126
|
fakeFunc = fakeFunc[f];
|
|
112
127
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature_data_format.js","sourceRoot":"","sources":["../../src/formatter/feature_data_format.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAuC;AACvC,4CAAmB;AACnB,gDAAuB;AAEvB,kDAAyB;AAEzB,MAAM,gBAAgB,GAAG,CACvB,kBAA0B,EAC1B,IAAU,EACV,QAGG,EACH,UAAmB,EACnB,EAAE;IACF,MAAM,MAAM,GAAG,2BAA2B,CAAA;IAC1C,MAAM,aAAa,GAAG,wBAAwB,CAAA;IAC9C,IAAI,UAAU,GAAG,kBAAkB,CAAA;IACnC,IAAI,KAAsB,CAAA;IAC1B,IAAI,CAAC,UAAU,EAAE;QACf,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;KAC3B;IACD,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAC7B,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,iBAAiB,CAClB,CAAA;IACD,IAAI,UAAU,GAAa,YAAE,CAAC,UAAU,CAAC,aAAa,CAAC;QACrD,CAAC,CAAC,IAAI,CAAC,KA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CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAKC,kFAAmC","sourcesContent":["import { faker } from '@faker-js/faker'\nimport fs from 'fs'\nimport path from 'path'\nimport { TableCell } from '@cucumber/messages'\nimport JSON5 from 'json5'\n\nconst generateTestData = (\n featureFileContent: string,\n vars?: any,\n fakeData?: {\n var: string\n fake: string\n }[],\n projectDir?: string\n) => {\n const regexp = /\\{\\{([^}]*\\([^)]*\\))\\}\\}/g\n const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g\n let newContent = featureFileContent\n let match: RegExpExecArray\n if (!projectDir) {\n projectDir = process.cwd()\n }\n const namespacePath = path.join(\n projectDir,\n 'features',\n 'step_definitions',\n 'namespaces.json'\n )\n let namespaces: string[] = fs.existsSync(namespacePath)\n ? JSON.parse(fs.readFileSync(namespacePath, 'utf-8'))\n : []\n if (!Array.isArray(namespaces)) {\n namespaces = []\n }\n const matches = []\n // collect all matches\n while ((match = regexp.exec(featureFileContent)) !== null) {\n // match[0] is the full match, match[1] is the first capturing group\n // Eg:- match[0] = {{name}}, match[1] = name\n if (!namespaces.includes(match[1].split('.')[0])) matches.push(match)\n }\n // find all variables in the matches\n const variables: any = { ...vars }\n\n if (Object.keys(variables).length > 0) {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n newContent = newContent.replaceAll(`{{${variable.var}}}`, variable.fake)\n }\n } else {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n variables[variableMatch[1]] = {\n var: variableMatch[1],\n toFake: variableMatch[2],\n }\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n const fake = getFakeString(\n variable.toFake.substring(2, variable.toFake.length - 2)\n )\n newContent = newContent.replaceAll(`{{${variable.var}}}`, fake)\n variables[key].fake = fake\n }\n }\n\n regexp.lastIndex = 0\n const otherFakeData = []\n const duplicateFakeData = fakeData ? [...fakeData] : []\n let fakeIndex = 0\n while ((match = regexp.exec(featureFileContent)) !== null) {\n if (namespaces.includes(match[1].split('.')[0])) continue\n try {\n const fake =\n duplicateFakeData &&\n duplicateFakeData.length > 0 &&\n duplicateFakeData[0].var === match[0]\n ? duplicateFakeData.shift().fake\n : getFakeString(match[0].substring(2, match[0].length - 2))\n otherFakeData.push({\n var: match[0],\n fake,\n })\n newContent = newContent.replace(match[0], fake)\n fakeIndex++\n } catch (err) {\n // eslint-disable-next-line no-console\n }\n }\n\n return {\n newContent,\n variables,\n otherFakeData,\n changed: newContent !== featureFileContent,\n fakeIndex,\n }\n}\n\nconst getFakeString = (content: string) => {\n // content example: helpers.fromRegExp('#{2,9}')\n const faking = content.split('(')[0].split('.')\n // faking example: ['helpers', 'fromRegExp']\n const argument = content.substring(\n content.indexOf('(') + 1,\n content.lastIndexOf(')')\n )\n // argument example: '#{2,9}'\n\n let fakeFunc: any = faker\n faking.forEach((f: string) => {\n fakeFunc = fakeFunc[f]\n })\n let regexpParam = false\n if (faking.length === 2 && faking[1] === 'fromRegExp') {\n regexpParam = true\n }\n if (regexpParam) {\n return fakeFunc(new RegExp(argument))\n }\n try {\n return fakeFunc(JSON5.parse(argument))\n } catch (error) {\n if (!argument) {\n return fakeFunc()\n }\n\n return fakeFunc(argument)\n }\n}\n\nconst getDefinitionFunction = (\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const mjsFiles = fs\n .readdirSync(path.join(feature_path, '../step_definitions'))\n .filter((file) => file === `${functionFile}.js`)\n\n if (mjsFiles.length === 0) {\n throw new Error(`File ${functionFile} not found in step_definitions folder`)\n }\n\n const [mjsData] = mjsFiles.map((file) => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { [functionName]: func } = require(path.join(\n feature_path,\n '../step_definitions',\n file\n ))\n if (!func)\n throw new Error(`Function ${functionName} not found in file ${file}`)\n\n return func()\n })\n\n return mjsData\n}\n\nconst generateExamplesFromFunction = (\n data: string,\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const examples = data.split('Examples:')[1].split('\\n').slice(1)\n const headers = examples[0]\n .split('|')\n .map((header) => header.trim())\n .filter((header) => header !== '')\n const values = examples[1]\n .split('|')\n .map((value) => value.trim())\n .filter((header) => header !== '')\n\n const mjsData = getDefinitionFunction(\n feature_path,\n functionName,\n functionFile\n )\n\n const newExamples = headers.map((header) => {\n if (mjsData[header]) {\n return mjsData[header]\n }\n return values[headers.indexOf(header)]\n })\n\n let newExamplesString = data.split('Examples:')[1]\n newExamples.forEach((example, index) => {\n newExamplesString = newExamplesString.replace(values[index], example)\n })\n\n const newData = data.replace(data.split('Examples:')[1], newExamplesString)\n\n return { newData, mjsData }\n}\n\nconst generateExamplesFromFunctionGherkin = (\n headers: readonly TableCell[],\n values: readonly TableCell[],\n mjsData: any\n) => {\n const newExamples = headers.map(({ value: header }, index) => {\n if (mjsData[header]) {\n return { header, value: mjsData[header] }\n }\n return { header, value: values[index].value }\n })\n\n return newExamples\n}\n\nexport {\n generateTestData,\n generateExamplesFromFunction,\n generateExamplesFromFunctionGherkin,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"feature_data_format.js","sourceRoot":"","sources":["../../src/formatter/feature_data_format.ts"],"names":[],"mappings":";;;;;;AAAA,uFAAuF;AACvF,4CAAmB;AACnB,gDAAuB;AAEvB,kDAAyB;AACzB,iEAAuC;AAEvC,MAAM,gBAAgB,GAAG,CACvB,kBAA0B,EAC1B,IAAU,EACV,QAGG,EACH,UAAmB,EACnB,EAAE;IACF,MAAM,MAAM,GAAG,2BAA2B,CAAA;IAC1C,MAAM,aAAa,GAAG,wBAAwB,CAAA;IAC9C,IAAI,UAAU,GAAG,kBAAkB,CAAA;IACnC,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AC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;QACrC,iBAAiB,GAAG,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAA;IACvE,CAAC,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;IAE3E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;AAC7B,CAAC,CAAA;AAmBC,oEAA4B;AAjB9B,MAAM,mCAAmC,GAAG,CAC1C,OAA6B,EAC7B,MAA4B,EAC5B,OAAY,EACZ,EAAE;IACF,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE;QAC3D,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;YACnB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;SAC1C;QACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAA;IAC/C,CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAKC,kFAAmC","sourcesContent":["// import { faker } from '@faker-js/faker' // it is taking more time to load the module\nimport fs from 'fs'\nimport path from 'path'\nimport { TableCell } from '@cucumber/messages'\nimport JSON5 from 'json5'\nimport tryRequire from '../try_require'\n\nconst generateTestData = (\n featureFileContent: string,\n vars?: any,\n fakeData?: {\n var: string\n fake: string\n }[],\n projectDir?: string\n) => {\n const regexp = /\\{\\{([^}]*\\([^)]*\\))\\}\\}/g\n const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g\n let newContent = featureFileContent\n let match: RegExpExecArray\n if (!projectDir) {\n projectDir = process.cwd()\n }\n const namespacePath = path.join(\n projectDir,\n 'features',\n 'step_definitions',\n 'namespaces.json'\n )\n let namespaces: string[] = fs.existsSync(namespacePath)\n ? JSON.parse(fs.readFileSync(namespacePath, 'utf-8'))\n : []\n if (!Array.isArray(namespaces)) {\n namespaces = []\n }\n const matches = []\n // collect all matches\n while ((match = regexp.exec(featureFileContent)) !== null) {\n // match[0] is the full match, match[1] is the first capturing group\n // Eg:- match[0] = {{name}}, match[1] = name\n if (!namespaces.includes(match[1].split('.')[0])) matches.push(match)\n }\n // find all variables in the matches\n const variables: any = { ...vars }\n\n if (Object.keys(variables).length > 0) {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n newContent = newContent.replaceAll(`{{${variable.var}}}`, variable.fake)\n }\n } else {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n variables[variableMatch[1]] = {\n var: variableMatch[1],\n toFake: variableMatch[2],\n }\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n const fake = getFakeString(\n variable.toFake.substring(2, variable.toFake.length - 2)\n )\n newContent = newContent.replaceAll(`{{${variable.var}}}`, fake)\n variables[key].fake = fake\n }\n }\n\n regexp.lastIndex = 0\n const otherFakeData = []\n const duplicateFakeData = fakeData ? [...fakeData] : []\n let fakeIndex = 0\n while ((match = regexp.exec(featureFileContent)) !== null) {\n if (namespaces.includes(match[1].split('.')[0])) continue\n try {\n let fake: any\n\n if (!duplicateFakeData || duplicateFakeData.length === 0) {\n fake = getFakeString(match[0].substring(2, match[0].length - 2))\n } else {\n const foundDuplicate = duplicateFakeData.find(\n (item) => item.var === match[0]\n )\n if (foundDuplicate) {\n fake = foundDuplicate.fake\n } else {\n fake = getFakeString(match[0].substring(2, match[0].length - 2))\n }\n }\n otherFakeData.push({\n var: match[0],\n fake,\n })\n newContent = newContent.replace(match[0], fake)\n fakeIndex++\n } catch (err) {\n // eslint-disable-next-line no-console\n }\n }\n\n return {\n newContent,\n variables,\n otherFakeData,\n changed: newContent !== featureFileContent,\n fakeIndex,\n }\n}\n\nlet globalFaker: any = null\n\nconst getFakeString = (content: string) => {\n // content example: helpers.fromRegExp('#{2,9}')\n const faking = content.split('(')[0].split('.')\n // faking example: ['helpers', 'fromRegExp']\n const argument = content.substring(\n content.indexOf('(') + 1,\n content.lastIndexOf(')')\n )\n // argument example: '#{2,9}'\n let faker = globalFaker\n if (!faker) {\n faker = tryRequire('@faker-js/faker/locale/en_US').faker\n globalFaker = faker\n }\n let fakeFunc: any = faker\n faking.forEach((f: string) => {\n fakeFunc = fakeFunc[f]\n })\n let regexpParam = false\n if (faking.length === 2 && faking[1] === 'fromRegExp') {\n regexpParam = true\n }\n if (regexpParam) {\n return fakeFunc(new RegExp(argument))\n }\n try {\n return fakeFunc(JSON5.parse(argument))\n } catch (error) {\n if (!argument) {\n return fakeFunc()\n }\n\n return fakeFunc(argument)\n }\n}\n\nconst getDefinitionFunction = (\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const mjsFiles = fs\n .readdirSync(path.join(feature_path, '../step_definitions'))\n .filter((file) => file === `${functionFile}.js`)\n\n if (mjsFiles.length === 0) {\n throw new Error(`File ${functionFile} not found in step_definitions folder`)\n }\n\n const [mjsData] = mjsFiles.map((file) => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { [functionName]: func } = require(\n path.join(feature_path, '../step_definitions', file)\n )\n if (!func)\n throw new Error(`Function ${functionName} not found in file ${file}`)\n\n return func()\n })\n\n return mjsData\n}\n\nconst generateExamplesFromFunction = (\n data: string,\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const examples = data.split('Examples:')[1].split('\\n').slice(1)\n const headers = examples[0]\n .split('|')\n .map((header) => header.trim())\n .filter((header) => header !== '')\n const values = examples[1]\n .split('|')\n .map((value) => value.trim())\n .filter((header) => header !== '')\n\n const mjsData = getDefinitionFunction(\n feature_path,\n functionName,\n functionFile\n )\n\n const newExamples = headers.map((header) => {\n if (mjsData[header]) {\n return mjsData[header]\n }\n return values[headers.indexOf(header)]\n })\n\n let newExamplesString = data.split('Examples:')[1]\n newExamples.forEach((example, index) => {\n newExamplesString = newExamplesString.replace(values[index], example)\n })\n\n const newData = data.replace(data.split('Examples:')[1], newExamplesString)\n\n return { newData, mjsData }\n}\n\nconst generateExamplesFromFunctionGherkin = (\n headers: readonly TableCell[],\n values: readonly TableCell[],\n mjsData: any\n) => {\n const newExamples = headers.map(({ value: header }, index) => {\n if (mjsData[header]) {\n return { header, value: mjsData[header] }\n }\n return { header, value: values[index].value }\n })\n\n return newExamples\n}\n\nexport {\n generateTestData,\n generateExamplesFromFunction,\n generateExamplesFromFunctionGherkin,\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/formatter/helpers/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,KAAK,GAAG;IACnB,GAAG,EAAE,gCAAgC;IACrC,SAAS,EAAE,qCAAqC;IAChD,IAAI,EAAE,gCAAgC;IACtC,OAAO,EAAE,mCAAmC;CAC7C,CAAA;AACY,QAAA,GAAG,GAAG;IACjB,GAAG,EAAE,mCAAmC;IACxC,SAAS,EAAE,wCAAwC;IACnD,IAAI,EAAE,mCAAmC;IACzC,OAAO,EAAE,sCAAsC;CAChD,CAAA;AACY,QAAA,IAAI,GAAG;IAClB,GAAG,EAAE,+BAA+B;IACpC,SAAS,EAAE,oCAAoC;IAC/C,IAAI,EAAE,+BAA+B;IACrC,OAAO,EAAE,kCAAkC;CAC5C,CAAA;AACY,QAAA,KAAK,GAAG;IACnB,GAAG,EAAE,qCAAqC;IAC1C,SAAS,E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/runs',\n STORAGE: 'http://localhost:5050/api/storage',\n}\nexport const DEV = {\n SSO: 'https://dev.api.blinq.io/api/auth',\n WORKSPACE: 'https://dev.api.blinq.io/api/workspace',\n RUNS: 'https://dev.api.blinq.io/api/runs',\n STORAGE: 'https://dev.api.blinq.io/api/storage',\n}\nexport const PROD = {\n SSO: 'https://api.blinq.io/api/auth',\n WORKSPACE: 'https://api.blinq.io/api/workspace',\n RUNS: 'https://api.blinq.io/api/runs',\n STORAGE: 'https://api.blinq.io/api/storage',\n}\nexport const STAGE = {\n SSO: 'https://stage.api.blinq.io/api/auth',\n WORKSPACE: 'https://stage.api.blinq.io/api/workspace',\n RUNS: 'https://stage.api.blinq.io/api/runs',\n STORAGE: 'https://stage.api.blinq.io/api/storage',\n}\n\nexport const CUSTOM = {\n SSO: `${process.env.NODE_ENV_BLINQ}/api/auth`,\n WORKSPACE: `${process.env.NODE_ENV_BLINQ}/api/workspace`,\n RUNS: `${process.env.NODE_ENV_BLINQ}/api/runs`,\n STORAGE: `${process.env.NODE_ENV_BLINQ}/api/storage`,\n}\n\nexport const SERVICES_URI =\n process.env.NODE_ENV_BLINQ === 'local'\n ? LOCAL // eslint-disable-line\n : process.env.NODE_ENV_BLINQ === 'dev'\n ? DEV // eslint-disable-line\n : process.env.NODE_ENV_BLINQ === 'stage'\n ? STAGE // eslint-disable-line\n : process.env.NODE_ENV_BLINQ === 'prod'\n ? PROD // eslint-disable-line\n : !process.env.NODE_ENV_BLINQ\n ? PROD // eslint-disable-line\n : CUSTOM // eslint-disable-line\n\nexport enum ActionEvents {\n record_scenario = 'record_scenario',\n download_editor = 'download_editor',\n launch_editor = 'launch_editor',\n click_start_recording = 'click_start_recording',\n click_run_scenario = 'click_run_scenario',\n publish_scenario = 'publish_scenario',\n click_ai_generate = 'click_ai_generate',\n click_run_all = 'click_run_all',\n click_open_vscode = 'click_open_vscode',\n error_open_vscode = 'error_open_vscode',\n cli_run_tests = 'cli_run_tests',\n upload_report = 'upload_report',\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as messages from '@cucumber/messages';
|
|
2
2
|
type JsonTimestamp = number;
|
|
3
|
-
type JsonStepType = 'Unknown' | 'Context' | 'Action' | 'Outcome' | 'Conjunction';
|
|
3
|
+
type JsonStepType = 'Unknown' | 'Context' | 'Action' | 'Outcome' | 'Conjunction' | 'After' | 'Before';
|
|
4
4
|
export type JsonResultUnknown = {
|
|
5
5
|
status: 'UNKNOWN';
|
|
6
6
|
};
|
|
@@ -93,6 +93,7 @@ export type JsonTestProgress = {
|
|
|
93
93
|
name: string;
|
|
94
94
|
baseUrl: string;
|
|
95
95
|
};
|
|
96
|
+
traceFileId?: string;
|
|
96
97
|
};
|
|
97
98
|
export type JsonReport = {
|
|
98
99
|
testCases: JsonTestProgress[];
|
|
@@ -129,6 +130,7 @@ export default class ReportGenerator {
|
|
|
129
130
|
private loggingOverridden;
|
|
130
131
|
reportFolder: null | string;
|
|
131
132
|
private uploadService;
|
|
133
|
+
private retryTestCaseId;
|
|
132
134
|
handleMessage(envelope: EnvelopeWithMetaMessage | messages.Envelope, reRunId?: string): Promise<any>;
|
|
133
135
|
getReport(): JsonReport;
|
|
134
136
|
private handleParseError;
|
|
@@ -80,6 +80,7 @@ class ReportGenerator {
|
|
|
80
80
|
this.loggingOverridden = false; // Flag to track if logging is overridden
|
|
81
81
|
this.reportFolder = null;
|
|
82
82
|
this.uploadService = new upload_serivce_1.RunUploadService(REPORT_SERVICE_URL, REPORT_SERVICE_TOKEN);
|
|
83
|
+
this.retryTestCaseId = null;
|
|
83
84
|
this.retryCount = 3;
|
|
84
85
|
}
|
|
85
86
|
async handleMessage(envelope, reRunId) {
|
|
@@ -138,6 +139,7 @@ class ReportGenerator {
|
|
|
138
139
|
break;
|
|
139
140
|
}
|
|
140
141
|
case 'testCaseStarted': {
|
|
142
|
+
this.retryTestCaseId = envelope[type].retryTestCaseId;
|
|
141
143
|
const testCaseStarted = envelope[type];
|
|
142
144
|
this.onTestCaseStarted(testCaseStarted);
|
|
143
145
|
break;
|
|
@@ -159,8 +161,12 @@ class ReportGenerator {
|
|
|
159
161
|
}
|
|
160
162
|
case 'testCaseFinished': {
|
|
161
163
|
const testCaseFinished = envelope[type];
|
|
164
|
+
let reRunIdFinal = this.retryTestCaseId;
|
|
165
|
+
if (reRunId) {
|
|
166
|
+
reRunIdFinal = reRunId;
|
|
167
|
+
}
|
|
162
168
|
// Call the onTestCaseFinished method
|
|
163
|
-
const result = await this.onTestCaseFinished(testCaseFinished,
|
|
169
|
+
const result = await this.onTestCaseFinished(testCaseFinished, reRunIdFinal);
|
|
164
170
|
return result;
|
|
165
171
|
}
|
|
166
172
|
// case "hook": { break} // After Hook
|
|
@@ -426,6 +432,31 @@ class ReportGenerator {
|
|
|
426
432
|
const testStep = this.testStepMap.get(testStepId);
|
|
427
433
|
if (testStep.pickleStepId === undefined) {
|
|
428
434
|
if (testStepResult.status === 'FAILED') {
|
|
435
|
+
const testCase = this.testCaseReportMap.get(testStepFinished.testCaseStartedId);
|
|
436
|
+
const type = testCase.steps[0].result.status === 'UNKNOWN' ? 'Before' : 'After';
|
|
437
|
+
const hookStep = {
|
|
438
|
+
ariaSnapshot: null,
|
|
439
|
+
commands: [],
|
|
440
|
+
keyword: type,
|
|
441
|
+
data: {},
|
|
442
|
+
networkData: [],
|
|
443
|
+
result: {
|
|
444
|
+
status: 'FAILED',
|
|
445
|
+
message: testStepResult.message,
|
|
446
|
+
startTime: this.getTimeStamp(timestamp),
|
|
447
|
+
endTime: this.getTimeStamp(timestamp),
|
|
448
|
+
},
|
|
449
|
+
text: 'Failed hook',
|
|
450
|
+
type,
|
|
451
|
+
webLog: [],
|
|
452
|
+
};
|
|
453
|
+
if (type === 'Before') {
|
|
454
|
+
testCase.steps = [hookStep, ...testCase.steps];
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
testCase.steps = [...testCase.steps, hookStep];
|
|
458
|
+
}
|
|
459
|
+
this.testCaseReportMap.set(testStepFinished.testCaseStartedId, testCase);
|
|
429
460
|
console.error(`Before/After hook failed with message: ${testStepResult.message}`);
|
|
430
461
|
}
|
|
431
462
|
return;
|
|
@@ -492,10 +523,10 @@ class ReportGenerator {
|
|
|
492
523
|
const _parameters = {};
|
|
493
524
|
Object.keys(parameters).map((key) => {
|
|
494
525
|
var _a;
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
const path =
|
|
498
|
-
let value = String((_a = object_path_1.default.get(data, path)) !== null && _a !== void 0 ? _a :
|
|
526
|
+
const valueParam = parameters[key].toString();
|
|
527
|
+
if (valueParam.startsWith('{{') && valueParam.endsWith('}}')) {
|
|
528
|
+
const path = valueParam.slice(2, -2).split('.');
|
|
529
|
+
let value = String((_a = object_path_1.default.get(data, path)) !== null && _a !== void 0 ? _a : valueParam);
|
|
499
530
|
if (value) {
|
|
500
531
|
if (value.startsWith('secret:')) {
|
|
501
532
|
value = 'secret:****';
|
|
@@ -557,6 +588,12 @@ class ReportGenerator {
|
|
|
557
588
|
}
|
|
558
589
|
}
|
|
559
590
|
getTestCaseResult(steps) {
|
|
591
|
+
if (steps[0] && steps[0].result.status === 'SKIPPED') {
|
|
592
|
+
return {
|
|
593
|
+
status: 'FAILED',
|
|
594
|
+
message: 'Test skipped due to failure in before hooks',
|
|
595
|
+
};
|
|
596
|
+
}
|
|
560
597
|
for (const step of steps) {
|
|
561
598
|
switch (step.result.status) {
|
|
562
599
|
case 'FAILED':
|
|
@@ -596,10 +633,15 @@ class ReportGenerator {
|
|
|
596
633
|
testProgress.webLog = this.logs;
|
|
597
634
|
testProgress.networkLog = this.networkLog;
|
|
598
635
|
testProgress.initialAriaSnapshot = this.initialAriaSnapshot;
|
|
636
|
+
if (process.env.TRACE) {
|
|
637
|
+
testProgress.traceFileId = path_1.default.join(`trace-${testCaseStartedId}.zip`);
|
|
638
|
+
}
|
|
599
639
|
this.initialAriaSnapshot = '';
|
|
600
640
|
this.networkLog = [];
|
|
601
641
|
this.logs = [];
|
|
602
|
-
if (this.testCaseLog &&
|
|
642
|
+
if (this.testCaseLog &&
|
|
643
|
+
this.testCaseLog.length > 0 &&
|
|
644
|
+
!testProgress.logFileId) {
|
|
603
645
|
// Create the logs directory
|
|
604
646
|
const logsDir = path_1.default.join(this.reportFolder, 'editorLogs');
|
|
605
647
|
const fileName = `testCaseLog_${testCaseStartedId}.log`;
|
|
@@ -663,7 +705,7 @@ class ReportGenerator {
|
|
|
663
705
|
projectId = process.env.PROJECT_ID;
|
|
664
706
|
}
|
|
665
707
|
else {
|
|
666
|
-
const runDoc = await this.uploadService.createRunDocument(this.runName);
|
|
708
|
+
const runDoc = await this.uploadService.createRunDocument(this.runName, testCase.env);
|
|
667
709
|
runId = runDoc._id;
|
|
668
710
|
projectId = runDoc.project_id;
|
|
669
711
|
if (!process.env.IGNORE_ENV_VARIABLES) {
|