@zohodesk/testinglibrary 0.1.8-exp-bdd-v10 → 0.1.8-exp.10

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 (109) hide show
  1. package/.babelrc +21 -18
  2. package/.eslintrc.js +31 -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 +3 -3
  7. package/build/bdd-framework/cli/options.js +4 -4
  8. package/build/bdd-framework/cli/worker.js +3 -3
  9. package/build/bdd-framework/config/dir.js +6 -6
  10. package/build/bdd-framework/config/env.js +3 -3
  11. package/build/bdd-framework/config/index.js +2 -2
  12. package/build/bdd-framework/config/lang.js +2 -2
  13. package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
  14. package/build/bdd-framework/cucumber/loadSnippetBuilder.js +3 -3
  15. package/build/bdd-framework/cucumber/loadSources.js +9 -9
  16. package/build/bdd-framework/gen/fixtures.js +8 -8
  17. package/build/bdd-framework/gen/formatter.js +7 -7
  18. package/build/bdd-framework/gen/i18n.js +3 -3
  19. package/build/bdd-framework/gen/index.js +2 -2
  20. package/build/bdd-framework/gen/testFile.js +16 -16
  21. package/build/bdd-framework/gen/testNode.js +3 -3
  22. package/build/bdd-framework/gen/testPoms.js +31 -31
  23. package/build/bdd-framework/hooks/scenario.js +6 -6
  24. package/build/bdd-framework/hooks/worker.js +4 -4
  25. package/build/bdd-framework/playwright/fixtureParameterNames.js +3 -3
  26. package/build/bdd-framework/playwright/getLocationInFile.js +4 -4
  27. package/build/bdd-framework/playwright/loadConfig.js +3 -3
  28. package/build/bdd-framework/playwright/testTypeImpl.js +11 -11
  29. package/build/bdd-framework/playwright/transform.js +4 -4
  30. package/build/bdd-framework/playwright/utils.js +2 -2
  31. package/build/bdd-framework/run/StepInvoker.js +2 -2
  32. package/build/bdd-framework/run/bddWorld.js +15 -15
  33. package/build/bdd-framework/snippets/index.js +2 -2
  34. package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
  35. package/build/bdd-framework/stepDefinitions/createBdd.js +2 -2
  36. package/build/bdd-framework/stepDefinitions/decorators/class.js +7 -7
  37. package/build/bdd-framework/stepDefinitions/decorators/steps.js +6 -6
  38. package/build/bdd-framework/stepDefinitions/defineStep.js +3 -3
  39. package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
  40. package/build/bdd-framework/utils/exit.js +22 -18
  41. package/build/bdd-framework/utils/index.js +9 -9
  42. package/build/bdd-framework/utils/jsStringWrap.js +9 -9
  43. package/build/bdd-framework/utils/logger.js +2 -2
  44. package/build/core/playwright/builtInFixtures/addTags.js +1 -1
  45. package/build/core/playwright/builtInFixtures/context.js +12 -1
  46. package/build/core/playwright/builtInFixtures/i18N.js +33 -0
  47. package/build/core/playwright/builtInFixtures/index.js +8 -5
  48. package/build/core/playwright/builtInFixtures/page.js +53 -39
  49. package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
  50. package/build/core/playwright/clear-caches.js +19 -8
  51. package/build/core/playwright/codegen.js +4 -4
  52. package/build/core/playwright/constants/browserTypes.js +12 -0
  53. package/build/core/playwright/custom-commands.js +1 -1
  54. package/build/core/playwright/env-initializer.js +10 -6
  55. package/build/core/playwright/helpers/auth/accountLogin.js +18 -0
  56. package/build/core/playwright/helpers/auth/checkAuthCookies.js +47 -0
  57. package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
  58. package/build/core/playwright/helpers/auth/getUsers.js +72 -0
  59. package/build/core/playwright/helpers/auth/index.js +58 -0
  60. package/build/core/playwright/helpers/auth/loginSteps.js +36 -0
  61. package/build/core/playwright/helpers/configFileNameProvider.js +13 -0
  62. package/build/core/playwright/helpers/getUserFixtures.js +18 -0
  63. package/build/core/playwright/helpers/mergeObjects.js +13 -0
  64. package/build/core/playwright/index.js +68 -7
  65. package/build/core/playwright/readConfigFile.js +49 -39
  66. package/build/core/playwright/report-generator.js +7 -7
  67. package/build/core/playwright/setup/config-creator.js +13 -14
  68. package/build/core/playwright/setup/config-utils.js +37 -26
  69. package/build/core/playwright/tag-processor.js +2 -4
  70. package/build/core/playwright/test-runner.js +37 -42
  71. package/build/core/playwright/types.js +43 -0
  72. package/build/decorators.d.ts +1 -1
  73. package/build/decorators.js +16 -2
  74. package/build/index.d.ts +77 -60
  75. package/build/index.js +51 -9
  76. package/build/lib/cli.js +0 -3
  77. package/build/lib/post-install.js +15 -10
  78. package/build/parser/sample.feature +34 -34
  79. package/build/parser/sample.spec.js +18 -18
  80. package/build/setup-folder-structure/helper.js +2 -0
  81. package/build/setup-folder-structure/reportEnhancement/addonScript.html +24 -24
  82. package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -72
  83. package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
  84. package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
  85. package/build/setup-folder-structure/samples/git-ignore.sample.js +36 -36
  86. package/build/setup-folder-structure/samples/uat-config-sample.js +44 -44
  87. package/build/utils/cliArgsToObject.js +30 -26
  88. package/build/utils/fileUtils.js +4 -19
  89. package/build/utils/getFilePath.js +1 -2
  90. package/build/utils/rootPath.js +16 -9
  91. package/changelog.md +139 -131
  92. package/jest.config.js +63 -63
  93. package/npm-shrinkwrap.json +6469 -5980
  94. package/package.json +55 -54
  95. package/playwright.config.js +112 -112
  96. package/build/bdd-poc/core-runner/exportMethods.js +0 -20
  97. package/build/bdd-poc/core-runner/main.js +0 -10
  98. package/build/bdd-poc/core-runner/runner.js +0 -21
  99. package/build/bdd-poc/core-runner/stepDefinitions.js +0 -52
  100. package/build/bdd-poc/index.js +0 -26
  101. package/build/bdd-poc/test/cucumber/featureFileParer.js +0 -84
  102. package/build/bdd-poc/test/cucumber/parserCucumber.js +0 -15
  103. package/build/bdd-poc/test/stepGenerate/extractTestInputs.js +0 -37
  104. package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +0 -39
  105. package/build/bdd-poc/test/stepGenerate/stepsnippets.js +0 -58
  106. package/build/bdd-poc/test/tagsHandle.js +0 -69
  107. package/build/bdd-poc/test/testDataMap.js +0 -98
  108. package/build/bdd-poc/test/testStructure.js +0 -98
  109. package/build/bdd-poc/utils/stringManipulation.js +0 -26
@@ -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
@@ -29,6 +29,8 @@ function helpercmd() {
29
29
  _commander.program.option('--debug', 'This command is used to initiate a debugging session');
30
30
  _commander.program.option('--tags', 'Run specific test case with mentioned tags (Usage: -- --tags="@live")');
31
31
  _commander.program.option('--workers', 'Specify number of workers to run the test case parallely (Usage: -- --workers=2)');
32
+ _commander.program.option('--edition', 'Specify edition to run the test cases (Usage: -- --edition="standard". This will run the test cases with either no edition mentioned or edition standard)');
33
+ _commander.program.option('--browsers', 'Specify the browsers on which the test case should run (Usage: -- --browsers="chrome,firefox,safari")');
32
34
  _commander.program.parse(process.argv);
33
35
  }
34
36
  var _default = exports.default = helpercmd;
@@ -1,25 +1,25 @@
1
- <script>
2
- function sortEdition(event) {
3
- var currentURL = window.location.href;
4
- const endPointCount = window.location.href.indexOf('#');
5
- if (!(endPointCount == -1)) {
6
- window.history.pushState({}, '', currentURL.slice(0, endPointCount));
7
- currentURL = currentURL.slice(0, endPointCount);
8
- }
9
- console.log(currentURL);
10
- window.open(`${currentURL}#?q=@edition_${event.target.value}`, '_self');
11
- }
12
- </script>
13
- <div class="mainContainer" style="margin-left: 20px; display: flex;">
14
- <div class="selectEditionContainer" style="padding: 20px;">
15
- <select class="selectEdition" style="padding: 5px; width: 100px; border-radius: 6px; border: 1px solid var(--color-border-default);" onchange="sortEdition(event)">
16
- <option value="EnterPrise">EnterPrise</option>
17
- <option value="Professional">Professional</option>
18
- <option value="Express">Express</option>
19
- <option value="Standard">Standard</option>
20
- <option value="Free">Free</option>
21
- </select>
22
- </div>
23
- </div>
24
-
1
+ <script>
2
+ function sortEdition(event) {
3
+ var currentURL = window.location.href;
4
+ const endPointCount = window.location.href.indexOf('#');
5
+ if (!(endPointCount == -1)) {
6
+ window.history.pushState({}, '', currentURL.slice(0, endPointCount));
7
+ currentURL = currentURL.slice(0, endPointCount);
8
+ }
9
+ console.log(currentURL);
10
+ window.open(`${currentURL}#?q=@edition_${event.target.value}`, '_self');
11
+ }
12
+ </script>
13
+ <div class="mainContainer" style="margin-left: 20px; display: flex;">
14
+ <div class="selectEditionContainer" style="padding: 20px;">
15
+ <select class="selectEdition" style="padding: 5px; width: 100px; border-radius: 6px; border: 1px solid var(--color-border-default);" onchange="sortEdition(event)">
16
+ <option value="EnterPrise">EnterPrise</option>
17
+ <option value="Professional">Professional</option>
18
+ <option value="Express">Express</option>
19
+ <option value="Standard">Standard</option>
20
+ <option value="Free">Free</option>
21
+ </select>
22
+ </div>
23
+ </div>
24
+
25
25
 
@@ -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,37 @@
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
+ 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
+
37
37
  export default updateGitIgnore;
@@ -1,44 +1,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. 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. 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
+ }
@@ -5,25 +5,29 @@ 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
+ function isMatchForOption(option) {
9
+ return /^--./.test(option);
10
+ }
11
+
12
+ /**
13
+ * Converts an array of command-line arguments into an object.
14
+ *
15
+ * @param {string[]} cliArgs - An array of command-line arguments.
16
+ * @param {boolean} [isKeyNeedToBeAdded=true] - Indicates whether the keys should be added to the resulting object.
17
+ * @returns {Object} An object representing the command-line arguments, where keys are argument names (without '--') and values are argument values.
18
+ * If `isKeyNeedToBeAdded` is set to `false`, only values are included in the object with numeric indexes as keys.
19
+ *
20
+ * @example
21
+ * // Example usage:
22
+ * const args = ['--port=8080', '--verbose', 'input.txt'];
23
+ * const result = cliArgsToObject(args);
24
+ * // result will be: { port: '8080', verbose: true }
21
25
  */
22
26
  // eslint-disable-next-line no-unused-vars
23
27
  function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
24
28
  const processEnv = {};
25
29
  cliArgs.forEach(option => {
26
- if (/^--./.test(option)) {
30
+ if (isMatchForOption(option)) {
27
31
  const equIndex = option.indexOf('=');
28
32
  let key = option.slice(2, equIndex);
29
33
  let value = option.slice(equIndex + 1);
@@ -37,18 +41,18 @@ function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
37
41
  return processEnv;
38
42
  }
39
43
 
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']
44
+ /**
45
+ * Converts an object to an array of command-line arguments.
46
+ *
47
+ * @param {Object} objectToBeConverted - The object to be converted to command-line arguments.
48
+ * @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.
49
+ * @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.
50
+ *
51
+ * @example
52
+ * // Example usage:
53
+ * const options = { port: 8080, verbose: true, input: 'input.txt' };
54
+ * const args = objectToCliArgs(options);
55
+ * // args will be: ['--port=8080', '--verbose', '--input=input.txt']
52
56
  */
53
57
  function objectToCliArgs(objectToBeConverted, isKeyNeedToBeAdded) {
54
58
  const argsArray = [];