@zohodesk/testinglibrary 3.0.4 → 3.0.8

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.
Files changed (26) hide show
  1. package/.gitlab-ci.yml +26 -13
  2. package/README.md +27 -0
  3. package/build/core/playwright/builtInFixtures/page.js +44 -39
  4. package/build/core/playwright/constants/fileMutexConfig.js +7 -3
  5. package/build/core/playwright/custom-commands.js +1 -1
  6. package/build/core/playwright/helpers/auth/loginSteps.js +15 -14
  7. package/build/core/playwright/helpers/checkAuthDirectory.js +10 -0
  8. package/build/core/playwright/helpers/fileMutex.js +20 -23
  9. package/build/core/playwright/runner/Runner.js +22 -0
  10. package/build/core/playwright/runner/RunnerHelper.js +43 -0
  11. package/build/core/playwright/runner/RunnerTypes.js +17 -0
  12. package/build/core/playwright/runner/SpawnRunner.js +110 -0
  13. package/build/core/playwright/setup/config-creator.js +10 -5
  14. package/build/core/playwright/test-runner.js +8 -34
  15. package/build/setup-folder-structure/samples/accountLogin-sample.js +19 -0
  16. package/build/setup-folder-structure/samples/auth-setup-sample.js +4 -10
  17. package/build/setup-folder-structure/samples/testSetup-sample.js +14 -0
  18. package/build/setup-folder-structure/samples/uat-config-sample.js +3 -1
  19. package/build/setup-folder-structure/setupProject.js +4 -0
  20. package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +45 -68
  21. package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +16 -0
  22. package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +27 -0
  23. package/npm-shrinkwrap.json +817 -494
  24. package/package.json +8 -7
  25. package/playwright.config.js +0 -48
  26. package/zohodesk-testinglibrary-3.0.4.tgz +0 -0
package/.gitlab-ci.yml CHANGED
@@ -18,14 +18,19 @@ default:
18
18
  paths:
19
19
  - node_modules
20
20
  - build
21
+ - npm-shrinkwrap.json
21
22
 
22
23
  # Install dependencies stage
23
24
  build:
24
25
  stage: build
25
26
  script:
27
+ - npm -v
28
+ - node -v
26
29
  - npm install --ignore-scripts
27
30
  - npm run build
28
31
  - npm install
32
+ - npm shrinkwrap
33
+ - npm run build
29
34
 
30
35
  # Unit tests stage
31
36
  unit:
@@ -45,9 +50,7 @@ uat-auth:
45
50
  - npm install $(npm pack ../../testing-framework | tail -1)
46
51
  - output=$(npm run uatauth)
47
52
  - echo "$output"
48
- - if [[ "$output" == *"failed"* ]]; then
49
- - exit 1
50
- - fi
53
+ - node ../ValidateUATReport.js examples
51
54
 
52
55
  artifacts:
53
56
  when: always
@@ -61,9 +64,7 @@ uat-noauth:
61
64
  - npm install $(npm pack ../../testing-framework | tail -1)
62
65
  - output=$(npm run uatnoauth)
63
66
  - echo "$output"
64
- - if [[ "$output" == *"failed"* ]]; then
65
- - exit 1
66
- - fi
67
+ - node ../ValidateUATReport.js examples
67
68
 
68
69
  artifacts:
69
70
  when: always
@@ -77,9 +78,23 @@ uat-profile:
77
78
  - npm install $(npm pack ../../testing-framework | tail -1)
78
79
  - output=$(npm run uatprofile)
79
80
  - echo "$output"
80
- - if [[ "$output" == *"failed"* ]]; then
81
- - exit 1
82
- - fi
81
+ - node ../ValidateUATReport.js examples
82
+
83
+ artifacts:
84
+ when: always
85
+ paths:
86
+ - examples/uat/playwright-report
87
+
88
+
89
+ uat-unauth:
90
+ stage: uat
91
+ script:
92
+ - cd examples
93
+ - npm install $(npm pack ../../testing-framework | tail -1)
94
+ - output=$(npm run uatunauth)
95
+ - echo "$output"
96
+ - node ../ValidateUATReport.js examples
97
+
83
98
 
84
99
  artifacts:
85
100
  when: always
@@ -91,11 +106,9 @@ uat-nobdd:
91
106
  script:
92
107
  - cd nobdd
93
108
  - npm install $(npm pack ../../testing-framework | tail -1)
94
- - output=$(npm run uatnobdd)
109
+ - output=$(npm run uatnobdd -- --headless)
95
110
  - echo "$output"
96
- - if [[ "$output" == *"failed"* ]]; then
97
- - exit 1
98
- - fi
111
+ - node ../ValidateUATReport.js nobdd
99
112
 
100
113
 
101
114
  artifacts:
package/README.md CHANGED
@@ -29,6 +29,28 @@
29
29
 
30
30
  ## Version History
31
31
 
32
+ ### v3.0.8 - 25-12-2024
33
+
34
+ #### Enhancement
35
+ - Added support to disable headless mode using command line arguments
36
+ - Proper validation added for node 14 build process
37
+ - Removed unwanted uat.config.js files in test projects (examples / nobdd)
38
+
39
+ ### v0.2.9.2 - 22-11-2024
40
+
41
+ #### BugFix
42
+ - Implemented synchronization for the login process. This fix will help avoid login session-related failures in UAT.
43
+
44
+ ### v0.3.1 - 13-11-2024
45
+
46
+ #### Issue Fix
47
+ - Adding bddmode to get the fixtures.
48
+
49
+ ### v0.2.9.1 - 14-11-2024
50
+
51
+ #### Enhancement
52
+ - Beta feature Actors and edition configurations are unified
53
+
32
54
  ### v0.2.9 - 25-10-2024
33
55
 
34
56
  #### Feature
@@ -60,6 +82,11 @@
60
82
  #### Issue Fix
61
83
  - Adding bddmode to get the fixtures.
62
84
 
85
+ ### v0.3.3 - 27-11-2024
86
+
87
+ #### Feature
88
+ - Custom report integration support (ReportPortal)
89
+
63
90
  ### v0.2.9.1 - 14-11-2024
64
91
 
65
92
  #### Enhancement
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
7
  var _auth = require("../helpers/auth");
9
- var _getUrlOrigin = _interopRequireDefault(require("../helpers/auth/getUrlOrigin"));
10
8
  var _readConfigFile = require("../readConfigFile");
11
9
  /* eslint-disable global-require */
12
10
 
@@ -34,6 +32,16 @@ function getCustomAccountDetails(tags) {
34
32
  const {
35
33
  testSetup
36
34
  } = (0, _readConfigFile.generateConfigFromFile)();
35
+ async function loginSteps(pageDetail) {
36
+ const {
37
+ page
38
+ } = pageDetail;
39
+ if (testSetup.loginSteps && typeof testSetup.loginSteps === 'function') {
40
+ return await testSetup.loginSteps(pageDetail);
41
+ } else {
42
+ await page.goto(process.env.domain);
43
+ }
44
+ }
37
45
  async function performDefaultPageSteps({
38
46
  context,
39
47
  $tags,
@@ -49,13 +57,11 @@ async function performDefaultPageSteps({
49
57
  await page.goto(process.env.domain);
50
58
  }
51
59
  }
52
- async function verifyPageIsLoaded(page) {
53
- const urlOrigin = (0, _getUrlOrigin.default)(page.url());
54
- const domainOrigin = (0, _getUrlOrigin.default)(process.env.domain);
55
- if (urlOrigin === domainOrigin) {
56
- return true;
60
+ async function verifyPageIsLoaded(testInfo) {
61
+ if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
62
+ return await testSetup.validateLogin(testInfo);
57
63
  }
58
- return false;
64
+ return true;
59
65
  }
60
66
  var _default = exports.default = {
61
67
  page: async ({
@@ -63,38 +69,37 @@ var _default = exports.default = {
63
69
  $tags,
64
70
  page
65
71
  }, use) => {
66
- const {
67
- isAuthMode
68
- } = (0, _readConfigFile.generateConfigFromFile)();
69
- if (!isAuthMode) {
70
- await use(page);
71
- return;
72
- }
73
- const testPortalDetails = getCustomAccountDetails($tags);
74
- if (testPortalDetails === null) {
75
- await performDefaultPageSteps({
76
- context,
77
- $tags,
78
- page
79
- });
80
- const user = (0, _auth.getDefaultActor)();
81
- process.env.actorInfo = JSON.stringify(user);
82
- await use(page);
83
- } else {
84
- await context.clearCookies();
72
+ try {
73
+ //This block is used to skip the login process if the @unauthenticated tag is added to the script
74
+ if ($tags.includes('@unauthenticated')) {
75
+ await context.clearCookies();
76
+ return;
77
+ }
85
78
  const {
86
- email,
87
- password
88
- } = testPortalDetails;
89
- await (0, _auth.performLoginSteps)({
90
- page,
91
- authFilePrefix: email,
92
- useremail: email,
93
- password: password
94
- }, async () => {
95
- return await verifyPageIsLoaded(page);
96
- });
97
- process.env.actorInfo = JSON.stringify(testPortalDetails);
79
+ isAuthMode
80
+ } = (0, _readConfigFile.generateConfigFromFile)();
81
+ if (!isAuthMode) {
82
+ return;
83
+ }
84
+ const testPortalDetails = getCustomAccountDetails($tags);
85
+ if (testPortalDetails) {
86
+ await context.clearCookies();
87
+ const {
88
+ email
89
+ } = testPortalDetails;
90
+ await (0, _auth.performLoginSteps)({
91
+ page,
92
+ $tags,
93
+ context,
94
+ ...testPortalDetails
95
+ }, async testInfo => {
96
+ return await verifyPageIsLoaded(testInfo);
97
+ }, loginSteps);
98
+ process.env.actorInfo = JSON.stringify(testPortalDetails);
99
+ }
100
+ } catch (error) {
101
+ console.error('Error during page', error);
102
+ } finally {
98
103
  await performDefaultPageSteps({
99
104
  context,
100
105
  $tags,
@@ -5,7 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.LOGIN_MUTEX_TIMEOUT = void 0;
7
7
  const LOGIN_MUTEX_TIMEOUT = exports.LOGIN_MUTEX_TIMEOUT = {
8
- "wait": 300000,
9
- "retries": 600,
10
- "stale": 240000
8
+ stale: 100000,
9
+ retries: {
10
+ retries: 10,
11
+ factor: 1,
12
+ minTimeout: 10000,
13
+ maxTimeout: 20000
14
+ }
11
15
  };
@@ -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'];
7
+ const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers', 'filePath', 'headless'];
@@ -8,40 +8,41 @@ exports.default = void 0;
8
8
  var _path = _interopRequireDefault(require("path"));
9
9
  var _fileMutex = _interopRequireDefault(require("../fileMutex"));
10
10
  var _fileMutexConfig = require("../../constants/fileMutexConfig");
11
- var _accountLogin = _interopRequireDefault(require("./accountLogin"));
12
11
  var _checkAuthCookies = require("./checkAuthCookies");
12
+ var _checkAuthDirectory = require("../checkAuthDirectory");
13
13
  /* eslint-disable no-console */
14
14
 
15
- async function performLoginSteps({
16
- page,
17
- authFilePrefix,
18
- useremail,
19
- password
20
- }, isLoggedIn) {
15
+ async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
16
+ let {
17
+ page,
18
+ authFilePrefix,
19
+ email
20
+ } = testInfo;
21
+ authFilePrefix = authFilePrefix || email;
21
22
  const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
22
- const lockFileName = useremail.replace(/[@.]/g, '_');
23
- const fileMutex = new _fileMutex.default((0, _checkAuthCookies.getAuthFileDirectory)(), lockFileName, _fileMutexConfig.LOGIN_MUTEX_TIMEOUT);
23
+ const lockFileName = email.replace(/[@.]/g, '_');
24
+ const fileMutex = new _fileMutex.default((0, _checkAuthDirectory.getLockDirectoryPath)(), lockFileName, _fileMutexConfig.LOGIN_MUTEX_TIMEOUT);
24
25
  try {
25
26
  await fileMutex.acquire();
26
27
  await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
27
28
  await page.goto(process.env.domain);
28
29
  await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
29
- const isAlreadyLoggedIn = await isLoggedIn(page);
30
+ const isAlreadyLoggedIn = await isLoggedIn(testInfo);
30
31
  if (!isAlreadyLoggedIn) {
31
- await (0, _accountLogin.default)(page, useremail, password);
32
+ await loginSteps(testInfo);
32
33
  await page.goto(process.env.domain);
33
- await isLoggedIn(page);
34
+ await isLoggedIn(testInfo);
34
35
  await page.context().storageState({
35
36
  path: authFile
36
37
  });
37
38
  }
38
39
  } catch (error) {
39
- console.error(`Error during login for ${useremail}:`, error);
40
+ console.error(`Error during login for ${email}:`, error);
40
41
  } finally {
41
42
  try {
42
43
  await fileMutex.release();
43
44
  } catch (releaseError) {
44
- console.error(`Error releasing lock for ${useremail}:`, releaseError);
45
+ console.error(`Error releasing lock for ${email}:`, releaseError);
45
46
  }
46
47
  }
47
48
  }
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.createAuthDirectoryIfNotExist = createAuthDirectoryIfNotExist;
8
+ exports.getLockDirectoryPath = getLockDirectoryPath;
7
9
  var _fs = require("fs");
10
+ var _path = _interopRequireDefault(require("path"));
8
11
  var _checkAuthCookies = require("./auth/checkAuthCookies");
12
+ var _readConfigFile = require("../readConfigFile");
9
13
  function createAuthDirectoryIfNotExist() {
10
14
  const authDirectory = (0, _checkAuthCookies.getAuthFileDirectory)();
11
15
  if (!(0, _fs.existsSync)(authDirectory)) {
@@ -14,4 +18,10 @@ function createAuthDirectoryIfNotExist() {
14
18
  recursive: true
15
19
  });
16
20
  }
21
+ }
22
+ function getLockDirectoryPath() {
23
+ const {
24
+ uatDirectory
25
+ } = (0, _readConfigFile.generateConfigFromFile)();
26
+ return _path.default.resolve(_path.default.join(uatDirectory, 'playwright', '.lock'));
17
27
  }
@@ -6,45 +6,42 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _path = _interopRequireDefault(require("path"));
9
- var _lockfile = _interopRequireDefault(require("lockfile"));
9
+ var _properLockfile = _interopRequireDefault(require("proper-lockfile"));
10
10
  var _fs = require("fs");
11
11
  function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
12
12
  function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
13
13
  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"); }
14
14
  var _FileMutex_brand = /*#__PURE__*/new WeakSet();
15
15
  class FileMutex {
16
- constructor(directory, lockFileName, timeout) {
16
+ constructor(directory, lockFileName, options = {}) {
17
17
  _classPrivateMethodInitSpec(this, _FileMutex_brand);
18
18
  this.directory = directory;
19
- this.lockFileName = lockFileName;
20
- this.timeout = timeout;
19
+ this.lockFileName = lockFileName + ".lock";
20
+ this.options = options;
21
21
  }
22
22
  async acquire() {
23
23
  _assertClassBrand(_FileMutex_brand, this, _createDirectoryIfNotExist).call(this);
24
- return new Promise((resolve, reject) => {
25
- _lockfile.default.lock(_assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this), this.timeout, err => {
26
- if (err) {
27
- reject(err);
28
- } else {
29
- resolve();
30
- }
31
- });
32
- });
24
+ const lockFilePath = _assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this);
25
+ try {
26
+ if (!(0, _fs.existsSync)(lockFilePath)) {
27
+ console.log(`[DEBUG] Creating missing lock file:`, this.lockFileName);
28
+ (0, _fs.writeFileSync)(lockFilePath, 'locked');
29
+ }
30
+ await _properLockfile.default.lock(lockFilePath, this.options);
31
+ } catch (err) {
32
+ throw new Error(`Failed to acquire lock after ${this.options.retries.retries} attempts: ${err.message}`);
33
+ }
33
34
  }
34
35
  async release() {
35
- return new Promise((resolve, reject) => {
36
- _lockfile.default.unlock(_assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this), err => {
37
- if (err) {
38
- reject(err);
39
- } else {
40
- resolve();
41
- }
42
- });
43
- });
36
+ try {
37
+ await _properLockfile.default.unlock(_assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this));
38
+ } catch (err) {
39
+ throw new Error(`Failed to release lock: ${err.message}`);
40
+ }
44
41
  }
45
42
  }
46
43
  function _getLockFilePath() {
47
- return _path.default.resolve(_path.default.join(this.directory, `/${this.lockFileName}.lock`));
44
+ return _path.default.resolve(_path.default.join(this.directory, this.lockFileName));
48
45
  }
49
46
  function _createDirectoryIfNotExist() {
50
47
  if (!(0, _fs.existsSync)(this.directory)) {
@@ -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,110 @@
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
+ class SpawnRunner extends _Runner.default {
12
+ constructor(runnerObj) {
13
+ super(runnerObj);
14
+ this.runnerObj = runnerObj;
15
+ }
16
+ run() {
17
+ const {
18
+ config
19
+ } = this.runnerObj;
20
+ let promises = [];
21
+ const {
22
+ bddMode
23
+ } = config.getAll();
24
+ if (bddMode) {
25
+ promises.push(this.runPreprocessing());
26
+ }
27
+ Promise.all(promises).then(() => this.runPlaywright()).catch(err => {
28
+ _logger.Logger.error(err);
29
+ process.exit();
30
+ });
31
+ }
32
+ runPreprocessing() {
33
+ const {
34
+ tagArgs
35
+ } = this.runnerObj;
36
+ const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve(__dirname, '../', '../', '../', '../', 'playwrightConfig.js');
37
+ const beforeCommand = 'node';
38
+ const bddGenPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('bddgen'));
39
+ const beforeArgs = [bddGenPath, '-c', require.resolve(configPath)];
40
+ if (tagArgs) {
41
+ beforeArgs.push('--tags');
42
+ beforeArgs.push(tagArgs);
43
+ }
44
+ return new Promise((resolve, reject) => {
45
+ const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
46
+ stdio: 'inherit',
47
+ env: {
48
+ ...process.env
49
+ }
50
+ });
51
+ childProcessForPreprocessing.on('error', data => {
52
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
53
+ reject(data);
54
+ });
55
+ childProcessForPreprocessing.on('exit', code => {
56
+ if (code === 0) {
57
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
58
+ resolve();
59
+ } else {
60
+ reject(`BddGen exited with code ${code}`);
61
+ }
62
+ });
63
+ });
64
+ }
65
+ runPlaywright() {
66
+ const {
67
+ tagArgs,
68
+ config,
69
+ userArgs
70
+ } = this.runnerObj;
71
+ const {
72
+ debug,
73
+ bddMode = false,
74
+ headless = false
75
+ } = config.getAll();
76
+ const playwrightArgs = _RunnerHelper.default.getPlaywrightArgs(userArgs, debug, bddMode, tagArgs, headless);
77
+ const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
78
+ const command = playwrightPath;
79
+ const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve('../', '../', '../', '../', 'playwrightConfig.js');
80
+ const args = ['test', '--config', require.resolve(configPath)].concat(playwrightArgs);
81
+ return new Promise((resolve, reject) => {
82
+ const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
83
+ stdio: 'inherit',
84
+ env: {
85
+ ...process.env
86
+ }
87
+ });
88
+ childProcessForRunningPlaywright.on('error', error => {
89
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
90
+ });
91
+ childProcessForRunningPlaywright.on('exit', (code, signal) => {
92
+ if (code !== 0) {
93
+ reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
94
+ } else {
95
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
96
+ resolve();
97
+ }
98
+ });
99
+ process.on('exit', () => {
100
+ childProcessForRunningPlaywright.kill();
101
+ reject('Terminating Playwright Process...');
102
+ });
103
+ process.on('SIGINT', () => {
104
+ childProcessForRunningPlaywright.kill();
105
+ reject('Cleaning up...');
106
+ });
107
+ });
108
+ }
109
+ }
110
+ module.exports = SpawnRunner;
@@ -25,7 +25,8 @@ const {
25
25
  featureFilesFolder,
26
26
  stepDefinitionsFolder,
27
27
  testIdAttribute,
28
- globalTimeout
28
+ globalTimeout,
29
+ customReporter
29
30
  } = uatConfig;
30
31
  const projects = (0, _configUtils.getProjects)({
31
32
  browsers,
@@ -45,6 +46,13 @@ const use = {
45
46
  viewport,
46
47
  testIdAttribute
47
48
  };
49
+ let reporter = [['html', {
50
+ outputFolder: reportPath,
51
+ open: openReportOn
52
+ }], ['list'], ['./custom-reporter.js']];
53
+ if (customReporter) {
54
+ reporter = [customReporter, ...reporter];
55
+ }
48
56
 
49
57
  /**
50
58
  * Playwright configuration object
@@ -57,10 +65,7 @@ function getPlaywrightConfig() {
57
65
  globalTimeout: globalTimeout || 3600000,
58
66
  outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
59
67
  fullyParallel: true,
60
- reporter: [['html', {
61
- outputFolder: reportPath,
62
- open: openReportOn
63
- }], ['list'], ['./custom-reporter.js']],
68
+ reporter,
64
69
  timeout: testTimeout,
65
70
  expect: {
66
71
  timeout: expectTimeout