@zohodesk/testinglibrary 0.1.8-exp-bdd-v1 → 0.1.8-exp.1
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/.babelrc +18 -18
- package/.eslintrc.js +31 -27
- package/.prettierrc +5 -5
- package/README.md +17 -17
- package/bin/cli.js +2 -2
- package/build/bdd-framework/cli/commands/env.js +4 -4
- package/build/bdd-framework/cli/commands/test.js +6 -2
- package/build/bdd-framework/cli/options.js +4 -4
- package/build/bdd-framework/cli/worker.js +3 -3
- package/build/bdd-framework/config/dir.js +6 -6
- package/build/bdd-framework/config/env.js +5 -4
- package/build/bdd-framework/config/index.js +2 -2
- package/build/bdd-framework/config/lang.js +14 -0
- package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +3 -3
- package/build/bdd-framework/cucumber/loadSources.js +9 -9
- package/build/bdd-framework/cucumber/loadSteps.js +8 -3
- package/build/bdd-framework/decorators.js +2 -2
- package/build/bdd-framework/gen/fixtures.js +48 -0
- package/build/bdd-framework/gen/formatter.js +64 -17
- package/build/bdd-framework/gen/i18n.js +9 -5
- package/build/bdd-framework/gen/index.js +9 -8
- package/build/bdd-framework/gen/testFile.js +121 -55
- package/build/bdd-framework/gen/testNode.js +19 -6
- package/build/bdd-framework/gen/testPoms.js +49 -39
- package/build/bdd-framework/hooks/scenario.js +107 -0
- package/build/bdd-framework/hooks/worker.js +83 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +27 -11
- package/build/bdd-framework/playwright/getLocationInFile.js +17 -11
- package/build/bdd-framework/playwright/loadConfig.js +3 -3
- package/build/bdd-framework/playwright/testTypeImpl.js +19 -15
- package/build/bdd-framework/playwright/transform.js +10 -6
- package/build/bdd-framework/playwright/utils.js +3 -6
- package/build/bdd-framework/run/StepInvoker.js +73 -0
- package/build/bdd-framework/run/bddFixtures.js +118 -55
- package/build/bdd-framework/run/bddWorld.js +24 -36
- package/build/bdd-framework/snippets/index.js +5 -3
- package/build/bdd-framework/snippets/snippetSyntax.js +3 -1
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
- package/build/bdd-framework/stepDefinitions/createBdd.js +30 -13
- package/build/bdd-framework/stepDefinitions/decorators/{poms.js → class.js} +13 -9
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +14 -8
- package/build/bdd-framework/stepDefinitions/defineStep.js +5 -4
- package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
- package/build/bdd-framework/utils/exit.js +26 -18
- package/build/bdd-framework/utils/index.js +30 -4
- package/build/bdd-framework/utils/jsStringWrap.js +9 -9
- package/build/bdd-framework/utils/logger.js +5 -3
- package/build/core/playwright/builtInFixtures/addTags.js +19 -0
- package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
- package/build/core/playwright/builtInFixtures/context.js +15 -0
- package/build/core/playwright/builtInFixtures/index.js +26 -0
- package/build/core/playwright/builtInFixtures/page.js +51 -0
- package/build/core/playwright/clear-caches.js +29 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/index.js +6 -74
- package/build/core/playwright/readConfigFile.js +37 -30
- package/build/core/playwright/report-generator.js +2 -1
- package/build/core/playwright/setup/config-creator.js +43 -20
- package/build/core/playwright/setup/config-utils.js +30 -0
- package/build/core/playwright/setup/custom-reporter.js +109 -0
- package/build/core/playwright/tag-processor.js +68 -0
- package/build/core/playwright/test-runner.js +8 -12
- package/build/index.d.ts +60 -5
- package/build/index.js +18 -12
- package/build/lib/cli.js +10 -1
- package/build/parser/sample.feature +34 -34
- package/build/parser/sample.spec.js +18 -18
- package/build/setup-folder-structure/helper.js +35 -0
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -72
- package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
- package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
- package/build/setup-folder-structure/samples/git-ignore.sample.js +36 -32
- package/build/setup-folder-structure/samples/uat-config-sample.js +44 -43
- package/build/setup-folder-structure/setupProject.js +10 -5
- package/build/utils/cliArgsToObject.js +29 -25
- package/build/utils/fileUtils.js +15 -4
- package/changelog.md +137 -74
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +6469 -7781
- package/package.json +55 -54
- package/playwright.config.js +112 -112
- package/build/bdd-framework/cucumber/gherkin.d.ts +0 -45
- package/build/bdd-framework/gen/poms.js +0 -46
- package/build/bdd-framework/stepDefinitions/createDecorators.js +0 -108
- package/build/bdd-poc/core-runner/exportMethods.js +0 -20
- package/build/bdd-poc/core-runner/stepDefinitions.js +0 -53
- package/build/bdd-poc/main.js +0 -10
- package/build/bdd-poc/runner.js +0 -19
- package/build/bdd-poc/test/cucumber/featureFileParer.js +0 -81
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +0 -36
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +0 -43
- package/build/bdd-poc/test/testDataMap.js +0 -98
- package/build/bdd-poc/test/testStructure.js +0 -83
- package/build/bdd-poc/utils/stringManipulation.js +0 -19
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.parseFeature = parseFeature;
|
|
8
|
-
var _gherkin = _interopRequireDefault(require("@cucumber/gherkin"));
|
|
9
|
-
var _messages = require("@cucumber/messages");
|
|
10
|
-
var uuidFn = _messages.IdGenerator.uuid();
|
|
11
|
-
var builder = new _gherkin.default.AstBuilder(uuidFn);
|
|
12
|
-
var matcher = new _gherkin.default.GherkinClassicTokenMatcher();
|
|
13
|
-
var parser = new _gherkin.default.Parser(builder, matcher);
|
|
14
|
-
function parseFeature(featureFileContent) {
|
|
15
|
-
var _gherkinDocument$feat;
|
|
16
|
-
var gherkinDocument = parser.parse(featureFileContent);
|
|
17
|
-
var currentFeature = {
|
|
18
|
-
feature: "",
|
|
19
|
-
tags: "",
|
|
20
|
-
scenarios: []
|
|
21
|
-
};
|
|
22
|
-
currentFeature.feature = gherkinDocument.feature.name;
|
|
23
|
-
currentFeature.tags = (_gherkinDocument$feat = gherkinDocument.feature) === null || _gherkinDocument$feat === void 0 ? void 0 : _gherkinDocument$feat.tags.map(tag => tag.name);
|
|
24
|
-
gherkinDocument.feature.children.forEach($scenario => {
|
|
25
|
-
var _$scenario$scenario, _$scenario$scenario2, _$scenario$scenario3, _$scenario$scenario4;
|
|
26
|
-
var scenarioSteps = {
|
|
27
|
-
scenariodescription: "",
|
|
28
|
-
steps: "",
|
|
29
|
-
tablebody: false,
|
|
30
|
-
tableheader: false,
|
|
31
|
-
examples: [],
|
|
32
|
-
scenarioTags: []
|
|
33
|
-
};
|
|
34
|
-
scenarioSteps.scenariodescription = (_$scenario$scenario = $scenario.scenario) === null || _$scenario$scenario === void 0 ? void 0 : _$scenario$scenario.name;
|
|
35
|
-
if ($scenario !== null && $scenario !== void 0 && $scenario.background) {
|
|
36
|
-
scenarioSteps.scenariodescription = "BackGround";
|
|
37
|
-
scenarioSteps.steps = $scenario.background.steps.pop().text;
|
|
38
|
-
currentFeature.scenarios.push(scenarioSteps);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
(_$scenario$scenario2 = $scenario.scenario) === null || _$scenario$scenario2 === void 0 || _$scenario$scenario2.examples.map(example => {
|
|
42
|
-
var _example$tableHeader;
|
|
43
|
-
scenarioSteps.tablebody = example === null || example === void 0 ? void 0 : example.tableBody.map(cell => {
|
|
44
|
-
return cell === null || cell === void 0 ? void 0 : cell.cells.map(example => example.value);
|
|
45
|
-
});
|
|
46
|
-
scenarioSteps.tableheader = example === null || example === void 0 || (_example$tableHeader = example.tableHeader) === null || _example$tableHeader === void 0 ? void 0 : _example$tableHeader.cells.map(exampleHead => {
|
|
47
|
-
return exampleHead.value;
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
if (scenarioSteps.tablebody && scenarioSteps.tableheader) {
|
|
51
|
-
scenarioSteps.examples = testDataExtraction(scenarioSteps.tableheader, scenarioSteps.tablebody);
|
|
52
|
-
} else {
|
|
53
|
-
scenarioSteps.examples = false;
|
|
54
|
-
}
|
|
55
|
-
scenarioSteps.scenarioTags = (_$scenario$scenario3 = $scenario.scenario) === null || _$scenario$scenario3 === void 0 ? void 0 : _$scenario$scenario3.tags.map(tag => tag.name);
|
|
56
|
-
const _scenarioDescription = $scenario === null || $scenario === void 0 || (_$scenario$scenario4 = $scenario.scenario) === null || _$scenario$scenario4 === void 0 ? void 0 : _$scenario$scenario4.steps.map(step => {
|
|
57
|
-
return {
|
|
58
|
-
stepDescription: step.text,
|
|
59
|
-
keyword: step.keyword
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
scenarioSteps.steps = _scenarioDescription;
|
|
63
|
-
currentFeature.scenarios.push(scenarioSteps);
|
|
64
|
-
});
|
|
65
|
-
return currentFeature;
|
|
66
|
-
}
|
|
67
|
-
function testDataExtraction(tableHeader, tableBody) {
|
|
68
|
-
const result = [];
|
|
69
|
-
if (tableBody && tableHeader) {
|
|
70
|
-
tableBody.forEach(array => {
|
|
71
|
-
const obj = {};
|
|
72
|
-
array.forEach((item, index) => {
|
|
73
|
-
obj[`<${tableHeader[index]}>`] = item;
|
|
74
|
-
});
|
|
75
|
-
result.push(obj);
|
|
76
|
-
});
|
|
77
|
-
} else {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.generateSpecFiles = generateSpecFiles;
|
|
8
|
-
var _fs = require("fs");
|
|
9
|
-
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
var _featureFileParer = require("../cucumber/featureFileParer");
|
|
12
|
-
var _testStructure = require("../testStructure");
|
|
13
|
-
async function stepFileCreation(featureContent, stepFilename, constructedFilePath) {
|
|
14
|
-
const generatedFolderPath = _path.default.resolve(process.cwd(), './feature-gen');
|
|
15
|
-
if (!(0, _fs.existsSync)(generatedFolderPath)) {
|
|
16
|
-
(0, _fs.mkdirSync)('./feature-gen', {
|
|
17
|
-
recursive: true
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
const stepsFilePath = _path.default.resolve(process.cwd(), 'feature-gen', stepFilename);
|
|
21
|
-
const stepsSnippets = (0, _testStructure.testSnippet)(featureContent, constructedFilePath);
|
|
22
|
-
await (0, _fs.writeFileSync)(stepsFilePath, stepsSnippets);
|
|
23
|
-
}
|
|
24
|
-
function generateSpecFiles() {
|
|
25
|
-
const featureFilePath = _path.default.resolve(process.cwd(), 'uat', 'modules', '**', '**', '**', '**', '**', '**', '**', '**', '*.feature').split(`\\`).join('/');
|
|
26
|
-
_fastGlob.default.globSync(featureFilePath, {
|
|
27
|
-
dot: true,
|
|
28
|
-
cwd: process.cwd()
|
|
29
|
-
}).forEach(filePath => {
|
|
30
|
-
console.log(filePath);
|
|
31
|
-
const featurefilePath = _path.default.resolve(process.cwd(), filePath);
|
|
32
|
-
const featureContent = (0, _featureFileParer.parseFeature)((0, _fs.readFileSync)(featurefilePath, 'utf-8'));
|
|
33
|
-
const fileName = _path.default.basename(filePath).replace('.feature', '.spec.js');
|
|
34
|
-
stepFileCreation(featureContent, fileName, featureFilePath);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TESTING_LIBRARY = void 0;
|
|
7
|
-
exports.testCase = testCase;
|
|
8
|
-
exports.testFile = testFile;
|
|
9
|
-
exports.testStep = testStep;
|
|
10
|
-
exports.testSuite = testSuite;
|
|
11
|
-
const TESTING_LIBRARY = exports.TESTING_LIBRARY = '@zohodesk/testinglibrary';
|
|
12
|
-
function testStep(keyword, description, browserObject, testData, options) {
|
|
13
|
-
return `await $${keyword}('${description}')(${browserObject},${testData})\n`;
|
|
14
|
-
}
|
|
15
|
-
function testSuite(description, scenariotestBlock, options) {
|
|
16
|
-
return `\ntest.describe('${description}', () => {
|
|
17
|
-
${scenariotestBlock}
|
|
18
|
-
})`;
|
|
19
|
-
}
|
|
20
|
-
function testCase(steps, examples, description, browserObjects, option) {
|
|
21
|
-
if (examples.length) {
|
|
22
|
-
const exmapleScenario = examples.map(($ele, index) => {
|
|
23
|
-
var exmapleDescription = Object.values($ele).map(val => {
|
|
24
|
-
return val.concat('-');
|
|
25
|
-
});
|
|
26
|
-
return testBlock(exmapleDescription.join('').concat(`Example-${index + 1}`), steps, browserObjects);
|
|
27
|
-
});
|
|
28
|
-
return testSuite(description, exmapleScenario.join('\n'));
|
|
29
|
-
}
|
|
30
|
-
return testBlock(description, steps, browserObjects);
|
|
31
|
-
}
|
|
32
|
-
function testBlock(description, steps, browserObjects) {
|
|
33
|
-
return `\ntest("${description}", async({${browserObjects.join(',')}}) => {
|
|
34
|
-
${steps.join(`\n\t`)}
|
|
35
|
-
})`;
|
|
36
|
-
}
|
|
37
|
-
function testFile(testCase, relativeFilePath) {
|
|
38
|
-
return ` // ${relativeFilePath}
|
|
39
|
-
import {test, createNativeBDD} from "${TESTING_LIBRARY}";
|
|
40
|
-
const {$Given,$When,$Then,$And} = createNativeBDD()
|
|
41
|
-
${testCase.join('')}
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.testDataCreation = testDataCreation;
|
|
8
|
-
var _gherkin = _interopRequireDefault(require("@cucumber/gherkin"));
|
|
9
|
-
var _messages = require("@cucumber/messages");
|
|
10
|
-
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
11
|
-
var _fs = require("fs");
|
|
12
|
-
var _path = _interopRequireDefault(require("path"));
|
|
13
|
-
var _testStructure = require("./testStructure");
|
|
14
|
-
async function testDataCreation() {
|
|
15
|
-
var uuidFn = _messages.IdGenerator.uuid();
|
|
16
|
-
var builder = new _gherkin.default.AstBuilder(uuidFn);
|
|
17
|
-
var matcher = new _gherkin.default.GherkinClassicTokenMatcher();
|
|
18
|
-
var parser = new _gherkin.default.Parser(builder, matcher);
|
|
19
|
-
var exampleSteps = [];
|
|
20
|
-
const globalTestdata = new Map();
|
|
21
|
-
const featurePath = _path.default.resolve('uat', 'modules', '**', '**', '**', '**', '**', '*.feature');
|
|
22
|
-
await _fastGlob.default.globSync([featurePath], {
|
|
23
|
-
dot: true,
|
|
24
|
-
cwd: process.cwd()
|
|
25
|
-
}).forEach(filePath => {
|
|
26
|
-
var body, header;
|
|
27
|
-
var gherkinDocument = parser.parse((0, _fs.readFileSync)(_path.default.resolve(process.cwd(), filePath), 'utf-8'));
|
|
28
|
-
gherkinDocument.feature.children.forEach($scenario => {
|
|
29
|
-
var _$scenario$scenario;
|
|
30
|
-
const $currentScenario = {
|
|
31
|
-
currentArgument: '',
|
|
32
|
-
dataTableStep: '',
|
|
33
|
-
inputParameter: '',
|
|
34
|
-
input: false,
|
|
35
|
-
steptable: false,
|
|
36
|
-
scenarioTable: false
|
|
37
|
-
};
|
|
38
|
-
(_$scenario$scenario = $scenario.scenario) === null || _$scenario$scenario === void 0 || _$scenario$scenario.steps.forEach(step => {
|
|
39
|
-
var _step$dataTable;
|
|
40
|
-
const {
|
|
41
|
-
refactoredStep,
|
|
42
|
-
currentArgument
|
|
43
|
-
} = (0, _testStructure.extactStepArgs)(step.text);
|
|
44
|
-
if (Object.values(currentArgument).length && !$scenario.scenario.examples.length) {
|
|
45
|
-
$currentScenario.currentArgument = currentArgument;
|
|
46
|
-
$currentScenario.input = true;
|
|
47
|
-
} else {
|
|
48
|
-
globalTestdata.set(refactoredStep, {});
|
|
49
|
-
}
|
|
50
|
-
const dataTableStep = [];
|
|
51
|
-
step === null || step === void 0 || (_step$dataTable = step.dataTable) === null || _step$dataTable === void 0 || _step$dataTable.rows.forEach(cell => {
|
|
52
|
-
const Table = cell.cells.map(element => element.value);
|
|
53
|
-
dataTableStep.push(Table);
|
|
54
|
-
});
|
|
55
|
-
if (step.dataTable) {
|
|
56
|
-
$currentScenario.dataTableStep = dataTableStep;
|
|
57
|
-
$currentScenario.steptable = true;
|
|
58
|
-
}
|
|
59
|
-
globalTestdata.set(refactoredStep, Object.assign({}, $currentScenario));
|
|
60
|
-
});
|
|
61
|
-
if ($scenario.scenario.examples.length) {
|
|
62
|
-
var _$scenario$scenario2;
|
|
63
|
-
exampleSteps = $scenario.scenario.steps.map(element => (0, _testStructure.extactStepArgs)(element.text).refactoredStep);
|
|
64
|
-
(_$scenario$scenario2 = $scenario.scenario) === null || _$scenario$scenario2 === void 0 || _$scenario$scenario2.examples.map(example => {
|
|
65
|
-
var _example$tableHeader;
|
|
66
|
-
body = example === null || example === void 0 ? void 0 : example.tableBody.map(cell => {
|
|
67
|
-
return cell === null || cell === void 0 ? void 0 : cell.cells.map(example => example.value);
|
|
68
|
-
});
|
|
69
|
-
header = example === null || example === void 0 || (_example$tableHeader = example.tableHeader) === null || _example$tableHeader === void 0 ? void 0 : _example$tableHeader.cells.map(exampleHead => {
|
|
70
|
-
return exampleHead.value;
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
const inputParameter = testDataExtraction(header, body);
|
|
74
|
-
exampleSteps.forEach(step => {
|
|
75
|
-
$currentScenario.inputParameter = Object.assign([], inputParameter);
|
|
76
|
-
$currentScenario.scenarioTable = true;
|
|
77
|
-
globalTestdata.set(step, Object.assign({}, $currentScenario));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
return globalTestdata;
|
|
83
|
-
}
|
|
84
|
-
function testDataExtraction(tableHeader, tableBody) {
|
|
85
|
-
const result = [];
|
|
86
|
-
if (tableBody && tableHeader) {
|
|
87
|
-
tableBody.forEach(array => {
|
|
88
|
-
const obj = {};
|
|
89
|
-
array.forEach((item, index) => {
|
|
90
|
-
obj[`${tableHeader[index].replace(/\s/g, '')}`] = item;
|
|
91
|
-
});
|
|
92
|
-
result.push(obj);
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
return [...result];
|
|
98
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.extactStepArgs = extactStepArgs;
|
|
8
|
-
exports.testSnippet = testSnippet;
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
11
|
-
var _fs = require("fs");
|
|
12
|
-
var _stringManipulation = require("../utils/stringManipulation");
|
|
13
|
-
var _stepsnippets = require("./stepGenerate/stepsnippets");
|
|
14
|
-
const inputsParamterMap = new Map();
|
|
15
|
-
function testSnippet(featureContent, constructedFilePath) {
|
|
16
|
-
const relativeFilePath = _path.default.relative(process.cwd(), constructedFilePath);
|
|
17
|
-
var currentScenarios = [];
|
|
18
|
-
featureContent.scenarios.forEach(scenario => {
|
|
19
|
-
const _constructStep = scenarioSnippet(scenario);
|
|
20
|
-
currentScenarioss.push(_constructStep);
|
|
21
|
-
});
|
|
22
|
-
return (0, _stepsnippets.testFile)(currentScenarios, relativeFilePath);
|
|
23
|
-
}
|
|
24
|
-
function extactStepArgs(step) {
|
|
25
|
-
var inputParam = [];
|
|
26
|
-
var currentArgument = {};
|
|
27
|
-
var refactoredStep = step.replace(/"([^"]+)"/g, (match, word) => {
|
|
28
|
-
if (!isNaN(Number(word))) {
|
|
29
|
-
inputParam.push(word.toString());
|
|
30
|
-
return '{int}';
|
|
31
|
-
} else {
|
|
32
|
-
inputParam.push(word.toString());
|
|
33
|
-
return '{string}';
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
currentArgument = inputParam.map(inputs => `"${(0, _stringManipulation.removeAll)(inputs, ['<', '>'], /\s/g)}"`);
|
|
37
|
-
return {
|
|
38
|
-
refactoredStep,
|
|
39
|
-
currentArgument
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function scenarioSnippet(scenario) {
|
|
43
|
-
var currentStep = [];
|
|
44
|
-
var currentInputs = [];
|
|
45
|
-
scenario.steps.forEach(step => {
|
|
46
|
-
var {
|
|
47
|
-
refactoredStep,
|
|
48
|
-
currentArgument
|
|
49
|
-
} = extactStepArgs(step.stepDescription);
|
|
50
|
-
var input = inputsParamterMap.get(`'${refactoredStep}'`);
|
|
51
|
-
currentInputs.push(input);
|
|
52
|
-
currentStep.push((0, _stepsnippets.testStep)(step.keyword, refactoredStep, input, currentArgument.join(',')));
|
|
53
|
-
return;
|
|
54
|
-
});
|
|
55
|
-
const pageObject = browserObjectHandle(currentInputs);
|
|
56
|
-
return (0, _stepsnippets.testCase)(currentStep, scenario === null || scenario === void 0 ? void 0 : scenario.examples, scenario === null || scenario === void 0 ? void 0 : scenario.scenariodescription, pageObject);
|
|
57
|
-
}
|
|
58
|
-
function readStepFile() {
|
|
59
|
-
const stepFilePath = _path.default.resolve(process.cwd(), 'uat', 'modules', '**', '**', '**', '**', '**', '**', '**', '**', '*.spec.js').split(`\\`).join('/');
|
|
60
|
-
_fastGlob.default.globSync(stepFilePath, {
|
|
61
|
-
dot: true,
|
|
62
|
-
cwd: process.cwd()
|
|
63
|
-
}).forEach(filePath => {
|
|
64
|
-
const code = (0, _fs.readFileSync)(_path.default.resolve(process.cwd(), filePath), 'utf-8');
|
|
65
|
-
code.split('\n').forEach(step => {
|
|
66
|
-
const trimmedStep = step.trim();
|
|
67
|
-
if (trimmedStep.startsWith('Given') || trimmedStep.startsWith('When') || trimmedStep.startsWith('Then')) {
|
|
68
|
-
var sortedSpecInput = trimmedStep.split(' ').slice(1).join('').match(/\((.*?)\)/)[1].match(/\{(.*?)\}/g) || [];
|
|
69
|
-
inputsParamterMap.set(trimmedStep.match(/'(.*?)'/g).pop(), sortedSpecInput.pop());
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
function browserObjectHandle(arrayofBrowserObjects) {
|
|
75
|
-
var browserinputs = [];
|
|
76
|
-
arrayofBrowserObjects.forEach(pageObject => {
|
|
77
|
-
browserinputs = [...browserinputs, ...(0, _stringManipulation.removeAll)(pageObject, ['{', '}']).split(',')];
|
|
78
|
-
});
|
|
79
|
-
return (0, _stringManipulation.avoidDuplicate)(browserinputs);
|
|
80
|
-
}
|
|
81
|
-
(async function () {
|
|
82
|
-
await readStepFile();
|
|
83
|
-
})();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.avoidDuplicate = avoidDuplicate;
|
|
7
|
-
exports.removeAll = removeAll;
|
|
8
|
-
function removeAll(InputString, toRemove, regex = undefined, options = null) {
|
|
9
|
-
if (regex) {
|
|
10
|
-
InputString = InputString.replace(regex, '').trim();
|
|
11
|
-
}
|
|
12
|
-
toRemove.forEach(ele => {
|
|
13
|
-
InputString = InputString.replace(ele, '').trim();
|
|
14
|
-
});
|
|
15
|
-
return InputString;
|
|
16
|
-
}
|
|
17
|
-
function avoidDuplicate(arrayOfInputs) {
|
|
18
|
-
return [...new Set(arrayOfInputs)];
|
|
19
|
-
}
|