@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
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { Logger } = require('../../utils/logger');
|
|
4
|
-
const { getExecutableBinaryPath } = require('../../utils/rootPath');
|
|
5
|
-
const { generateConfigFromFile } = require('./readConfigFile');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const userArgs = process.argv.slice(3);
|
|
9
|
-
|
|
10
|
-
const playwrightPath = path.resolve(getExecutableBinaryPath('playwright'));;
|
|
11
|
-
const command = playwrightPath;
|
|
12
|
-
const { reportPath : htmlPath = path.resolve(process.cwd(), './playwright-report') } = generateConfigFromFile()
|
|
13
|
-
const reportPath = htmlPath
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const args = ['show-report', htmlPath].concat(userArgs);
|
|
17
|
-
|
|
18
|
-
function generateReport() {
|
|
19
|
-
const childProcess = spawn(command, args, { stdio: 'inherit' });
|
|
20
|
-
childProcess.on('error', (error) => {
|
|
21
|
-
Logger.log(Logger.FAILURE_TYPE, error);
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
childProcess.on('exit', (code, signal) => {
|
|
25
|
-
Logger.log(Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
26
|
-
|
|
27
|
-
process.exit();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
process.on('exit', () => {
|
|
31
|
-
Logger.log(Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
32
|
-
childProcess.kill();
|
|
33
|
-
return;
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
process.on('SIGINT', () => {
|
|
37
|
-
Logger.log(Logger.INFO_TYPE, 'Cleaning up...');
|
|
38
|
-
childProcess.kill();
|
|
39
|
-
process.exit();
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
module.exports = generateReport;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
const { defineConfig, devices } = require('@playwright/test');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const { generateConfigFromFile, getAuthFilePath } = require('../readConfigFile');
|
|
5
|
-
const { existsSync } = require('fs');
|
|
6
|
-
const numCPUs = require('os').cpus().length;
|
|
7
|
-
|
|
8
|
-
const defaultBrowser = ['Chrome']
|
|
9
|
-
|
|
10
|
-
const { browsers = defaultBrowser, trace = false, video = false, isAuthMode, openReportOn, reportPath = path.join(process.cwd(), 'playwright-report') } = generateConfigFromFile();
|
|
11
|
-
|
|
12
|
-
let projects = browsers.map(browser => {
|
|
13
|
-
if (browser === 'Chrome') {
|
|
14
|
-
return {
|
|
15
|
-
name: 'chromium',
|
|
16
|
-
use: {
|
|
17
|
-
...devices['Desktop Chrome'],
|
|
18
|
-
storageState: isAuthMode ? getAuthFilePath(path.resolve(process.cwd(), 'playwright/.auth/user.json')) : {}
|
|
19
|
-
},
|
|
20
|
-
dependencies: isAuthMode ? ['setup'] : [],
|
|
21
|
-
};
|
|
22
|
-
} else if (browser === 'Firefox') {
|
|
23
|
-
return {
|
|
24
|
-
name: 'firefox',
|
|
25
|
-
timeout: 4 * 60 * 1000,
|
|
26
|
-
expect: {
|
|
27
|
-
timeout: 80 * 1000,
|
|
28
|
-
},
|
|
29
|
-
use: {
|
|
30
|
-
...devices['Desktop Firefox'],
|
|
31
|
-
storageState: isAuthMode ? getAuthFilePath(path.resolve(process.cwd(), 'playwright/.auth/user.json')) : {}
|
|
32
|
-
},
|
|
33
|
-
dependencies: isAuthMode ? ['setup'] : [],
|
|
34
|
-
};
|
|
35
|
-
} else if (browser === 'safari') {
|
|
36
|
-
return {
|
|
37
|
-
name: 'webkit',
|
|
38
|
-
timeout: 2 * 60 * 1000,
|
|
39
|
-
expect: {
|
|
40
|
-
timeout: 80 * 1000,
|
|
41
|
-
},
|
|
42
|
-
use: {
|
|
43
|
-
...devices['Desktop Safari'],
|
|
44
|
-
storageState: isAuthMode ? getAuthFilePath(path.resolve(process.cwd(), 'playwright/.auth/user.json')) : {}
|
|
45
|
-
},
|
|
46
|
-
dependencies: isAuthMode ? ['setup'] : null,
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}).filter(Boolean);
|
|
50
|
-
|
|
51
|
-
module.exports = defineConfig({
|
|
52
|
-
testDir: path.join(path.resolve(process.cwd()), 'uat'),
|
|
53
|
-
outputDir: path.join(process.cwd(), 'test-results'),
|
|
54
|
-
fullyParallel: true,
|
|
55
|
-
forbidOnly: !!process.env.CI,
|
|
56
|
-
retries: process.env.CI ? 2 : 0,
|
|
57
|
-
workers: process.env.CI ? 1 : 1,
|
|
58
|
-
reporter: [['html', { outputFolder: reportPath, open: openReportOn }]],
|
|
59
|
-
timeout: 60 * 1000,
|
|
60
|
-
expect: {
|
|
61
|
-
timeout: 5 * 1000,
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
use: {
|
|
65
|
-
trace: trace ? 'on' : 'off',
|
|
66
|
-
video: video ? {
|
|
67
|
-
mode: 'on',
|
|
68
|
-
size: { width: 640, height: 480 }
|
|
69
|
-
} : 'off'
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
projects: isAuthMode ? [
|
|
73
|
-
{ name: 'setup', testMatch: /.*\.setup\.js/ },
|
|
74
|
-
...projects
|
|
75
|
-
] : [...projects]
|
|
76
|
-
});
|
|
77
|
-
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { CUSTOM_COMMANDS } = require('./custom-commands');
|
|
4
|
-
const { cliArgsToObject, objectToCliArgs } = require('../../utils/cliArgsToObject');
|
|
5
|
-
const { initializeEnvConfig } = require('./env-initializer');
|
|
6
|
-
const { Logger } = require('../../utils/logger');
|
|
7
|
-
const { isUserConfigFileAvailable, generateConfigFromFile } = require('./readConfigFile');
|
|
8
|
-
const { getExecutableBinaryPath } = require('../../utils/rootPath');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function createTestRunner() {
|
|
12
|
-
// Access the command line arguments
|
|
13
|
-
const userArgs = process.argv.slice(2);
|
|
14
|
-
|
|
15
|
-
const userArgsObject = cliArgsToObject(userArgs);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const { debug, mode = 'dev' } = generateConfigFromFile();
|
|
19
|
-
|
|
20
|
-
// Environment variables Initialization
|
|
21
|
-
initializeEnvConfig(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const playwrightArgs = objectToCliArgs(userArgsObject, (key) => !CUSTOM_COMMANDS.includes(key));
|
|
25
|
-
|
|
26
|
-
if (debug) {
|
|
27
|
-
playwrightArgs.push('--debug')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Command and arguments for npx playwright test
|
|
31
|
-
const playwrightPath = path.resolve(getExecutableBinaryPath('playwright'));
|
|
32
|
-
|
|
33
|
-
const command = playwrightPath;
|
|
34
|
-
|
|
35
|
-
const configPath = isUserConfigFileAvailable() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
|
|
36
|
-
|
|
37
|
-
const args = ['test', '--config', configPath].concat(playwrightArgs);
|
|
38
|
-
// Spawn the child process
|
|
39
|
-
|
|
40
|
-
const childProcess = spawn(command, args, { stdio: 'inherit' });
|
|
41
|
-
|
|
42
|
-
childProcess.on('error', (error) => {
|
|
43
|
-
Logger.log(Logger.FAILURE_TYPE, error);
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
childProcess.on('exit', (code, signal) => {
|
|
47
|
-
Logger.log(Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
48
|
-
|
|
49
|
-
process.exit();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
process.on('exit', () => {
|
|
53
|
-
Logger.log(Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
54
|
-
//childProcess.kill();
|
|
55
|
-
return;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
process.on('SIGINT', () => {
|
|
59
|
-
Logger.log(Logger.INFO_TYPE, 'Cleaning up...');
|
|
60
|
-
//childProcess.kill();
|
|
61
|
-
process.exit();
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
module.exports = createTestRunner;
|
package/src/index.js
DELETED
package/src/lib/cli.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const createTestRunner = require("../core/playwright/test-runner");
|
|
2
|
-
const createJestRunner = require('../core/jest/runner/jest-runner');
|
|
3
|
-
const generateReport = require("../core/playwright/report-generator");
|
|
4
|
-
const generateCodegen = require('../core/playwright/codegen')
|
|
5
|
-
const { Logger } = require("../utils/logger");
|
|
6
|
-
const setupProject = require("../setup-folder-structure/setupProject");
|
|
7
|
-
|
|
8
|
-
const [, , option] = process.argv;
|
|
9
|
-
const args = process.argv.slice(3);
|
|
10
|
-
const appPath = process.cwd();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
switch (option) {
|
|
14
|
-
case 'test': {
|
|
15
|
-
Logger.log(Logger.SUCCESS_TYPE, 'Running Tests..');
|
|
16
|
-
createTestRunner();
|
|
17
|
-
//createJestRunner();
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
case 'report': {
|
|
21
|
-
// console.log('\x1b[36mGenerating Reports...\x1b[0m');
|
|
22
|
-
Logger.log(Logger.SUCCESS_TYPE, 'Generating Reports...');
|
|
23
|
-
generateReport();
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
case 'codegen': {
|
|
27
|
-
Logger.log(Logger.INFO_TYPE, 'The purpose of codegen is to assist developer .....')
|
|
28
|
-
generateCodegen();
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
case 'init': {
|
|
33
|
-
Logger.log(Logger.SUCCESS_TYPE, 'Initializing projects...');
|
|
34
|
-
setupProject();
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
default: {
|
|
39
|
-
console.log('Supported Commands test and report')
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const { readFileSync, existsSync, writeFileSync, mkdirSync } = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { Logger } = require('../utils/logger');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function getScriptsToBeAdded() {
|
|
7
|
-
return {
|
|
8
|
-
"ua-test": "ZDTestingFramework test --mode=prod --headed",
|
|
9
|
-
"ua-test-debug": "ZDTestingFramework test --mode=prod --debug",
|
|
10
|
-
"ua-report": "ZDTestingFramework report --port=9009",
|
|
11
|
-
"codegen": "ZDTestingFramework codegen deskclientapp.localzoho.com/agent"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function updatePackageJSONScripts() {
|
|
16
|
-
const packageJsonPath = path.resolve(process.cwd(), './package.json')
|
|
17
|
-
if (existsSync(packageJsonPath)) {
|
|
18
|
-
const packageContents = readFileSync(packageJsonPath);
|
|
19
|
-
const configJSON = JSON.parse(packageContents);
|
|
20
|
-
const { scripts = {} } = configJSON;
|
|
21
|
-
const modifiedScripts = { ...scripts, ...getScriptsToBeAdded() };
|
|
22
|
-
const modifiedConfigJSON = { ...configJSON, scripts: modifiedScripts };
|
|
23
|
-
writeFileSync(packageJsonPath, JSON.stringify(modifiedConfigJSON, null, 2));
|
|
24
|
-
} else {
|
|
25
|
-
Logger.log(Logger.FAILURE_TYPE, 'Unable to find package json. Run init command in the root path of the project.');
|
|
26
|
-
process.exit();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function createFolderForUAT() {
|
|
32
|
-
const uatFolder = path.resolve(process.cwd(), 'uat');
|
|
33
|
-
|
|
34
|
-
if (existsSync(uatFolder)) {
|
|
35
|
-
Logger.log(Logger.INFO_TYPE, 'Uat Folder already Exists.');
|
|
36
|
-
process.exit();
|
|
37
|
-
} else {
|
|
38
|
-
Logger.log(Logger.INFO_TYPE, 'Creating Uat Folder');
|
|
39
|
-
mkdirSync(uatFolder);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getSetupFileAsString(fileName) {
|
|
44
|
-
return readFileSync(path.resolve(__dirname, './', fileName)).toString();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function createUatConfig() {
|
|
48
|
-
const uatConfigPath = path.resolve(process.cwd(), 'uat.config.js');
|
|
49
|
-
if (existsSync(uatConfigPath)) {
|
|
50
|
-
Logger.log(Logger.INFO_TYPE, 'Uat Config already Exists.');
|
|
51
|
-
process.exit();
|
|
52
|
-
} else {
|
|
53
|
-
Logger.log(Logger.INFO_TYPE, 'Creating Uat config file...');
|
|
54
|
-
writeFileSync(uatConfigPath, getSetupFileAsString('uat-config-sample.js'), null, 2)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function createAuthenticationFile() {
|
|
59
|
-
const isUATexist = path.resolve(process.cwd(), 'uat')
|
|
60
|
-
if (existsSync(isUATexist)) {
|
|
61
|
-
Logger.log(Logger.INFO_TYPE, 'Creating Authentication File ....')
|
|
62
|
-
try {
|
|
63
|
-
mkdirSync(path.resolve(process.cwd(), 'playwright'), { recursive: true })
|
|
64
|
-
mkdirSync(path.resolve(process.cwd(), 'playwright', '.auth'), { recursive: true })
|
|
65
|
-
const authFilePath = path.resolve(process.cwd(), 'playwright', '.auth', 'user.json')
|
|
66
|
-
writeFileSync(authFilePath, getSetupFileAsString('user-example.json'), null, 2)
|
|
67
|
-
} catch (err) {
|
|
68
|
-
Logger.log(Logger.FAILURE_TYPE, 'Something went wrong ! Folder not Created. Please re-initialize npm init-uat')
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
Logger.log(Logger.INFO_TYPE, 'Something went wrong. Please re-initialize the @zohodesk/testinglibrary');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function createConfigJson() {
|
|
76
|
-
const uatFolder = path.resolve(process.cwd(), 'uat');
|
|
77
|
-
if (existsSync(uatFolder)) {
|
|
78
|
-
Logger.log(Logger.INFO_TYPE, 'Creating env-config file inside UAT Folder');
|
|
79
|
-
writeFileSync(path.resolve(uatFolder, './env-config.json'), getSetupFileAsString('env-config-sample.json'), null, 2)
|
|
80
|
-
} else {
|
|
81
|
-
Logger.log(Logger.INFO_TYPE, 'Something went wrong. Please re-initialize the @zohodesk/testinglibrary');
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function setupProject() {
|
|
86
|
-
updatePackageJSONScripts();
|
|
87
|
-
createUatConfig();
|
|
88
|
-
createFolderForUAT();
|
|
89
|
-
createConfigJson();
|
|
90
|
-
createAuthenticationFile()
|
|
91
|
-
// Create folder for playwright . Inside .auth folder needs to be created. user.json
|
|
92
|
-
// Add playwright and test-results to .gitignore
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
setTimeout(() => {
|
|
96
|
-
Logger.log(Logger.SUCCESS_TYPE, 'Setup Project is Ready ..')
|
|
97
|
-
}, 2000)
|
|
98
|
-
|
|
99
|
-
module.exports = setupProject;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the user configuration object.
|
|
3
|
-
* @typedef {Object} UserConfig
|
|
4
|
-
* @property {string} headless - Headless Browsers mode.
|
|
5
|
-
* @property {number} trace - trace for test cases.
|
|
6
|
-
* @property {boolean} video - video for test cases,
|
|
7
|
-
* @property {boolean} debug - debug mode
|
|
8
|
-
* @property {string} mode: mode in which the test cases needs to run
|
|
9
|
-
* @property {boolean} isAuthMode - Auth Mode
|
|
10
|
-
* @property {any} browsers: List of browsers
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @type {UserConfig}
|
|
14
|
-
*/
|
|
15
|
-
module.exports = {
|
|
16
|
-
headed: true,
|
|
17
|
-
browsers: ['Chrome', 'Firefox'],
|
|
18
|
-
mode: 'dev',
|
|
19
|
-
isAuthMode: true,
|
|
20
|
-
trace: true,
|
|
21
|
-
video: true,
|
|
22
|
-
}
|
package/src/utils/getFilePath.js
DELETED
package/src/utils/logger.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const SUCCESS_TYPE = 'success';
|
|
2
|
-
const FAILURE_TYPE = 'failure';
|
|
3
|
-
const INFO_TYPE = 'info';
|
|
4
|
-
|
|
5
|
-
function logger() {
|
|
6
|
-
this.colors = {
|
|
7
|
-
'success': ['\x1b[36m', '\x1b[0m'],
|
|
8
|
-
'failure': ['\x1b[31m', '\x1b[0m'],
|
|
9
|
-
'info': ['\x1b[33m', '\x1b[0m']
|
|
10
|
-
}
|
|
11
|
-
this.consoleLogger = console;
|
|
12
|
-
return {
|
|
13
|
-
SUCCESS_TYPE,
|
|
14
|
-
FAILURE_TYPE,
|
|
15
|
-
INFO_TYPE,
|
|
16
|
-
error: () => { },
|
|
17
|
-
info: () => { },
|
|
18
|
-
log: (type, message) => {
|
|
19
|
-
const color = this.colors[type];
|
|
20
|
-
this.consoleLogger.log(`${color[0]}${message}${color[1]}`)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
module.exports = {
|
|
27
|
-
Logger: logger()
|
|
28
|
-
}
|
package/src/utils/rootPath.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const { Logger } = require('./logger');
|
|
4
|
-
const getFilePathWithExtension = require('./getFilePath');
|
|
5
|
-
|
|
6
|
-
function findBinaryPath(directory, command) {
|
|
7
|
-
const binaryPath = path.join(directory, '.bin', getFilePathWithExtension(command));
|
|
8
|
-
if (fs.existsSync(binaryPath)) {
|
|
9
|
-
return binaryPath;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Recursively search parent directories. Might be time-consuming ?? Can we look for npm module like which?
|
|
13
|
-
const parentDir = path.dirname(directory);
|
|
14
|
-
if (parentDir === directory) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return findBinaryPath(parentDir, command);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getRootPath() {
|
|
22
|
-
return path.resolve(__dirname, '../', '../');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getRootNodeModulesPath() {
|
|
26
|
-
return path.resolve(getRootPath(), 'node_modules');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function getBinPath(command) {
|
|
30
|
-
const packageNodeModulesPath = getRootNodeModulesPath();
|
|
31
|
-
return findBinaryPath(packageNodeModulesPath, command);
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function getExecutableBinaryPath(command) {
|
|
37
|
-
const binPath = getBinPath(command);
|
|
38
|
-
if (binPath !== null) {
|
|
39
|
-
return binPath;
|
|
40
|
-
} else {
|
|
41
|
-
Logger.log(Logger.FAILURE_TYPE, `Error: Could not find executable bin file. Make sure to npm install before proceeding`);
|
|
42
|
-
process.exit();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = {
|
|
47
|
-
getRootPath,
|
|
48
|
-
getBinPath,
|
|
49
|
-
getRootNodeModulesPath,
|
|
50
|
-
getExecutableBinaryPath
|
|
51
|
-
}
|