@zohodesk/testinglibrary 0.0.5 → 0.0.6
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 +19 -0
- package/.eslintrc.js +27 -0
- package/.prettierrc +6 -0
- package/{changelog.md → Changelog.md} +38 -25
- package/README.md +17 -17
- package/bin/cli.js +2 -2
- package/bin/postinstall.js +1 -16
- package/build/bdd-framework/cli/commands/env.js +43 -0
- package/build/bdd-framework/cli/commands/export.js +48 -0
- package/build/bdd-framework/cli/commands/test.js +59 -0
- package/build/bdd-framework/cli/index.js +11 -0
- package/build/bdd-framework/cli/options.js +20 -0
- package/build/bdd-framework/cli/worker.js +13 -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 +43 -0
- package/build/bdd-framework/cucumber/gherkin.d.js +5 -0
- package/build/bdd-framework/cucumber/gherkin.d.ts +45 -0
- package/build/bdd-framework/cucumber/loadConfig.js +17 -0
- package/build/bdd-framework/cucumber/loadFeatures.js +39 -0
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +20 -0
- package/build/bdd-framework/cucumber/loadSources.js +57 -0
- package/build/bdd-framework/cucumber/loadSteps.js +35 -0
- package/build/bdd-framework/decorators.js +22 -0
- package/build/bdd-framework/gen/formatter.js +88 -0
- package/build/bdd-framework/gen/i18n.js +35 -0
- package/build/bdd-framework/gen/index.js +160 -0
- package/build/bdd-framework/gen/poms.js +46 -0
- package/build/bdd-framework/gen/testFile.js +356 -0
- package/build/bdd-framework/gen/testNode.js +48 -0
- package/build/bdd-framework/gen/testPoms.js +123 -0
- package/build/bdd-framework/index.js +45 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +77 -0
- package/build/bdd-framework/playwright/getLocationInFile.js +46 -0
- package/build/bdd-framework/playwright/loadConfig.js +42 -0
- package/build/bdd-framework/playwright/testTypeImpl.js +41 -0
- package/build/bdd-framework/playwright/transform.js +80 -0
- package/build/bdd-framework/playwright/types.js +5 -0
- package/build/bdd-framework/playwright/utils.js +34 -0
- package/build/bdd-framework/run/bddFixtures.js +108 -0
- package/build/bdd-framework/run/bddWorld.js +87 -0
- package/build/bdd-framework/snippets/index.js +131 -0
- package/build/bdd-framework/snippets/snippetSyntax.js +41 -0
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +26 -0
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +18 -0
- package/build/bdd-framework/stepDefinitions/createBdd.js +49 -0
- package/build/bdd-framework/stepDefinitions/createDecorators.js +109 -0
- package/build/bdd-framework/stepDefinitions/decorators/poms.js +50 -0
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +94 -0
- package/build/bdd-framework/stepDefinitions/defineStep.js +61 -0
- package/build/bdd-framework/stepDefinitions/stepConfig.js +24 -0
- package/build/bdd-framework/utils/index.js +50 -0
- package/build/bdd-framework/utils/jsStringWrap.js +44 -0
- package/build/bdd-framework/utils/logger.js +29 -0
- package/build/core/jest/preprocessor/jsPreprocessor.js +13 -0
- package/{src → build}/core/jest/runner/jest-runner.js +46 -44
- package/build/core/jest/setup/index.js +9 -0
- package/build/core/playwright/codegen.js +55 -0
- package/build/core/playwright/custom-commands.js +8 -0
- package/build/core/playwright/env-initializer.js +21 -0
- package/{src → build}/core/playwright/index.js +112 -82
- package/build/core/playwright/readConfigFile.js +69 -0
- package/build/core/playwright/report-generator.js +41 -0
- package/build/core/playwright/setup/config-creator.js +117 -0
- package/build/core/playwright/test-runner.js +132 -0
- package/build/decorators.d.ts +1 -0
- package/build/decorators.js +16 -0
- package/build/index.d.ts +5 -0
- package/build/index.js +59 -0
- package/build/lib/cli.js +54 -0
- package/build/lib/post-install.js +17 -0
- package/build/lint/index.js +4 -0
- package/build/parser/parser.js +206 -0
- package/build/parser/sample.feature +34 -0
- package/build/parser/sample.spec.js +37 -0
- package/build/parser/verifier.js +130 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -0
- package/build/setup-folder-structure/samples/authUsers-sample.json +9 -0
- package/build/setup-folder-structure/samples/env-config-sample.json +21 -0
- package/build/setup-folder-structure/samples/git-ignore.sample.js +33 -0
- package/build/setup-folder-structure/samples/uat-config-sample.js +35 -0
- package/build/setup-folder-structure/setupProject.js +100 -0
- package/{src → build}/utils/cliArgsToObject.js +65 -63
- package/build/utils/fileUtils.js +53 -0
- package/build/utils/getFilePath.js +11 -0
- package/build/utils/logger.js +58 -0
- package/build/utils/rootPath.js +46 -0
- package/build/utils/stepDefinitionsFormatter.js +12 -0
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +8790 -5772
- package/package.json +51 -30
- package/playwright.config.js +112 -112
- 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/readConfigFile.js +0 -63
- package/src/core/playwright/report-generator.js +0 -45
- package/src/core/playwright/setup/config-creator.js +0 -77
- package/src/core/playwright/test-runner.js +0 -67
- package/src/index.js +0 -9
- package/src/lib/cli.js +0 -42
- package/src/setup-folder-structure/env-config-sample.json +0 -17
- package/src/setup-folder-structure/setupProject.js +0 -99
- package/src/setup-folder-structure/uat-config-sample.js +0 -22
- package/src/setup-folder-structure/user-example.json +0 -3
- package/src/utils/getFilePath.js +0 -9
- package/src/utils/logger.js +0 -28
- package/src/utils/rootPath.js +0 -51
|
@@ -0,0 +1,100 @@
|
|
|
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 _fs = require("fs");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _logger = require("../utils/logger");
|
|
11
|
+
function getScriptsToBeAdded() {
|
|
12
|
+
return {
|
|
13
|
+
"ua-test": "ZDTestingFramework test --mode=prod --headed",
|
|
14
|
+
"ua-test-debug": "ZDTestingFramework test --mode=prod --debug",
|
|
15
|
+
"ua-test-ci": "ZDTestingFramework test --mode=prod",
|
|
16
|
+
"ua-report": "ZDTestingFramework report --port=9009",
|
|
17
|
+
"codegen": "ZDTestingFramework codegen deskclientapp.localzoho.com/agent"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function updatePackageJSONScripts() {
|
|
21
|
+
const packageJsonPath = _path.default.resolve(process.cwd(), './package.json');
|
|
22
|
+
if ((0, _fs.existsSync)(packageJsonPath)) {
|
|
23
|
+
const packageContents = (0, _fs.readFileSync)(packageJsonPath);
|
|
24
|
+
const configJSON = JSON.parse(packageContents);
|
|
25
|
+
const {
|
|
26
|
+
scripts = {}
|
|
27
|
+
} = configJSON;
|
|
28
|
+
const modifiedScripts = {
|
|
29
|
+
...scripts,
|
|
30
|
+
...getScriptsToBeAdded()
|
|
31
|
+
};
|
|
32
|
+
const modifiedConfigJSON = {
|
|
33
|
+
...configJSON,
|
|
34
|
+
scripts: modifiedScripts
|
|
35
|
+
};
|
|
36
|
+
(0, _fs.writeFileSync)(packageJsonPath, JSON.stringify(modifiedConfigJSON, null, 2));
|
|
37
|
+
} else {
|
|
38
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Unable to find package json. Run init command in the root path of the project.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function createFolderForUAT() {
|
|
42
|
+
const uatFolder = _path.default.resolve(process.cwd(), 'uat');
|
|
43
|
+
if ((0, _fs.existsSync)(uatFolder)) {
|
|
44
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Uat Folder already Exists.');
|
|
45
|
+
} else {
|
|
46
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Uat Folder');
|
|
47
|
+
(0, _fs.mkdirSync)(uatFolder);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function getSetupFileAsString(fileName) {
|
|
51
|
+
return (0, _fs.readFileSync)(_path.default.resolve(__dirname, './samples/', fileName)).toString();
|
|
52
|
+
}
|
|
53
|
+
function createUatConfig() {
|
|
54
|
+
const uatConfigPath = _path.default.resolve(process.cwd(), 'uat.config.js');
|
|
55
|
+
if ((0, _fs.existsSync)(uatConfigPath)) {
|
|
56
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Uat Config already Exists.');
|
|
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
|
+
const 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(), 'uat', 'fixtures'));
|
|
68
|
+
(0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'playwright', '.auth'), {
|
|
69
|
+
recursive: true
|
|
70
|
+
});
|
|
71
|
+
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'auth.setup.js'), getSetupFileAsString('auth-setup-sample.js'), null, 2);
|
|
72
|
+
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'authUsers.json'), getSetupFileAsString('authUsers-sample.json'), null, 2);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Something went wrong ! Folder not Created. Please re-initialize npm init-uat');
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Something went wrong. Please re-initialize the @zohodesk/testinglibrary');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function createConfigJson() {
|
|
81
|
+
const uatFolder = _path.default.resolve(process.cwd(), 'uat');
|
|
82
|
+
if ((0, _fs.existsSync)(uatFolder)) {
|
|
83
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating env-config file inside UAT Folder');
|
|
84
|
+
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, './env-config.json'), getSetupFileAsString('env-config-sample.json'), null, 2);
|
|
85
|
+
} else {
|
|
86
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Something went wrong. Please re-initialize the @zohodesk/testinglibrary');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function setupProject() {
|
|
90
|
+
updatePackageJSONScripts();
|
|
91
|
+
createUatConfig();
|
|
92
|
+
createFolderForUAT();
|
|
93
|
+
createConfigJson();
|
|
94
|
+
createAuthenticationFile();
|
|
95
|
+
// Create folder for playwright . Inside .auth folder needs to be created. user.json
|
|
96
|
+
// Add playwright and test-results to .gitignore
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Setup Project is Ready ..');
|
|
99
|
+
}, 2000);
|
|
100
|
+
}
|
|
@@ -1,63 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
// eslint-disable-next-line no-unused-vars
|
|
23
|
+
function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
|
|
24
|
+
const processEnv = {};
|
|
25
|
+
cliArgs.forEach(option => {
|
|
26
|
+
if (/^--./.test(option)) {
|
|
27
|
+
const equIndex = option.indexOf('=');
|
|
28
|
+
let key = option.slice(2, equIndex);
|
|
29
|
+
let value = option.slice(equIndex + 1);
|
|
30
|
+
if (equIndex === -1) {
|
|
31
|
+
key = option.slice(2);
|
|
32
|
+
value = true;
|
|
33
|
+
}
|
|
34
|
+
processEnv[key] = value;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return processEnv;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Converts an object to an array of command-line arguments.
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} objectToBeConverted - The object to be converted to command-line arguments.
|
|
44
|
+
* @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.
|
|
45
|
+
* @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.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Example usage:
|
|
49
|
+
* const options = { port: 8080, verbose: true, input: 'input.txt' };
|
|
50
|
+
* const args = objectToCliArgs(options);
|
|
51
|
+
* // args will be: ['--port=8080', '--verbose', '--input=input.txt']
|
|
52
|
+
*/
|
|
53
|
+
function objectToCliArgs(objectToBeConverted, isKeyNeedToBeAdded) {
|
|
54
|
+
const argsArray = [];
|
|
55
|
+
Object.keys(objectToBeConverted).forEach(key => {
|
|
56
|
+
if (isKeyNeedToBeAdded(key)) {
|
|
57
|
+
if (typeof objectToBeConverted[key] === 'boolean' && objectToBeConverted[key]) {
|
|
58
|
+
argsArray.push(`--${key}`);
|
|
59
|
+
} else {
|
|
60
|
+
argsArray.push(`--${key}=${objectToBeConverted[key]}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return argsArray;
|
|
65
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.checkIfFileExists = checkIfFileExists;
|
|
8
|
+
exports.deleteFile = deleteFile;
|
|
9
|
+
exports.readFileContents = readFileContents;
|
|
10
|
+
exports.writeFileContents = writeFileContents;
|
|
11
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
+
function checkIfFileExists(file) {
|
|
13
|
+
try {
|
|
14
|
+
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|
|
15
|
+
return true;
|
|
16
|
+
} catch (err) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function readFileContents(filePath) {
|
|
21
|
+
try {
|
|
22
|
+
let fileContents = _fs.default.readFileSync(filePath, 'utf-8');
|
|
23
|
+
return fileContents;
|
|
24
|
+
} catch (err) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function writeFileContents(filePath, content, writeOptions = {}) {
|
|
29
|
+
let filePaths = filePath.split('/');
|
|
30
|
+
let fileName = filePaths.pop();
|
|
31
|
+
let directoryPath = filePaths.join('/');
|
|
32
|
+
|
|
33
|
+
// Check if the directory exists
|
|
34
|
+
if (!_fs.default.existsSync(directoryPath)) {
|
|
35
|
+
_fs.default.mkdirSync(directoryPath, {
|
|
36
|
+
recursive: true
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
_fs.default.writeFileSync(`${directoryPath}/${fileName}`, content, writeOptions);
|
|
41
|
+
} catch (err) {
|
|
42
|
+
throw new Error(err);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function deleteFile(filePath) {
|
|
46
|
+
if (checkIfFileExists(filePath)) {
|
|
47
|
+
try {
|
|
48
|
+
_fs.default.unlinkSync(filePath);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
throw new Error(`Error while deleting the test data file: ${filePath}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -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
|
+
const isWindows = (0, _os.platform)().toLowerCase() === 'win32';
|
|
9
|
+
function getFilePathWithExtension(binName) {
|
|
10
|
+
return isWindows ? `${binName}.cmd` : binName;
|
|
11
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Logger = void 0;
|
|
7
|
+
// const SUCCESS_TYPE = 'success';
|
|
8
|
+
// const FAILURE_TYPE = 'failure';
|
|
9
|
+
// const INFO_TYPE = 'info';
|
|
10
|
+
|
|
11
|
+
// function logger() {
|
|
12
|
+
// this.colors = {
|
|
13
|
+
// 'success': ['\x1b[36m', '\x1b[0m'],
|
|
14
|
+
// 'failure': ['\x1b[31m', '\x1b[0m'],
|
|
15
|
+
// 'info': ['\x1b[33m', '\x1b[0m']
|
|
16
|
+
// }
|
|
17
|
+
// this.consoleLogger = console;
|
|
18
|
+
// return {
|
|
19
|
+
// SUCCESS_TYPE,
|
|
20
|
+
// FAILURE_TYPE,
|
|
21
|
+
// INFO_TYPE,
|
|
22
|
+
// error: () => { },
|
|
23
|
+
// info: () => { },
|
|
24
|
+
// log: (type, message) => {
|
|
25
|
+
// const color = this.colors[type];
|
|
26
|
+
// console.log(type, color)
|
|
27
|
+
// this.consoleLogger.log(`${color[0]}${message}${color[1]}`)
|
|
28
|
+
// }
|
|
29
|
+
// }
|
|
30
|
+
// }
|
|
31
|
+
|
|
32
|
+
// module.exports = {
|
|
33
|
+
// Logger: logger()
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
class LoggerImpl {
|
|
37
|
+
constructor() {
|
|
38
|
+
this.SUCCESS_TYPE = 'success';
|
|
39
|
+
this.FAILURE_TYPE = 'failure';
|
|
40
|
+
this.INFO_TYPE = 'info';
|
|
41
|
+
this.colors = {
|
|
42
|
+
'success': ['\x1b[36m', '\x1b[0m'],
|
|
43
|
+
'failure': ['\x1b[31m', '\x1b[0m'],
|
|
44
|
+
'info': ['\x1b[33m', '\x1b[0m']
|
|
45
|
+
};
|
|
46
|
+
this.consoleLogger = console;
|
|
47
|
+
}
|
|
48
|
+
error(err) {
|
|
49
|
+
this.consoleLogger.error(err);
|
|
50
|
+
}
|
|
51
|
+
info() {}
|
|
52
|
+
log(type, message) {
|
|
53
|
+
const color = this.colors[type];
|
|
54
|
+
this.consoleLogger.log(`${color[0]}${message}${color[1]}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const Logger = new LoggerImpl();
|
|
58
|
+
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
|
+
const 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
|
+
const 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
|
+
const packageNodeModulesPath = getRootNodeModulesPath();
|
|
36
|
+
return findBinaryPath(packageNodeModulesPath, command);
|
|
37
|
+
}
|
|
38
|
+
function getExecutableBinaryPath(command) {
|
|
39
|
+
const 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 ${command} file. Make sure to npm install before proceeding`);
|
|
44
|
+
process.exit();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.delimiters = void 0;
|
|
7
|
+
exports.findDelimiterFromStep = findDelimiterFromStep;
|
|
8
|
+
const delimiters = ["Given", "When", "Then", "And"];
|
|
9
|
+
exports.delimiters = delimiters;
|
|
10
|
+
function findDelimiterFromStep(step) {
|
|
11
|
+
return delimiters.find(delimiter => step.includes(delimiter));
|
|
12
|
+
}
|
package/jest.config.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const { existsSync } = require('fs');
|
|
3
|
-
const appPath = process.cwd();
|
|
4
|
-
|
|
5
|
-
const appGlobals = path.resolve(appPath, '__testUtils__', 'globals.js');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
rootDir: process.cwd(),
|
|
9
|
-
testEnvironment: 'jsdom',
|
|
10
|
-
|
|
11
|
-
setupFilesAfterEnv: [
|
|
12
|
-
existsSync(appGlobals) && appGlobals,
|
|
13
|
-
path.resolve(__dirname, 'src', 'core', 'jest', 'setup', 'index.js')
|
|
14
|
-
].filter(Boolean),
|
|
15
|
-
|
|
16
|
-
transform: {
|
|
17
|
-
'^.+\\.(js|jsx)$': path.resolve(
|
|
18
|
-
__dirname,
|
|
19
|
-
'src',
|
|
20
|
-
'core',
|
|
21
|
-
'jest',
|
|
22
|
-
'preprocessor',
|
|
23
|
-
'jsPreprocessor.js'
|
|
24
|
-
)
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
modulePathIgnorePatterns: ['/build/'],
|
|
28
|
-
|
|
29
|
-
transformIgnorePatterns: [
|
|
30
|
-
'/node_modules/(?!(@zohodesk)/)'
|
|
31
|
-
],
|
|
32
|
-
|
|
33
|
-
testPathIgnorePatterns: [
|
|
34
|
-
'/node_modules/',
|
|
35
|
-
'/build/',
|
|
36
|
-
'/uat/'
|
|
37
|
-
],
|
|
38
|
-
|
|
39
|
-
watchPathIgnorePatterns: [
|
|
40
|
-
'/node_modules/',
|
|
41
|
-
'/build/'
|
|
42
|
-
],
|
|
43
|
-
|
|
44
|
-
clearMocks: true,
|
|
45
|
-
resetMocks: false,
|
|
46
|
-
|
|
47
|
-
collectCoverage: true,
|
|
48
|
-
collectCoverageFrom: ['src/**/*.js'],
|
|
49
|
-
coverageDirectory: './build/cov',
|
|
50
|
-
coverageReporters: ['lcov', 'json', 'html', 'json-summary', 'text'],
|
|
51
|
-
coverageThreshold: {
|
|
52
|
-
global: {
|
|
53
|
-
branches: 100,
|
|
54
|
-
functions: 100,
|
|
55
|
-
lines: 100,
|
|
56
|
-
statements: 100
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
globals: {
|
|
60
|
-
__DEVELOPMENT__: true,
|
|
61
|
-
__DOCS__: false,
|
|
62
|
-
__TEST__: true
|
|
63
|
-
}
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { existsSync } = require('fs');
|
|
3
|
+
const appPath = process.cwd();
|
|
4
|
+
|
|
5
|
+
const appGlobals = path.resolve(appPath, '__testUtils__', 'globals.js');
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
rootDir: process.cwd(),
|
|
9
|
+
testEnvironment: 'jsdom',
|
|
10
|
+
|
|
11
|
+
setupFilesAfterEnv: [
|
|
12
|
+
existsSync(appGlobals) && appGlobals,
|
|
13
|
+
path.resolve(__dirname, 'src', 'core', 'jest', 'setup', 'index.js')
|
|
14
|
+
].filter(Boolean),
|
|
15
|
+
|
|
16
|
+
transform: {
|
|
17
|
+
'^.+\\.(js|jsx)$': path.resolve(
|
|
18
|
+
__dirname,
|
|
19
|
+
'src',
|
|
20
|
+
'core',
|
|
21
|
+
'jest',
|
|
22
|
+
'preprocessor',
|
|
23
|
+
'jsPreprocessor.js'
|
|
24
|
+
)
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
modulePathIgnorePatterns: ['/build/'],
|
|
28
|
+
|
|
29
|
+
transformIgnorePatterns: [
|
|
30
|
+
'/node_modules/(?!(@zohodesk)/)'
|
|
31
|
+
],
|
|
32
|
+
|
|
33
|
+
testPathIgnorePatterns: [
|
|
34
|
+
'/node_modules/',
|
|
35
|
+
'/build/',
|
|
36
|
+
'/uat/'
|
|
37
|
+
],
|
|
38
|
+
|
|
39
|
+
watchPathIgnorePatterns: [
|
|
40
|
+
'/node_modules/',
|
|
41
|
+
'/build/'
|
|
42
|
+
],
|
|
43
|
+
|
|
44
|
+
clearMocks: true,
|
|
45
|
+
resetMocks: false,
|
|
46
|
+
|
|
47
|
+
collectCoverage: true,
|
|
48
|
+
collectCoverageFrom: ['src/**/*.js'],
|
|
49
|
+
coverageDirectory: './build/cov',
|
|
50
|
+
coverageReporters: ['lcov', 'json', 'html', 'json-summary', 'text'],
|
|
51
|
+
coverageThreshold: {
|
|
52
|
+
global: {
|
|
53
|
+
branches: 100,
|
|
54
|
+
functions: 100,
|
|
55
|
+
lines: 100,
|
|
56
|
+
statements: 100
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
globals: {
|
|
60
|
+
__DEVELOPMENT__: true,
|
|
61
|
+
__DOCS__: false,
|
|
62
|
+
__TEST__: true
|
|
63
|
+
}
|
|
64
64
|
};
|