@zohodesk/testinglibrary 0.1.8-stb-bdd-v24 → 0.1.8-stb-bdd-v26
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.
|
@@ -10,7 +10,7 @@ var _fileUtils = require("../../../utils/fileUtils");
|
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
var _pathConfig = require("../../config/pathConfig");
|
|
12
12
|
var _throwError = require("../../errors/throwError");
|
|
13
|
-
globalThis.testDataMap = new Map();
|
|
13
|
+
// globalThis.testDataMap = new Map();
|
|
14
14
|
function createStepDataMap() {
|
|
15
15
|
const stepFilePath = (0, _pathConfig.getStepFilePath)();
|
|
16
16
|
const processedSpecFile = [];
|
|
@@ -36,13 +36,17 @@ function extractPageFixtures(filePath) {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
function extractInputFrmStep(trimmedStep, filePath) {
|
|
39
|
+
var _inputNames$split;
|
|
39
40
|
var toRemovePattern = trimmedStep.match(/async\s*\(([^)]*)\)/)[1].match(/{(.*?)}/);
|
|
40
|
-
var
|
|
41
|
+
var inputNames = trimmedStep.match(/async\s*\(([^)]*)\)/)[1].replace(toRemovePattern[0], "$null") || [];
|
|
42
|
+
var filteredInputs = (_inputNames$split = inputNames.split(',')) === null || _inputNames$split === void 0 ? void 0 : _inputNames$split.slice(1);
|
|
43
|
+
if (filteredInputs.length) {
|
|
44
|
+
filteredInputs = filteredInputs.map(input => `"${input}"`);
|
|
45
|
+
}
|
|
41
46
|
try {
|
|
42
|
-
var _InputNames$split;
|
|
43
47
|
return {
|
|
44
48
|
stepPageFixtureName: trimmedStep.split(' ').slice(1).join('').match(/\((.*?)\)/)[1].match(/\{(.*?)\}/g).pop() || [false].pop(),
|
|
45
|
-
stepInputKey:
|
|
49
|
+
stepInputKey: filteredInputs
|
|
46
50
|
};
|
|
47
51
|
} catch (error) {
|
|
48
52
|
// Logger.log(Logger.FAILURE_TYPE,`${filePath} - Steps Has MisMatched Pattern`)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.traverseASTstep = traverseASTstep;
|
|
8
|
+
var _acorn = require("acorn");
|
|
9
|
+
var _fileUtils = require("../../../utils/fileUtils");
|
|
10
|
+
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
11
|
+
var _pathConfig = require("../../config/pathConfig");
|
|
12
|
+
globalThis.testDataMap = new Map();
|
|
13
|
+
async function extractFixtureFrmNode(node) {
|
|
14
|
+
var stepText;
|
|
15
|
+
return await new Promise(resolve => {
|
|
16
|
+
if ((node === null || node === void 0 ? void 0 : node.type) == 'ExpressionStatement' || (node === null || node === void 0 ? void 0 : node.type) == 'CallExpression' || (node === null || node === void 0 ? void 0 : node.type) == 'ArrowFunctionExpression') {
|
|
17
|
+
extractFixtureFrmNode(node.expression);
|
|
18
|
+
}
|
|
19
|
+
if ((node === null || node === void 0 ? void 0 : node.type) == 'CallExpression') {
|
|
20
|
+
if (node.arguments[0].type == 'Literal') {
|
|
21
|
+
stepText = node.arguments[0].raw;
|
|
22
|
+
}
|
|
23
|
+
if (node.arguments[1].type == 'ArrowFunctionExpression') {
|
|
24
|
+
let callbackInputs = [];
|
|
25
|
+
var fixtures;
|
|
26
|
+
node.arguments[1].params.forEach(input => {
|
|
27
|
+
if (input.type == 'ObjectPattern') {
|
|
28
|
+
fixtures = getPageFixture(input.properties);
|
|
29
|
+
if (fixtures.includes('page')) {
|
|
30
|
+
fixtures.push('page');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (input.type == 'Identifier') {
|
|
34
|
+
callbackInputs.push(input.name);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
testDataMap.set(stepText, {
|
|
38
|
+
stepPageFixtureName: combineAllFixture(fixtures),
|
|
39
|
+
stepInputKey: callbackInputs.map(element => `"${element}"`)
|
|
40
|
+
});
|
|
41
|
+
resolve();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function combineAllFixture(fixturesArray) {
|
|
47
|
+
if (!fixturesArray.includes('page')) {
|
|
48
|
+
fixturesArray.push('page');
|
|
49
|
+
}
|
|
50
|
+
if (fixturesArray.length === 1) {
|
|
51
|
+
return `{${fixturesArray}}`;
|
|
52
|
+
}
|
|
53
|
+
const lastFixture = fixturesArray.pop();
|
|
54
|
+
const allFixture = fixturesArray.join(',');
|
|
55
|
+
return `{${allFixture}${lastFixture}}`;
|
|
56
|
+
}
|
|
57
|
+
function traverseASTstep() {
|
|
58
|
+
var $promise = [];
|
|
59
|
+
_fastGlob.default.globSync((0, _pathConfig.getStepFilePath)(), {
|
|
60
|
+
dot: true,
|
|
61
|
+
cwd: process.cwd()
|
|
62
|
+
}).forEach(filePath => {
|
|
63
|
+
$promise.push(nodeAST((0, _fileUtils.readFileContents)(filePath)));
|
|
64
|
+
});
|
|
65
|
+
Promise.all($promise);
|
|
66
|
+
}
|
|
67
|
+
function nodeAST(stepContent) {
|
|
68
|
+
const options = {
|
|
69
|
+
ecmaVersion: 2020
|
|
70
|
+
};
|
|
71
|
+
const $node = (0, _acorn.parse)(stepContent, options).body;
|
|
72
|
+
$node.forEach(node => {
|
|
73
|
+
extractFixtureFrmNode(node);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function getPageFixture(fixtureNode) {
|
|
77
|
+
return fixtureNode.map($element => {
|
|
78
|
+
var _$element$key;
|
|
79
|
+
return ($element === null || $element === void 0 || (_$element$key = $element.key) === null || _$element$key === void 0 ? void 0 : _$element$key.name) || 'page';
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -10,15 +10,17 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
10
10
|
var _featureFileParer = require("../cucumber/featureFileParer");
|
|
11
11
|
var _testStructure = require("../testStructure");
|
|
12
12
|
var _fileUtils = require("../../../utils/fileUtils");
|
|
13
|
-
var _extractTestInputs = require("./extractTestInputs");
|
|
14
13
|
var _pathConfig = require("../../config/pathConfig");
|
|
14
|
+
var _parserSteps = require("./parserSteps");
|
|
15
|
+
// import { createStepDataMap } from './extractTestInputs';
|
|
16
|
+
|
|
15
17
|
function stepFileCreation(parsedFeatureContent, stepFilename, featureFilePath) {
|
|
16
18
|
const stepsFilePath = _path.default.resolve(process.cwd(), 'uat', '.feature-gen', stepFilename);
|
|
17
19
|
const stepsSnippets = (0, _testStructure.testSnippet)(parsedFeatureContent, featureFilePath);
|
|
18
20
|
(0, _fileUtils.writeFileContents)(stepsFilePath, stepsSnippets);
|
|
19
21
|
}
|
|
20
22
|
async function generateSpecFiles() {
|
|
21
|
-
await (0,
|
|
23
|
+
await (0, _parserSteps.traverseASTstep)();
|
|
22
24
|
const featureFilePattern = (0, _pathConfig.getFeatureFilePath)();
|
|
23
25
|
const featureFileFolderPath = _path.default.resolve(process.cwd(), 'uat', '.feature-gen');
|
|
24
26
|
if (!(0, _fileUtils.checkIfFileExists)(featureFileFolderPath)) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.1.8-stb-bdd-
|
|
3
|
+
"version": "0.1.8-stb-bdd-v25",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
@@ -2333,9 +2333,9 @@
|
|
|
2333
2333
|
"integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA=="
|
|
2334
2334
|
},
|
|
2335
2335
|
"acorn": {
|
|
2336
|
-
"version": "
|
|
2337
|
-
"resolved": "https://registry.npmjs.org/acorn/-/acorn-
|
|
2338
|
-
"integrity": "sha512-
|
|
2336
|
+
"version": "7.4.1",
|
|
2337
|
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
|
|
2338
|
+
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A=="
|
|
2339
2339
|
},
|
|
2340
2340
|
"acorn-globals": {
|
|
2341
2341
|
"version": "7.0.1",
|
|
@@ -2344,6 +2344,13 @@
|
|
|
2344
2344
|
"requires": {
|
|
2345
2345
|
"acorn": "^8.1.0",
|
|
2346
2346
|
"acorn-walk": "^8.0.2"
|
|
2347
|
+
},
|
|
2348
|
+
"dependencies": {
|
|
2349
|
+
"acorn": {
|
|
2350
|
+
"version": "8.11.3",
|
|
2351
|
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
|
2352
|
+
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg=="
|
|
2353
|
+
}
|
|
2347
2354
|
}
|
|
2348
2355
|
},
|
|
2349
2356
|
"acorn-walk": {
|
|
@@ -4584,6 +4591,13 @@
|
|
|
4584
4591
|
"whatwg-url": "^11.0.0",
|
|
4585
4592
|
"ws": "^8.11.0",
|
|
4586
4593
|
"xml-name-validator": "^4.0.0"
|
|
4594
|
+
},
|
|
4595
|
+
"dependencies": {
|
|
4596
|
+
"acorn": {
|
|
4597
|
+
"version": "8.11.3",
|
|
4598
|
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
|
4599
|
+
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg=="
|
|
4600
|
+
}
|
|
4587
4601
|
}
|
|
4588
4602
|
},
|
|
4589
4603
|
"jsesc": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.1.8-stb-bdd-
|
|
3
|
+
"version": "0.1.8-stb-bdd-v26",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@testing-library/jest-dom": "5.11.9",
|
|
28
28
|
"@testing-library/react": "11.2.7",
|
|
29
29
|
"@testing-library/react-hooks": "7.0.2",
|
|
30
|
+
"acorn": "^7.4.1",
|
|
30
31
|
"babel-jest": "29.6.2",
|
|
31
32
|
"babel-plugin-transform-dynamic-import": "2.1.0",
|
|
32
33
|
"fast-glob": "3.3.1",
|
|
@@ -50,7 +51,6 @@
|
|
|
50
51
|
"@babel/polyfill": "7.12.1",
|
|
51
52
|
"@babel/preset-env": "7.22.15",
|
|
52
53
|
"@babel/runtime": "7.22.15",
|
|
53
|
-
"acorn": "^8.11.3",
|
|
54
54
|
"commander": "^11.0.0"
|
|
55
55
|
}
|
|
56
56
|
}
|