@zohodesk/testinglibrary 0.1.7 → 0.1.8-exp-bdd
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 +27 -31
- 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 +2 -6
- 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 +4 -5
- package/build/bdd-framework/config/index.js +2 -2
- package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
- package/build/bdd-framework/cucumber/gherkin.d.ts +45 -0
- 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 +3 -8
- package/build/bdd-framework/decorators.js +2 -2
- package/build/bdd-framework/gen/formatter.js +17 -64
- package/build/bdd-framework/gen/i18n.js +5 -9
- package/build/bdd-framework/gen/index.js +8 -9
- package/build/bdd-framework/gen/poms.js +46 -0
- package/build/bdd-framework/gen/testFile.js +55 -121
- package/build/bdd-framework/gen/testNode.js +6 -19
- package/build/bdd-framework/gen/testPoms.js +39 -49
- package/build/bdd-framework/playwright/fixtureParameterNames.js +11 -27
- package/build/bdd-framework/playwright/getLocationInFile.js +11 -17
- package/build/bdd-framework/playwright/loadConfig.js +3 -3
- package/build/bdd-framework/playwright/testTypeImpl.js +15 -19
- package/build/bdd-framework/playwright/transform.js +6 -10
- package/build/bdd-framework/playwright/utils.js +6 -3
- package/build/bdd-framework/run/bddFixtures.js +55 -118
- package/build/bdd-framework/run/bddWorld.js +36 -24
- package/build/bdd-framework/snippets/index.js +3 -5
- package/build/bdd-framework/snippets/snippetSyntax.js +1 -3
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
- package/build/bdd-framework/stepDefinitions/createBdd.js +13 -30
- package/build/bdd-framework/stepDefinitions/createDecorators.js +108 -0
- package/build/bdd-framework/stepDefinitions/decorators/{class.js → poms.js} +9 -13
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +8 -14
- package/build/bdd-framework/stepDefinitions/defineStep.js +4 -5
- package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
- package/build/bdd-framework/utils/exit.js +18 -26
- package/build/bdd-framework/utils/index.js +4 -30
- package/build/bdd-framework/utils/jsStringWrap.js +9 -9
- package/build/bdd-framework/utils/logger.js +3 -5
- package/build/bdd-poc/core-runner/exportMethods.js +14 -0
- package/build/bdd-poc/core-runner/stepDefinitions.js +55 -0
- package/build/bdd-poc/main.js +10 -0
- package/build/bdd-poc/test/cucumber/featureFileParer.js +81 -0
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +36 -0
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +43 -0
- package/build/bdd-poc/test/testDataMap.js +98 -0
- package/build/bdd-poc/test/testStructure.js +83 -0
- package/build/bdd-poc/utils/stringManipulation.js +19 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/index.js +0 -15
- package/build/core/playwright/readConfigFile.js +30 -37
- package/build/core/playwright/report-generator.js +1 -2
- package/build/core/playwright/setup/config-creator.js +15 -21
- package/build/core/playwright/setup/config-utils.js +0 -30
- package/build/core/playwright/test-runner.js +5 -7
- package/build/index.d.ts +5 -60
- package/build/index.js +3 -5
- package/build/lib/cli.js +1 -10
- package/build/parser/sample.feature +34 -34
- package/build/parser/sample.spec.js +18 -18
- 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 +32 -36
- package/build/setup-folder-structure/samples/uat-config-sample.js +43 -44
- package/build/setup-folder-structure/setupProject.js +5 -10
- package/build/utils/cliArgsToObject.js +25 -25
- package/build/utils/fileUtils.js +0 -12
- package/changelog.md +74 -124
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +7781 -6469
- package/package.json +54 -55
- package/playwright.config.js +112 -112
- package/build/bdd-framework/config/lang.js +0 -14
- package/build/bdd-framework/gen/fixtures.js +0 -48
- package/build/bdd-framework/hooks/scenario.js +0 -107
- package/build/bdd-framework/hooks/worker.js +0 -83
- package/build/bdd-framework/run/StepInvoker.js +0 -73
- package/build/core/playwright/clear-caches.js +0 -29
- package/build/core/playwright/setup/custom-reporter.js +0 -100
- package/build/core/playwright/tag-processor.js +0 -68
- package/build/setup-folder-structure/helper.js +0 -34
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +0 -25
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +0 -25
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
})();
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
|
@@ -55,7 +55,6 @@ const {
|
|
|
55
55
|
bddMode
|
|
56
56
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
57
57
|
let base = bddMode ? _bddFramework.test : _test.test;
|
|
58
|
-
const cacheMap = new Map();
|
|
59
58
|
const test = exports.test = base.extend({
|
|
60
59
|
page: async ({
|
|
61
60
|
page
|
|
@@ -99,20 +98,6 @@ const test = exports.test = base.extend({
|
|
|
99
98
|
await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
|
|
100
99
|
await use(context);
|
|
101
100
|
},
|
|
102
|
-
cacheLayer: async ({}, use) => {
|
|
103
|
-
await use(cacheMap);
|
|
104
|
-
},
|
|
105
|
-
addTags: [async ({
|
|
106
|
-
$tags
|
|
107
|
-
}, use, testInfo) => {
|
|
108
|
-
testInfo.annotations.push({
|
|
109
|
-
type: 'tags',
|
|
110
|
-
description: $tags.join(', ')
|
|
111
|
-
});
|
|
112
|
-
await use();
|
|
113
|
-
}, {
|
|
114
|
-
auto: true
|
|
115
|
-
}],
|
|
116
101
|
...additionalPages
|
|
117
102
|
});
|
|
118
103
|
const {
|
|
@@ -14,7 +14,6 @@ var _logger = require("../../utils/logger");
|
|
|
14
14
|
const fileName = exports.fileName = 'uat.config.js';
|
|
15
15
|
function getDefaultConfig() {
|
|
16
16
|
return {
|
|
17
|
-
headless: false,
|
|
18
17
|
browsers: ['Chrome'],
|
|
19
18
|
trace: false,
|
|
20
19
|
video: false,
|
|
@@ -31,11 +30,7 @@ function getDefaultConfig() {
|
|
|
31
30
|
},
|
|
32
31
|
debug: false,
|
|
33
32
|
mode: 'dev',
|
|
34
|
-
additionalPages: {}
|
|
35
|
-
featureFilesFolder: 'feature-files',
|
|
36
|
-
stepDefinitionsFolder: 'steps',
|
|
37
|
-
testIdAttribute: 'data-testid',
|
|
38
|
-
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
33
|
+
additionalPages: {}
|
|
39
34
|
};
|
|
40
35
|
}
|
|
41
36
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
@@ -43,7 +38,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
43
38
|
let configurationObj = {};
|
|
44
39
|
Object.keys(userConfiguration).forEach(configKey => {
|
|
45
40
|
let configValue = userConfiguration[configKey];
|
|
46
|
-
if (configValue
|
|
41
|
+
if (configValue && configValue !== null) {
|
|
47
42
|
configurationObj[configKey] = configValue;
|
|
48
43
|
} else if (defaultConfig[configKey]) {
|
|
49
44
|
configurationObj[configKey] = defaultConfig[configKey];
|
|
@@ -57,40 +52,38 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
57
52
|
};
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
/**
|
|
61
|
-
* @typedef {Object|null} viewportConfig
|
|
62
|
-
* @property {number} width - width of the viewport
|
|
63
|
-
* @property {number} height - height of the viewport
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {Object|null} viewportConfig
|
|
57
|
+
* @property {number} width - width of the viewport
|
|
58
|
+
* @property {number} height - height of the viewport
|
|
64
59
|
*/
|
|
65
60
|
|
|
66
|
-
/**
|
|
67
|
-
* Represents the user configuration object.
|
|
68
|
-
* @typedef {Object} UserConfig
|
|
69
|
-
* @property {string} headless - Headless Browsers mode.
|
|
70
|
-
* @property {number} trace - trace for test cases.
|
|
71
|
-
* @property {boolean} video - video for test cases,
|
|
72
|
-
* @property {boolean} debug - debug mode
|
|
73
|
-
* @property {string} mode: mode in which the test cases needs to run
|
|
74
|
-
* @property {boolean} isAuthMode - Auth Mode
|
|
75
|
-
* @property {string} authFilePath - File Path where the cookies stored
|
|
76
|
-
* @property {any} browsers: List of browsers
|
|
77
|
-
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
78
|
-
* @property {any} reportPath : directory where report is generate
|
|
79
|
-
* @property {boolean} bddMode: Feature files needs to be processed
|
|
80
|
-
* @property {number} expectTimeout: time in milliseconds which the expect condition should fail
|
|
81
|
-
* @property {number} testTimeout: time in milliseconds which the test should fail
|
|
82
|
-
* @property {Object} additionalPages: custom pages configuration
|
|
83
|
-
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
84
|
-
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
85
|
-
* @property {viewportConfig} viewport: viewport configuration
|
|
86
|
-
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
87
|
-
* @property {Array} editionOrder: Order in the form of larger editions in the back. Edition with the most privelages should be last
|
|
61
|
+
/**
|
|
62
|
+
* Represents the user configuration object.
|
|
63
|
+
* @typedef {Object} UserConfig
|
|
64
|
+
* @property {string} headless - Headless Browsers mode.
|
|
65
|
+
* @property {number} trace - trace for test cases.
|
|
66
|
+
* @property {boolean} video - video for test cases,
|
|
67
|
+
* @property {boolean} debug - debug mode
|
|
68
|
+
* @property {string} mode: mode in which the test cases needs to run
|
|
69
|
+
* @property {boolean} isAuthMode - Auth Mode
|
|
70
|
+
* @property {string} authFilePath - File Path where the cookies stored
|
|
71
|
+
* @property {any} browsers: List of browsers
|
|
72
|
+
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
73
|
+
* @property {any} reportPath : directory where report is generate
|
|
74
|
+
* @property {boolean} bddMode: Feature files needs to be processed
|
|
75
|
+
* @property {number} expectTimeout: time in milliseconds which the expect condition should fail
|
|
76
|
+
* @property {number} testTimeout: time in milliseconds which the test should fail
|
|
77
|
+
* @property {Object} additionalPages: custom pages configuration
|
|
78
|
+
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
79
|
+
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
80
|
+
* @property {viewportConfig} viewport: viewport configuration
|
|
88
81
|
*/
|
|
89
82
|
|
|
90
|
-
/**
|
|
91
|
-
* Generates a configuration object from a file, if it exists.
|
|
92
|
-
*
|
|
93
|
-
* @returns {UserConfig}
|
|
83
|
+
/**
|
|
84
|
+
* Generates a configuration object from a file, if it exists.
|
|
85
|
+
*
|
|
86
|
+
* @returns {UserConfig}
|
|
94
87
|
*/
|
|
95
88
|
function generateConfigFromFile() {
|
|
96
89
|
const filePath = _path.default.resolve(process.cwd(), fileName);
|
|
@@ -17,8 +17,7 @@ const {
|
|
|
17
17
|
reportPath: htmlPath
|
|
18
18
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
19
19
|
const args = ['show-report', htmlPath].concat(userArgs);
|
|
20
|
-
|
|
21
|
-
// await preProcessReport()
|
|
20
|
+
function generateReport() {
|
|
22
21
|
const childProcess = (0, _child_process.spawn)(command, args, {
|
|
23
22
|
stdio: 'inherit'
|
|
24
23
|
});
|
|
@@ -9,6 +9,8 @@ var _test = require("@playwright/test");
|
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
var _readConfigFile = require("../readConfigFile");
|
|
11
11
|
var _configUtils = require("./config-utils");
|
|
12
|
+
var _main = require("../../../bdd-poc/main");
|
|
13
|
+
var _testDataMap = require("../../../bdd-poc/test/testDataMap");
|
|
12
14
|
const {
|
|
13
15
|
browsers,
|
|
14
16
|
trace,
|
|
@@ -22,8 +24,7 @@ const {
|
|
|
22
24
|
authFilePath,
|
|
23
25
|
viewport,
|
|
24
26
|
featureFilesFolder,
|
|
25
|
-
stepDefinitionsFolder
|
|
26
|
-
testIdAttribute
|
|
27
|
+
stepDefinitionsFolder
|
|
27
28
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
28
29
|
const projects = (0, _configUtils.getProjects)({
|
|
29
30
|
browsers,
|
|
@@ -37,19 +38,8 @@ const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd(), {
|
|
|
37
38
|
featureFilesFolder,
|
|
38
39
|
stepDefinitionsFolder
|
|
39
40
|
});
|
|
40
|
-
const testOptions = (0, _configUtils.getTestUseOptions)({
|
|
41
|
-
trace,
|
|
42
|
-
video,
|
|
43
|
-
viewport,
|
|
44
|
-
testIdAttribute
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Playwright configuration object
|
|
49
|
-
*
|
|
50
|
-
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
51
|
-
*/
|
|
52
41
|
function getPlaywrightConfig() {
|
|
42
|
+
(0, _main.cucumberBDDtoTestFile)();
|
|
53
43
|
return {
|
|
54
44
|
testDir,
|
|
55
45
|
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|
|
@@ -60,20 +50,24 @@ function getPlaywrightConfig() {
|
|
|
60
50
|
reporter: [['html', {
|
|
61
51
|
outputFolder: reportPath,
|
|
62
52
|
open: openReportOn
|
|
63
|
-
}]
|
|
53
|
+
}]],
|
|
64
54
|
timeout: testTimeout,
|
|
65
55
|
expect: {
|
|
66
56
|
timeout: expectTimeout
|
|
67
57
|
},
|
|
68
|
-
use:
|
|
58
|
+
use: {
|
|
59
|
+
viewport,
|
|
60
|
+
trace: trace ? 'on' : 'off',
|
|
61
|
+
video: video ? {
|
|
62
|
+
mode: 'on',
|
|
63
|
+
size: {
|
|
64
|
+
...viewport
|
|
65
|
+
}
|
|
66
|
+
} : 'off'
|
|
67
|
+
},
|
|
69
68
|
projects: isAuthMode ? [{
|
|
70
69
|
name: 'setup',
|
|
71
70
|
testMatch: /.*\.setup\.js/,
|
|
72
|
-
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
73
|
-
teardown: 'cleanup'
|
|
74
|
-
}, {
|
|
75
|
-
name: 'cleanup',
|
|
76
|
-
testMatch: /.*\.teardown\.js/,
|
|
77
71
|
testDir: _path.default.join(process.cwd(), 'uat')
|
|
78
72
|
}, ...projects] : [...projects]
|
|
79
73
|
};
|
|
@@ -6,15 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getProjects = getProjects;
|
|
8
8
|
exports.getTestDir = getTestDir;
|
|
9
|
-
exports.getTestUseOptions = getTestUseOptions;
|
|
10
9
|
var _test = require("@playwright/test");
|
|
11
10
|
var _path = _interopRequireDefault(require("path"));
|
|
12
11
|
var _readConfigFile = require("../readConfigFile");
|
|
13
12
|
var _bddFramework = require("../../../bdd-framework");
|
|
14
|
-
/**
|
|
15
|
-
** Playwright project configuration
|
|
16
|
-
* @returns {import('@playwright/test').Project}
|
|
17
|
-
*/
|
|
18
13
|
function getBrowserConfig({
|
|
19
14
|
browserName,
|
|
20
15
|
isAuthMode,
|
|
@@ -86,12 +81,6 @@ function getBrowserConfig({
|
|
|
86
81
|
return false;
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
* @param {*} param0
|
|
93
|
-
* @returns {import('@playwright/test').Project[]}
|
|
94
|
-
*/
|
|
95
84
|
function getProjects({
|
|
96
85
|
browsers,
|
|
97
86
|
isAuthMode,
|
|
@@ -119,23 +108,4 @@ function getTestDir(bddMode, cwd, {
|
|
|
119
108
|
outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
|
|
120
109
|
publish: true
|
|
121
110
|
}) : _path.default.join(cwd, 'uat');
|
|
122
|
-
}
|
|
123
|
-
function getTestUseOptions({
|
|
124
|
-
viewport,
|
|
125
|
-
trace,
|
|
126
|
-
video,
|
|
127
|
-
testIdAttribute
|
|
128
|
-
}) {
|
|
129
|
-
let defaultTestuseOptions = {
|
|
130
|
-
viewport,
|
|
131
|
-
testIdAttribute,
|
|
132
|
-
trace: trace ? 'on' : 'off',
|
|
133
|
-
video: video ? {
|
|
134
|
-
mode: 'on',
|
|
135
|
-
size: {
|
|
136
|
-
...viewport
|
|
137
|
-
}
|
|
138
|
-
} : 'off'
|
|
139
|
-
};
|
|
140
|
-
return defaultTestuseOptions;
|
|
141
111
|
}
|
|
@@ -13,7 +13,6 @@ var _envInitializer = require("./env-initializer");
|
|
|
13
13
|
var _logger = require("../../utils/logger");
|
|
14
14
|
var _readConfigFile = require("./readConfigFile");
|
|
15
15
|
var _rootPath = require("../../utils/rootPath");
|
|
16
|
-
var _tagProcessor = require("./tag-processor");
|
|
17
16
|
function parseUserArgs() {
|
|
18
17
|
return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
|
|
19
18
|
}
|
|
@@ -67,6 +66,7 @@ function runPlaywright(command, args) {
|
|
|
67
66
|
});
|
|
68
67
|
childProcessForRunningPlaywright.on('exit', (code, signal) => {
|
|
69
68
|
if (code !== 0) {
|
|
69
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
70
70
|
reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
71
71
|
} else {
|
|
72
72
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
|
|
@@ -74,11 +74,11 @@ function runPlaywright(command, args) {
|
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
process.on('exit', () => {
|
|
77
|
-
childProcessForRunningPlaywright.kill();
|
|
77
|
+
//childProcessForRunningPlaywright.kill();
|
|
78
78
|
reject('Terminating Playwright Process...');
|
|
79
79
|
});
|
|
80
80
|
process.on('SIGINT', () => {
|
|
81
|
-
childProcessForRunningPlaywright.kill();
|
|
81
|
+
//childProcessForRunningPlaywright.kill();
|
|
82
82
|
reject('Cleaning up...');
|
|
83
83
|
});
|
|
84
84
|
});
|
|
@@ -86,15 +86,13 @@ function runPlaywright(command, args) {
|
|
|
86
86
|
function main() {
|
|
87
87
|
const userArgsObject = parseUserArgs();
|
|
88
88
|
// eslint-disable-next-line
|
|
89
|
-
|
|
89
|
+
const tagArgs = userArgsObject['tags'];
|
|
90
90
|
const {
|
|
91
91
|
debug,
|
|
92
92
|
mode = 'dev',
|
|
93
93
|
bddMode = false,
|
|
94
|
-
headless = false
|
|
95
|
-
editionOrder
|
|
94
|
+
headless = false
|
|
96
95
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
97
|
-
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
98
96
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
99
97
|
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
100
98
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
package/build/index.d.ts
CHANGED
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
import { expect, test } from './core/playwright/index';
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
PlaywrightWorkerArgs,
|
|
7
|
-
PlaywrightWorkerOptions,
|
|
8
|
-
TestType,
|
|
9
|
-
Page
|
|
10
|
-
} from '@playwright/test';
|
|
11
|
-
import { DefineStepPattern } from '@cucumber/cucumber/lib/support_code_library_builder/types';
|
|
12
|
-
|
|
13
|
-
export type KeyValue = { [key: string]: any };
|
|
14
|
-
|
|
15
|
-
export type BuiltInFixturesWorker = PlaywrightWorkerArgs &
|
|
16
|
-
PlaywrightWorkerOptions;
|
|
17
|
-
export type BuiltInFixtures = PlaywrightTestArgs &
|
|
18
|
-
PlaywrightTestOptions &
|
|
19
|
-
BuiltInFixturesWorker;
|
|
20
|
-
|
|
21
|
-
export type FixturesArg<T extends KeyValue = {}, W extends KeyValue = {}> = T &
|
|
22
|
-
W &
|
|
23
|
-
BuiltInFixtures;
|
|
24
|
-
|
|
25
|
-
export declare let hasCustomTest: boolean;
|
|
26
|
-
|
|
27
|
-
export declare function createBdd<
|
|
28
|
-
T extends KeyValue = BuiltInFixtures,
|
|
29
|
-
W extends KeyValue = BuiltInFixturesWorker,
|
|
30
|
-
World
|
|
31
|
-
>(
|
|
32
|
-
customTest?: TestType<T, W> | null,
|
|
33
|
-
_CustomWorld?: new (...args: any[]) => World
|
|
34
|
-
): {
|
|
35
|
-
Given: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
36
|
-
When: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
37
|
-
Then: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
38
|
-
And: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
39
|
-
But: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
40
|
-
Step: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
41
|
-
Before: any;
|
|
42
|
-
After: any;
|
|
43
|
-
BeforeAll: any;
|
|
44
|
-
AfterAll: any;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type StepFunctionFixturesArg<
|
|
48
|
-
T extends KeyValue,
|
|
49
|
-
W extends KeyValue
|
|
50
|
-
> = FixturesArg<T, W>;
|
|
51
|
-
type StepFunction<T extends KeyValue, W extends KeyValue> = (
|
|
52
|
-
fixtures: StepFunctionFixturesArg<T, W>,
|
|
53
|
-
...args: any[]
|
|
54
|
-
) => unknown;
|
|
55
|
-
|
|
56
|
-
const { Given, Then, When, Step, And, But } = createBdd();
|
|
57
|
-
|
|
58
|
-
export { Given, Then, When, Step, And, But, expect, test, createBdd, Page };
|
|
59
|
-
|
|
60
|
-
export * from '@playwright/test/types/test';
|
|
1
|
+
import { Given, Then, When, Step, expect, test, createBdd } from './core/playwright/index';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
export { Given, Then, When, Step, expect, test, createBdd, fireEvent, render };
|
|
5
|
+
export * from '@playwright/test/types/test';
|
package/build/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.When = exports.Then = exports.Step = exports.Given =
|
|
6
|
+
exports.When = exports.Then = exports.Step = exports.Given = void 0;
|
|
7
7
|
Object.defineProperty(exports, "createBdd", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
@@ -35,7 +35,7 @@ var _index = require("./core/playwright/index");
|
|
|
35
35
|
// }
|
|
36
36
|
|
|
37
37
|
// import { fireEvent, render } from '@testing-library/react';
|
|
38
|
-
|
|
38
|
+
globalThis.globalStepMap = new Map();
|
|
39
39
|
const {
|
|
40
40
|
Given,
|
|
41
41
|
Then,
|
|
@@ -45,6 +45,4 @@ const {
|
|
|
45
45
|
exports.Step = Step;
|
|
46
46
|
exports.When = When;
|
|
47
47
|
exports.Then = Then;
|
|
48
|
-
exports.Given = Given;
|
|
49
|
-
const And = exports.And = Then;
|
|
50
|
-
const But = exports.But = Then;
|
|
48
|
+
exports.Given = Given;
|