@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
|
@@ -1,29 +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.default = void 0;
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _fileUtils = require("../../utils/fileUtils");
|
|
10
|
-
var _logger = require("../../utils/logger");
|
|
11
|
-
var _readConfigFile = require("./readConfigFile");
|
|
12
|
-
function clearCaches() {
|
|
13
|
-
try {
|
|
14
|
-
const {
|
|
15
|
-
authFilePath,
|
|
16
|
-
reportPath
|
|
17
|
-
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
18
|
-
authFilePath.split('/').pop();
|
|
19
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting auth files present in ${authFilePath}`);
|
|
20
|
-
(0, _fileUtils.deleteFolder)(_path.default.resolve(process.cwd(), authFilePath));
|
|
21
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting Playwright report ${reportPath}`);
|
|
22
|
-
(0, _fileUtils.deleteFolder)(reportPath);
|
|
23
|
-
(0, _fileUtils.deleteFolder)(_path.default.resolve(process.cwd(), 'uat', '.features-gen'));
|
|
24
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Caches Cleared');
|
|
25
|
-
} catch (err) {
|
|
26
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error While clearing cookies');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
var _default = exports.default = clearCaches;
|
|
@@ -1,100 +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.default = void 0;
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _readline = _interopRequireDefault(require("readline"));
|
|
10
|
-
var _fileUtils = require("../../../utils/fileUtils");
|
|
11
|
-
var _readConfigFile = require("../readConfigFile");
|
|
12
|
-
var _logger = require("../../../utils/logger");
|
|
13
|
-
class JSONSummaryReporter {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.durationInMS = -1;
|
|
16
|
-
this.passed = [];
|
|
17
|
-
this.skipped = [];
|
|
18
|
-
this.failed = [];
|
|
19
|
-
this.warned = [];
|
|
20
|
-
this.interrupted = [];
|
|
21
|
-
this.timedOut = [];
|
|
22
|
-
this.flakey = [];
|
|
23
|
-
this.status = 'unknown';
|
|
24
|
-
this.startedAt = 0;
|
|
25
|
-
this._open = (0, _readConfigFile.generateConfigFromFile)().openReportOn;
|
|
26
|
-
}
|
|
27
|
-
onBegin() {
|
|
28
|
-
this.startedAt = Date.now();
|
|
29
|
-
}
|
|
30
|
-
onTestEnd(test, result) {
|
|
31
|
-
const title = [];
|
|
32
|
-
const fileName = [];
|
|
33
|
-
let clean = true;
|
|
34
|
-
for (const s of test.titlePath()) {
|
|
35
|
-
if (s === '' && clean) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
clean = false;
|
|
39
|
-
title.push(s);
|
|
40
|
-
if (s.includes('.ts') || s.includes('.js')) {
|
|
41
|
-
fileName.push(s);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// This will publish the file name + line number test begins on
|
|
45
|
-
const z = `${fileName[0]}:${test.location.line}:${test.location.column}`;
|
|
46
|
-
// Using the t variable in the push will push a full test name + test description
|
|
47
|
-
const t = title.join(' > ');
|
|
48
|
-
// Set the status
|
|
49
|
-
const status = !['passed', 'skipped'].includes(result.status) && t.includes('@warn') ? 'warned' : result.status;
|
|
50
|
-
// Logic to push the results into the correct array
|
|
51
|
-
if (result.status === 'passed' && result.retry >= 1) {
|
|
52
|
-
this.flakey.push(z);
|
|
53
|
-
} else {
|
|
54
|
-
this[status].push(z);
|
|
55
|
-
}
|
|
56
|
-
this[status].push(z);
|
|
57
|
-
}
|
|
58
|
-
onEnd(result) {
|
|
59
|
-
this.durationInMS = Date.now() - this.startedAt;
|
|
60
|
-
this.status = result.status;
|
|
61
|
-
// removing duplicate tests from passed array
|
|
62
|
-
this.passed = this.passed.filter((element, index) => {
|
|
63
|
-
return this.passed.indexOf(element) === index;
|
|
64
|
-
});
|
|
65
|
-
// removing duplicate tests from the failed array
|
|
66
|
-
this.failed = this.failed.filter((element, index) => {
|
|
67
|
-
if (!this.passed.includes(element)) {
|
|
68
|
-
return this.failed.indexOf(element) === index;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
// removing duplicate tests from the skipped array
|
|
72
|
-
this.skipped = this.skipped.filter((element, index) => {
|
|
73
|
-
return this.skipped.indexOf(element) === index;
|
|
74
|
-
});
|
|
75
|
-
// removing duplicate tests from the timedOut array
|
|
76
|
-
this.timedOut = this.timedOut.filter((element, index) => {
|
|
77
|
-
return this.timedOut.indexOf(element) === index;
|
|
78
|
-
});
|
|
79
|
-
// removing duplicate tests from the interrupted array
|
|
80
|
-
this.interrupted = this.interrupted.filter((element, index) => {
|
|
81
|
-
return this.interrupted.indexOf(element) === index;
|
|
82
|
-
});
|
|
83
|
-
// fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));
|
|
84
|
-
let {
|
|
85
|
-
reportPath
|
|
86
|
-
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
87
|
-
(0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', 'test-summary.json'), JSON.stringify(this, null, ' '));
|
|
88
|
-
}
|
|
89
|
-
onExit() {
|
|
90
|
-
const shouldClearLastLine = this._open !== 'always' || this._open !== 'on-failure';
|
|
91
|
-
if (shouldClearLastLine) {
|
|
92
|
-
/**Below code is to replace the playwright default report commond with abstraction tool command */
|
|
93
|
-
_readline.default.moveCursor(process.stdout, 0, -2); // up two line
|
|
94
|
-
_readline.default.clearLine(process.stdout, 1); // from cursor to end
|
|
95
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'npx ZDTestingFramework report or npm run uat-report');
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
var _default = exports.default = JSONSummaryReporter;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.tagProcessor = tagProcessor;
|
|
7
|
-
var _logger = require("../../utils/logger");
|
|
8
|
-
/* eslint-disable dot-notation */
|
|
9
|
-
|
|
10
|
-
function getTagsString(tags, editionTags) {
|
|
11
|
-
return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
|
|
12
|
-
}
|
|
13
|
-
function getEdition(edition) {
|
|
14
|
-
if (edition.startsWith('<=')) {
|
|
15
|
-
return ['<=', edition.slice(2)];
|
|
16
|
-
} else if (edition.startsWith('>=')) {
|
|
17
|
-
return ['>=', edition.slice(2)];
|
|
18
|
-
} else if (edition.startsWith('<')) {
|
|
19
|
-
return ['<', edition.slice(1)];
|
|
20
|
-
} else if (edition.startsWith('>')) {
|
|
21
|
-
return ['>', edition.slice(1)];
|
|
22
|
-
}
|
|
23
|
-
return [null, edition];
|
|
24
|
-
}
|
|
25
|
-
function editionPreprocessing(editionOrder, selectedEdition) {
|
|
26
|
-
const [operator, editionToBeSearched] = getEdition(selectedEdition.toLowerCase());
|
|
27
|
-
const index = editionOrder.findIndex(edition => edition.toLowerCase() === editionToBeSearched);
|
|
28
|
-
if (index !== -1) {
|
|
29
|
-
let resultArray;
|
|
30
|
-
if (operator === '<=') {
|
|
31
|
-
resultArray = editionOrder.slice(index + 1);
|
|
32
|
-
} else if (operator === '>=') {
|
|
33
|
-
resultArray = editionOrder.slice(0, index);
|
|
34
|
-
} else if (operator === '<') {
|
|
35
|
-
resultArray = editionOrder.slice(index);
|
|
36
|
-
} else if (operator === '>') {
|
|
37
|
-
resultArray = editionOrder.slice(0, index + 1);
|
|
38
|
-
} else {
|
|
39
|
-
resultArray = editionOrder.filter((_, order) => order !== index);
|
|
40
|
-
}
|
|
41
|
-
return resultArray;
|
|
42
|
-
}
|
|
43
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
function buildEditionTags(editionArgs, operator) {
|
|
47
|
-
return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
|
|
48
|
-
}
|
|
49
|
-
function tagProcessor(userArgsObject, editionOrder) {
|
|
50
|
-
let tagArgs = userArgsObject['tags'];
|
|
51
|
-
const edition = userArgsObject['edition'] || null;
|
|
52
|
-
if (edition !== null) {
|
|
53
|
-
let editionsArray = edition.split(',');
|
|
54
|
-
if (editionsArray.length === 1) {
|
|
55
|
-
const editionArgs = editionPreprocessing(editionOrder, edition);
|
|
56
|
-
if (editionArgs && editionArgs.length > 0) {
|
|
57
|
-
const editionTags = buildEditionTags(editionArgs, 'or');
|
|
58
|
-
tagArgs = `${getTagsString(tagArgs, editionTags)}`;
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
// More than one edition given
|
|
62
|
-
const filteredEditions = editionOrder.filter(edition => !editionsArray.includes(edition));
|
|
63
|
-
const editionTags = buildEditionTags(filteredEditions, 'or');
|
|
64
|
-
tagArgs = `${getTagsString(tagArgs, editionTags)}`;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return tagArgs;
|
|
68
|
-
}
|
|
@@ -1,34 +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.default = void 0;
|
|
8
|
-
var _commander = require("commander");
|
|
9
|
-
var _fs = require("fs");
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
var _logger = require("../utils/logger");
|
|
12
|
-
function helpercmd() {
|
|
13
|
-
const packageJsonPath = _path.default.resolve(process.cwd(), './package.json');
|
|
14
|
-
if ((0, _fs.existsSync)(packageJsonPath) && process.argv.includes('--version')) {
|
|
15
|
-
const {
|
|
16
|
-
dependencies
|
|
17
|
-
} = require(packageJsonPath);
|
|
18
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `zohodesk/testinglibrary Version : ${dependencies['@zohodesk/testinglibrary']}`);
|
|
19
|
-
_commander.program.version(dependencies['@zohodesk/testinglibrary'] || '0.0.1');
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Supported Commands...');
|
|
23
|
-
_commander.program.name('npx ZDTestingFramework');
|
|
24
|
-
_commander.program.command('test').description('This command is used to execute tests');
|
|
25
|
-
_commander.program.command('init').description('This command will initialize Project');
|
|
26
|
-
_commander.program.command('report').description('This command is used to generate a report summarizing the results of executed tests.');
|
|
27
|
-
_commander.program.command('codegen').description('This command is used to assist developer to write test case');
|
|
28
|
-
_commander.program.option('--headed', 'Run tests with a headed browser.');
|
|
29
|
-
_commander.program.option('--debug', 'This command is used to initiate a debugging session');
|
|
30
|
-
_commander.program.option('--tags', 'Run specific test case with mentioned tags (Usage: -- --tags="@live")');
|
|
31
|
-
_commander.program.option('--workers', 'Specify number of workers to run the test case parallely (Usage: -- --workers=2)');
|
|
32
|
-
_commander.program.parse(process.argv);
|
|
33
|
-
}
|
|
34
|
-
var _default = exports.default = helpercmd;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
function sortEdition(event) {
|
|
3
|
-
var currentURL = window.location.href;
|
|
4
|
-
const endPointCount = window.location.href.indexOf('#');
|
|
5
|
-
if (!(endPointCount == -1)) {
|
|
6
|
-
window.history.pushState({}, '', currentURL.slice(0, endPointCount));
|
|
7
|
-
currentURL = currentURL.slice(0, endPointCount);
|
|
8
|
-
}
|
|
9
|
-
console.log(currentURL);
|
|
10
|
-
window.open(`${currentURL}#?q=@edition_${event.target.value}`, '_self');
|
|
11
|
-
}
|
|
12
|
-
</script>
|
|
13
|
-
<div class="mainContainer" style="margin-left: 20px; display: flex;">
|
|
14
|
-
<div class="selectEditionContainer" style="padding: 20px;">
|
|
15
|
-
<select class="selectEdition" style="padding: 5px; width: 100px; border-radius: 6px; border: 1px solid var(--color-border-default);" onchange="sortEdition(event)">
|
|
16
|
-
<option value="EnterPrise">EnterPrise</option>
|
|
17
|
-
<option value="Professional">Professional</option>
|
|
18
|
-
<option value="Express">Express</option>
|
|
19
|
-
<option value="Standard">Standard</option>
|
|
20
|
-
<option value="Free">Free</option>
|
|
21
|
-
</select>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
|
|
25
|
-
|
|
@@ -1,25 +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.preProcessReport = preProcessReport;
|
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
var _logger = require("./../../utils/logger");
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
const htmlFilePath = _path.default.resolve(process.cwd(), 'uat', 'playwright-report', 'index.html');
|
|
12
|
-
const fileHtml = _fs.default.readFileSync(htmlFilePath, 'utf-8');
|
|
13
|
-
const addOnHtml = _fs.default.readFileSync(_path.default.resolve(__filename, '../', 'addonScript.html'), 'utf-8');
|
|
14
|
-
const splitedHTML = fileHtml.split('\n');
|
|
15
|
-
const toAdd = addOnHtml.split('\n');
|
|
16
|
-
function preProcessReport() {
|
|
17
|
-
if (_fs.default.existsSync(htmlFilePath)) {
|
|
18
|
-
const modifiedContent = [...splitedHTML.slice(0, 55), ...toAdd, ...splitedHTML.slice(56)].join('').toString();
|
|
19
|
-
_fs.default.writeFileSync(htmlFilePath, modifiedContent);
|
|
20
|
-
return;
|
|
21
|
-
} else {
|
|
22
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Report is not generated Properly ...');
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|