@zohodesk/testinglibrary 2.9.9 → 2.9.11
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/.gitlab-ci.yml +30 -0
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +1 -2
- package/build/bdd-framework/reporter/cucumber/json.js +1 -2
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +1 -2
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +1 -2
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +1 -2
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +8 -9
- package/build/core/playwright/helpers/auth/loginSteps.js +12 -3
- package/build/core/playwright/helpers/fileMutex.js +14 -19
- package/build/core/playwright/setup/config-utils.js +19 -0
- package/build/core/playwright/test-runner.js +4 -0
- package/build/core/playwright/types.js +2 -1
- package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +2 -19
- package/build/utils/fileUtils.js +16 -0
- package/package.json +4 -3
- package/npm-shrinkwrap.json +0 -6493
- package/unit_reports/unit-report.html +0 -260
package/.gitlab-ci.yml
CHANGED
|
@@ -115,3 +115,33 @@ uat-nobdd:
|
|
|
115
115
|
when: always
|
|
116
116
|
paths:
|
|
117
117
|
- nobdd/uat/playwright-report
|
|
118
|
+
|
|
119
|
+
uatmodule:
|
|
120
|
+
stage: uat
|
|
121
|
+
script:
|
|
122
|
+
- cd examples
|
|
123
|
+
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
124
|
+
- output=$(npm run uatmodule)
|
|
125
|
+
- echo "$output"
|
|
126
|
+
- node ../ValidateUATReport.js examples
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
artifacts:
|
|
130
|
+
when: always
|
|
131
|
+
paths:
|
|
132
|
+
- examples/uat/playwright-report
|
|
133
|
+
|
|
134
|
+
uatconfigmodule:
|
|
135
|
+
stage: uat
|
|
136
|
+
script:
|
|
137
|
+
- cd examples
|
|
138
|
+
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
139
|
+
- output=$(npm run uatconfigmodule)
|
|
140
|
+
- echo "$output"
|
|
141
|
+
- node ../ValidateUATReport.js examples
|
|
142
|
+
|
|
143
|
+
artifacts:
|
|
144
|
+
when: always
|
|
145
|
+
paths:
|
|
146
|
+
- examples/uat/playwright-report
|
|
147
|
+
|
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var messages = _interopRequireWildcard(require("@cucumber/messages"));
|
|
8
8
|
var _valueChecker = require("../valueChecker");
|
|
9
|
-
function
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
10
|
/**
|
|
12
11
|
* Groups Cucumber messages for easier access.
|
|
13
12
|
* Based on Cucumber, with some changes due to strictNullChecks errors.
|
|
@@ -15,8 +15,7 @@ var _durationHelpers = require("../../cucumber/formatter/durationHelpers");
|
|
|
15
15
|
var _locationHelpers = require("../../cucumber/formatter/locationHelpers");
|
|
16
16
|
var _GherkinDocument = require("./messagesBuilder/GherkinDocument");
|
|
17
17
|
var _Projects = require("./messagesBuilder/Projects");
|
|
18
|
-
function
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
19
|
/**
|
|
21
20
|
* Cucumber json reporter.
|
|
22
21
|
* Based on: https://github.com/cucumber/cucumber-js/blob/main/src/formatter/json_formatter.ts
|
|
@@ -8,8 +8,7 @@ exports.Meta = void 0;
|
|
|
8
8
|
var _os = _interopRequireDefault(require("os"));
|
|
9
9
|
var messages = _interopRequireWildcard(require("@cucumber/messages"));
|
|
10
10
|
var _utils = require("../../../utils");
|
|
11
|
-
function
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
12
|
/**
|
|
14
13
|
* Builds meta message.
|
|
15
14
|
* See: https://github.com/cucumber/cucumber-js/blob/main/src/cli/helpers.ts#L100
|
|
@@ -8,8 +8,7 @@ exports.TestStepAttachments = void 0;
|
|
|
8
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
9
|
var messages = _interopRequireWildcard(require("@cucumber/messages"));
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
function
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
12
|
/**
|
|
14
13
|
* Class for getting attachment messages for a particular step.
|
|
15
14
|
*/
|
|
@@ -8,8 +8,7 @@ var messages = _interopRequireWildcard(require("@cucumber/messages"));
|
|
|
8
8
|
var _stripAnsiEscapes = require("../../../utils/stripAnsiEscapes");
|
|
9
9
|
var _timing = require("./timing");
|
|
10
10
|
var _TestStepAttachments = require("./TestStepAttachments");
|
|
11
|
-
function
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
12
|
class TestStepRun {
|
|
14
13
|
testCaseRun;
|
|
15
14
|
testStep;
|
|
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CUSTOM_COMMANDS = void 0;
|
|
7
|
-
const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers', 'filePath', 'headless'];
|
|
7
|
+
const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers', 'filePath', 'headless', 'modules'];
|
|
@@ -24,11 +24,7 @@ function getAuthFileDirectory() {
|
|
|
24
24
|
return _path.default.resolve(_path.default.join(uatDirectory, 'playwright', '.auth'));
|
|
25
25
|
}
|
|
26
26
|
function verifyIfCookieFileExists(authFile) {
|
|
27
|
-
(0,
|
|
28
|
-
if (!(0, _fs.existsSync)(authFile)) {
|
|
29
|
-
console.log('creating auth file..');
|
|
30
|
-
(0, _fs.writeFileSync)(authFile, JSON.stringify(authContent, null, 2));
|
|
31
|
-
}
|
|
27
|
+
return (0, _fs.existsSync)(authFile);
|
|
32
28
|
}
|
|
33
29
|
function convertCookiesToParse(cookies, authFilePath) {
|
|
34
30
|
try {
|
|
@@ -39,8 +35,11 @@ function convertCookiesToParse(cookies, authFilePath) {
|
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
37
|
async function loadCookiesIfPresent(page, authFile) {
|
|
42
|
-
verifyIfCookieFileExists(authFile)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
if (verifyIfCookieFileExists(authFile)) {
|
|
39
|
+
const fileContent = (0, _fs.readFileSync)(authFile);
|
|
40
|
+
const stroageState = convertCookiesToParse(fileContent, authFile);
|
|
41
|
+
if (stroageState.cookies) {
|
|
42
|
+
await page.context().addCookies(stroageState.cookies);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
46
45
|
}
|
|
@@ -10,6 +10,7 @@ var _fileMutex = _interopRequireDefault(require("../fileMutex"));
|
|
|
10
10
|
var _fileMutexConfig = require("../../constants/fileMutexConfig");
|
|
11
11
|
var _checkAuthCookies = require("./checkAuthCookies");
|
|
12
12
|
var _checkAuthDirectory = require("../checkAuthDirectory");
|
|
13
|
+
var _fs = require("fs");
|
|
13
14
|
/* eslint-disable no-console */
|
|
14
15
|
|
|
15
16
|
async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
|
|
@@ -21,9 +22,15 @@ async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
|
|
|
21
22
|
authFilePrefix = authFilePrefix || email;
|
|
22
23
|
const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
|
|
23
24
|
const lockFileName = email.replace(/[@.]/g, '_');
|
|
24
|
-
const fileMutex = new _fileMutex.default((0, _checkAuthDirectory.getLockDirectoryPath)(), lockFileName,
|
|
25
|
+
const fileMutex = new _fileMutex.default((0, _checkAuthDirectory.getLockDirectoryPath)(), lockFileName, _fileMutexConfig.fileDeletionTimeoutConfig);
|
|
26
|
+
let loginUsingCookie = false;
|
|
25
27
|
try {
|
|
26
|
-
|
|
28
|
+
if ((0, _checkAuthCookies.verifyIfCookieFileExists)(authFile)) {
|
|
29
|
+
console.log(`${email} Cookie file exists. Loading cookies, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
30
|
+
loginUsingCookie = true;
|
|
31
|
+
} else {
|
|
32
|
+
await fileMutex.acquire();
|
|
33
|
+
}
|
|
27
34
|
await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
|
|
28
35
|
const isAlreadyLoggedIn = await isLoggedIn(testInfo);
|
|
29
36
|
if (!isAlreadyLoggedIn) {
|
|
@@ -36,7 +43,9 @@ async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
|
|
|
36
43
|
} catch (error) {
|
|
37
44
|
console.error(`Error during login for ${email}:`, error);
|
|
38
45
|
} finally {
|
|
39
|
-
|
|
46
|
+
if (!loginUsingCookie) {
|
|
47
|
+
await fileMutex.release();
|
|
48
|
+
}
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
51
|
var _default = exports.default = performLoginSteps;
|
|
@@ -12,25 +12,19 @@ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("C
|
|
|
12
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
13
|
var _FileMutex_brand = /*#__PURE__*/new WeakSet();
|
|
14
14
|
class FileMutex {
|
|
15
|
-
constructor(directory, lockFileName,
|
|
15
|
+
constructor(directory, lockFileName, fileDeletionTimeoutConfig) {
|
|
16
16
|
_classPrivateMethodInitSpec(this, _FileMutex_brand);
|
|
17
17
|
this.directory = directory;
|
|
18
18
|
this.lockFileName = lockFileName + ".lock";
|
|
19
|
-
this.email = email;
|
|
20
|
-
this.authFile = authFile;
|
|
21
19
|
this.fileDeletionTimeout = fileDeletionTimeoutConfig.timeout;
|
|
22
|
-
this.createDirectoryIfNotExist();
|
|
23
20
|
this.lockFilePath = _assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this);
|
|
21
|
+
_assertClassBrand(_FileMutex_brand, this, _createDirectoryIfNotExist).call(this);
|
|
24
22
|
}
|
|
25
23
|
async acquire() {
|
|
26
|
-
if ((0, _fs.existsSync)(this.authFile)) {
|
|
27
|
-
console.log(`${this.email} Cookie file exists. Loading cookies...`);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
24
|
return new Promise((resolve, reject) => {
|
|
31
25
|
if (!(0, _fs.existsSync)(this.lockFilePath)) {
|
|
32
26
|
(0, _fs.writeFileSync)(this.lockFilePath, 'locked');
|
|
33
|
-
console.log(`Lock file created: ${this.lockFilePath}`);
|
|
27
|
+
console.log(`Lock file created: ${this.lockFilePath}, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
34
28
|
return resolve();
|
|
35
29
|
}
|
|
36
30
|
const timeout = setTimeout(() => {
|
|
@@ -41,7 +35,7 @@ class FileMutex {
|
|
|
41
35
|
try {
|
|
42
36
|
if (eventType === 'rename' && filename === this.lockFileName) {
|
|
43
37
|
clearTimeout(timeout);
|
|
44
|
-
console.log(`Lock file deleted! Proceeding
|
|
38
|
+
console.log(`Lock file deleted! Proceeding, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
45
39
|
watcher.close();
|
|
46
40
|
resolve();
|
|
47
41
|
}
|
|
@@ -56,21 +50,22 @@ class FileMutex {
|
|
|
56
50
|
try {
|
|
57
51
|
if ((0, _fs.existsSync)(this.lockFilePath)) {
|
|
58
52
|
(0, _fs.unlinkSync)(this.lockFilePath);
|
|
59
|
-
console.log(`Lock file deleted: ${this.lockFilePath}`);
|
|
53
|
+
console.log(`Lock file deleted: ${this.lockFilePath}, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
60
54
|
}
|
|
61
55
|
} catch (err) {
|
|
62
|
-
console.error(`Error deleting lock file: ${err.message}`);
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
async createDirectoryIfNotExist() {
|
|
66
|
-
if (!(0, _fs.existsSync)(this.directory)) {
|
|
67
|
-
(0, _fs.mkdirSync)(this.directory, {
|
|
68
|
-
recursive: true
|
|
69
|
-
});
|
|
56
|
+
console.error(`Error deleting lock file: ${err.message}, worker index - ${process.env.TEST_WORKER_INDEX}`);
|
|
57
|
+
throw err;
|
|
70
58
|
}
|
|
71
59
|
}
|
|
72
60
|
}
|
|
73
61
|
function _getLockFilePath() {
|
|
74
62
|
return _path.default.resolve(_path.default.join(this.directory, this.lockFileName));
|
|
75
63
|
}
|
|
64
|
+
async function _createDirectoryIfNotExist() {
|
|
65
|
+
if (!(0, _fs.existsSync)(this.directory)) {
|
|
66
|
+
(0, _fs.mkdirSync)(this.directory, {
|
|
67
|
+
recursive: true
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
76
71
|
var _default = exports.default = FileMutex;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getBrowsersList = getBrowsersList;
|
|
8
|
+
exports.getModulePathForFeatureFiles = getModulePathForFeatureFiles;
|
|
8
9
|
exports.getProjects = getProjects;
|
|
9
10
|
exports.getTestDir = getTestDir;
|
|
10
11
|
exports.getTestUseOptions = getTestUseOptions;
|
|
@@ -142,9 +143,27 @@ function getPathsForFeatureFiles(cwd) {
|
|
|
142
143
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Unable to read test summary from the ${reportPath}. Verify If File Exists in the path`);
|
|
143
144
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Going to run all test cases');
|
|
144
145
|
}
|
|
146
|
+
} else if (process.env.modules !== 'undefined' && process.env.modules.length > 0) {
|
|
147
|
+
let modules = process.env.modules;
|
|
148
|
+
let moduleList = modules.split(',');
|
|
149
|
+
return getModulePathForFeatureFiles(moduleList);
|
|
145
150
|
}
|
|
146
151
|
return [_path.default.join(cwd, 'uat', '**', '*.feature')];
|
|
147
152
|
}
|
|
153
|
+
function getModulePathForFeatureFiles(moduleList) {
|
|
154
|
+
let validModuleList = [];
|
|
155
|
+
moduleList.forEach(moduleName => {
|
|
156
|
+
let modulePath = _path.default.join(process.cwd(), 'uat', 'modules', '**', `${moduleName}`);
|
|
157
|
+
if ((0, _fileUtils.checkIfFolderExistsWithPattern)(modulePath)) {
|
|
158
|
+
validModuleList.push(_path.default.join(modulePath, '**', '*.feature'));
|
|
159
|
+
} else {
|
|
160
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Module ${moduleName} does not exist, Please check the module name`);
|
|
161
|
+
validModuleList = [];
|
|
162
|
+
return validModuleList;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return validModuleList;
|
|
166
|
+
}
|
|
148
167
|
function getTestDir(bddMode, cwd, {
|
|
149
168
|
stepDefinitionsFolder
|
|
150
169
|
}) {
|
|
@@ -92,6 +92,10 @@ function main() {
|
|
|
92
92
|
|
|
93
93
|
// overriding the user config's from CLI
|
|
94
94
|
uatConfig.addAll(userArgConfig);
|
|
95
|
+
const modules = uatConfig.get('modules');
|
|
96
|
+
|
|
97
|
+
//We need to change this process.env variable to pass the module name in future.
|
|
98
|
+
process.env.modules = modules;
|
|
95
99
|
const {
|
|
96
100
|
isAuthMode,
|
|
97
101
|
editionOrder,
|
|
@@ -39,5 +39,6 @@
|
|
|
39
39
|
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
40
40
|
* @property {Array} editionOrder: Order in the form of larger editions in the back. Edition with the most privelages should be last
|
|
41
41
|
* @property {testSetupConfig} testSetup: Specify page and context functions that will be called while intilaizing fixtures.
|
|
42
|
-
|
|
42
|
+
* @property {string} modules: Modules name to be used for running the specific module test cases.
|
|
43
|
+
*/
|
|
43
44
|
"use strict";
|
|
@@ -8,8 +8,6 @@ jest.mock('fs');
|
|
|
8
8
|
describe('FileMutex', () => {
|
|
9
9
|
const directory = '/tmp/locks';
|
|
10
10
|
const lockFileName = 'test-lock';
|
|
11
|
-
const email = 'test@example.com';
|
|
12
|
-
const authFile = '/tmp/authFile';
|
|
13
11
|
const fileDeletionTimeoutConfig = {
|
|
14
12
|
timeout: 1000
|
|
15
13
|
};
|
|
@@ -17,27 +15,14 @@ describe('FileMutex', () => {
|
|
|
17
15
|
let fileMutex;
|
|
18
16
|
beforeEach(() => {
|
|
19
17
|
jest.clearAllMocks();
|
|
20
|
-
fileMutex = new _fileMutex.default(directory, lockFileName,
|
|
18
|
+
fileMutex = new _fileMutex.default(directory, lockFileName, fileDeletionTimeoutConfig);
|
|
21
19
|
});
|
|
22
20
|
describe('acquire', () => {
|
|
23
|
-
it('should create directory if it does not exist', async () => {
|
|
24
|
-
_fs.existsSync.mockReturnValue(false);
|
|
25
|
-
await fileMutex.createDirectoryIfNotExist();
|
|
26
|
-
expect(_fs.mkdirSync).toHaveBeenCalledWith(directory, {
|
|
27
|
-
recursive: true
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
21
|
it('should create the lock file if it does not exist', async () => {
|
|
31
|
-
_fs.existsSync.mockImplementation(filePath => filePath === authFile ? false : false);
|
|
32
22
|
_fs.writeFileSync.mockImplementation(() => {});
|
|
33
23
|
await fileMutex.acquire();
|
|
34
24
|
expect(_fs.writeFileSync).toHaveBeenCalledWith(fileMutex.lockFilePath, 'locked');
|
|
35
25
|
});
|
|
36
|
-
it('should resolve immediately if auth file exists', async () => {
|
|
37
|
-
_fs.existsSync.mockImplementation(filePath => filePath === authFile);
|
|
38
|
-
await fileMutex.acquire();
|
|
39
|
-
expect(_fs.existsSync).toHaveBeenCalledWith(authFile);
|
|
40
|
-
});
|
|
41
26
|
it('should wait for lock file deletion if it exists', async () => {
|
|
42
27
|
_fs.existsSync.mockImplementation(filePath => filePath === fileMutex.lockFilePath);
|
|
43
28
|
_fs.watch.mockImplementation((dir, callback) => {
|
|
@@ -88,9 +73,7 @@ describe('FileMutex', () => {
|
|
|
88
73
|
_fs.unlinkSync.mockImplementation(() => {
|
|
89
74
|
throw new Error(errorMessage);
|
|
90
75
|
});
|
|
91
|
-
|
|
92
|
-
await fileMutex.release();
|
|
93
|
-
expect(console.error).toHaveBeenCalledWith(`Error deleting lock file: ${errorMessage}`);
|
|
76
|
+
await expect(fileMutex.release()).rejects.toThrow(errorMessage);
|
|
94
77
|
});
|
|
95
78
|
});
|
|
96
79
|
});
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.checkIfFileExists = checkIfFileExists;
|
|
8
|
+
exports.checkIfFolderExistsWithPattern = checkIfFolderExistsWithPattern;
|
|
8
9
|
exports.deleteFile = deleteFile;
|
|
9
10
|
exports.deleteFolder = deleteFolder;
|
|
10
11
|
exports.readFileContents = readFileContents;
|
|
@@ -12,6 +13,8 @@ exports.writeFileContents = writeFileContents;
|
|
|
12
13
|
var _fs = _interopRequireDefault(require("fs"));
|
|
13
14
|
var _path = _interopRequireDefault(require("path"));
|
|
14
15
|
var _logger = require("./logger");
|
|
16
|
+
var glob = _interopRequireWildcard(require("glob"));
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
18
|
function checkIfFileExists(file) {
|
|
16
19
|
try {
|
|
17
20
|
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|
|
@@ -69,4 +72,17 @@ function deleteFolder(folderPath) {
|
|
|
69
72
|
throw new Error(`Error while deleting the test data file: ${folderPath}`);
|
|
70
73
|
}
|
|
71
74
|
}
|
|
75
|
+
}
|
|
76
|
+
// This function uses glob to check if a folder exists with a specific pattern
|
|
77
|
+
// Glob is define patterns for matching file and directory names based on wildcards
|
|
78
|
+
function checkIfFolderExistsWithPattern(folderPath) {
|
|
79
|
+
try {
|
|
80
|
+
if (glob.sync(folderPath).length > 0) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
} catch (err) {
|
|
85
|
+
_logger.Logger.error(err);
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
72
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@testing-library/jest-dom": "5.11.9",
|
|
28
28
|
"@testing-library/react": "11.2.7",
|
|
29
29
|
"@testing-library/react-hooks": "7.0.2",
|
|
30
|
+
"@zohodesk/testinglibrary": "^3.1.2",
|
|
30
31
|
"babel-jest": "29.6.2",
|
|
31
32
|
"babel-plugin-transform-dynamic-import": "2.1.0",
|
|
32
33
|
"fast-glob": "3.3.1",
|
|
@@ -40,9 +41,9 @@
|
|
|
40
41
|
"ZDTestingFramework": "./bin/cli.js"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
44
|
+
"eslint": "*",
|
|
43
45
|
"react": "*",
|
|
44
|
-
"react-dom": "*"
|
|
45
|
-
"eslint": "*"
|
|
46
|
+
"react-dom": "*"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@babel/cli": "7.22.15",
|