@zohodesk/testinglibrary 0.4.98-n18-experimental → 0.4.100-n18-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/README.md CHANGED
@@ -17,22 +17,20 @@
17
17
 
18
18
  - npm run report
19
19
 
20
- ### v3.2.13 - 30-10-2025
21
-
22
- #### Enhancement
23
-
24
- - A teardown option has been introduced in the configuration to manage and clean up login sessions stored in the NFS environment.
25
-
26
- ### Issue fix
27
-
28
- - Custom teardown comment provided
29
-
30
20
  ### v3.2.11 - 13-10-2025
31
21
 
32
22
  ### Feature
33
23
 
34
24
  - New step a search entity using {string} provided for search indexing, This step will use run time data generation response as input for the indexing
35
25
 
26
+ ### Issue fix
27
+ - Custom teardown comment provided
28
+
29
+ ### v3.2.10 - 09-10-2025
30
+
31
+ #### Enhancement
32
+ - A teardown option has been introduced in the configuration to manage and clean up login sessions stored in the NFS environment.
33
+
36
34
 
37
35
  ### v3.2.9 - 26-09-2025
38
36
 
@@ -1,15 +1,17 @@
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.combineConfiguration = combineConfiguration;
7
8
  exports.getApplicationConfig = getApplicationConfig;
8
- exports.getRunStage = getRunStage;
9
+ var _path = _interopRequireDefault(require("path"));
9
10
  var _logger = require("../../../utils/logger");
10
11
  var _configFileNameProvider = require("../helpers/configFileNameProvider");
11
12
  var _mergeObjects = require("../helpers/mergeObjects");
12
13
  var _fs = require("fs");
14
+ const Configuration = require("./Configuration");
13
15
  function combineConfiguration(defaultConfig, userConfiguration) {
14
16
  let configurationObj = {};
15
17
  Object.keys(userConfiguration).forEach(configKey => {
@@ -24,10 +26,10 @@ function combineConfiguration(defaultConfig, userConfiguration) {
24
26
  });
25
27
  return (0, _mergeObjects.mergeObjects)(defaultConfig, configurationObj);
26
28
  }
27
- function getApplicationConfig(stage, mode) {
29
+ function getApplicationConfig(mode) {
28
30
  let filePath = "";
29
31
  try {
30
- filePath = (0, _configFileNameProvider.getUATFileName)(stage, mode);
32
+ filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)(mode));
31
33
  if (!(0, _fs.existsSync)(filePath)) {
32
34
  throw new Error("Exception while getting the uat file from the application - " + filePath);
33
35
  }
@@ -38,8 +40,4 @@ function getApplicationConfig(stage, mode) {
38
40
  _logger.Logger.error(err);
39
41
  return {};
40
42
  }
41
- }
42
- function getRunStage() {
43
- const stage = process.env.stage;
44
- return stage || 'uat';
45
43
  }
@@ -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 = ['stage', 'mode', 'tags', 'edition', 'browsers', 'filePath', 'headless', 'modules', 'isTearDown'];
7
+ const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers', 'filePath', 'headless', 'modules', 'isTearDown'];
@@ -17,24 +17,19 @@ function setEnvironmentVariables(configJSON) {
17
17
  }
18
18
  function addHelperLogsForEnvInitialization() {
19
19
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `Mode under which test cases should run has not been specified in args.`);
20
- _logger.Logger.log(_logger.Logger.INFO_TYPE, `Please specify --mode='dev/ci/cd/devautomation' while running ZDTestingFramework test`);
20
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Please specify --mode='dev/prod' while running ZDTestingFramework test`);
21
21
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `Going to use default mode as dev`);
22
22
  }
23
- function initializeEnvConfig(stage, mode, isAuthMode) {
23
+ function initializeEnvConfig(mode, isAuthMode) {
24
24
  try {
25
25
  if (!mode) {
26
26
  addHelperLogsForEnvInitialization();
27
27
  mode = 'dev';
28
28
  }
29
- if (!stage) {
30
- stage = 'uat';
31
- _logger.Logger.log(_logger.Logger.INFO_TYPE, `No stage specified. Using default stage as 'uat'`);
32
- }
33
- const configFile = (0, _fs.readFileSync)(_path.default.resolve(process.cwd(), `./${(0, _configFileNameProvider.getEnvConfigFilePath)(stage, mode)}`));
29
+ const configFile = (0, _fs.readFileSync)(_path.default.resolve(process.cwd(), `./${(0, _configFileNameProvider.getEnvConfigFilePath)(mode)}`));
34
30
  const configJSON = JSON.parse(configFile);
35
31
  setEnvironmentVariables({
36
32
  ...configJSON,
37
- stage,
38
33
  mode
39
34
  });
40
35
  if (isAuthMode) {
@@ -43,6 +38,6 @@ function initializeEnvConfig(stage, mode, isAuthMode) {
43
38
  }
44
39
  } catch (err) {
45
40
  _logger.Logger.error(err);
46
- throw new Error(`Config File Not Exists. Please provide a config file to initialize the environment variables`);
41
+ throw new Error(`Config File Not Exists. Please provide a config file ${(0, _configFileNameProvider.getEnvConfigFilePath)(mode)} to intiailize the environment variables `);
47
42
  }
48
43
  }
@@ -13,8 +13,7 @@ exports.isCI = isCI;
13
13
  exports.isDevelopmentSetup = isDevelopmentSetup;
14
14
  var _path = _interopRequireDefault(require("path"));
15
15
  var _fs = require("fs");
16
- var _resolveStageConfigPath = require("./../resolveStageConfigPath");
17
- var _ConfigurationHelper = require("./../../configuration/ConfigurationHelper");
16
+ var _readConfigFile = require("../../readConfigFile");
18
17
  /* eslint-disable global-require */
19
18
  function getRunMode() {
20
19
  let {
@@ -31,18 +30,19 @@ function isDevelopmentSetup() {
31
30
  return mode === 'DEV' || mode === 'dev';
32
31
  }
33
32
  function getDefaultActorConf() {
34
- const stage = (0, _ConfigurationHelper.getRunStage)();
35
- const stageConfig = (0, _resolveStageConfigPath.resolveStageConfigPath)(stage);
36
- const modeSettingsFile = `${stageConfig}/${getRunMode()}/settings.json`;
37
- const filePath = _path.default.join(_path.default.resolve(process.cwd(), modeSettingsFile));
33
+ const {
34
+ uatDirectory
35
+ } = (0, _readConfigFile.generateConfigFromFile)();
36
+ const modeSettingsFile = `conf/${getRunMode()}/settings.json`;
37
+ const filePath = _path.default.join(uatDirectory, modeSettingsFile);
38
38
  try {
39
39
  if (!(0, _fs.existsSync)(filePath)) {
40
- const defaultSettingsFile = _path.default.join(_path.default.resolve(process.cwd(), `${stage}/conf/default/settings.json`));
40
+ const defaultSettingsFile = _path.default.join(uatDirectory, `conf/default/settings.json`);
41
41
  return require(defaultSettingsFile);
42
42
  }
43
43
  return require(filePath);
44
44
  } catch (error) {
45
- throw new Error(`${filePath} file missing.`);
45
+ throw new Error(`${defaultSettingFile} ${filePath} both files are missing.`);
46
46
  }
47
47
  }
48
48
  function getDefaultActor() {
@@ -53,17 +53,18 @@ function getDefaultActor() {
53
53
  return getUserForSelectedEditionAndProfile(edition, profile);
54
54
  }
55
55
  function getListOfActors(betaFeature) {
56
+ const {
57
+ uatDirectory
58
+ } = (0, _readConfigFile.generateConfigFromFile)();
56
59
  const mode = getRunMode();
57
- const stage = (0, _ConfigurationHelper.getRunStage)();
58
- const stageConfig = (0, _resolveStageConfigPath.resolveStageConfigPath)(stage);
59
- let configFile = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${mode}/actors/index.js`));
60
+ let configFile = _path.default.join(uatDirectory, `conf/${mode}/actors/index.js`);
60
61
  let betaReference = mode;
61
62
  if (!(0, _fs.existsSync)(configFile)) {
62
- configFile = _path.default.join(_path.default.resolve(process.cwd(), `${stage}/conf/default/actors/index.js`));
63
+ configFile = _path.default.join(uatDirectory, `conf/default/actors/index.js`);
63
64
  betaReference = "default";
64
65
  }
65
66
  if (betaFeature) {
66
- configFile = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${betaReference}/actors/beta/${betaFeature}/index.js`));
67
+ configFile = _path.default.join(uatDirectory, `conf/${betaReference}/actors/beta/${betaFeature}/index.js`);
67
68
  if (!(0, _fs.existsSync)(configFile)) {
68
69
  throw new Error(`There is no beta feature configured with the name "${betaFeature}"`);
69
70
  }
@@ -10,27 +10,21 @@ exports.getUATFileName = getUATFileName;
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
  var _fs = _interopRequireDefault(require("fs"));
12
12
  var _auth = require("./auth");
13
- var _ConfigurationHelper = require("./../configuration/ConfigurationHelper");
14
- var _resolveStageConfigPath = require("./resolveStageConfigPath");
15
- function getUATFileName(stage, mode) {
16
- stage = stage || (0, _ConfigurationHelper.getRunStage)();
13
+ function getUATFileName(mode) {
17
14
  mode = mode || (0, _auth.getRunMode)();
18
- const stageConfig = (0, _resolveStageConfigPath.resolveStageConfigPath)(stage);
19
- const uatConfFilePath = _path.default.resolve(process.cwd(), `${stageConfig}/${mode}/uat.config.js`);
15
+ const uatConfFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/uat.config.js`);
20
16
  if (_fs.default.existsSync(uatConfFilePath)) {
21
17
  return uatConfFilePath;
22
18
  }
23
- ;
24
- return _path.default.resolve(process.cwd(), `${stage}/conf/default/uat.config.js`);
19
+ return _path.default.resolve(process.cwd(), `uat/conf/default/uat.config.js`);
25
20
  }
26
- function getEnvConfigFilePath(stage, mode) {
27
- const stageConfig = (0, _resolveStageConfigPath.resolveStageConfigPath)(stage);
28
- const confFilePath = `${stageConfig}/${mode}/settings.json`;
21
+ function getEnvConfigFilePath(mode) {
22
+ const confFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/settings.json`);
29
23
  // TODO: Actors Mode as config
30
24
  if (_fs.default.existsSync(confFilePath)) {
31
- return confFilePath;
25
+ return `uat/conf/${mode}/settings.json`;
32
26
  }
33
- return `${stage}/conf/default/settings.json`;
27
+ return `uat/conf/default/settings.json`;
34
28
  }
35
29
  function getReportFileName() {
36
30
  return `test-summary.json`;
@@ -111,16 +111,15 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
111
111
  */
112
112
 
113
113
  function getConfigFilePath() {
114
- return (0, _configFileNameProvider.getUATFileName)();
114
+ return _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
115
115
  }
116
116
  function generateConfigFromFile() {
117
117
  if (cachedConfig === null) {
118
118
  // Getting the default config's from framework
119
119
  const uatConfig = new _Configuration.default(getDefaultConfig());
120
120
  // overriding the application config's from project
121
+ const appConfig = new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)());
121
122
  const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
122
- const stage = userArgConfig.get("stage");
123
- const appConfig = new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(stage));
124
123
  // overriding the user config's from CLI
125
124
  uatConfig.addAll(appConfig);
126
125
  uatConfig.addAll(userArgConfig);
@@ -11,6 +11,7 @@ var _fileUtils = require("../../../utils/fileUtils");
11
11
  var _readConfigFile = require("../readConfigFile");
12
12
  var _logger = require("../../../utils/logger");
13
13
  var _configFileNameProvider = require("../helpers/configFileNameProvider");
14
+ var _lastRunUpdater = _interopRequireDefault(require("./lastRunUpdater"));
14
15
  class JSONSummaryReporter {
15
16
  constructor() {
16
17
  this.durationInMS = -1;
@@ -123,6 +124,8 @@ class JSONSummaryReporter {
123
124
  (0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', (0, _configFileNameProvider.getReportFileName)()), JSON.stringify(this, null, ' '));
124
125
  }
125
126
  onExit() {
127
+ // Update .last-run.json with aborted tests due to timing out or interruption
128
+ (0, _lastRunUpdater.default)();
126
129
  const shouldClearLastLine = this._open !== 'always' || this._open !== 'on-failure';
127
130
  if (shouldClearLastLine) {
128
131
  /**Below code is to replace the playwright default report commond with abstraction tool command */
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = mergeAbortedTestsIntoLastRun;
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _path = _interopRequireDefault(require("path"));
10
+ var _logger = require("../../../utils/logger");
11
+ var _fileUtils = require("../../../utils/fileUtils");
12
+ function mergeAbortedTestsIntoLastRun() {
13
+ let projectName = 'chromium',
14
+ resultsFile = _path.default.join(process.cwd(), 'uat', 'test-results', 'playwright-test-results.json'),
15
+ lastRunFile = _path.default.join(process.cwd(), 'uat', 'test-results', '.last-run.json');
16
+ try {
17
+ if (!_fs.default.existsSync(resultsFile)) {
18
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `No test results found at ${resultsFile}, skipping .last-run update.`);
19
+ return;
20
+ }
21
+ let report;
22
+ try {
23
+ report = JSON.parse(_fs.default.readFileSync(resultsFile, 'utf-8'));
24
+ } catch (e) {
25
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to parse results file: ${resultsFile}`);
26
+ return;
27
+ }
28
+ const abortedTests = new Set();
29
+ const isAbortedSpec = spec => {
30
+ const tags = Array.isArray(spec.tags) ? spec.tags : [];
31
+ // If no test satisfies all three, it returns false
32
+ return spec.tests.some(test => !tags.includes('skip') && test.projectName === projectName && test.status === 'skipped');
33
+ };
34
+ const traverseSuites = suite => {
35
+ if (suite.suites) {
36
+ for (const child of suite.suites) {
37
+ traverseSuites(child);
38
+ }
39
+ }
40
+ if (suite.specs) {
41
+ for (const spec of suite.specs) {
42
+ if (isAbortedSpec(spec)) {
43
+ abortedTests.add(spec.id);
44
+ }
45
+ }
46
+ }
47
+ };
48
+ if (Array.isArray(report.suites)) {
49
+ for (const suite of report.suites) {
50
+ traverseSuites(suite);
51
+ }
52
+ }
53
+ let lastRunData = {
54
+ status: 'passed',
55
+ failedTests: []
56
+ };
57
+ if (_fs.default.existsSync(lastRunFile)) {
58
+ try {
59
+ const parsed = JSON.parse(_fs.default.readFileSync(lastRunFile, 'utf-8'));
60
+ lastRunData.status = parsed.status || lastRunData.status;
61
+ lastRunData.failedTests = Array.isArray(parsed.failedTests) ? parsed.failedTests : [];
62
+ } catch (e) {
63
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to parse existing last-run file: ${lastRunFile}. Rebuilding.`);
64
+ }
65
+ }
66
+
67
+ // Merge existing failed tests + aborted tests
68
+ const failedSet = new Set(lastRunData.failedTests);
69
+ for (const id of abortedTests) {
70
+ failedSet.add(id);
71
+ }
72
+ lastRunData.failedTests = [...failedSet];
73
+ lastRunData.status = failedSet.size > 0 ? 'failed' : lastRunData.status;
74
+ (0, _fileUtils.writeFileContents)(lastRunFile, JSON.stringify(lastRunData, null, 2));
75
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Updated → → → ${abortedTests.size} aborted tests in .last-run.json file`);
76
+ return lastRunData;
77
+ } catch (err) {
78
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error updating .last-run.json: ${err.message}`);
79
+ }
80
+ }
@@ -86,8 +86,7 @@ function main() {
86
86
  // overriding the application config's from project
87
87
  const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
88
88
  const mode = userArgConfig.get("mode");
89
- const stage = userArgConfig.get("stage");
90
- uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(stage, mode)));
89
+ uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(mode)));
91
90
  // overriding the user config's from CLI
92
91
  uatConfig.addAll(userArgConfig);
93
92
  const modules = uatConfig.get('modules');
@@ -96,7 +95,6 @@ function main() {
96
95
  //We need to change this process.env variable to pass the module name in future.
97
96
  process.env.modules = modules;
98
97
  process.env.tearDown = tearDown;
99
- process.env.stage = stage;
100
98
  const {
101
99
  isAuthMode,
102
100
  editionOrder,
@@ -104,7 +102,7 @@ function main() {
104
102
  bddMode = false,
105
103
  headless = false
106
104
  } = uatConfig.getAll();
107
- (0, _envInitializer.initializeEnvConfig)(stage, mode, isAuthMode);
105
+ (0, _envInitializer.initializeEnvConfig)(mode, isAuthMode);
108
106
 
109
107
  //This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
110
108
  const userArgsObject = userArgConfig.getAll();
@@ -4,72 +4,31 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  var _fs = require("fs");
5
5
  var _path = _interopRequireDefault(require("path"));
6
6
  var _configFileNameProvider = require("../../../../../core/playwright/helpers/configFileNameProvider");
7
- var _resolveStageConfigPath = require("../../../../../core/playwright/helpers/resolveStageConfigPath");
8
7
  jest.mock('fs');
9
- jest.mock('path', () => ({
10
- resolve: jest.fn()
11
- }));
12
- jest.mock("../../../../../core/playwright/helpers/resolveStageConfigPath", () => ({
13
- resolveStageConfigPath: jest.fn()
14
- }));
8
+ jest.mock('path');
15
9
  const mockCwd = '/mock/current/directory';
16
10
  _path.default.resolve = jest.fn();
17
11
  process.cwd = jest.fn(() => mockCwd);
18
12
  describe('getUATFileName', () => {
19
13
  beforeEach(() => {
20
14
  jest.clearAllMocks();
21
- _path.default.resolve.mockImplementation((...segments) => segments.join('/'));
22
15
  });
23
- test('should return pipeline-matched config path when file exists', () => {
24
- const stage = 'uat';
16
+ test('return the pipeline matched config files for pipeline matched files exists', () => {
25
17
  const mode = 'cd';
26
- _resolveStageConfigPath.resolveStageConfigPath.mockReturnValue(`${stage}/conf`);
27
- _fs.existsSync.mockReturnValue(true);
28
- const expected = `${process.cwd()}/${stage}/conf/${mode}/uat.config.js`;
29
- const result = (0, _configFileNameProvider.getUATFileName)(stage, mode);
30
- expect(_resolveStageConfigPath.resolveStageConfigPath).toHaveBeenCalledWith(stage);
31
- expect(_fs.existsSync).toHaveBeenCalledWith(expected);
32
- expect(result).toBe(expected);
33
- });
34
- test('should use default stage and mode when not provided', () => {
35
- const mode = 'dev';
36
- const stageConfigPath = 'uat/conf';
37
- const expectedPath = `${mockCwd}/${stageConfigPath}/${mode}/uat.config.js`;
18
+ const mockPath = `${mockCwd}/uat/conf/${mode}/uat.config.js`;
38
19
  _fs.existsSync.mockReturnValue(true);
20
+ _path.default.resolve.mockImplementation((...args) => args.join('/'));
39
21
  const result = (0, _configFileNameProvider.getUATFileName)(mode);
40
- expect(_fs.existsSync).toHaveBeenCalledWith(`${mockCwd}/uat/conf/${mode}/uat.config.js`);
41
- expect(result).toBe(expectedPath);
42
- });
43
- test('should return the default config files for pipeline matched files not exists', () => {
44
- const mockStage = 'uat';
45
- const mockMode = 'ci';
46
- const stageConfigPath = 'uat/conf';
47
- const nonExistingPath = `${mockCwd}/${stageConfigPath}/${mockMode}/uat.config.js`;
48
- const expectedDefaultPath = `${mockCwd}/${mockStage}/conf/default/uat.config.js`;
49
- _resolveStageConfigPath.resolveStageConfigPath.mockReturnValue(stageConfigPath);
50
- _fs.existsSync.mockReturnValue(false);
51
- const result = (0, _configFileNameProvider.getUATFileName)(mockStage, mockMode);
52
- expect(_fs.existsSync).toHaveBeenCalledWith(nonExistingPath);
53
- expect(result).toBe(expectedDefaultPath);
54
- });
55
- });
56
- describe('getEnvConfigFilePath', () => {
57
- beforeEach(() => {
58
- jest.clearAllMocks();
59
- _path.default.resolve.mockImplementation((...segments) => segments.join('/'));
60
- });
61
- test('should return conf file path when file exists', () => {
62
- _resolveStageConfigPath.resolveStageConfigPath.mockReturnValue('uat/conf');
63
- _fs.existsSync.mockReturnValue(true);
64
- const result = (0, _configFileNameProvider.getEnvConfigFilePath)('uat', 'cd');
65
- expect(_resolveStageConfigPath.resolveStageConfigPath).toHaveBeenCalledWith('uat');
66
- expect(_fs.existsSync).toHaveBeenCalled();
67
- expect(result).toBe('uat/conf/cd/settings.json');
22
+ expect(_fs.existsSync).toHaveBeenCalledWith(mockPath);
23
+ expect(result).toBe(mockPath);
68
24
  });
69
- test('should return default path when file does not exist', () => {
70
- _resolveStageConfigPath.resolveStageConfigPath.mockReturnValue('uat/conf');
25
+ test('return the default config files for pipeline matched files not exists', () => {
26
+ const mode = 'ci';
27
+ const defaultPath = `${mockCwd}/uat/conf/default/uat.config.js`;
71
28
  _fs.existsSync.mockReturnValue(false);
72
- const result = (0, _configFileNameProvider.getEnvConfigFilePath)('uat', 'ci');
73
- expect(result).toBe('uat/conf/default/settings.json');
29
+ _path.default.resolve.mockImplementation((...args) => args.join('/'));
30
+ const result = (0, _configFileNameProvider.getUATFileName)(mode);
31
+ expect(_fs.existsSync).toHaveBeenCalledWith(`${mockCwd}/uat/conf/${mode}/uat.config.js`);
32
+ expect(result).toBe(defaultPath);
74
33
  });
75
34
  });
@@ -1,83 +1,80 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _fs = _interopRequireDefault(require("fs"));
4
+ var _fs = require("fs");
5
5
  var _path = _interopRequireDefault(require("path"));
6
- var _getUsers = require("../../../../../core/playwright/helpers/auth/getUsers");
7
- var _resolveStageConfigPath = require("../../../../../core/playwright/helpers/resolveStageConfigPath");
8
6
  jest.mock('fs');
9
7
  jest.mock('path');
10
- jest.mock('../../../../../core/playwright/helpers/resolveStageConfigPath', () => ({
11
- resolveStageConfigPath: jest.fn()
8
+ jest.mock('../../../../../core/playwright/readConfigFile', () => ({
9
+ generateConfigFromFile: jest.fn(() => ({
10
+ uatDirectory: '/test/directory'
11
+ })),
12
+ getRunMode: jest.fn(() => 'dev')
12
13
  }));
14
+ const {
15
+ getListOfActors
16
+ } = require('../../../../../core/playwright/helpers/auth/getUsers');
13
17
  describe('getListOfActors', () => {
14
- const stageConfig = 'uat/conf';
15
- const mode = 'dev';
16
- const stage = 'uat';
17
18
  beforeEach(() => {
18
19
  jest.clearAllMocks();
19
20
  _path.default.join.mockImplementation((...args) => args.join('/'));
20
- _path.default.resolve.mockImplementation((...args) => args.join('/'));
21
- _resolveStageConfigPath.resolveStageConfigPath.mockReturnValue('uat/conf');
22
21
  });
23
22
  test('throws an error when config file cannot be loaded', () => {
24
- _fs.default.existsSync.mockReturnValueOnce(true);
25
- jest.mock('/uat/conf/dev/actors/index.js', () => {
23
+ _fs.existsSync.mockReturnValueOnce(true); // Main config file exists
24
+
25
+ jest.mock('/test/directory/conf/dev/actors/index.js', () => {
26
26
  throw new Error('Loading error');
27
27
  }, {
28
28
  virtual: true
29
29
  });
30
- expect(() => (0, _getUsers.getListOfActors)()).toThrow(`Error loading actor configuration from ${_path.default.join(_path.default.resolve(process.cwd(), 'uat/conf/dev/actors/index.js'))}`);
30
+ expect(() => getListOfActors()).toThrow('Error loading actor configuration from /test/directory/conf/dev/actors/index.js');
31
31
  });
32
32
  test('throws an error when beta feature config does not exist', () => {
33
- _fs.default.existsSync.mockReturnValueOnce(true) // Main config file exists
33
+ _fs.existsSync.mockReturnValueOnce(true) // Main config file exists
34
34
  .mockReturnValueOnce(false); // Beta feature config does not exist in either path
35
35
 
36
36
  const betaFeature = 'nonExistentFeature';
37
- expect(() => (0, _getUsers.getListOfActors)(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
37
+ expect(() => getListOfActors(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
38
38
  });
39
- test('loads main configuration when betaFeature is not provided and main config exists', () => {
40
- _fs.default.existsSync.mockReturnValueOnce(true);
41
- const file = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${mode}/actors/index.js`));
42
- jest.doMock(file, () => ({
39
+ test('loads main configuration when betaFeature is not provided and main config file exists', () => {
40
+ _fs.existsSync.mockReturnValueOnce(true);
41
+ jest.doMock('/test/directory/conf/dev/actors/index.js', () => ({
43
42
  actors: []
44
43
  }), {
45
44
  virtual: true
46
45
  });
47
- const result = (0, _getUsers.getListOfActors)();
46
+ const result = getListOfActors();
48
47
  expect(result).toEqual({
49
48
  actors: []
50
49
  });
51
50
  });
52
51
  test('falls back to default configuration if main config file does not exist', () => {
53
- _fs.default.existsSync.mockReturnValueOnce(false) // Main config file missing
54
- .mockReturnValueOnce(true); // Beta feature config exists
55
-
56
- const defaultConfigFile = _path.default.join(_path.default.resolve(process.cwd(), `${stage}/conf/default/actors/index.js`));
57
- jest.doMock(defaultConfigFile, () => ({
52
+ _fs.existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
53
+ jest.doMock('/test/directory/conf/default/actors/index.js', () => ({
58
54
  actors: []
59
55
  }), {
60
56
  virtual: true
61
57
  });
62
- const result = (0, _getUsers.getListOfActors)();
58
+ const result = getListOfActors();
63
59
  expect(result).toEqual({
64
60
  actors: []
65
61
  });
66
62
  });
67
63
  test('loads beta feature configuration when betaFeature is provided', () => {
68
- _fs.default.existsSync.mockReturnValueOnce(true) // Main config file exists
64
+ _fs.existsSync.mockReturnValueOnce(true) // Main config file exists
69
65
  .mockReturnValueOnce(true); // Beta feature config exists
70
66
 
71
67
  const betaFeature = 'parentchild';
72
- const betaFeaturePath = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${mode}/actors/beta/${betaFeature}/index.js`));
68
+ const betaFeaturePath = `/test/directory/conf/dev/actors/beta/${betaFeature}/index.js`;
73
69
  jest.doMock(betaFeaturePath, () => ({
74
70
  betaActors: []
75
71
  }), {
76
72
  virtual: true
77
73
  });
78
- const result = (0, _getUsers.getListOfActors)(betaFeature);
74
+ const result = getListOfActors(betaFeature);
79
75
  expect(result).toEqual({
80
76
  betaActors: []
81
77
  });
78
+ expect(_path.default.join).toHaveBeenCalledWith('/test/directory', `conf/dev/actors/beta/${betaFeature}/index.js`);
82
79
  });
83
80
  });
@@ -22,7 +22,7 @@ class LoggerImpl {
22
22
  info() {}
23
23
  log(type, message) {
24
24
  const color = this.colors[type];
25
- this.consoleLogger.log(`${color[0]}${message}${color[1]}`);
25
+ this.consoleLogger.log(`${color[0]}${message}${color[1]}\n`);
26
26
  }
27
27
  }
28
28
  const Logger = exports.Logger = new LoggerImpl();