@zohodesk/testinglibrary 0.0.1 → 0.0.2-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 +23 -0
- package/.eslintrc.js +31 -0
- package/.gitlab-ci.yml +163 -0
- package/.prettierrc +6 -0
- package/README.md +98 -18
- package/bin/cli.js +2 -2
- package/bin/postinstall.js +1 -16
- package/{src → build}/core/jest/preprocessor/jsPreprocessor.js +7 -9
- package/{src → build}/core/jest/runner/jest-runner.js +46 -45
- package/build/core/jest/setup/index.js +3 -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 +44 -0
- package/build/core/playwright/builtInFixtures/page.js +101 -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 +18 -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/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/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 +110 -0
- package/build/core/playwright/setup/config-creator.js +113 -0
- package/build/core/playwright/setup/config-utils.js +189 -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__/configFileNameProvider.test.js +34 -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/fileUtils.js +89 -0
- package/build/utils/getFilePath.js +11 -0
- package/build/utils/logger.js +57 -0
- package/build/utils/rootPath.js +53 -0
- package/build/utils/stepDefinitionsFormatter.js +11 -0
- package/changelog.md +167 -0
- package/jest.config.js +81 -63
- package/npm-shrinkwrap.json +12575 -0
- package/package.json +60 -31
- package/playwright.config.js +62 -112
- package/src/core/jest/setup/index.js +0 -165
- package/src/core/playwright/codegen.js +0 -61
- 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 -81
- package/src/core/playwright/readConfigFile.js +0 -18
- package/src/core/playwright/report-generator.js +0 -44
- 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 -19
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "accountLogin", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _accountLogin.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "getDefaultActor", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _getUsers.getDefaultActor;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "getDefaultActorConf", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _getUsers.getDefaultActorConf;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "getListOfActors", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _getUsers.getListOfActors;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "getRunMode", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return _getUsers.getRunMode;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "getUserForSelectedEditionAndProfile", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _getUsers.getUserForSelectedEditionAndProfile;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "isCI", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _getUsers.isCI;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "isDevelopmentSetup", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return _getUsers.isDevelopmentSetup;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "loadCookiesIfPresent", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _checkAuthCookies.loadCookiesIfPresent;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, "performLoginSteps", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return _loginSteps.default;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "verifyIfCookieFileExists", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () {
|
|
70
|
+
return _checkAuthCookies.verifyIfCookieFileExists;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
var _accountLogin = _interopRequireDefault(require("./accountLogin"));
|
|
74
|
+
var _checkAuthCookies = require("./checkAuthCookies");
|
|
75
|
+
var _getUsers = require("./getUsers");
|
|
76
|
+
var _loginSteps = _interopRequireDefault(require("./loginSteps"));
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _fileMutex = _interopRequireDefault(require("../fileMutex"));
|
|
10
|
+
var _fileMutexConfig = require("../../constants/fileMutexConfig");
|
|
11
|
+
var _checkAuthCookies = require("./checkAuthCookies");
|
|
12
|
+
var _checkAuthDirectory = require("../checkAuthDirectory");
|
|
13
|
+
/* eslint-disable no-console */
|
|
14
|
+
|
|
15
|
+
async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
|
|
16
|
+
let {
|
|
17
|
+
page,
|
|
18
|
+
authFilePrefix,
|
|
19
|
+
email
|
|
20
|
+
} = testInfo;
|
|
21
|
+
authFilePrefix = authFilePrefix || email;
|
|
22
|
+
const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
|
|
23
|
+
const lockFileName = email.replace(/[@.]/g, '_');
|
|
24
|
+
const fileMutex = new _fileMutex.default((0, _checkAuthDirectory.getLockDirectoryPath)(), lockFileName, _fileMutexConfig.fileDeletionTimeoutConfig);
|
|
25
|
+
let loginUsingCookie = false;
|
|
26
|
+
try {
|
|
27
|
+
if ((0, _checkAuthCookies.verifyIfCookieFileExists)(authFile)) {
|
|
28
|
+
console.log(`${email} Cookie file exists. Loading cookies, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
29
|
+
loginUsingCookie = true;
|
|
30
|
+
} else {
|
|
31
|
+
await fileMutex.acquire();
|
|
32
|
+
}
|
|
33
|
+
await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
|
|
34
|
+
const isAlreadyLoggedIn = await isLoggedIn(testInfo);
|
|
35
|
+
if (!isAlreadyLoggedIn) {
|
|
36
|
+
await loginSteps(testInfo);
|
|
37
|
+
await isLoggedIn(testInfo);
|
|
38
|
+
await page.context().storageState({
|
|
39
|
+
path: authFile
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error(`Error during login for ${email}:`, error);
|
|
44
|
+
} finally {
|
|
45
|
+
if (!loginUsingCookie) {
|
|
46
|
+
await fileMutex.release();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var _default = exports.default = performLoginSteps;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createAuthDirectoryIfNotExist = createAuthDirectoryIfNotExist;
|
|
8
|
+
exports.getLockDirectoryPath = getLockDirectoryPath;
|
|
9
|
+
var _fs = require("fs");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _checkAuthCookies = require("./auth/checkAuthCookies");
|
|
12
|
+
var _readConfigFile = require("../readConfigFile");
|
|
13
|
+
function createAuthDirectoryIfNotExist() {
|
|
14
|
+
const authDirectory = (0, _checkAuthCookies.getAuthFileDirectory)();
|
|
15
|
+
if (!(0, _fs.existsSync)(authDirectory)) {
|
|
16
|
+
console.log('Creating auth directory for the first time setup...');
|
|
17
|
+
(0, _fs.mkdirSync)(authDirectory, {
|
|
18
|
+
recursive: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function getLockDirectoryPath() {
|
|
23
|
+
const {
|
|
24
|
+
uatDirectory
|
|
25
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
26
|
+
return _path.default.resolve(_path.default.join(uatDirectory, 'playwright', '.lock'));
|
|
27
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getEnvConfigFilePath = getEnvConfigFilePath;
|
|
8
|
+
exports.getReportFileName = getReportFileName;
|
|
9
|
+
exports.getUATFileName = getUATFileName;
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
+
var _auth = require("./auth");
|
|
13
|
+
function getUATFileName(mode) {
|
|
14
|
+
mode = mode || (0, _auth.getRunMode)();
|
|
15
|
+
const uatConfFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/uat.config.js`);
|
|
16
|
+
if (_fs.default.existsSync(uatConfFilePath)) {
|
|
17
|
+
return uatConfFilePath;
|
|
18
|
+
}
|
|
19
|
+
return _path.default.resolve(process.cwd(), `uat/conf/default/uat.config.js`);
|
|
20
|
+
}
|
|
21
|
+
function getEnvConfigFilePath(mode) {
|
|
22
|
+
const confFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/settings.json`);
|
|
23
|
+
// TODO: Actors Mode as config
|
|
24
|
+
if (_fs.default.existsSync(confFilePath)) {
|
|
25
|
+
return `uat/conf/${mode}/settings.json`;
|
|
26
|
+
}
|
|
27
|
+
return `uat/conf/default/settings.json`;
|
|
28
|
+
}
|
|
29
|
+
function getReportFileName() {
|
|
30
|
+
return `test-summary.json`;
|
|
31
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _fs = require("fs");
|
|
10
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
11
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
12
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
13
|
+
var _FileMutex_brand = /*#__PURE__*/new WeakSet();
|
|
14
|
+
class FileMutex {
|
|
15
|
+
constructor(directory, lockFileName, fileDeletionTimeoutConfig) {
|
|
16
|
+
_classPrivateMethodInitSpec(this, _FileMutex_brand);
|
|
17
|
+
this.directory = directory;
|
|
18
|
+
this.lockFileName = lockFileName + ".lock";
|
|
19
|
+
this.fileDeletionTimeout = fileDeletionTimeoutConfig.timeout;
|
|
20
|
+
this.lockFilePath = _assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this);
|
|
21
|
+
_assertClassBrand(_FileMutex_brand, this, _createDirectoryIfNotExist).call(this);
|
|
22
|
+
}
|
|
23
|
+
async acquire() {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
if (!(0, _fs.existsSync)(this.lockFilePath)) {
|
|
26
|
+
(0, _fs.writeFileSync)(this.lockFilePath, 'locked');
|
|
27
|
+
console.log(`Lock file created: ${this.lockFilePath}, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
28
|
+
return resolve();
|
|
29
|
+
}
|
|
30
|
+
const timeout = setTimeout(() => {
|
|
31
|
+
watcher.close();
|
|
32
|
+
reject(new Error('Watch timeout exceeded'));
|
|
33
|
+
}, this.fileDeletionTimeout);
|
|
34
|
+
const watcher = (0, _fs.watch)(this.directory, (eventType, filename) => {
|
|
35
|
+
try {
|
|
36
|
+
if (eventType === 'rename' && filename === this.lockFileName) {
|
|
37
|
+
clearTimeout(timeout);
|
|
38
|
+
console.log(`Lock file deleted! Proceeding, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
39
|
+
watcher.close();
|
|
40
|
+
resolve();
|
|
41
|
+
}
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.error(`Error watching for lock file deletion: ${err.message}`);
|
|
44
|
+
watcher.close();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async release() {
|
|
50
|
+
try {
|
|
51
|
+
if ((0, _fs.existsSync)(this.lockFilePath)) {
|
|
52
|
+
(0, _fs.unlinkSync)(this.lockFilePath);
|
|
53
|
+
console.log(`Lock file deleted: ${this.lockFilePath}, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
54
|
+
}
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.error(`Error deleting lock file: ${err.message}, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function _getLockFilePath() {
|
|
62
|
+
return _path.default.resolve(_path.default.join(this.directory, this.lockFileName));
|
|
63
|
+
}
|
|
64
|
+
async function _createDirectoryIfNotExist() {
|
|
65
|
+
if (!(0, _fs.existsSync)(this.directory)) {
|
|
66
|
+
(0, _fs.mkdirSync)(this.directory, {
|
|
67
|
+
recursive: true
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
var _default = exports.default = FileMutex;
|
|
@@ -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;
|