@zohodesk/testinglibrary 0.1.8-stb-bdd-v26 → 0.1.9-exp-actors

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 (170) 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 +42 -0
  7. package/build/bdd-framework/cli/commands/export.js +47 -0
  8. package/build/bdd-framework/cli/commands/test.js +64 -0
  9. package/build/bdd-framework/cli/index.js +11 -0
  10. package/build/bdd-framework/cli/options.js +19 -0
  11. package/build/bdd-framework/cli/worker.js +13 -0
  12. package/build/bdd-framework/config/configDir.js +35 -0
  13. package/build/bdd-framework/config/enrichReporterData.js +23 -0
  14. package/build/bdd-framework/config/env.js +50 -0
  15. package/build/bdd-framework/config/index.js +94 -0
  16. package/build/bdd-framework/config/lang.js +14 -0
  17. package/build/bdd-framework/cucumber/buildStepDefinition.js +43 -0
  18. package/build/bdd-framework/cucumber/createTestStep.js +43 -0
  19. package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +126 -0
  20. package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +72 -0
  21. package/build/bdd-framework/cucumber/formatter/PickleParser.js +25 -0
  22. package/build/bdd-framework/cucumber/formatter/durationHelpers.js +13 -0
  23. package/build/bdd-framework/cucumber/formatter/getColorFns.js +57 -0
  24. package/build/bdd-framework/cucumber/formatter/index.js +16 -0
  25. package/build/bdd-framework/cucumber/formatter/locationHelpers.js +16 -0
  26. package/build/bdd-framework/cucumber/loadConfig.js +17 -0
  27. package/build/bdd-framework/cucumber/loadFeatures.js +70 -0
  28. package/build/bdd-framework/cucumber/loadSnippetBuilder.js +20 -0
  29. package/build/bdd-framework/cucumber/loadSteps.js +47 -0
  30. package/build/bdd-framework/cucumber/resolveFeaturePaths.js +62 -0
  31. package/build/bdd-framework/cucumber/stepArguments.js +21 -0
  32. package/build/bdd-framework/cucumber/types.js +5 -0
  33. package/build/bdd-framework/cucumber/valueChecker.js +23 -0
  34. package/build/bdd-framework/decorators.js +18 -0
  35. package/build/bdd-framework/gen/fixtures.js +48 -0
  36. package/build/bdd-framework/gen/formatter.js +123 -0
  37. package/build/bdd-framework/gen/i18n.js +39 -0
  38. package/build/bdd-framework/gen/index.js +185 -0
  39. package/build/bdd-framework/gen/testFile.js +465 -0
  40. package/build/bdd-framework/gen/testMeta.js +60 -0
  41. package/build/bdd-framework/gen/testNode.js +60 -0
  42. package/build/bdd-framework/gen/testPoms.js +133 -0
  43. package/build/bdd-framework/hooks/scenario.js +130 -0
  44. package/build/bdd-framework/hooks/worker.js +89 -0
  45. package/build/bdd-framework/index.js +52 -0
  46. package/build/bdd-framework/playwright/fixtureParameterNames.js +93 -0
  47. package/build/bdd-framework/playwright/getLocationInFile.js +79 -0
  48. package/build/bdd-framework/playwright/loadConfig.js +42 -0
  49. package/build/bdd-framework/playwright/loadUtils.js +33 -0
  50. package/build/bdd-framework/playwright/testTypeImpl.js +61 -0
  51. package/build/bdd-framework/playwright/transform.js +88 -0
  52. package/build/bdd-framework/playwright/types.js +5 -0
  53. package/build/bdd-framework/playwright/utils.js +34 -0
  54. package/build/bdd-framework/reporter/cucumber/base.js +57 -0
  55. package/build/bdd-framework/reporter/cucumber/custom.js +73 -0
  56. package/build/bdd-framework/reporter/cucumber/helper.js +12 -0
  57. package/build/bdd-framework/reporter/cucumber/html.js +35 -0
  58. package/build/bdd-framework/reporter/cucumber/index.js +74 -0
  59. package/build/bdd-framework/reporter/cucumber/json.js +312 -0
  60. package/build/bdd-framework/reporter/cucumber/junit.js +205 -0
  61. package/build/bdd-framework/reporter/cucumber/message.js +20 -0
  62. package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +64 -0
  63. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +196 -0
  64. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +43 -0
  65. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +52 -0
  66. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +105 -0
  67. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +70 -0
  68. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +45 -0
  69. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +27 -0
  70. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +38 -0
  71. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +128 -0
  72. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +126 -0
  73. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +102 -0
  74. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +50 -0
  75. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +88 -0
  76. package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +30 -0
  77. package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwUtils.js +51 -0
  78. package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +35 -0
  79. package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +5 -0
  80. package/build/bdd-framework/run/StepInvoker.js +68 -0
  81. package/build/bdd-framework/run/bddDataAttachment.js +46 -0
  82. package/build/bdd-framework/run/bddFixtures.js +191 -0
  83. package/build/bdd-framework/run/bddWorld.js +79 -0
  84. package/build/bdd-framework/run/bddWorldInternal.js +15 -0
  85. package/build/bdd-framework/snippets/index.js +132 -0
  86. package/build/bdd-framework/snippets/snippetSyntax.js +43 -0
  87. package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +26 -0
  88. package/build/bdd-framework/snippets/snippetSyntaxTs.js +18 -0
  89. package/build/bdd-framework/stepDefinitions/createBdd.js +66 -0
  90. package/build/bdd-framework/stepDefinitions/decorators/class.js +68 -0
  91. package/build/bdd-framework/stepDefinitions/decorators/steps.js +99 -0
  92. package/build/bdd-framework/stepDefinitions/defineStep.js +62 -0
  93. package/build/bdd-framework/stepDefinitions/stepConfig.js +24 -0
  94. package/build/bdd-framework/utils/AutofillMap.js +20 -0
  95. package/build/bdd-framework/utils/exit.js +62 -0
  96. package/build/bdd-framework/utils/index.js +93 -0
  97. package/build/bdd-framework/utils/jsStringWrap.js +44 -0
  98. package/build/bdd-framework/utils/logger.js +30 -0
  99. package/build/bdd-framework/utils/stripAnsiEscapes.js +20 -0
  100. package/build/core/playwright/builtInFixtures/addTags.js +1 -1
  101. package/build/core/playwright/builtInFixtures/context.js +18 -1
  102. package/build/core/playwright/builtInFixtures/i18N.js +33 -0
  103. package/build/core/playwright/builtInFixtures/index.js +19 -7
  104. package/build/core/playwright/builtInFixtures/page.js +87 -39
  105. package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
  106. package/build/core/playwright/clear-caches.js +19 -8
  107. package/build/core/playwright/codegen.js +4 -4
  108. package/build/core/playwright/constants/browserTypes.js +12 -0
  109. package/build/core/playwright/custom-commands.js +1 -1
  110. package/build/core/playwright/env-initializer.js +10 -6
  111. package/build/core/playwright/helpers/auth/accountLogin.js +18 -0
  112. package/build/core/playwright/helpers/auth/checkAuthCookies.js +50 -0
  113. package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
  114. package/build/core/playwright/helpers/auth/getUsers.js +111 -0
  115. package/build/core/playwright/helpers/auth/index.js +70 -0
  116. package/build/core/playwright/helpers/auth/loginSteps.js +36 -0
  117. package/build/core/playwright/helpers/configFileNameProvider.js +24 -0
  118. package/build/core/playwright/helpers/getUserFixtures.js +23 -0
  119. package/build/core/playwright/helpers/mergeObjects.js +13 -0
  120. package/build/core/playwright/helpers/parseUserArgs.js +11 -0
  121. package/build/core/playwright/index.js +81 -15
  122. package/build/core/playwright/readConfigFile.js +50 -39
  123. package/build/core/playwright/report-generator.js +7 -7
  124. package/build/core/playwright/setup/config-creator.js +15 -16
  125. package/build/core/playwright/setup/config-utils.js +60 -26
  126. package/build/core/playwright/setup/custom-reporter.js +3 -2
  127. package/build/core/playwright/tag-processor.js +12 -23
  128. package/build/core/playwright/test-runner.js +50 -65
  129. package/build/core/playwright/types.js +43 -0
  130. package/build/decorators.d.ts +1 -1
  131. package/build/decorators.js +16 -2
  132. package/build/index.d.ts +97 -12
  133. package/build/index.js +63 -9
  134. package/build/lib/cli.js +12 -3
  135. package/build/lib/post-install.js +18 -10
  136. package/build/parser/sample.feature +34 -34
  137. package/build/parser/sample.spec.js +18 -18
  138. package/build/setup-folder-structure/helper.js +3 -0
  139. package/build/setup-folder-structure/reportEnhancement/addonScript.html +24 -24
  140. package/build/setup-folder-structure/samples/auth-setup-sample.js +71 -72
  141. package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
  142. package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
  143. package/build/setup-folder-structure/samples/git-ignore.sample.js +36 -36
  144. package/build/setup-folder-structure/samples/uat-config-sample.js +44 -44
  145. package/build/utils/cliArgsToObject.js +30 -26
  146. package/build/utils/fileUtils.js +4 -19
  147. package/build/utils/getFilePath.js +1 -2
  148. package/build/utils/rootPath.js +16 -9
  149. package/changelog.md +144 -131
  150. package/jest.config.js +63 -63
  151. package/npm-shrinkwrap.json +6475 -5994
  152. package/package.json +57 -56
  153. package/playwright.config.js +112 -112
  154. package/build/bdd-poc/config/pathConfig.js +0 -22
  155. package/build/bdd-poc/core-runner/exportMethods.js +0 -22
  156. package/build/bdd-poc/core-runner/main.js +0 -15
  157. package/build/bdd-poc/core-runner/stepDefinitions.js +0 -157
  158. package/build/bdd-poc/core-runner/stepRunner.js +0 -25
  159. package/build/bdd-poc/errors/throwError.js +0 -23
  160. package/build/bdd-poc/index.js +0 -26
  161. package/build/bdd-poc/test/cucumber/featureFileParer.js +0 -84
  162. package/build/bdd-poc/test/cucumber/parserCucumber.js +0 -15
  163. package/build/bdd-poc/test/stepGenerate/extractTestInputs.js +0 -65
  164. package/build/bdd-poc/test/stepGenerate/parserSteps.js +0 -81
  165. package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +0 -40
  166. package/build/bdd-poc/test/stepGenerate/stepsnippets.js +0 -61
  167. package/build/bdd-poc/test/tagsHandle.js +0 -70
  168. package/build/bdd-poc/test/testData.js +0 -125
  169. package/build/bdd-poc/test/testStructure.js +0 -92
  170. package/build/bdd-poc/utils/stringManipulation.js +0 -26
@@ -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,71 @@
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
+ import { getAuthFileDirectory } from '../../core/playwright';
6
+
7
+ const userdata = require('./authUsers.json');
8
+
9
+ const authContent = { cookies: [] };
10
+
11
+ const LOGIN_ERR_MESSAGE = 'Need go be logged in';
12
+ // const AUTH_ERR_MESSAGE = `Founded Path - ${path.resolve(process.cwd(),'uat','playwright','.auth')} \n Find if file is Properly Created. Cookies Cannot Be Read .. `
13
+
14
+ function convertCookiesToParse(cookies, authFilePath) {
15
+ try {
16
+ return JSON.parse(cookies);
17
+ } catch (err) {
18
+ throw new Error(
19
+ ` Error while parsing cookies ${err} \n${path.resolve(
20
+ process.cwd(),
21
+ authFilePath
22
+ )} File is Empty`
23
+ );
24
+ // process.exit()
25
+ }
26
+ }
27
+ const authDirectory = getAuthFileDirectory(); //path.resolve(process.cwd(), 'uat', 'playwright', '.auth');
28
+ if (!existsSync(authDirectory)) {
29
+ console.log('Creating auth directory for the first time setup...');
30
+ mkdirSync(authDirectory, { recursive: true });
31
+ }
32
+
33
+ userdata.forEach(data => {
34
+ const authFile = path.resolve(path.join(authDirectory, `${data.filename}`));
35
+ if (!existsSync(authFile)) {
36
+ console.log('creating auth file..');
37
+ writeFileSync(authFile, JSON.stringify(authContent, null, 2));
38
+ }
39
+ setup(data.description, async ({ page }) => {
40
+ try {
41
+ const cookies = readFileSync(authFile);
42
+ const parsedCookies = convertCookiesToParse(cookies, authFile);
43
+ await page
44
+ .context()
45
+ .addCookies(
46
+ parsedCookies.cookies === undefined ? [] : parsedCookies.cookies
47
+ );
48
+ await page.goto(page.getBaseUrl());
49
+ await page.waitForLoadState();
50
+ if (await page.url().includes(process.env.domain)) {
51
+ await page.waitForSelector(data.locator);
52
+ } else {
53
+ throw new Error(LOGIN_ERR_MESSAGE);
54
+ }
55
+ } catch (err) {
56
+ if (err.message === LOGIN_ERR_MESSAGE) {
57
+ await expect(page.locator('.load-bg')).toBeHidden();
58
+ await page.locator('#login_id').type(data.useremail);
59
+ await page.locator('#nextbtn').click();
60
+ await page.locator('#password').type(data.password);
61
+ await page.locator('#nextbtn').click();
62
+
63
+ await page.waitForLoadState('networkidle');
64
+
65
+ await page.waitForSelector(data.locator);
66
+
67
+ await page.context().storageState({ path: authFile });
68
+ }
69
+ }
70
+ });
71
+ });
@@ -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 = [];
@@ -5,15 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.checkIfFileExists = checkIfFileExists;
8
- exports.createFolderSync = createFolderSync;
9
8
  exports.deleteFile = deleteFile;
10
9
  exports.deleteFolder = deleteFolder;
11
10
  exports.readFileContents = readFileContents;
12
11
  exports.writeFileContents = writeFileContents;
13
- var _fs = _interopRequireWildcard(require("fs"));
12
+ var _fs = _interopRequireDefault(require("fs"));
14
13
  var _path = _interopRequireDefault(require("path"));
15
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ var _logger = require("./logger");
17
15
  function checkIfFileExists(file) {
18
16
  try {
19
17
  _fs.default.accessSync(file, _fs.default.constants.F_OK);
@@ -52,6 +50,8 @@ function deleteFile(filePath) {
52
50
  } catch (err) {
53
51
  throw new Error(`Error while deleting the test data file: ${filePath}`);
54
52
  }
53
+ } else {
54
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `File Does not Exist in the path ${filePath}`);
55
55
  }
56
56
  }
57
57
  function deleteFolder(folderPath) {
@@ -64,19 +64,4 @@ function deleteFolder(folderPath) {
64
64
  throw new Error(`Error while deleting the test data file: ${folderPath}`);
65
65
  }
66
66
  }
67
- }
68
- function resolveFilePath(...filePath) {
69
- var resolvedPath;
70
- for (let i = 0; i < filePath.length; i++) {
71
- resolvedPath = _path.default.resolve(resolvedPath, filePath[i]);
72
- }
73
- return resolvedPath;
74
- }
75
- function createFolderSync(folderPath, options = {}) {
76
- if ((0, _fs.existsSync)(folderPath)) {
77
- return null;
78
- }
79
- return (0, _fs.mkdirSync)(folderPath, {
80
- recursive: true
81
- });
82
67
  }
@@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getFilePathWithExtension;
7
- exports.isWindows = void 0;
8
7
  var _os = require("os");
9
- const isWindows = exports.isWindows = (0, _os.platform)().toLowerCase() === 'win32';
8
+ const isWindows = (0, _os.platform)().toLowerCase() === 'win32';
10
9
  function getFilePathWithExtension(binName) {
11
10
  return isWindows ? `${binName}.cmd` : binName;
12
11
  }
@@ -12,24 +12,31 @@ var _path = _interopRequireDefault(require("path"));
12
12
  var _fs = _interopRequireDefault(require("fs"));
13
13
  var _logger = require("./logger");
14
14
  var _getFilePath = _interopRequireDefault(require("./getFilePath"));
15
- function findBinaryPath(directory, command) {
16
- const binaryPath = _path.default.join(directory, '.bin', (0, _getFilePath.default)(command));
17
- if (_fs.default.existsSync(binaryPath)) {
18
- return binaryPath;
15
+ // TODO: Publish and check this change of finding package.json working fine.
16
+ function findPath(directory, pathToFind) {
17
+ const filePath = _path.default.join(directory, pathToFind);
18
+ if (_fs.default.existsSync(filePath)) {
19
+ return filePath;
19
20
  }
20
-
21
- // Recursively search parent directories. Might be time-consuming ?? Can we look for npm module like which?
22
21
  const parentDir = _path.default.dirname(directory);
23
22
  if (parentDir === directory) {
24
23
  return null;
25
24
  }
26
- return findBinaryPath(parentDir, command);
25
+ return findPath(parentDir, pathToFind);
26
+ }
27
+ function findPackageJSON(startDir) {
28
+ return findPath(startDir, 'package.json');
29
+ }
30
+ function findBinaryPath(directory, command) {
31
+ const binaryPath = _path.default.join('.bin', (0, _getFilePath.default)(command));
32
+ return findPath(directory, binaryPath);
27
33
  }
28
34
  function getRootPath() {
29
- return _path.default.resolve(__dirname, '../', '../');
35
+ return findPackageJSON(_path.default.resolve(__dirname));
30
36
  }
31
37
  function getRootNodeModulesPath() {
32
- return _path.default.resolve(getRootPath(), 'node_modules');
38
+ const rootPath = getRootPath();
39
+ return _path.default.resolve(_path.default.dirname(rootPath), 'node_modules');
33
40
  }
34
41
  function getBinPath(command) {
35
42
  const packageNodeModulesPath = getRootNodeModulesPath();