@zohodesk/testinglibrary 0.1.7 → 0.1.8-exp-bdd

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 (91) hide show
  1. package/.babelrc +18 -18
  2. package/.eslintrc.js +27 -31
  3. package/.prettierrc +5 -5
  4. package/README.md +17 -17
  5. package/bin/cli.js +2 -2
  6. package/build/bdd-framework/cli/commands/env.js +4 -4
  7. package/build/bdd-framework/cli/commands/test.js +2 -6
  8. package/build/bdd-framework/cli/options.js +4 -4
  9. package/build/bdd-framework/cli/worker.js +3 -3
  10. package/build/bdd-framework/config/dir.js +6 -6
  11. package/build/bdd-framework/config/env.js +4 -5
  12. package/build/bdd-framework/config/index.js +2 -2
  13. package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
  14. package/build/bdd-framework/cucumber/gherkin.d.ts +45 -0
  15. package/build/bdd-framework/cucumber/loadSnippetBuilder.js +3 -3
  16. package/build/bdd-framework/cucumber/loadSources.js +9 -9
  17. package/build/bdd-framework/cucumber/loadSteps.js +3 -8
  18. package/build/bdd-framework/decorators.js +2 -2
  19. package/build/bdd-framework/gen/formatter.js +17 -64
  20. package/build/bdd-framework/gen/i18n.js +5 -9
  21. package/build/bdd-framework/gen/index.js +8 -9
  22. package/build/bdd-framework/gen/poms.js +46 -0
  23. package/build/bdd-framework/gen/testFile.js +55 -121
  24. package/build/bdd-framework/gen/testNode.js +6 -19
  25. package/build/bdd-framework/gen/testPoms.js +39 -49
  26. package/build/bdd-framework/playwright/fixtureParameterNames.js +11 -27
  27. package/build/bdd-framework/playwright/getLocationInFile.js +11 -17
  28. package/build/bdd-framework/playwright/loadConfig.js +3 -3
  29. package/build/bdd-framework/playwright/testTypeImpl.js +15 -19
  30. package/build/bdd-framework/playwright/transform.js +6 -10
  31. package/build/bdd-framework/playwright/utils.js +6 -3
  32. package/build/bdd-framework/run/bddFixtures.js +55 -118
  33. package/build/bdd-framework/run/bddWorld.js +36 -24
  34. package/build/bdd-framework/snippets/index.js +3 -5
  35. package/build/bdd-framework/snippets/snippetSyntax.js +1 -3
  36. package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
  37. package/build/bdd-framework/stepDefinitions/createBdd.js +13 -30
  38. package/build/bdd-framework/stepDefinitions/createDecorators.js +108 -0
  39. package/build/bdd-framework/stepDefinitions/decorators/{class.js → poms.js} +9 -13
  40. package/build/bdd-framework/stepDefinitions/decorators/steps.js +8 -14
  41. package/build/bdd-framework/stepDefinitions/defineStep.js +4 -5
  42. package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
  43. package/build/bdd-framework/utils/exit.js +18 -26
  44. package/build/bdd-framework/utils/index.js +4 -30
  45. package/build/bdd-framework/utils/jsStringWrap.js +9 -9
  46. package/build/bdd-framework/utils/logger.js +3 -5
  47. package/build/bdd-poc/core-runner/exportMethods.js +14 -0
  48. package/build/bdd-poc/core-runner/stepDefinitions.js +55 -0
  49. package/build/bdd-poc/main.js +10 -0
  50. package/build/bdd-poc/test/cucumber/featureFileParer.js +81 -0
  51. package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +36 -0
  52. package/build/bdd-poc/test/stepGenerate/stepsnippets.js +43 -0
  53. package/build/bdd-poc/test/testDataMap.js +98 -0
  54. package/build/bdd-poc/test/testStructure.js +83 -0
  55. package/build/bdd-poc/utils/stringManipulation.js +19 -0
  56. package/build/core/playwright/custom-commands.js +1 -1
  57. package/build/core/playwright/index.js +0 -15
  58. package/build/core/playwright/readConfigFile.js +30 -37
  59. package/build/core/playwright/report-generator.js +1 -2
  60. package/build/core/playwright/setup/config-creator.js +15 -21
  61. package/build/core/playwright/setup/config-utils.js +0 -30
  62. package/build/core/playwright/test-runner.js +5 -7
  63. package/build/index.d.ts +5 -60
  64. package/build/index.js +3 -5
  65. package/build/lib/cli.js +1 -10
  66. package/build/parser/sample.feature +34 -34
  67. package/build/parser/sample.spec.js +18 -18
  68. package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -72
  69. package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
  70. package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
  71. package/build/setup-folder-structure/samples/git-ignore.sample.js +32 -36
  72. package/build/setup-folder-structure/samples/uat-config-sample.js +43 -44
  73. package/build/setup-folder-structure/setupProject.js +5 -10
  74. package/build/utils/cliArgsToObject.js +25 -25
  75. package/build/utils/fileUtils.js +0 -12
  76. package/changelog.md +74 -124
  77. package/jest.config.js +63 -63
  78. package/npm-shrinkwrap.json +7781 -6469
  79. package/package.json +54 -55
  80. package/playwright.config.js +112 -112
  81. package/build/bdd-framework/config/lang.js +0 -14
  82. package/build/bdd-framework/gen/fixtures.js +0 -48
  83. package/build/bdd-framework/hooks/scenario.js +0 -107
  84. package/build/bdd-framework/hooks/worker.js +0 -83
  85. package/build/bdd-framework/run/StepInvoker.js +0 -73
  86. package/build/core/playwright/clear-caches.js +0 -29
  87. package/build/core/playwright/setup/custom-reporter.js +0 -100
  88. package/build/core/playwright/tag-processor.js +0 -68
  89. package/build/setup-folder-structure/helper.js +0 -34
  90. package/build/setup-folder-structure/reportEnhancement/addonScript.html +0 -25
  91. package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +0 -25
package/build/lib/cli.js CHANGED
@@ -7,8 +7,6 @@ var _codegen = _interopRequireDefault(require("../core/playwright/codegen"));
7
7
  var _logger = require("../utils/logger");
8
8
  var _setupProject = _interopRequireDefault(require("../setup-folder-structure/setupProject"));
9
9
  var _parser = require("../parser/parser");
10
- var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-caches"));
11
- var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
12
10
  // import createJestRunner from '../core/jest/runner/jest-runner';
13
11
 
14
12
  const [,, option, ...otherOptions] = process.argv;
@@ -48,16 +46,9 @@ switch (option) {
48
46
  (0, _parser.generateSpecCodeForFeatureFile)(otherOptions);
49
47
  break;
50
48
  }
51
- case 'clearCaches':
52
- {
53
- _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Clearing caches...');
54
- (0, _clearCaches.default)();
55
- break;
56
- }
57
- case 'help':
58
49
  default:
59
50
  {
60
- (0, _helper.default)();
51
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Supported Commands test and report');
61
52
  break;
62
53
  }
63
54
  }
@@ -1,34 +1,34 @@
1
- Feature: Home Page
2
-
3
- Scenario: Home Page Default content
4
- Given user is on "<App>" home page
5
- Then user gets a "<App>" bootcamp section
6
- And username is also displayed on right corner
7
-
8
- Examples:
9
- | App |
10
- | GitHub |
11
-
12
- Scenario: GitHub Bootcamp Section
13
- Given user is on "<Site>" home page
14
- When user focuses on "<Site>" Bootcamp Section
15
- Then user gets an option to setup git
16
- And user gets an option to create repository
17
- And user gets an option to Fork Repository
18
- And user gets an option to work together
19
-
20
- Examples:
21
- | Site |
22
- | GitHub |
23
-
24
- Scenario: Top Banner content
25
- Given user is on "<Product>" home page
26
- When user focuses on Top Banner
27
- Then user gets an option of home page
28
- And user gets an option to search
29
- And user gets settings options
30
- And user gets an option to logout
31
-
32
- Examples:
33
- | Product |
34
- | GitHub |
1
+ Feature: Home Page
2
+
3
+ Scenario: Home Page Default content
4
+ Given user is on "<App>" home page
5
+ Then user gets a "<App>" bootcamp section
6
+ And username is also displayed on right corner
7
+
8
+ Examples:
9
+ | App |
10
+ | GitHub |
11
+
12
+ Scenario: GitHub Bootcamp Section
13
+ Given user is on "<Site>" home page
14
+ When user focuses on "<Site>" Bootcamp Section
15
+ Then user gets an option to setup git
16
+ And user gets an option to create repository
17
+ And user gets an option to Fork Repository
18
+ And user gets an option to work together
19
+
20
+ Examples:
21
+ | Site |
22
+ | GitHub |
23
+
24
+ Scenario: Top Banner content
25
+ Given user is on "<Product>" home page
26
+ When user focuses on Top Banner
27
+ Then user gets an option of home page
28
+ And user gets an option to search
29
+ And user gets settings options
30
+ And user gets an option to logout
31
+
32
+ Examples:
33
+ | Product |
34
+ | GitHub |
@@ -2,34 +2,34 @@
2
2
 
3
3
  var _testinglibrary = require("@zohodesk/testinglibrary");
4
4
  _testinglibrary.test.describe('Home Page', () => {
5
- /*
6
- ** Given user is on "<App>" home page
7
- ** Then user gets a "<App>" bootcamp section
8
- ** And username is also displayed on right corner
5
+ /*
6
+ ** Given user is on "<App>" home page
7
+ ** Then user gets a "<App>" bootcamp section
8
+ ** And username is also displayed on right corner
9
9
  */
10
10
  (0, _testinglibrary.test)('Home Page Default content', () => {
11
11
  // Your implementation here
12
12
  });
13
13
 
14
- /*
15
- ** Given user is on "<Site>" home page
16
- ** When user focuses on "<Site>" Bootcamp Section
17
- ** Then user gets an option to setup git
18
- ** And user gets an option to create repository
19
- ** And user gets an option to Fork Repository
20
- ** And user gets an option to work together
14
+ /*
15
+ ** Given user is on "<Site>" home page
16
+ ** When user focuses on "<Site>" Bootcamp Section
17
+ ** Then user gets an option to setup git
18
+ ** And user gets an option to create repository
19
+ ** And user gets an option to Fork Repository
20
+ ** And user gets an option to work together
21
21
  */
22
22
  (0, _testinglibrary.test)('GitHub Bootcamp Section', () => {
23
23
  // Your implementation here
24
24
  });
25
25
 
26
- /*
27
- ** Given user is on "<Product>" home page
28
- ** When user focuses on Top Banner
29
- ** Then user gets an option of home page
30
- ** And user gets an option to search
31
- ** And user gets settings options
32
- ** And user gets an option to logout
26
+ /*
27
+ ** Given user is on "<Product>" home page
28
+ ** When user focuses on Top Banner
29
+ ** Then user gets an option of home page
30
+ ** And user gets an option to search
31
+ ** And user gets settings options
32
+ ** And user gets an option to logout
33
33
  */
34
34
  (0, _testinglibrary.test)('Top Banner content', () => {
35
35
  // Your implementation here
@@ -1,72 +1,72 @@
1
- /* eslint-disable no-console */
2
- import { test as setup, expect } from '@zohodesk/testinglibrary';
3
- import path from 'path';
4
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
5
-
6
- const userdata = require('./authUsers.json');
7
-
8
- const authDirectory = path.resolve(process.cwd(), 'uat', 'playwright', '.auth');
9
-
10
- const authContent = { "cookies": [] };
11
-
12
- const LOGIN_ERR_MESSAGE = 'Need go be logged in';
13
- // const AUTH_ERR_MESSAGE = `Founded Path - ${path.resolve(process.cwd(),'uat','playwright','.auth')} \n Find if file is Properly Created. Cookies Cannot Be Read .. `
14
-
15
-
16
- function convertCookiesToParse(cookies, authFilePath) {
17
- try {
18
- return JSON.parse(cookies)
19
- } catch (err) {
20
- throw new Error(` Error while parsing cookies ${err} \n${path.resolve(process.cwd(), authFilePath)} File is Empty`)
21
- // process.exit()
22
- }
23
- }
24
-
25
- if (!existsSync(authDirectory)) {
26
- console.log('Creating auth directory for the first time setup...');
27
- mkdirSync(authDirectory, { recursive: true });
28
- }
29
-
30
- userdata.forEach((data) => {
31
- const authFile = path.resolve(path.join(authDirectory, `${data.filename}`));
32
- if (!existsSync(authFile)) {
33
- console.log('creating auth file..');
34
- writeFileSync(authFile, JSON.stringify(authContent, null, 2))
35
- }
36
- setup(data.description, async ({ page }) => {
37
-
38
- try {
39
- const cookies = readFileSync(authFile);
40
- const parsedCookies = convertCookiesToParse(cookies, authFile);
41
- await page.context().addCookies(parsedCookies.cookies === undefined ? [] : parsedCookies.cookies)
42
- await page.goto(page.getBaseUrl());
43
- await page.waitForLoadState();
44
- if (await page.url().includes(process.env.domain)) {
45
- await page.waitForSelector(data.locator);
46
- } else {
47
- throw new Error(LOGIN_ERR_MESSAGE);
48
- }
49
-
50
-
51
- } catch (err) {
52
- if (err.message === LOGIN_ERR_MESSAGE) {
53
-
54
- await expect(page.locator('.load-bg')).toBeHidden();
55
- await page.locator('#login_id').type(data.useremail);
56
- await page.locator('#nextbtn').click();
57
- await page.locator('#password').type(data.password);
58
- await page.locator('#nextbtn').click();
59
-
60
- await page.waitForLoadState("networkidle");
61
-
62
- await page.waitForSelector(data.locator)
63
-
64
- await page.context().storageState({ path: authFile });
65
- }
66
-
67
- }
68
-
69
- });
70
-
71
-
72
- })
1
+ /* eslint-disable no-console */
2
+ import { test as setup, expect } from '@zohodesk/testinglibrary';
3
+ import path from 'path';
4
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
5
+
6
+ const userdata = require('./authUsers.json');
7
+
8
+ const authDirectory = path.resolve(process.cwd(), 'uat', 'playwright', '.auth');
9
+
10
+ const authContent = { "cookies": [] };
11
+
12
+ const LOGIN_ERR_MESSAGE = 'Need go be logged in';
13
+ // const AUTH_ERR_MESSAGE = `Founded Path - ${path.resolve(process.cwd(),'uat','playwright','.auth')} \n Find if file is Properly Created. Cookies Cannot Be Read .. `
14
+
15
+
16
+ function convertCookiesToParse(cookies, authFilePath) {
17
+ try {
18
+ return JSON.parse(cookies)
19
+ } catch (err) {
20
+ throw new Error(` Error while parsing cookies ${err} \n${path.resolve(process.cwd(), authFilePath)} File is Empty`)
21
+ // process.exit()
22
+ }
23
+ }
24
+
25
+ if (!existsSync(authDirectory)) {
26
+ console.log('Creating auth directory for the first time setup...');
27
+ mkdirSync(authDirectory, { recursive: true });
28
+ }
29
+
30
+ userdata.forEach((data) => {
31
+ const authFile = path.resolve(path.join(authDirectory, `${data.filename}`));
32
+ if (!existsSync(authFile)) {
33
+ console.log('creating auth file..');
34
+ writeFileSync(authFile, JSON.stringify(authContent, null, 2))
35
+ }
36
+ setup(data.description, async ({ page }) => {
37
+
38
+ try {
39
+ const cookies = readFileSync(authFile);
40
+ const parsedCookies = convertCookiesToParse(cookies, authFile);
41
+ await page.context().addCookies(parsedCookies.cookies === undefined ? [] : parsedCookies.cookies)
42
+ await page.goto(page.getBaseUrl());
43
+ await page.waitForLoadState();
44
+ if (await page.url().includes(process.env.domain)) {
45
+ await page.waitForSelector(data.locator);
46
+ } else {
47
+ throw new Error(LOGIN_ERR_MESSAGE);
48
+ }
49
+
50
+
51
+ } catch (err) {
52
+ if (err.message === LOGIN_ERR_MESSAGE) {
53
+
54
+ await expect(page.locator('.load-bg')).toBeHidden();
55
+ await page.locator('#login_id').type(data.useremail);
56
+ await page.locator('#nextbtn').click();
57
+ await page.locator('#password').type(data.password);
58
+ await page.locator('#nextbtn').click();
59
+
60
+ await page.waitForLoadState("networkidle");
61
+
62
+ await page.waitForSelector(data.locator)
63
+
64
+ await page.context().storageState({ path: authFile });
65
+ }
66
+
67
+ }
68
+
69
+ });
70
+
71
+
72
+ })
@@ -1,9 +1,9 @@
1
- [
2
- {
3
- "useremail": "/ user name /",
4
- "password": "/ password /",
5
- "description": "/ description/",
6
- "filename": "user.json",
7
- "locator": "/ selector to identify page has been loaded completely /"
8
- }
1
+ [
2
+ {
3
+ "useremail": "/ user name /",
4
+ "password": "/ password /",
5
+ "description": "/ description/",
6
+ "filename": "user.json",
7
+ "locator": "/ selector to identify page has been loaded completely /"
8
+ }
9
9
  ]
@@ -1,21 +1,21 @@
1
- {
2
- "dev": {
3
- "domain": "https://desk.localzoho.com/agent",
4
- "orgName": "org-name",
5
- "deptName": "dept-name",
6
- "moduleName": "module-name",
7
- "devURL": "Provide your devURL here"
8
- },
9
- "prod": {
10
- "domain": "https://desk.localzoho.com/agent",
11
- "orgName": "org-name",
12
- "deptName": "dept-name",
13
- "moduleName": "module-name"
14
- },
15
- "k8test": {
16
- "domain": "https://desk.localzoho.com/agent",
17
- "orgName": "org-name",
18
- "deptName": "dept-name",
19
- "moduleName": "module-name"
20
- }
1
+ {
2
+ "dev": {
3
+ "domain": "https://desk.localzoho.com/agent",
4
+ "orgName": "org-name",
5
+ "deptName": "dept-name",
6
+ "moduleName": "module-name",
7
+ "devURL": "Provide your devURL here"
8
+ },
9
+ "prod": {
10
+ "domain": "https://desk.localzoho.com/agent",
11
+ "orgName": "org-name",
12
+ "deptName": "dept-name",
13
+ "moduleName": "module-name"
14
+ },
15
+ "k8test": {
16
+ "domain": "https://desk.localzoho.com/agent",
17
+ "orgName": "org-name",
18
+ "deptName": "dept-name",
19
+ "moduleName": "module-name"
20
+ }
21
21
  }
@@ -1,37 +1,33 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'fs';
2
- import path from 'path';
3
- import { Logger } from '../utils/logger';
4
- import { generateConfigFromFile } from '../core/playwright/readConfigFile';
5
- const gitIgnoreAbsolutePath = path.resolve(process.cwd(), '../', '../')
6
-
7
- const { reportPath = path.resolve(process.cwd(), 'uat', 'playwright-reports') } = generateConfigFromFile();
8
- const testResultsPath = path.resolve(process.cwd(), 'uat', 'test-results');
9
-
10
- const testResultsRelativepath = path.relative(gitIgnoreAbsolutePath, testResultsPath)
11
- const reportRelativepath = path.relative(gitIgnoreAbsolutePath, reportPath)
12
-
13
-
14
- const absolutePathfeaturegen = path.resolve(process.cwd(), 'uat', '.features-gen');
15
- const featuregenRelativePath = path.relative(gitIgnoreAbsolutePath,absolutePathfeaturegen)
16
-
17
- const dirpathtoIgnore = `${testResultsRelativepath}\n${reportRelativepath}\n${featuregenRelativePath}`
18
-
19
- function updateGitIgnore() {
20
- if (existsSync(path.resolve(process.cwd(), '../', '../', '.gitignore'))) {
21
- let gitIgnoreData = readFileSync(path.resolve(process.cwd(), '../', '../', '.gitignore'), 'utf-8', (err) => {
22
- if (err) {
23
- Logger.log(Logger.FAILURE_TYPE, 'cannot able to read git ignore ')
24
- // process.exit()
25
- }
26
- })
27
- if (gitIgnoreData.includes(dirpathtoIgnore)) {
28
- return
29
- } else {
30
- writeFileSync(path.resolve(process.cwd(), '../', '../', '.gitignore', dirpathtoIgnore, null, 2))
31
- }
32
- } else {
33
- Logger.log(Logger.INFO_TYPE, 'GitIgnore file is No Found ....')
34
- }
35
- }
36
-
1
+ import { existsSync, readFileSync, writeFileSync } from 'fs';
2
+ import path from 'path';
3
+ import { Logger } from '../utils/logger';
4
+ import { generateConfigFromFile } from '../core/playwright/readConfigFile';
5
+
6
+
7
+ const { reportPath = path.resolve(process.cwd(), 'uat', 'playwright-reports') } = generateConfigFromFile();
8
+ const testResultsPath = path.resolve(process.cwd(), 'uat', 'test-results');
9
+
10
+ const testResultsRelativepath = path.relative(path.resolve(process.cwd(), '../', '../'), testResultsPath)
11
+ const reportRelativepath = path.relative(path.resolve(process.cwd(), '../', '../'), reportPath)
12
+
13
+ const dirpathtoIgnore = `${testResultsRelativepath}\n${reportRelativepath}`
14
+
15
+ function updateGitIgnore() {
16
+ if (existsSync(path.resolve(process.cwd(), '../', '../', '.gitignore'))) {
17
+ let gitIgnoreData = readFileSync(path.resolve(process.cwd(), '../', '../', '.gitignore'), 'utf-8', (err) => {
18
+ if (err) {
19
+ Logger.log(Logger.FAILURE_TYPE, 'cannot able to read git ignore ')
20
+ // process.exit()
21
+ }
22
+ })
23
+ if (gitIgnoreData.includes(dirpathtoIgnore)) {
24
+ return
25
+ } else {
26
+ writeFileSync(path.resolve(process.cwd(), '../', '../', '.gitignore', dirpathtoIgnore, null, 2))
27
+ }
28
+ } else {
29
+ Logger.log(Logger.INFO_TYPE, 'GitIgnore file is No Found ....')
30
+ }
31
+ }
32
+
37
33
  export default updateGitIgnore;
@@ -1,44 +1,43 @@
1
- /**
2
- * @typedef {Object|null} viewportConfig
3
- * @property {number} width - width of the viewport
4
- * @property {number} height - height of the viewport
5
- */
6
- /**
7
- * Represents the user configuration object.
8
- * @typedef {Object} UserConfig
9
- * @property {string} headless - Headless Browsers mode.
10
- * @property {number} trace - trace for test cases.
11
- * @property {boolean} video - video for test cases,
12
- * @property {boolean} debug - debug mode
13
- * @property {string} mode: mode in which the test cases needs to run
14
- * @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
15
- * @property {string} authFilePath - File Path where the cookies stored
16
- * @property {any} browsers: List of browsers
17
- * @property {string} openReportOn: default Option value (never, on-failure and always)
18
- * @property {any} reportPath : directory where report is generate
19
- * @property {boolean} bddMode: Feature files needs to be processed
20
- * @property {number} expectTimeout: time in milliseconds which the expect condition should fail
21
- * @property {number} testTimeout: time in milliseconds which the test should fail
22
- * @property {Object} additionalPages: custom pages configuration
23
- * @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
24
- * @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
25
- * @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
26
- * @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
27
- */
28
-
29
- /**
30
- * @type {UserConfig}
31
- */
32
- module.exports = {
33
- headless: false,
34
- browsers: ['Chrome', 'Firefox', 'Safari', 'Edge'],
35
- mode: 'dev',
36
- isAuthMode: true,
37
- authFilePath: 'uat/playwright/.auth/user.json',
38
- trace: true,
39
- video: true,
40
- bddMode: true,
41
- featureFilesFolder: 'feature-files',
42
- stepDefinitionsFolder: 'steps',
43
- viewport: { width: 1280, height: 720 }
44
- }
1
+ /**
2
+ * @typedef {Object|null} viewportConfig
3
+ * @property {number} width - width of the viewport
4
+ * @property {number} height - height of the viewport
5
+ */
6
+ /**
7
+ * Represents the user configuration object.
8
+ * @typedef {Object} UserConfig
9
+ * @property {string} headless - Headless Browsers mode.
10
+ * @property {number} trace - trace for test cases.
11
+ * @property {boolean} video - video for test cases,
12
+ * @property {boolean} debug - debug mode
13
+ * @property {string} mode: mode in which the test cases needs to run
14
+ * @property {boolean} isAuthMode - Auth Mode
15
+ * @property {string} authFilePath - File Path where the cookies stored
16
+ * @property {any} browsers: List of browsers
17
+ * @property {string} openReportOn: default Option value (never, on-failure and always)
18
+ * @property {any} reportPath : directory where report is generate
19
+ * @property {boolean} bddMode: Feature files needs to be processed
20
+ * @property {number} expectTimeout: time in milliseconds which the expect condition should fail
21
+ * @property {number} testTimeout: time in milliseconds which the test should fail
22
+ * @property {Object} additionalPages: custom pages configuration
23
+ * @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
24
+ * @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
25
+ * @property {viewportConfig} viewport: viewport configuration for the browser. Default is {width: 1280, height: 720 }
26
+ */
27
+
28
+ /**
29
+ * @type {UserConfig}
30
+ */
31
+ module.exports = {
32
+ headless: false,
33
+ browsers: ['Chrome', 'Firefox', 'Safari', 'Edge'],
34
+ mode: 'dev',
35
+ isAuthMode: true,
36
+ authFilePath: 'uat/playwright/.auth/user.json',
37
+ trace: true,
38
+ video: true,
39
+ bddMode: true,
40
+ featureFilesFolder: 'feature-files',
41
+ stepDefinitionsFolder: 'steps',
42
+ viewport: { width: 1280, height: 720 }
43
+ }
@@ -61,18 +61,14 @@ function createUatConfig() {
61
61
  function createAuthenticationFile() {
62
62
  const isUATexist = _path.default.resolve(process.cwd(), 'uat');
63
63
  if ((0, _fs.existsSync)(isUATexist)) {
64
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
64
65
  try {
65
- if (!(0, _fs.existsSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures'))) {
66
- (0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures'));
67
- }
68
- if (!(0, _fs.existsSync)(_path.default.resolve(process.cwd(), 'uat', 'playwright', '.auth'))) {
69
- (0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'playwright', '.auth'), {
70
- recursive: true
71
- });
72
- }
66
+ (0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures'));
67
+ (0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'playwright', '.auth'), {
68
+ recursive: true
69
+ });
73
70
  (0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'auth.setup.js'), getSetupFileAsString('auth-setup-sample.js'), null, 2);
74
71
  (0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'authUsers.json'), getSetupFileAsString('authUsers-sample.json'), null, 2);
75
- _logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
76
72
  } catch (err) {
77
73
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Something went wrong ! Folder not Created. Please re-initialize npm init-uat');
78
74
  }
@@ -95,7 +91,6 @@ function setupProject() {
95
91
  createFolderForUAT();
96
92
  createConfigJson();
97
93
  createAuthenticationFile();
98
- //updateGitIgnore()
99
94
  // Create folder for playwright . Inside .auth folder needs to be created. user.json
100
95
  // Add playwright and test-results to .gitignore
101
96
  setTimeout(() => {
@@ -5,19 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.cliArgsToObject = cliArgsToObject;
7
7
  exports.objectToCliArgs = objectToCliArgs;
8
- /**
9
- * Converts an array of command-line arguments into an object.
10
- *
11
- * @param {string[]} cliArgs - An array of command-line arguments.
12
- * @param {boolean} [isKeyNeedToBeAdded=true] - Indicates whether the keys should be added to the resulting object.
13
- * @returns {Object} An object representing the command-line arguments, where keys are argument names (without '--') and values are argument values.
14
- * If `isKeyNeedToBeAdded` is set to `false`, only values are included in the object with numeric indexes as keys.
15
- *
16
- * @example
17
- * // Example usage:
18
- * const args = ['--port=8080', '--verbose', 'input.txt'];
19
- * const result = cliArgsToObject(args);
20
- * // result will be: { port: '8080', verbose: true }
8
+ /**
9
+ * Converts an array of command-line arguments into an object.
10
+ *
11
+ * @param {string[]} cliArgs - An array of command-line arguments.
12
+ * @param {boolean} [isKeyNeedToBeAdded=true] - Indicates whether the keys should be added to the resulting object.
13
+ * @returns {Object} An object representing the command-line arguments, where keys are argument names (without '--') and values are argument values.
14
+ * If `isKeyNeedToBeAdded` is set to `false`, only values are included in the object with numeric indexes as keys.
15
+ *
16
+ * @example
17
+ * // Example usage:
18
+ * const args = ['--port=8080', '--verbose', 'input.txt'];
19
+ * const result = cliArgsToObject(args);
20
+ * // result will be: { port: '8080', verbose: true }
21
21
  */
22
22
  // eslint-disable-next-line no-unused-vars
23
23
  function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
@@ -37,18 +37,18 @@ function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
37
37
  return processEnv;
38
38
  }
39
39
 
40
- /**
41
- * Converts an object to an array of command-line arguments.
42
- *
43
- * @param {Object} objectToBeConverted - The object to be converted to command-line arguments.
44
- * @param {(string|function(string): boolean)} [isKeyNeedToBeAdded=true] - A string representing a key, or a function that determines whether a key should be added to the resulting array.
45
- * @returns {string[]} An array of command-line arguments generated from the object's key-value pairs. Keys are transformed into argument names (with '--') and values are added as argument values.
46
- *
47
- * @example
48
- * // Example usage:
49
- * const options = { port: 8080, verbose: true, input: 'input.txt' };
50
- * const args = objectToCliArgs(options);
51
- * // args will be: ['--port=8080', '--verbose', '--input=input.txt']
40
+ /**
41
+ * Converts an object to an array of command-line arguments.
42
+ *
43
+ * @param {Object} objectToBeConverted - The object to be converted to command-line arguments.
44
+ * @param {(string|function(string): boolean)} [isKeyNeedToBeAdded=true] - A string representing a key, or a function that determines whether a key should be added to the resulting array.
45
+ * @returns {string[]} An array of command-line arguments generated from the object's key-value pairs. Keys are transformed into argument names (with '--') and values are added as argument values.
46
+ *
47
+ * @example
48
+ * // Example usage:
49
+ * const options = { port: 8080, verbose: true, input: 'input.txt' };
50
+ * const args = objectToCliArgs(options);
51
+ * // args will be: ['--port=8080', '--verbose', '--input=input.txt']
52
52
  */
53
53
  function objectToCliArgs(objectToBeConverted, isKeyNeedToBeAdded) {
54
54
  const argsArray = [];
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.checkIfFileExists = checkIfFileExists;
8
8
  exports.deleteFile = deleteFile;
9
- exports.deleteFolder = deleteFolder;
10
9
  exports.readFileContents = readFileContents;
11
10
  exports.writeFileContents = writeFileContents;
12
11
  var _fs = _interopRequireDefault(require("fs"));
@@ -51,15 +50,4 @@ function deleteFile(filePath) {
51
50
  throw new Error(`Error while deleting the test data file: ${filePath}`);
52
51
  }
53
52
  }
54
- }
55
- function deleteFolder(folderPath) {
56
- if (_fs.default.existsSync(folderPath)) {
57
- try {
58
- _fs.default.rmdirSync(folderPath, {
59
- recursive: true
60
- });
61
- } catch (err) {
62
- throw new Error(`Error while deleting the test data file: ${folderPath}`);
63
- }
64
- }
65
53
  }