@zohodesk/testinglibrary 0.0.4 → 0.0.5-exp.2
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 +6 -0
- package/bin/cli.js +1 -1
- package/bin/postinstall.js +1 -16
- package/build/bdd-framework/cli/commands/env.js +44 -0
- package/build/bdd-framework/cli/commands/export.js +95 -0
- package/build/bdd-framework/cli/commands/test.js +98 -0
- package/build/bdd-framework/cli/index.js +11 -0
- package/build/bdd-framework/cli/options.js +21 -0
- package/build/bdd-framework/cli/worker.js +27 -0
- package/build/bdd-framework/config/dir.js +27 -0
- package/build/bdd-framework/config/env.js +49 -0
- package/build/bdd-framework/config/index.js +91 -0
- package/build/bdd-framework/cucumber/buildStepDefinition.js +44 -0
- package/build/bdd-framework/cucumber/gherkin.d.ts +45 -0
- package/build/bdd-framework/cucumber/loadConfig.js +32 -0
- package/build/bdd-framework/cucumber/loadFeatures.js +55 -0
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +33 -0
- package/build/bdd-framework/cucumber/loadSources.js +89 -0
- package/build/bdd-framework/cucumber/loadSteps.js +66 -0
- package/build/bdd-framework/decorators.js +21 -0
- package/build/bdd-framework/gen/formatter.js +124 -0
- package/build/bdd-framework/gen/i18n.js +46 -0
- package/build/bdd-framework/gen/index.js +322 -0
- package/build/bdd-framework/gen/poms.js +68 -0
- package/build/bdd-framework/gen/testFile.js +422 -0
- package/build/bdd-framework/gen/testNode.js +64 -0
- package/build/bdd-framework/index.js +33 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +109 -0
- package/build/bdd-framework/playwright/getLocationInFile.js +51 -0
- package/build/bdd-framework/playwright/loadConfig.js +56 -0
- package/build/bdd-framework/playwright/testTypeImpl.js +48 -0
- package/build/bdd-framework/playwright/transform.js +86 -0
- package/build/bdd-framework/playwright/utils.js +25 -0
- package/build/bdd-framework/run/bddFixtures.js +166 -0
- package/build/bdd-framework/run/bddWorld.js +166 -0
- package/build/bdd-framework/snippets/index.js +184 -0
- package/build/bdd-framework/snippets/snippetSyntax.js +61 -0
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +42 -0
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +37 -0
- package/build/bdd-framework/stepDefinitions/createBdd.js +54 -0
- package/build/bdd-framework/stepDefinitions/createDecorators.js +123 -0
- package/build/bdd-framework/stepDefinitions/defineStep.js +64 -0
- package/build/bdd-framework/utils/index.js +59 -0
- package/build/bdd-framework/utils/jsStringWrap.js +45 -0
- package/build/bdd-framework/utils/logger.js +23 -0
- package/build/core/jest/preprocessor/jsPreprocessor.js +13 -0
- package/{src → build}/core/jest/runner/jest-runner.js +18 -17
- package/build/core/jest/setup/index.js +9 -0
- package/build/core/playwright/codegen.js +56 -0
- package/build/core/playwright/custom-commands.js +8 -0
- package/build/core/playwright/env-initializer.js +22 -0
- package/build/core/playwright/index.js +117 -0
- package/build/core/playwright/readConfigFile.js +61 -0
- package/build/core/playwright/report-generator.js +43 -0
- package/build/core/playwright/setup/config-creator.js +107 -0
- package/build/core/playwright/test-runner.js +102 -0
- package/build/index.js +37 -0
- package/build/lib/cli.js +47 -0
- package/build/lib/post-install.js +17 -0
- package/build/lint/index.js +6 -0
- package/build/setup-folder-structure/env-config-sample.json +17 -0
- package/build/setup-folder-structure/setupProject.js +102 -0
- package/build/setup-folder-structure/uat-config-sample.js +27 -0
- package/build/setup-folder-structure/user-example.json +3 -0
- package/build/utils/cliArgsToObject.js +64 -0
- package/build/utils/getFilePath.js +11 -0
- package/build/utils/logger.js +66 -0
- package/build/utils/rootPath.js +46 -0
- package/changelog.md +14 -0
- package/npm-shrinkwrap.json +2097 -147
- package/package.json +18 -4
- package/playwright.config.js +1 -1
- package/src/core/jest/preprocessor/jsPreprocessor.js +0 -9
- package/src/core/jest/setup/index.js +0 -165
- package/src/core/playwright/codegen.js +0 -60
- package/src/core/playwright/custom-commands.js +0 -3
- package/src/core/playwright/env-initializer.js +0 -24
- package/src/core/playwright/index.js +0 -82
- package/src/core/playwright/readConfigFile.js +0 -30
- package/src/core/playwright/report-generator.js +0 -43
- package/src/core/playwright/setup/config-creator.js +0 -77
- package/src/core/playwright/test-runner.js +0 -64
- package/src/index.js +0 -9
- package/src/lib/cli.js +0 -35
- package/src/utils/cliArgsToObject.js +0 -35
- package/src/utils/getFilePath.js +0 -9
- package/src/utils/logger.js +0 -28
- package/src/utils/rootPath.js +0 -51
package/build/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "createBdd", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _index.createBdd;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "expect", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _index.expect;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "fireEvent", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _react.fireEvent;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "render", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _react.render;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "test", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _index.test;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _index = require("./core/playwright/index");
|
|
37
|
+
var _react = require("@testing-library/react");
|
package/build/lib/cli.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
5
|
+
var _testRunner = _interopRequireDefault(require("../core/playwright/test-runner"));
|
|
6
|
+
var _jestRunner = _interopRequireDefault(require("../core/jest/runner/jest-runner"));
|
|
7
|
+
var _reportGenerator = _interopRequireDefault(require("../core/playwright/report-generator"));
|
|
8
|
+
var _codegen = _interopRequireDefault(require("../core/playwright/codegen"));
|
|
9
|
+
var _logger = require("../utils/logger");
|
|
10
|
+
var _setupProject = _interopRequireDefault(require("../setup-folder-structure/setupProject"));
|
|
11
|
+
var _process$argv = (0, _slicedToArray2["default"])(process.argv, 3),
|
|
12
|
+
option = _process$argv[2];
|
|
13
|
+
var args = process.argv.slice(3);
|
|
14
|
+
var appPath = process.cwd();
|
|
15
|
+
switch (option) {
|
|
16
|
+
case 'test':
|
|
17
|
+
{
|
|
18
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Running Tests..');
|
|
19
|
+
(0, _testRunner["default"])();
|
|
20
|
+
//createJestRunner();
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case 'report':
|
|
24
|
+
{
|
|
25
|
+
// console.log('\x1b[36mGenerating Reports...\x1b[0m');
|
|
26
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Generating Reports...');
|
|
27
|
+
(0, _reportGenerator["default"])();
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case 'codegen':
|
|
31
|
+
{
|
|
32
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'The purpose of codegen is to assist developer .....');
|
|
33
|
+
(0, _codegen["default"])();
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case 'init':
|
|
37
|
+
{
|
|
38
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Initializing projects...');
|
|
39
|
+
(0, _setupProject["default"])();
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
default:
|
|
43
|
+
{
|
|
44
|
+
console.log('Supported Commands test and report');
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _path = _interopRequireDefault(require("path"));
|
|
5
|
+
var _child_process = require("child_process");
|
|
6
|
+
var _logger = require("../utils/logger");
|
|
7
|
+
var _getFilePath = _interopRequireDefault(require("../utils/getFilePath"));
|
|
8
|
+
var playwrightPath = _path["default"].resolve('node_modules', '.bin', (0, _getFilePath["default"])('playwright'));
|
|
9
|
+
var command = playwrightPath;
|
|
10
|
+
var args = ['install'];
|
|
11
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Downloading browsers for running tests');
|
|
12
|
+
var childProcess = (0, _child_process.spawn)(command, args, {
|
|
13
|
+
stdio: 'inherit'
|
|
14
|
+
});
|
|
15
|
+
childProcess.on('error', function (error) {
|
|
16
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
17
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dev": {
|
|
3
|
+
"domain": "https://desk.localzoho.com/agent",
|
|
4
|
+
"username": "your-username",
|
|
5
|
+
"password": "your-password"
|
|
6
|
+
},
|
|
7
|
+
"prod": {
|
|
8
|
+
"domain": "https://desk.localzoho.com/agent",
|
|
9
|
+
"username": "your-username",
|
|
10
|
+
"password": "your-password"
|
|
11
|
+
},
|
|
12
|
+
"k8test": {
|
|
13
|
+
"domain": "https://desk.localzoho.com/agent",
|
|
14
|
+
"username": "your-username",
|
|
15
|
+
"password": "your-password"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = setupProject;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _fs = require("fs");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _logger = require("../utils/logger");
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function getScriptsToBeAdded() {
|
|
15
|
+
return {
|
|
16
|
+
"ua-test": "ZDTestingFramework test --mode=prod --headed",
|
|
17
|
+
"ua-test-debug": "ZDTestingFramework test --mode=prod --debug",
|
|
18
|
+
"ua-report": "ZDTestingFramework report --port=9009",
|
|
19
|
+
"codegen": "ZDTestingFramework codegen deskclientapp.localzoho.com/agent"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function updatePackageJSONScripts() {
|
|
23
|
+
var packageJsonPath = _path["default"].resolve(process.cwd(), './package.json');
|
|
24
|
+
if ((0, _fs.existsSync)(packageJsonPath)) {
|
|
25
|
+
var packageContents = (0, _fs.readFileSync)(packageJsonPath);
|
|
26
|
+
var configJSON = JSON.parse(packageContents);
|
|
27
|
+
var _configJSON$scripts = configJSON.scripts,
|
|
28
|
+
scripts = _configJSON$scripts === void 0 ? {} : _configJSON$scripts;
|
|
29
|
+
var modifiedScripts = _objectSpread(_objectSpread({}, scripts), getScriptsToBeAdded());
|
|
30
|
+
var modifiedConfigJSON = _objectSpread(_objectSpread({}, configJSON), {}, {
|
|
31
|
+
scripts: modifiedScripts
|
|
32
|
+
});
|
|
33
|
+
(0, _fs.writeFileSync)(packageJsonPath, JSON.stringify(modifiedConfigJSON, null, 2));
|
|
34
|
+
} else {
|
|
35
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Unable to find package json. Run init command in the root path of the project.');
|
|
36
|
+
process.exit();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function createFolderForUAT() {
|
|
40
|
+
var uatFolder = _path["default"].resolve(process.cwd(), 'uat');
|
|
41
|
+
if ((0, _fs.existsSync)(uatFolder)) {
|
|
42
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Uat Folder already Exists.');
|
|
43
|
+
process.exit();
|
|
44
|
+
} else {
|
|
45
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Uat Folder');
|
|
46
|
+
(0, _fs.mkdirSync)(uatFolder);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function getSetupFileAsString(fileName) {
|
|
50
|
+
return (0, _fs.readFileSync)(_path["default"].resolve(__dirname, './', fileName)).toString();
|
|
51
|
+
}
|
|
52
|
+
function createUatConfig() {
|
|
53
|
+
var uatConfigPath = _path["default"].resolve(process.cwd(), 'uat.config.js');
|
|
54
|
+
if ((0, _fs.existsSync)(uatConfigPath)) {
|
|
55
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Uat Config already Exists.');
|
|
56
|
+
process.exit();
|
|
57
|
+
} else {
|
|
58
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Uat config file...');
|
|
59
|
+
(0, _fs.writeFileSync)(uatConfigPath, getSetupFileAsString('uat-config-sample.js'), null, 2);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function createAuthenticationFile() {
|
|
63
|
+
var isUATexist = _path["default"].resolve(process.cwd(), 'uat');
|
|
64
|
+
if ((0, _fs.existsSync)(isUATexist)) {
|
|
65
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
|
|
66
|
+
try {
|
|
67
|
+
(0, _fs.mkdirSync)(_path["default"].resolve(process.cwd(), 'playwright'), {
|
|
68
|
+
recursive: true
|
|
69
|
+
});
|
|
70
|
+
(0, _fs.mkdirSync)(_path["default"].resolve(process.cwd(), 'playwright', '.auth'), {
|
|
71
|
+
recursive: true
|
|
72
|
+
});
|
|
73
|
+
var authFilePath = _path["default"].resolve(process.cwd(), 'playwright', '.auth', 'user.json');
|
|
74
|
+
(0, _fs.writeFileSync)(authFilePath, getSetupFileAsString('user-example.json'), null, 2);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Something went wrong ! Folder not Created. Please re-initialize npm init-uat');
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Something went wrong. Please re-initialize the @zohodesk/testinglibrary');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function createConfigJson() {
|
|
83
|
+
var uatFolder = _path["default"].resolve(process.cwd(), 'uat');
|
|
84
|
+
if ((0, _fs.existsSync)(uatFolder)) {
|
|
85
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating env-config file inside UAT Folder');
|
|
86
|
+
(0, _fs.writeFileSync)(_path["default"].resolve(uatFolder, './env-config.json'), getSetupFileAsString('env-config-sample.json'), null, 2);
|
|
87
|
+
} else {
|
|
88
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Something went wrong. Please re-initialize the @zohodesk/testinglibrary');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function setupProject() {
|
|
92
|
+
updatePackageJSONScripts();
|
|
93
|
+
createUatConfig();
|
|
94
|
+
createFolderForUAT();
|
|
95
|
+
createConfigJson();
|
|
96
|
+
createAuthenticationFile();
|
|
97
|
+
// Create folder for playwright . Inside .auth folder needs to be created. user.json
|
|
98
|
+
// Add playwright and test-results to .gitignore
|
|
99
|
+
setTimeout(function () {
|
|
100
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Setup Project is Ready ..');
|
|
101
|
+
}, 2000);
|
|
102
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents the user configuration object.
|
|
5
|
+
* @typedef {Object} UserConfig
|
|
6
|
+
* @property {string} headless - Headless Browsers mode.
|
|
7
|
+
* @property {number} trace - trace for test cases.
|
|
8
|
+
* @property {boolean} video - video for test cases,
|
|
9
|
+
* @property {boolean} debug - debug mode
|
|
10
|
+
* @property {string} mode: mode in which the test cases needs to run
|
|
11
|
+
* @property {boolean} isAuthMode - Auth Mode
|
|
12
|
+
* @property {any} browsers: List of browsers
|
|
13
|
+
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
14
|
+
* @property {any} reportPath : directory where report is generate
|
|
15
|
+
* @property {boolean} isCucumberPreprocessingRequired: Feature files needs to be processed
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @type {UserConfig}
|
|
19
|
+
*/
|
|
20
|
+
module.exports = {
|
|
21
|
+
headed: true,
|
|
22
|
+
browsers: ['Chrome', 'Firefox'],
|
|
23
|
+
mode: 'dev',
|
|
24
|
+
isAuthMode: true,
|
|
25
|
+
trace: true,
|
|
26
|
+
video: true
|
|
27
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cliArgsToObject = cliArgsToObject;
|
|
7
|
+
exports.objectToCliArgs = objectToCliArgs;
|
|
8
|
+
/**
|
|
9
|
+
* Converts an array of command-line arguments into an object.
|
|
10
|
+
*
|
|
11
|
+
* @param {string[]} cliArgs - An array of command-line arguments.
|
|
12
|
+
* @param {boolean} [isKeyNeedToBeAdded=true] - Indicates whether the keys should be added to the resulting object.
|
|
13
|
+
* @returns {Object} An object representing the command-line arguments, where keys are argument names (without '--') and values are argument values.
|
|
14
|
+
* If `isKeyNeedToBeAdded` is set to `false`, only values are included in the object with numeric indexes as keys.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Example usage:
|
|
18
|
+
* const args = ['--port=8080', '--verbose', 'input.txt'];
|
|
19
|
+
* const result = cliArgsToObject(args);
|
|
20
|
+
* // result will be: { port: '8080', verbose: true }
|
|
21
|
+
*/
|
|
22
|
+
function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
|
|
23
|
+
var processEnv = {};
|
|
24
|
+
cliArgs.forEach(function (option) {
|
|
25
|
+
if (/^--./.test(option)) {
|
|
26
|
+
var equIndex = option.indexOf('=');
|
|
27
|
+
var key = option.slice(2, equIndex);
|
|
28
|
+
var value = option.slice(equIndex + 1);
|
|
29
|
+
if (equIndex === -1) {
|
|
30
|
+
key = option.slice(2);
|
|
31
|
+
value = true;
|
|
32
|
+
}
|
|
33
|
+
processEnv[key] = value;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return processEnv;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Converts an object to an array of command-line arguments.
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} objectToBeConverted - The object to be converted to command-line arguments.
|
|
43
|
+
* @param {(string|function(string): boolean)} [isKeyNeedToBeAdded=true] - A string representing a key, or a function that determines whether a key should be added to the resulting array.
|
|
44
|
+
* @returns {string[]} An array of command-line arguments generated from the object's key-value pairs. Keys are transformed into argument names (with '--') and values are added as argument values.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Example usage:
|
|
48
|
+
* const options = { port: 8080, verbose: true, input: 'input.txt' };
|
|
49
|
+
* const args = objectToCliArgs(options);
|
|
50
|
+
* // args will be: ['--port=8080', '--verbose', '--input=input.txt']
|
|
51
|
+
*/
|
|
52
|
+
function objectToCliArgs(objectToBeConverted, isKeyNeedToBeAdded) {
|
|
53
|
+
var argsArray = [];
|
|
54
|
+
Object.keys(objectToBeConverted).forEach(function (key) {
|
|
55
|
+
if (isKeyNeedToBeAdded(key)) {
|
|
56
|
+
if (typeof objectToBeConverted[key] === 'boolean' && objectToBeConverted[key]) {
|
|
57
|
+
argsArray.push("--".concat(key));
|
|
58
|
+
} else {
|
|
59
|
+
argsArray.push("--".concat(key, "=").concat(objectToBeConverted[key]));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return argsArray;
|
|
64
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = getFilePathWithExtension;
|
|
7
|
+
var _os = require("os");
|
|
8
|
+
var isWindows = (0, _os.platform)().toLowerCase() === 'win32';
|
|
9
|
+
function getFilePathWithExtension(binName) {
|
|
10
|
+
return isWindows ? "".concat(binName, ".cmd") : binName;
|
|
11
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.Logger = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
// const SUCCESS_TYPE = 'success';
|
|
12
|
+
// const FAILURE_TYPE = 'failure';
|
|
13
|
+
// const INFO_TYPE = 'info';
|
|
14
|
+
// function logger() {
|
|
15
|
+
// this.colors = {
|
|
16
|
+
// 'success': ['\x1b[36m', '\x1b[0m'],
|
|
17
|
+
// 'failure': ['\x1b[31m', '\x1b[0m'],
|
|
18
|
+
// 'info': ['\x1b[33m', '\x1b[0m']
|
|
19
|
+
// }
|
|
20
|
+
// this.consoleLogger = console;
|
|
21
|
+
// return {
|
|
22
|
+
// SUCCESS_TYPE,
|
|
23
|
+
// FAILURE_TYPE,
|
|
24
|
+
// INFO_TYPE,
|
|
25
|
+
// error: () => { },
|
|
26
|
+
// info: () => { },
|
|
27
|
+
// log: (type, message) => {
|
|
28
|
+
// const color = this.colors[type];
|
|
29
|
+
// console.log(type, color)
|
|
30
|
+
// this.consoleLogger.log(`${color[0]}${message}${color[1]}`)
|
|
31
|
+
// }
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
34
|
+
// module.exports = {
|
|
35
|
+
// Logger: logger()
|
|
36
|
+
// }
|
|
37
|
+
var LoggerImpl = /*#__PURE__*/function () {
|
|
38
|
+
function LoggerImpl() {
|
|
39
|
+
(0, _classCallCheck2["default"])(this, LoggerImpl);
|
|
40
|
+
(0, _defineProperty2["default"])(this, "SUCCESS_TYPE", 'success');
|
|
41
|
+
(0, _defineProperty2["default"])(this, "FAILURE_TYPE", 'failure');
|
|
42
|
+
(0, _defineProperty2["default"])(this, "INFO_TYPE", 'info');
|
|
43
|
+
this.colors = {
|
|
44
|
+
'success': ['\x1b[36m', '\x1b[0m'],
|
|
45
|
+
'failure': ['\x1b[31m', '\x1b[0m'],
|
|
46
|
+
'info': ['\x1b[33m', '\x1b[0m']
|
|
47
|
+
};
|
|
48
|
+
this.consoleLogger = console;
|
|
49
|
+
}
|
|
50
|
+
(0, _createClass2["default"])(LoggerImpl, [{
|
|
51
|
+
key: "error",
|
|
52
|
+
value: function error() {}
|
|
53
|
+
}, {
|
|
54
|
+
key: "info",
|
|
55
|
+
value: function info() {}
|
|
56
|
+
}, {
|
|
57
|
+
key: "log",
|
|
58
|
+
value: function log(type, message) {
|
|
59
|
+
var color = this.colors[type];
|
|
60
|
+
this.consoleLogger.log("".concat(color[0]).concat(message).concat(color[1]));
|
|
61
|
+
}
|
|
62
|
+
}]);
|
|
63
|
+
return LoggerImpl;
|
|
64
|
+
}();
|
|
65
|
+
var Logger = new LoggerImpl();
|
|
66
|
+
exports.Logger = Logger;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getBinPath = getBinPath;
|
|
8
|
+
exports.getExecutableBinaryPath = getExecutableBinaryPath;
|
|
9
|
+
exports.getRootNodeModulesPath = getRootNodeModulesPath;
|
|
10
|
+
exports.getRootPath = getRootPath;
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
13
|
+
var _logger = require("./logger");
|
|
14
|
+
var _getFilePath = _interopRequireDefault(require("./getFilePath"));
|
|
15
|
+
function findBinaryPath(directory, command) {
|
|
16
|
+
var binaryPath = _path["default"].join(directory, '.bin', (0, _getFilePath["default"])(command));
|
|
17
|
+
if (_fs["default"].existsSync(binaryPath)) {
|
|
18
|
+
return binaryPath;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Recursively search parent directories. Might be time-consuming ?? Can we look for npm module like which?
|
|
22
|
+
var parentDir = _path["default"].dirname(directory);
|
|
23
|
+
if (parentDir === directory) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return findBinaryPath(parentDir, command);
|
|
27
|
+
}
|
|
28
|
+
function getRootPath() {
|
|
29
|
+
return _path["default"].resolve(__dirname, '../', '../');
|
|
30
|
+
}
|
|
31
|
+
function getRootNodeModulesPath() {
|
|
32
|
+
return _path["default"].resolve(getRootPath(), 'node_modules');
|
|
33
|
+
}
|
|
34
|
+
function getBinPath(command) {
|
|
35
|
+
var packageNodeModulesPath = getRootNodeModulesPath();
|
|
36
|
+
return findBinaryPath(packageNodeModulesPath, command);
|
|
37
|
+
}
|
|
38
|
+
function getExecutableBinaryPath(command) {
|
|
39
|
+
var binPath = getBinPath(command);
|
|
40
|
+
if (binPath !== null) {
|
|
41
|
+
return binPath;
|
|
42
|
+
} else {
|
|
43
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, "Error: Could not find executable bin ".concat(command, " file. Make sure to npm install before proceeding"));
|
|
44
|
+
process.exit();
|
|
45
|
+
}
|
|
46
|
+
}
|
package/changelog.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
4
|
|
|
5
|
+
# 0.0.5-exp.2
|
|
6
|
+
|
|
7
|
+
- Provided Initial Support for cucumber feature files
|
|
8
|
+
- Playwright-bdd and cucumber
|
|
9
|
+
- Added config isCucumberPreprocessingRequired which toggles the feature files processing
|
|
10
|
+
- Internal Library change
|
|
11
|
+
- Provided support for import/export statements
|
|
12
|
+
|
|
13
|
+
# 0.0.5
|
|
14
|
+
|
|
15
|
+
- Added Init command to initialize the folder structure and configuration for testing
|
|
16
|
+
- Renamed config.json to env-config.json
|
|
17
|
+
- Configured report file path directory and Handled Edge case in Cookies Handling
|
|
18
|
+
|
|
5
19
|
# 0.0.4
|
|
6
20
|
|
|
7
21
|
- Issue Fixes while loading the storage state
|