@zohodesk/testinglibrary 0.0.5-exp.26 → 0.0.5-exp.28

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.
@@ -30,6 +30,8 @@ const fileName = 'uat.config.js';
30
30
  * @property {number} expectTimeout: time in milliseconds which the expect condition should fail
31
31
  * @property {number} testTimeout: time in milliseconds which the test should fail
32
32
  * @property {Object} additionalPages: custom pages configuration
33
+ * @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
34
+ * @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
33
35
  */
34
36
 
35
37
  /**
@@ -59,7 +61,7 @@ function getAuthFilePath(filePath) {
59
61
  if ((0, _fs.existsSync)(filePath)) {
60
62
  return filePath;
61
63
  } else {
62
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Ensure cookies present in ${filePath}. Authetication file not Exist ...`);
64
+ return {};
63
65
  }
64
66
  } catch (err) {
65
67
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Founded Path - ${filePath} Authetication file not Exist ...`);
@@ -26,8 +26,9 @@ const {
26
26
  testTimeout = 60 * 1000,
27
27
  authFilePath = 'uat/playwright/.auth/user.json'
28
28
  } = (0, _readConfigFile.generateConfigFromFile)();
29
- let projects = browsers.map(browser => {
30
- if (browser === 'Chrome') {
29
+ let projects = browsers.map(browserName => {
30
+ let browser = browserName.toLowerCase();
31
+ if (browser === 'chrome') {
31
32
  return {
32
33
  name: 'chromium',
33
34
  use: {
@@ -36,7 +37,7 @@ let projects = browsers.map(browser => {
36
37
  },
37
38
  dependencies: isAuthMode ? ['setup'] : []
38
39
  };
39
- } else if (browser === 'Edge') {
40
+ } else if (browser === 'edge') {
40
41
  return {
41
42
  name: 'Microsoft Edge',
42
43
  use: {
@@ -46,7 +47,7 @@ let projects = browsers.map(browser => {
46
47
  },
47
48
  dependencies: isAuthMode ? ['setup'] : []
48
49
  };
49
- } else if (browser === 'Firefox') {
50
+ } else if (browser === 'firefox') {
50
51
  return {
51
52
  name: 'firefox',
52
53
  timeout: 4 * 60 * 1000,
@@ -12,6 +12,7 @@ var _path = _interopRequireDefault(require("path"));
12
12
  var _logger = require("../utils/logger");
13
13
  var _cliArgsToObject = require("../utils/cliArgsToObject");
14
14
  var _fileUtils = require("../utils/fileUtils");
15
+ var _readConfigFile = require("../core/playwright/readConfigFile");
15
16
  function parseFeature(featureContent) {
16
17
  const lines = featureContent.split('\n');
17
18
  let currentFeature = null;
@@ -98,6 +99,10 @@ function generateSpecFileContent({
98
99
  function specFileGenerator(filePath) {
99
100
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `Generating spec file using file ${filePath}`);
100
101
  // Read the Gherkin feature file
102
+ let {
103
+ featureFilesFolder = 'feature-files',
104
+ stepDefinitionsFolder = 'steps'
105
+ } = (0, _readConfigFile.generateConfigFromFile)();
101
106
  _fs.default.readFile(filePath, 'utf8', (err, data) => {
102
107
  if (err) {
103
108
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error reading the file: ${err}`);
@@ -105,10 +110,10 @@ function specFileGenerator(filePath) {
105
110
  // Parse the feature file content and get the JSON-like object
106
111
  const parsedFeature = parseFeature(data);
107
112
  let specFilePath = filePath.replace(/\.feature$/, '.spec.js');
108
- if (filePath.includes('feature-files')) {
109
- specFilePath = specFilePath.replace(/\/feature-files\//, '/steps/');
113
+ if (filePath.includes(`${featureFilesFolder}`)) {
114
+ specFilePath = specFilePath.replace(`/${featureFilesFolder}/`, `/${stepDefinitionsFolder}/`);
110
115
  } else {
111
- specFilePath = specFilePath.replace('./', '../steps/');
116
+ specFilePath = specFilePath.replace('./', `${stepDefinitionsFolder}`);
112
117
  }
113
118
  if ((0, _fileUtils.checkIfFileExists)(specFilePath)) {
114
119
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'File Already exists. Make sure to either delete or pass --update option true');
@@ -6,6 +6,7 @@ var _fastGlob = _interopRequireDefault(require("fast-glob"));
6
6
  var _parser = require("./parser");
7
7
  var _logger = require("../utils/logger");
8
8
  var _fileUtils = require("../utils/fileUtils");
9
+ var _readConfigFile = require("../core/playwright/readConfigFile");
9
10
  // Specify the directory where you want to search for .feature and .spec.js files
10
11
  const directoryPath = './uat';
11
12
 
@@ -44,12 +45,16 @@ function verifyFeatureFileWithSpecFile() {
44
45
  try {
45
46
  let errorCount = 0;
46
47
  let allStepsFound = {};
48
+ let {
49
+ featureFilesFolder = 'feature-files',
50
+ stepDefinitionsFolder = 'steps'
51
+ } = (0, _readConfigFile.generateConfigFromFile)();
47
52
  const featureFiles = _fastGlob.default.globSync([featurePattern], {
48
53
  dot: true
49
54
  });
50
55
  featureFiles.forEach(featureFile => {
51
56
  // Construct the corresponding .spec.js filename
52
- const specFile = featureFile.replace(/\.feature$/, '.spec.js').replace(/\/feature-files\//, '/steps/');
57
+ const specFile = featureFile.replace(/\.feature$/, '.spec.js').replace(`/${featureFilesFolder}/`, `/${stepDefinitionsFolder}/`);
53
58
  let featureFileNameExtract = featureFile.split('/').pop();
54
59
  let featurePrefixName = featureFileNameExtract.split('.')[0];
55
60
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `parsing feature file ${featureFileNameExtract}...`);
@@ -66,7 +71,7 @@ function verifyFeatureFileWithSpecFile() {
66
71
  if (specContents.includes(featureName)) {
67
72
  const scenarios = featureJSON.feature.scenarios;
68
73
  const specLines = specContents.split('\n'); // Split specContents into lines
69
- let testDataFilePath = featureFile.replace(/\/feature-files\//, '/test-data/').replace(/\.feature$/, '.data.js');
74
+ let testDataFilePath = featureFile.replace(`/${featureFilesFolder}/`, '/test-data/').replace(/\.feature$/, '.data.js');
70
75
  // Examples to test data conversion. we are deleting the existing test data file and create a new file.
71
76
  (0, _fileUtils.deleteFile)(testDataFilePath);
72
77
  for (let i = 0; i < scenarios.length; i++) {
@@ -42,7 +42,7 @@ userdata.forEach((data) => {
42
42
  await page.goto(page.getBaseUrl());
43
43
  await page.waitForLoadState();
44
44
  if (await page.url().includes(process.env.domain)) {
45
- await page.waitForSelector('header [data-id="zdsetup"]');
45
+ await page.waitForSelector(data.locator);
46
46
  } else {
47
47
  throw new Error(LOGIN_ERR_MESSAGE);
48
48
  }
@@ -3,7 +3,7 @@
3
3
  "useremail": "/ user name /",
4
4
  "password": "/ password /",
5
5
  "description": "/ description/",
6
- "filename": "/ filename in json format/",
6
+ "filename": "user.json",
7
7
  "locator": "/ selector to identify page has been loaded completely /"
8
8
  }
9
9
  ]
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "dev": {
3
3
  "domain": "https://desk.localzoho.com/agent",
4
- "username": "your-username",
5
- "password": "your-password"
4
+ "orgName": "org-name",
5
+ "deptName": "dept-name",
6
+ "moduleName": "module-name",
7
+ "devURL": "Provide your devURL here"
6
8
  },
7
9
  "prod": {
8
10
  "domain": "https://desk.localzoho.com/agent",
9
- "username": "your-username",
10
- "password": "your-password"
11
+ "orgName": "org-name",
12
+ "deptName": "dept-name",
13
+ "moduleName": "module-name"
11
14
  },
12
15
  "k8test": {
13
16
  "domain": "https://desk.localzoho.com/agent",
14
- "username": "your-username",
15
- "password": "your-password"
17
+ "orgName": "org-name",
18
+ "deptName": "dept-name",
19
+ "moduleName": "module-name"
16
20
  }
17
21
  }
@@ -15,6 +15,8 @@
15
15
  * @property {number} expectTimeout: time in milliseconds which the expect condition should fail
16
16
  * @property {number} testTimeout: time in milliseconds which the test should fail
17
17
  * @property {Object} additionalPages: custom pages configuration
18
+ * @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
19
+ * @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
18
20
  */
19
21
 
20
22
  /**
@@ -22,10 +24,12 @@
22
24
  */
23
25
  module.exports = {
24
26
  headless: false,
25
- browsers: ['Chrome', 'Firefox'],
27
+ browsers: ['Chrome', 'Firefox', 'Safari', 'Edge'],
26
28
  mode: 'dev',
27
29
  isAuthMode: true,
28
30
  authFilePath: 'uat/playwright/.auth/user.json',
29
31
  trace: true,
30
32
  video: true,
33
+ featureFilesFolder: 'feature-files',
34
+ stepDefinitionsFolder: 'steps'
31
35
  }
package/changelog.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Framework that abstracts the configuration for playwright and Jest
4
4
 
5
+ # 0.0.5-exp.28
6
+
7
+ - Bug fix while creating spec file
8
+
9
+ # 0.0.5-exp.27
10
+
11
+ - Added config for feature files and step definitions folder name
12
+
5
13
  # 0.0.5-exp.26
6
14
 
7
15
  - Type definitions for playwright added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.0.5-exp.26",
3
+ "version": "0.0.5-exp.28",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {