@zohodesk/testinglibrary 0.0.3 → 0.0.4-n20-experimental
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 +24 -0
- package/.eslintrc.js +31 -0
- package/.gitlab-ci.yml +175 -0
- package/.prettierrc +6 -0
- package/README.md +151 -1
- package/bin/cli.js +1 -1
- package/bin/postinstall.js +1 -16
- package/build/common/data-generator/steps/DataGenerator.spec.js +19 -0
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +19 -0
- package/build/common/multi-actor/steps/multiActorHandling.spec.js +26 -0
- package/build/common/searchFake/helpers/rpcRequestHelper.js +41 -0
- package/build/common/searchFake/steps/searchFake.spec.js +26 -0
- package/build/core/dataGenerator/DataGenerator.js +94 -0
- package/build/core/dataGenerator/DataGeneratorHelper.js +49 -0
- package/{src → build}/core/jest/preprocessor/jsPreprocessor.js +4 -6
- package/{src → build}/core/jest/runner/jest-runner.js +17 -15
- package/build/core/jest/setup/index.js +3 -0
- package/build/core/playwright/builtInFixtures/actorContext.js +75 -0
- package/build/core/playwright/builtInFixtures/addTags.js +19 -0
- package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
- package/build/core/playwright/builtInFixtures/context.js +32 -0
- package/build/core/playwright/builtInFixtures/executionContext.js +17 -0
- package/build/core/playwright/builtInFixtures/i18N.js +41 -0
- package/build/core/playwright/builtInFixtures/index.js +46 -0
- package/build/core/playwright/builtInFixtures/page.js +38 -0
- package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
- package/build/core/playwright/clear-caches.js +49 -0
- package/build/core/playwright/codegen.js +55 -0
- package/build/core/playwright/configuration/Configuration.js +25 -0
- package/build/core/playwright/configuration/ConfigurationHelper.js +43 -0
- package/build/core/playwright/configuration/UserArgs.js +12 -0
- package/build/core/playwright/constants/browserTypes.js +12 -0
- package/build/core/playwright/constants/fileMutexConfig.js +9 -0
- package/build/core/playwright/custom-commands.js +7 -0
- package/build/core/playwright/env-initializer.js +43 -0
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/additionalProfiles.js +25 -0
- package/build/core/playwright/helpers/auth/accountLogin.js +21 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +41 -0
- package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
- package/build/core/playwright/helpers/auth/getUsers.js +118 -0
- package/build/core/playwright/helpers/auth/index.js +76 -0
- package/build/core/playwright/helpers/auth/loginDefaultStepsHelper.js +54 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +50 -0
- package/build/core/playwright/helpers/checkAuthDirectory.js +27 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +31 -0
- package/build/core/playwright/helpers/customFixturesHelper.js +58 -0
- package/build/core/playwright/helpers/fileMutex.js +71 -0
- package/build/core/playwright/helpers/getUserFixtures.js +23 -0
- package/build/core/playwright/helpers/mergeObjects.js +13 -0
- package/build/core/playwright/helpers/parseUserArgs.js +10 -0
- package/build/core/playwright/index.js +24 -0
- package/build/core/playwright/readConfigFile.js +147 -0
- package/build/core/playwright/report-generator.js +42 -0
- package/build/core/playwright/runner/Runner.js +22 -0
- package/build/core/playwright/runner/RunnerHelper.js +43 -0
- package/build/core/playwright/runner/RunnerTypes.js +17 -0
- package/build/core/playwright/runner/SpawnRunner.js +113 -0
- package/build/core/playwright/setup/config-creator.js +117 -0
- package/build/core/playwright/setup/config-utils.js +188 -0
- package/build/core/playwright/setup/custom-reporter.js +136 -0
- package/build/core/playwright/setup/qc-custom-reporter.js +291 -0
- package/build/core/playwright/tagProcessor.js +69 -0
- package/build/core/playwright/test-runner.js +116 -0
- package/build/core/playwright/types.js +44 -0
- package/build/core/playwright/validateFeature.js +28 -0
- package/build/decorators.d.ts +1 -0
- package/build/decorators.js +16 -0
- package/build/index.d.ts +78 -0
- package/build/index.js +105 -0
- package/build/lib/cli.js +78 -0
- package/build/lib/post-install.js +25 -0
- package/build/lint/index.js +4 -0
- package/build/parser/parser.js +205 -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/helper.js +37 -0
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
- package/build/setup-folder-structure/samples/accountLogin-sample.js +19 -0
- package/build/setup-folder-structure/samples/actors-index.js +2 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +15 -0
- package/build/setup-folder-structure/samples/editions-index.js +3 -0
- package/build/setup-folder-structure/samples/free-sample.json +25 -0
- package/build/setup-folder-structure/samples/git-ignore.sample.js +37 -0
- package/build/setup-folder-structure/samples/settings.json +7 -0
- package/build/setup-folder-structure/samples/testSetup-sample.js +14 -0
- package/build/setup-folder-structure/samples/uat-config-sample.js +46 -0
- package/build/setup-folder-structure/setupProject.js +122 -0
- package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
- package/build/test/core/playwright/__tests__/validateFeature.test.js +69 -0
- package/build/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js +27 -0
- package/build/test/core/playwright/configuration/__tests__/Configuration.test.js +53 -0
- package/build/test/core/playwright/helpers/__tests__/additionalProfiles.test.js +45 -0
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +34 -0
- package/build/test/core/playwright/helpers/__tests__/customFixturesHelper.test.js +51 -0
- package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +79 -0
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +80 -0
- package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +16 -0
- package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +27 -0
- package/build/utils/cliArgsToObject.js +72 -0
- package/build/utils/commonUtils.js +17 -0
- package/build/utils/fileUtils.js +109 -0
- package/build/utils/getFilePath.js +11 -0
- package/build/utils/logger.js +28 -0
- package/build/utils/rootPath.js +53 -0
- package/build/utils/stepDefinitionsFormatter.js +11 -0
- package/changelog.md +153 -1
- package/jest.config.js +29 -11
- package/npm-shrinkwrap.json +10902 -4825
- package/package.json +47 -17
- package/playwright.config.js +6 -56
- package/test-results/.last-run.json +4 -0
- package/unit_reports/unit-report.html +260 -0
- 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 -79
- 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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _logger = require("../../../utils/logger");
|
|
8
|
+
var _readConfigFile = require("../readConfigFile");
|
|
9
|
+
function getUserFixtures() {
|
|
10
|
+
const {
|
|
11
|
+
additionalPages
|
|
12
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
13
|
+
|
|
14
|
+
// if (additionalPages.page || additionalPages.context) {
|
|
15
|
+
// // Logger.log(
|
|
16
|
+
// // Logger.INFO_TYPE,
|
|
17
|
+
// // 'Not allowed to override the page and context fixture. Use Test Setup in uat configuration'
|
|
18
|
+
// // );
|
|
19
|
+
// }
|
|
20
|
+
|
|
21
|
+
return additionalPages;
|
|
22
|
+
}
|
|
23
|
+
var _default = exports.default = getUserFixtures;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mergeObjects = mergeObjects;
|
|
7
|
+
// Utility function to merge objects using spread operator
|
|
8
|
+
function mergeObjects(obj1, obj2) {
|
|
9
|
+
return {
|
|
10
|
+
...obj1,
|
|
11
|
+
...obj2
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseUserArgs = parseUserArgs;
|
|
7
|
+
var _cliArgsToObject = require("../../../utils/cliArgsToObject");
|
|
8
|
+
function parseUserArgs() {
|
|
9
|
+
return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createBdd = void 0;
|
|
7
|
+
Object.defineProperty(exports, "expect", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _test.expect;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "test", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _playwrightBdd.test;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _playwrightBdd = require("playwright-bdd");
|
|
20
|
+
var _test = require("@playwright/test");
|
|
21
|
+
let createBdd = function () {
|
|
22
|
+
return (0, _playwrightBdd.createBdd)(_playwrightBdd.test);
|
|
23
|
+
};
|
|
24
|
+
exports.createBdd = createBdd;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.generateConfigFromFile = generateConfigFromFile;
|
|
8
|
+
exports.getAuthFilePath = getAuthFilePath;
|
|
9
|
+
exports.getDefaultConfig = getDefaultConfig;
|
|
10
|
+
exports.isUserConfigFileAvailable = isUserConfigFileAvailable;
|
|
11
|
+
var _fs = require("fs");
|
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
var _logger = require("../../utils/logger");
|
|
14
|
+
var _configFileNameProvider = require("./helpers/configFileNameProvider");
|
|
15
|
+
var _mergeObjects = require("./helpers/mergeObjects");
|
|
16
|
+
var _Configuration = _interopRequireDefault(require("./configuration/Configuration"));
|
|
17
|
+
var _UserArgs = _interopRequireDefault(require("./configuration/UserArgs"));
|
|
18
|
+
var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
|
|
19
|
+
let cachedConfig = null;
|
|
20
|
+
function getDefaultConfig() {
|
|
21
|
+
return {
|
|
22
|
+
uatDirectory: _path.default.join(process.cwd(), 'uat'),
|
|
23
|
+
headless: false,
|
|
24
|
+
browsers: ['Chrome'],
|
|
25
|
+
forbidOnly: false,
|
|
26
|
+
retries: 0,
|
|
27
|
+
trace: false,
|
|
28
|
+
video: false,
|
|
29
|
+
isAuthMode: false,
|
|
30
|
+
openReportOn: 'never',
|
|
31
|
+
reportPath: _path.default.join(process.cwd(), 'uat', 'playwright-report'),
|
|
32
|
+
bddMode: false,
|
|
33
|
+
expectTimeout: 5 * 1000,
|
|
34
|
+
testTimeout: 60 * 1000,
|
|
35
|
+
authFilePath: 'uat/playwright/.auth/user.json',
|
|
36
|
+
viewport: {
|
|
37
|
+
width: 1280,
|
|
38
|
+
height: 720
|
|
39
|
+
},
|
|
40
|
+
debug: false,
|
|
41
|
+
testIdAttribute: 'data-testid',
|
|
42
|
+
additionalPages: {},
|
|
43
|
+
featureFilesFolder: 'feature-files',
|
|
44
|
+
stepDefinitionsFolder: 'steps',
|
|
45
|
+
testSetup: {},
|
|
46
|
+
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
50
|
+
let defaultConfig = getDefaultConfig();
|
|
51
|
+
let configurationObj = {};
|
|
52
|
+
Object.keys(userConfiguration).forEach(configKey => {
|
|
53
|
+
let configValue = userConfiguration[configKey];
|
|
54
|
+
if (configValue !== null && configValue !== undefined) {
|
|
55
|
+
configurationObj[configKey] = configValue;
|
|
56
|
+
} else if (defaultConfig[configKey]) {
|
|
57
|
+
configurationObj[configKey] = defaultConfig[configKey];
|
|
58
|
+
} else {
|
|
59
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `key - ${configKey} is not yet supported in uat configuration. This will not be used while creating playwright configuration`);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return (0, _mergeObjects.mergeObjects)(defaultConfig, configurationObj);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @typedef {Object|null} viewportConfig
|
|
66
|
+
* @property {number} width - width of the viewport
|
|
67
|
+
* @property {number} height - height of the viewport
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* @typedef {Object|null} viewportConfig
|
|
71
|
+
* @property {number} width - width of the viewport
|
|
72
|
+
* @property {number} height - height of the viewport
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @typedef {Object|null} testSetupConfig
|
|
77
|
+
* @property {any} page - Function that will be called while setting up page fixtures
|
|
78
|
+
* @property {any} context - Function that will be called while setting up context fixtures
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Represents the user configuration object.
|
|
83
|
+
* @typedef {Object} UserConfig
|
|
84
|
+
* @property {string} uatDirectory - Directory in which uat configuration is places.
|
|
85
|
+
* @property {string} headless - Headless Browsers mode.
|
|
86
|
+
* @property {number} trace - trace for test cases.
|
|
87
|
+
* @property {boolean} video - video for test cases,
|
|
88
|
+
* @property {boolean} debug - debug mode
|
|
89
|
+
* @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
|
|
90
|
+
* @property {string} authFilePath - File Path where the cookies stored
|
|
91
|
+
* @property {any} browsers: List of browsers
|
|
92
|
+
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
93
|
+
* @property {any} reportPath : directory where report is generate
|
|
94
|
+
* @property {boolean} bddMode: Feature files needs to be processed
|
|
95
|
+
* @property {number} expectTimeout: time in milliseconds which the expect condition should fail
|
|
96
|
+
* @property {number} testTimeout: time in milliseconds which the test should fail
|
|
97
|
+
* @property {Object} additionalPages: custom pages configuration
|
|
98
|
+
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
99
|
+
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
100
|
+
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
|
|
101
|
+
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
102
|
+
* @property {Array} editionOrder: Order in the form of larger editions in the back. Edition with the most privelages should be last
|
|
103
|
+
* @property {testSetupConfig} testSetup: Specify page and context functions that will be called while intilaizing fixtures.
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Generates a configuration object from a file, if it exists.
|
|
108
|
+
*
|
|
109
|
+
* @returns {UserConfig}
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
function getConfigFilePath() {
|
|
113
|
+
return _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
114
|
+
}
|
|
115
|
+
function generateConfigFromFile() {
|
|
116
|
+
if (cachedConfig === null) {
|
|
117
|
+
// Getting the default config's from framework
|
|
118
|
+
const uatConfig = new _Configuration.default(getDefaultConfig());
|
|
119
|
+
// overriding the application config's from project
|
|
120
|
+
const appConfig = new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)());
|
|
121
|
+
const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
|
|
122
|
+
// overriding the user config's from CLI
|
|
123
|
+
uatConfig.addAll(appConfig);
|
|
124
|
+
uatConfig.addAll(userArgConfig);
|
|
125
|
+
cachedConfig = uatConfig.getAll();
|
|
126
|
+
}
|
|
127
|
+
return cachedConfig;
|
|
128
|
+
}
|
|
129
|
+
function isUserConfigFileAvailable() {
|
|
130
|
+
const filePath = getConfigFilePath();
|
|
131
|
+
if ((0, _fs.existsSync)(filePath)) {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
function getAuthFilePath(filePath) {
|
|
137
|
+
try {
|
|
138
|
+
if ((0, _fs.existsSync)(filePath)) {
|
|
139
|
+
return filePath;
|
|
140
|
+
} else {
|
|
141
|
+
return {};
|
|
142
|
+
}
|
|
143
|
+
} catch (err) {
|
|
144
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Founded Path - ${filePath} Authetication file not Exist ...`);
|
|
145
|
+
_logger.Logger.error(err);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = generateReport;
|
|
8
|
+
var _child_process = require("child_process");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _logger = require("../../utils/logger");
|
|
11
|
+
var _rootPath = require("../../utils/rootPath");
|
|
12
|
+
var _readConfigFile = require("./readConfigFile");
|
|
13
|
+
async function generateReport() {
|
|
14
|
+
// await preProcessReport()
|
|
15
|
+
const userArgs = process.argv.slice(3);
|
|
16
|
+
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
17
|
+
const command = playwrightPath;
|
|
18
|
+
const {
|
|
19
|
+
reportPath: htmlPath
|
|
20
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
21
|
+
const args = ['show-report', htmlPath].concat(userArgs);
|
|
22
|
+
const childProcess = (0, _child_process.spawn)(command, args, {
|
|
23
|
+
stdio: 'inherit'
|
|
24
|
+
});
|
|
25
|
+
childProcess.on('error', error => {
|
|
26
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
27
|
+
});
|
|
28
|
+
childProcess.on('exit', (code, signal) => {
|
|
29
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
30
|
+
process.exit();
|
|
31
|
+
});
|
|
32
|
+
process.on('exit', () => {
|
|
33
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
34
|
+
childProcess.kill();
|
|
35
|
+
return;
|
|
36
|
+
});
|
|
37
|
+
process.on('SIGINT', () => {
|
|
38
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Cleaning up...');
|
|
39
|
+
childProcess.kill();
|
|
40
|
+
process.exit();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class Runner {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.tagArgs = "";
|
|
6
|
+
this.userArgs = "";
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
setUserArgs(userArgs) {
|
|
10
|
+
this.userArgs = userArgs;
|
|
11
|
+
}
|
|
12
|
+
setTagArgs(tagArgs) {
|
|
13
|
+
this.tagArgs = tagArgs;
|
|
14
|
+
}
|
|
15
|
+
setConfig(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
}
|
|
18
|
+
run() {
|
|
19
|
+
throw new Error("Method 'run()' must be implemented.");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
module.exports = Runner;
|
|
@@ -0,0 +1,43 @@
|
|
|
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 _RunnerTypes = _interopRequireDefault(require("./RunnerTypes"));
|
|
9
|
+
var _configUtils = require("../setup/config-utils");
|
|
10
|
+
var _cliArgsToObject = require("../../../utils/cliArgsToObject");
|
|
11
|
+
var _browserTypes = require("../constants/browserTypes");
|
|
12
|
+
var _customCommands = require("../custom-commands");
|
|
13
|
+
class RunnerHelper {
|
|
14
|
+
static createRunner(type, runnerObj) {
|
|
15
|
+
const runnerClass = _RunnerTypes.default.getRunnerClass(type, runnerObj);
|
|
16
|
+
if (!runnerClass) {
|
|
17
|
+
throw new Error("Invalid runner type");
|
|
18
|
+
}
|
|
19
|
+
return runnerClass;
|
|
20
|
+
}
|
|
21
|
+
static getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
22
|
+
const {
|
|
23
|
+
browsers = null
|
|
24
|
+
} = userArgsObject;
|
|
25
|
+
let browserList = (0, _configUtils.getBrowsersList)(browsers);
|
|
26
|
+
const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
|
|
27
|
+
if (debug) {
|
|
28
|
+
playwrightArgs.push('--debug');
|
|
29
|
+
}
|
|
30
|
+
if (!bddMode && tagArgs) {
|
|
31
|
+
playwrightArgs.push('--grep');
|
|
32
|
+
playwrightArgs.push(tagArgs);
|
|
33
|
+
}
|
|
34
|
+
if (!headless && !userArgsObject.headed) {
|
|
35
|
+
playwrightArgs.push('--headed');
|
|
36
|
+
}
|
|
37
|
+
if (browserList && browserList.length > 0) {
|
|
38
|
+
browserList.map(browser => playwrightArgs.push(`--project=${_browserTypes.BROWSER_PROJECT_MAPPING[browser.toUpperCase()]}`));
|
|
39
|
+
}
|
|
40
|
+
return playwrightArgs;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var _default = exports.default = RunnerHelper;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _SpawnRunner = _interopRequireDefault(require("./SpawnRunner"));
|
|
5
|
+
class RunnerTypes {
|
|
6
|
+
static getRunnerClass(type, runnerObj) {
|
|
7
|
+
const RunnerClass = this.runnerTypes[type];
|
|
8
|
+
if (!RunnerClass) {
|
|
9
|
+
throw new Error("Invalid runner type");
|
|
10
|
+
}
|
|
11
|
+
return new RunnerClass(runnerObj);
|
|
12
|
+
}
|
|
13
|
+
static runnerTypes = {
|
|
14
|
+
spawn: _SpawnRunner.default //require("./SpawnRunner"), // used lazy loading to reduce circular dependencies
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
module.exports = RunnerTypes;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _readConfigFile = require("../readConfigFile");
|
|
5
|
+
var _rootPath = require("../../../utils/rootPath");
|
|
6
|
+
var _path = _interopRequireDefault(require("path"));
|
|
7
|
+
var _logger = require("../../../utils/logger");
|
|
8
|
+
var _child_process = require("child_process");
|
|
9
|
+
var _RunnerHelper = _interopRequireDefault(require("./RunnerHelper"));
|
|
10
|
+
var _Runner = _interopRequireDefault(require("./Runner"));
|
|
11
|
+
var _commonUtils = require("../../../utils/commonUtils");
|
|
12
|
+
class SpawnRunner extends _Runner.default {
|
|
13
|
+
constructor(runnerObj) {
|
|
14
|
+
super(runnerObj);
|
|
15
|
+
this.runnerObj = runnerObj;
|
|
16
|
+
}
|
|
17
|
+
run() {
|
|
18
|
+
const {
|
|
19
|
+
config
|
|
20
|
+
} = this.runnerObj;
|
|
21
|
+
let promises = [];
|
|
22
|
+
const {
|
|
23
|
+
bddMode
|
|
24
|
+
} = config.getAll();
|
|
25
|
+
if (bddMode) {
|
|
26
|
+
promises.push(this.runPreprocessing());
|
|
27
|
+
}
|
|
28
|
+
Promise.all(promises).then(() => this.runPlaywright()).catch(err => {
|
|
29
|
+
_logger.Logger.error(err);
|
|
30
|
+
process.exit();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
runPreprocessing() {
|
|
34
|
+
//This below functoin is called to copy the data generator spec files to the current project
|
|
35
|
+
(0, _commonUtils.copyCommonSpecs)();
|
|
36
|
+
const {
|
|
37
|
+
tagArgs
|
|
38
|
+
} = this.runnerObj;
|
|
39
|
+
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve(__dirname, '../', '../', '../', '../', 'playwrightConfig.js');
|
|
40
|
+
const beforeCommand = 'node';
|
|
41
|
+
const bddGenPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('bddgen'));
|
|
42
|
+
const beforeArgs = [bddGenPath, '-c', require.resolve(configPath)];
|
|
43
|
+
if (tagArgs) {
|
|
44
|
+
beforeArgs.push('--tags');
|
|
45
|
+
beforeArgs.push(tagArgs);
|
|
46
|
+
}
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
|
|
49
|
+
stdio: 'inherit',
|
|
50
|
+
env: {
|
|
51
|
+
...process.env
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
childProcessForPreprocessing.on('error', data => {
|
|
55
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
56
|
+
reject(data);
|
|
57
|
+
});
|
|
58
|
+
childProcessForPreprocessing.on('exit', code => {
|
|
59
|
+
if (code === 0) {
|
|
60
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
|
|
61
|
+
resolve();
|
|
62
|
+
} else {
|
|
63
|
+
reject(`BddGen exited with code ${code}`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
runPlaywright() {
|
|
69
|
+
const {
|
|
70
|
+
tagArgs,
|
|
71
|
+
config,
|
|
72
|
+
userArgs
|
|
73
|
+
} = this.runnerObj;
|
|
74
|
+
const {
|
|
75
|
+
debug,
|
|
76
|
+
bddMode = false,
|
|
77
|
+
headless = false
|
|
78
|
+
} = config.getAll();
|
|
79
|
+
const playwrightArgs = _RunnerHelper.default.getPlaywrightArgs(userArgs, debug, bddMode, tagArgs, headless);
|
|
80
|
+
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
81
|
+
const command = playwrightPath;
|
|
82
|
+
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve('../', '../', '../', '../', 'playwrightConfig.js');
|
|
83
|
+
const args = ['test', '--config', require.resolve(configPath)].concat(playwrightArgs);
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
|
|
86
|
+
stdio: 'inherit',
|
|
87
|
+
env: {
|
|
88
|
+
...process.env
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
childProcessForRunningPlaywright.on('error', error => {
|
|
92
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
93
|
+
});
|
|
94
|
+
childProcessForRunningPlaywright.on('exit', (code, signal) => {
|
|
95
|
+
if (code !== 0) {
|
|
96
|
+
reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
97
|
+
} else {
|
|
98
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
|
|
99
|
+
resolve();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
process.on('exit', () => {
|
|
103
|
+
childProcessForRunningPlaywright.kill();
|
|
104
|
+
reject('Terminating Playwright Process...');
|
|
105
|
+
});
|
|
106
|
+
process.on('SIGINT', () => {
|
|
107
|
+
childProcessForRunningPlaywright.kill();
|
|
108
|
+
reject('Cleaning up...');
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
module.exports = SpawnRunner;
|
|
@@ -0,0 +1,117 @@
|
|
|
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 _test = require("@playwright/test");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _readConfigFile = require("../readConfigFile");
|
|
11
|
+
var _configUtils = require("./config-utils");
|
|
12
|
+
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
13
|
+
const {
|
|
14
|
+
browsers,
|
|
15
|
+
isSmokeTest,
|
|
16
|
+
trace,
|
|
17
|
+
video,
|
|
18
|
+
isAuthMode,
|
|
19
|
+
openReportOn,
|
|
20
|
+
reportPath,
|
|
21
|
+
bddMode,
|
|
22
|
+
expectTimeout,
|
|
23
|
+
testTimeout,
|
|
24
|
+
authFilePath,
|
|
25
|
+
viewport,
|
|
26
|
+
featureFilesFolder,
|
|
27
|
+
stepDefinitionsFolder,
|
|
28
|
+
testIdAttribute,
|
|
29
|
+
globalTimeout,
|
|
30
|
+
customReporter
|
|
31
|
+
} = uatConfig;
|
|
32
|
+
const projects = (0, _configUtils.getProjects)({
|
|
33
|
+
browsers,
|
|
34
|
+
isAuthMode,
|
|
35
|
+
isSmokeTest,
|
|
36
|
+
authFilePath,
|
|
37
|
+
expectTimeout,
|
|
38
|
+
testTimeout,
|
|
39
|
+
viewport
|
|
40
|
+
});
|
|
41
|
+
const testDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
42
|
+
featureFilesFolder: (0, _configUtils.getPathsForFeatureFiles)(process.cwd()),
|
|
43
|
+
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
44
|
+
outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
|
|
45
|
+
uatPath: _path.default.join(process.cwd(), 'uat')
|
|
46
|
+
});
|
|
47
|
+
const use = {
|
|
48
|
+
trace,
|
|
49
|
+
video,
|
|
50
|
+
viewport,
|
|
51
|
+
testIdAttribute
|
|
52
|
+
};
|
|
53
|
+
let reporter = [['html', {
|
|
54
|
+
outputFolder: reportPath,
|
|
55
|
+
open: openReportOn
|
|
56
|
+
}], ['list'], ['json', {
|
|
57
|
+
outputFile: _path.default.join(process.cwd(), 'uat', 'test-results', 'playwright-test-results.json')
|
|
58
|
+
}], ['./custom-reporter.js'], ['./qc-custom-reporter.js']];
|
|
59
|
+
if (customReporter) {
|
|
60
|
+
reporter = [customReporter, ...reporter];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Playwright configuration object
|
|
65
|
+
*
|
|
66
|
+
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
function getPlaywrightConfig() {
|
|
70
|
+
const commonConfig = {
|
|
71
|
+
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
72
|
+
};
|
|
73
|
+
const dependencies = isAuthMode ? ['setup'] : [];
|
|
74
|
+
const smokeTestProject = isSmokeTest ? smokeTestConfig() : [];
|
|
75
|
+
function smokeTestConfig() {
|
|
76
|
+
const smokeTestDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
77
|
+
featureFilesFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*.feature'),
|
|
78
|
+
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
79
|
+
outputDir: _path.default.join(process.cwd(), 'uat', '.features-smoke-gen'),
|
|
80
|
+
uatPath: _path.default.join(process.cwd(), 'uat', 'smokeTest')
|
|
81
|
+
});
|
|
82
|
+
return [{
|
|
83
|
+
name: 'smokeTest',
|
|
84
|
+
testDir: smokeTestDir,
|
|
85
|
+
use: {
|
|
86
|
+
...commonConfig
|
|
87
|
+
},
|
|
88
|
+
dependencies: dependencies,
|
|
89
|
+
retries: 0
|
|
90
|
+
}];
|
|
91
|
+
}
|
|
92
|
+
const playwrightConfig = {
|
|
93
|
+
testDir,
|
|
94
|
+
globalTimeout: globalTimeout || 3600000,
|
|
95
|
+
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|
|
96
|
+
fullyParallel: true,
|
|
97
|
+
reporter,
|
|
98
|
+
timeout: testTimeout,
|
|
99
|
+
expect: {
|
|
100
|
+
timeout: expectTimeout
|
|
101
|
+
},
|
|
102
|
+
use,
|
|
103
|
+
projects: isAuthMode ? [{
|
|
104
|
+
name: 'setup',
|
|
105
|
+
testMatch: /.*\.setup\.js/,
|
|
106
|
+
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
107
|
+
teardown: 'cleanup'
|
|
108
|
+
}, ...smokeTestProject, {
|
|
109
|
+
name: 'cleanup',
|
|
110
|
+
testMatch: /.*\.teardown\.js/,
|
|
111
|
+
testDir: _path.default.join(process.cwd(), 'uat')
|
|
112
|
+
}, ...projects] : [...projects, ...smokeTestProject],
|
|
113
|
+
...uatConfig
|
|
114
|
+
};
|
|
115
|
+
return playwrightConfig;
|
|
116
|
+
}
|
|
117
|
+
var _default = exports.default = (0, _test.defineConfig)(getPlaywrightConfig());
|