@zohodesk/testinglibrary 0.0.1 → 0.0.2-n20-experimental

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/.babelrc +23 -0
  2. package/.eslintrc.js +31 -0
  3. package/.gitlab-ci.yml +163 -0
  4. package/.prettierrc +6 -0
  5. package/README.md +98 -18
  6. package/bin/cli.js +2 -2
  7. package/bin/postinstall.js +1 -16
  8. package/{src → build}/core/jest/preprocessor/jsPreprocessor.js +7 -9
  9. package/{src → build}/core/jest/runner/jest-runner.js +46 -45
  10. package/build/core/jest/setup/index.js +3 -0
  11. package/build/core/playwright/builtInFixtures/addTags.js +19 -0
  12. package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
  13. package/build/core/playwright/builtInFixtures/context.js +32 -0
  14. package/build/core/playwright/builtInFixtures/executionContext.js +17 -0
  15. package/build/core/playwright/builtInFixtures/i18N.js +41 -0
  16. package/build/core/playwright/builtInFixtures/index.js +44 -0
  17. package/build/core/playwright/builtInFixtures/page.js +101 -0
  18. package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
  19. package/build/core/playwright/clear-caches.js +49 -0
  20. package/build/core/playwright/codegen.js +55 -0
  21. package/build/core/playwright/configuration/Configuration.js +25 -0
  22. package/build/core/playwright/configuration/ConfigurationHelper.js +43 -0
  23. package/build/core/playwright/configuration/UserArgs.js +12 -0
  24. package/build/core/playwright/constants/browserTypes.js +12 -0
  25. package/build/core/playwright/constants/fileMutexConfig.js +9 -0
  26. package/build/core/playwright/custom-commands.js +7 -0
  27. package/build/core/playwright/env-initializer.js +43 -0
  28. package/build/core/playwright/fixtures.js +24 -0
  29. package/build/core/playwright/helpers/additionalProfiles.js +18 -0
  30. package/build/core/playwright/helpers/auth/accountLogin.js +21 -0
  31. package/build/core/playwright/helpers/auth/checkAuthCookies.js +41 -0
  32. package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
  33. package/build/core/playwright/helpers/auth/getUsers.js +118 -0
  34. package/build/core/playwright/helpers/auth/index.js +76 -0
  35. package/build/core/playwright/helpers/auth/loginSteps.js +50 -0
  36. package/build/core/playwright/helpers/checkAuthDirectory.js +27 -0
  37. package/build/core/playwright/helpers/configFileNameProvider.js +31 -0
  38. package/build/core/playwright/helpers/fileMutex.js +71 -0
  39. package/build/core/playwright/helpers/getUserFixtures.js +23 -0
  40. package/build/core/playwright/helpers/mergeObjects.js +13 -0
  41. package/build/core/playwright/helpers/parseUserArgs.js +10 -0
  42. package/build/core/playwright/index.js +24 -0
  43. package/build/core/playwright/readConfigFile.js +147 -0
  44. package/build/core/playwright/report-generator.js +42 -0
  45. package/build/core/playwright/runner/Runner.js +22 -0
  46. package/build/core/playwright/runner/RunnerHelper.js +43 -0
  47. package/build/core/playwright/runner/RunnerTypes.js +17 -0
  48. package/build/core/playwright/runner/SpawnRunner.js +110 -0
  49. package/build/core/playwright/setup/config-creator.js +113 -0
  50. package/build/core/playwright/setup/config-utils.js +189 -0
  51. package/build/core/playwright/setup/custom-reporter.js +136 -0
  52. package/build/core/playwright/setup/qc-custom-reporter.js +291 -0
  53. package/build/core/playwright/tagProcessor.js +69 -0
  54. package/build/core/playwright/test-runner.js +116 -0
  55. package/build/core/playwright/types.js +44 -0
  56. package/build/core/playwright/validateFeature.js +28 -0
  57. package/build/decorators.d.ts +1 -0
  58. package/build/decorators.js +16 -0
  59. package/build/index.d.ts +78 -0
  60. package/build/index.js +105 -0
  61. package/build/lib/cli.js +78 -0
  62. package/build/lib/post-install.js +25 -0
  63. package/build/lint/index.js +4 -0
  64. package/build/parser/parser.js +205 -0
  65. package/build/parser/sample.feature +34 -0
  66. package/build/parser/sample.spec.js +37 -0
  67. package/build/parser/verifier.js +130 -0
  68. package/build/setup-folder-structure/helper.js +37 -0
  69. package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
  70. package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
  71. package/build/setup-folder-structure/samples/accountLogin-sample.js +19 -0
  72. package/build/setup-folder-structure/samples/actors-index.js +2 -0
  73. package/build/setup-folder-structure/samples/auth-setup-sample.js +15 -0
  74. package/build/setup-folder-structure/samples/editions-index.js +3 -0
  75. package/build/setup-folder-structure/samples/free-sample.json +25 -0
  76. package/build/setup-folder-structure/samples/git-ignore.sample.js +37 -0
  77. package/build/setup-folder-structure/samples/settings.json +7 -0
  78. package/build/setup-folder-structure/samples/testSetup-sample.js +14 -0
  79. package/build/setup-folder-structure/samples/uat-config-sample.js +46 -0
  80. package/build/setup-folder-structure/setupProject.js +122 -0
  81. package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
  82. package/build/test/core/playwright/__tests__/validateFeature.test.js +69 -0
  83. package/build/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js +27 -0
  84. package/build/test/core/playwright/configuration/__tests__/Configuration.test.js +53 -0
  85. package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +34 -0
  86. package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +79 -0
  87. package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +80 -0
  88. package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +16 -0
  89. package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +27 -0
  90. package/build/utils/cliArgsToObject.js +72 -0
  91. package/build/utils/fileUtils.js +89 -0
  92. package/build/utils/getFilePath.js +11 -0
  93. package/build/utils/logger.js +57 -0
  94. package/build/utils/rootPath.js +53 -0
  95. package/build/utils/stepDefinitionsFormatter.js +11 -0
  96. package/changelog.md +167 -0
  97. package/jest.config.js +81 -63
  98. package/npm-shrinkwrap.json +12575 -0
  99. package/package.json +60 -31
  100. package/playwright.config.js +62 -112
  101. package/src/core/jest/setup/index.js +0 -165
  102. package/src/core/playwright/codegen.js +0 -61
  103. package/src/core/playwright/custom-commands.js +0 -3
  104. package/src/core/playwright/env-initializer.js +0 -24
  105. package/src/core/playwright/index.js +0 -81
  106. package/src/core/playwright/readConfigFile.js +0 -18
  107. package/src/core/playwright/report-generator.js +0 -44
  108. package/src/core/playwright/test-runner.js +0 -64
  109. package/src/index.js +0 -9
  110. package/src/lib/cli.js +0 -35
  111. package/src/utils/cliArgsToObject.js +0 -35
  112. package/src/utils/getFilePath.js +0 -9
  113. package/src/utils/logger.js +0 -28
  114. package/src/utils/rootPath.js +0 -19
package/package.json CHANGED
@@ -1,31 +1,60 @@
1
- {
2
- "name": "@zohodesk/testinglibrary",
3
- "version": "0.0.1",
4
- "description": "",
5
- "main": "./src/index.js",
6
- "scripts": {
7
- "postinstall": "node bin/postinstall.js",
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "keywords": [],
11
- "author": "",
12
- "license": "ISC",
13
- "dependencies": {
14
- "@babel/preset-env": "^7.22.9",
15
- "@babel/preset-react": "^7.22.5",
16
- "@playwright/test": "^1.37.1",
17
- "@testing-library/jest-dom": "^5.11.9",
18
- "@testing-library/react": "^11.2.7",
19
- "@testing-library/react-hooks": "^7.0.2",
20
- "babel-jest": "^29.6.2",
21
- "babel-plugin-transform-dynamic-import": "^2.1.0",
22
- "jest": "^29.6.2",
23
- "jest-environment-jsdom": "^29.6.2",
24
- "msw": "^1.2.3",
25
- "react": "16.13.1",
26
- "react-dom": "16.13.1"
27
- },
28
- "bin": {
29
- "ZDTestingFramework": "./bin/cli.js"
30
- }
31
- }
1
+ {
2
+ "name": "@zohodesk/testinglibrary",
3
+ "version": "0.0.2-n20-experimental",
4
+ "description": "",
5
+ "main": "./build/index.js",
6
+ "scripts": {
7
+ "postinstall": "node bin/postinstall.js",
8
+ "test": "jest",
9
+ "clean": "rm -rf build && mkdir build",
10
+ "build-babel": "babel -d ./build ./src --copy-files",
11
+ "build": "npm run clean && npm run build-babel",
12
+ "prepare": "npm run build",
13
+ "lint": "eslint src/* --fix"
14
+ },
15
+ "exports": {
16
+ ".": "./build/index.js",
17
+ "./decorators": "./build/decorators.js",
18
+ "./helpers": "./build/core/playwright/helpers/auth/index.js"
19
+ },
20
+ "keywords": [],
21
+ "author": "",
22
+ "license": "ISC",
23
+ "dependencies": {
24
+ "@babel/code-frame": "7.27.1",
25
+ "@babel/preset-react": "7.27.1",
26
+ "@cucumber/cucumber": "11.3.0",
27
+ "@playwright/test": "1.53.2",
28
+ "@reportportal/agent-js-playwright": "5.1.11",
29
+ "@testing-library/jest-dom": "5.11.9",
30
+ "@testing-library/react": "11.2.7",
31
+ "@testing-library/react-hooks": "7.0.2",
32
+ "babel-jest": "29.6.2",
33
+ "babel-plugin-transform-dynamic-import": "2.1.0",
34
+ "fast-glob": "3.3.3",
35
+ "jest": "29.6.2",
36
+ "jest-environment-jsdom": "29.6.2",
37
+ "msw": "2.10.4",
38
+ "playwright": "1.53.2",
39
+ "supports-color": "8.1.1",
40
+ "playwright-bdd": "8.3.1"
41
+ },
42
+ "bin": {
43
+ "ZDTestingFramework": "./bin/cli.js"
44
+ },
45
+ "peerDependencies": {
46
+ "eslint": "*",
47
+ "react": "*",
48
+ "react-dom": "*"
49
+ },
50
+ "devDependencies": {
51
+ "@babel/cli": "7.28.0",
52
+ "@babel/core": "7.28.0",
53
+ "@babel/node": "7.28.0",
54
+ "@babel/plugin-transform-runtime": "7.28.0",
55
+ "@babel/preset-env": "7.28.0",
56
+ "@babel/runtime": "7.28.2",
57
+ "commander": "14.0.0",
58
+ "jest-html-reporter": "4.3.0"
59
+ }
60
+ }
@@ -1,112 +1,62 @@
1
- // @ts-check
2
- const { defineConfig, devices } = require('@playwright/test');
3
- const path = require('path');
4
- const numCPUs = require('os').cpus().length;
5
-
6
- /**
7
- * Read environment variables from file.
8
- * https://github.com/motdotla/dotenv
9
- */
10
- // require('dotenv').config();
11
-
12
- /**
13
- * @see https://playwright.dev/docs/test-configuration
14
- */
15
- module.exports = defineConfig({
16
- testDir: path.join(path.resolve(process.cwd()), 'uat'),
17
- outputDir: path.join(process.cwd(), 'test-results'),
18
- /* Run tests in files in parallel */
19
- fullyParallel: true,
20
- /* Fail the build on CI if you accidentally left test.only in the source code. */
21
- forbidOnly: !!process.env.CI,
22
- /* Retry on CI only */
23
- retries: process.env.CI ? 2 : 0,
24
- /* Opt out of parallel tests on CI. */
25
- workers: process.env.CI ? 1 : 1,
26
- /* Reporter to use. See https://playwright.dev/docs/test-reporters */
27
- reporter: [['html', { outputFolder: path.join(process.cwd(), 'playwright-report'), open: "always" }]],
28
- timeout: 60 * 1000,
29
- expect: {
30
- timeout: 5 * 1000,
31
- },
32
-
33
- /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
34
- use: {
35
- /* Base URL to use in actions like `await page.goto('/')`. */
36
- //baseURL: process.env.domain,
37
-
38
- /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
39
- trace: 'on',
40
- video: {
41
- mode: 'on',
42
- size: { width: 640, height: 480 }
43
- }
44
- },
45
-
46
- /* Configure projects for major browsers */
47
- projects: [
48
- { name: 'setup', testMatch: /.*\.setup\.js/ },
49
- {
50
- name: 'chromium',
51
- use: {
52
- ...devices['Desktop Chrome'],
53
- storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json')
54
- },
55
- dependencies: ['setup'],
56
- },
57
-
58
- {
59
- name: 'firefox',
60
- timeout: 4 * 60 * 1000,
61
- expect: {
62
- timeout: 80 * 1000,
63
- },
64
- use: {
65
- ...devices['Desktop Firefox'],
66
- storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json')
67
- },
68
- dependencies: ['setup'],
69
- },
70
-
71
- {
72
- name: 'webkit',
73
- timeout: 2 * 60 * 1000,
74
- expect: {
75
- timeout: 80 * 1000,
76
- },
77
- use: {
78
- ...devices['Desktop Safari'],
79
- storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json')
80
- },
81
- dependencies: ['setup'],
82
- },
83
-
84
- /* Test against mobile viewports. */
85
- // {
86
- // name: 'Mobile Chrome',
87
- // use: { ...devices['Pixel 5'] },
88
- // },
89
- // {
90
- // name: 'Mobile Safari',
91
- // use: { ...devices['iPhone 12'] },
92
- // },
93
-
94
- /* Test against branded browsers. */
95
- // {
96
- // name: 'Microsoft Edge',
97
- // use: { ...devices['Desktop Edge'], channel: 'msedge' },
98
- // },
99
- // {
100
- // name: 'Google Chrome',
101
- // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
102
- // },
103
- ],
104
-
105
- /* Run your local dev server before starting the tests */
106
- // webServer: {
107
- // command: 'npm run start',
108
- // url: 'http://127.0.0.1:3000',
109
- // reuseExistingServer: !process.env.CI,
110
- // },
111
- });
112
-
1
+ // @ts-check
2
+ const { defineConfig, devices } = require('@playwright/test');
3
+ const path = require('path');
4
+ const numCPUs = require('os').cpus().length;
5
+
6
+ export default defineConfig({
7
+ testDir: path.join(path.resolve(process.cwd()), 'uat'),
8
+ outputDir: path.join(process.cwd(), 'uat', 'test-results'),
9
+ fullyParallel: true,
10
+ retries: process.env.CI ? 2 : 0,
11
+ reporter: [['html', { outputFolder: path.join(process.cwd(), 'uat', 'playwright-report'), open: "always" }]],
12
+ timeout: 60 * 1000,
13
+ expect: {
14
+ timeout: 5 * 1000,
15
+ },
16
+ use: {
17
+ trace: 'on',
18
+ video: {
19
+ mode: 'on',
20
+ size: { width: 640, height: 480 }
21
+ }
22
+ },
23
+ projects: [
24
+ { name: 'setup', testMatch: /.*\.setup\.js/ },
25
+ {
26
+ name: 'chromium',
27
+ use: {
28
+ ...devices['Desktop Chrome'],
29
+ storageState: path.resolve(process.cwd(), 'uat', 'playwright/.auth/user.json')
30
+ },
31
+ dependencies: ['setup'],
32
+ },
33
+
34
+ {
35
+ name: 'firefox',
36
+ timeout: 4 * 60 * 1000,
37
+ expect: {
38
+ timeout: 80 * 1000,
39
+ },
40
+ use: {
41
+ ...devices['Desktop Firefox'],
42
+ storageState: path.resolve(process.cwd(), 'uat', 'playwright/.auth/user.json')
43
+ },
44
+ dependencies: ['setup'],
45
+ },
46
+
47
+ {
48
+ name: 'webkit',
49
+ timeout: 2 * 60 * 1000,
50
+ expect: {
51
+ timeout: 80 * 1000,
52
+ },
53
+ use: {
54
+ ...devices['Desktop Safari'],
55
+ storageState: path.resolve(process.cwd(), 'uat', 'playwright/.auth/user.json')
56
+ },
57
+ dependencies: ['setup'],
58
+ },
59
+
60
+ ],
61
+ });
62
+
@@ -1,165 +0,0 @@
1
- //$Id$//
2
- import TestUtils from 'react-dom/test-utils';
3
- import { expect } from '@jest/globals'
4
- import React from 'react';
5
- import PropTypes from 'prop-types';
6
- import ReactDOM from 'react-dom';
7
- import '@testing-library/jest-dom/extend-expect';
8
- // let mockDomain = 'htt' + 'p://zoho.com';
9
- // const { document } = new JSDOM('').window;
10
- // global.document = document;
11
- // global.window = document.defaultView;
12
- // global.navigator = global.window.navigator;
13
- // global.localStorage = global.sessionStorage = {
14
- // getItem(key) {
15
- // return this[key];
16
- // },
17
- // setItem(key, value) {
18
- // if (value.length > 100) {
19
- // throw new Error('Data size is too exceeded');
20
- // }
21
- // this[key] = value;
22
- // },
23
- // removeItem(key) {
24
- // delete this[key];
25
- // },
26
- // clear() {
27
- // let keys = ['getItem', 'setItem', 'removeItem', 'clear'];
28
- // for (let key in this) {
29
- // if (keys.indexOf(key) === -1) {
30
- // delete this[key];
31
- // }
32
- // }
33
- // }
34
- // };
35
- // global.ZE_Init = {};
36
- // global.String.prototype.contains = function (text) {
37
- // return this.indexOf(text) != -1;
38
- // };
39
- // global.TestUtils = TestUtils;
40
- // // let xmlReq = XMLHttpRequest;
41
- // // window.XMLHttpRequest = function () {
42
- // // let xmlReqCopy = new xmlReq();
43
- // // let originalOpen = xmlReqCopy.open;
44
- // // xmlReqCopy.open = function () {
45
- // // if (arguments[1].indexOf('http') != 0) {
46
- // // arguments[1] = mockDomain + arguments[1];
47
- // // }
48
- // // return originalOpen.apply(this, arguments);
49
- // // };
50
- // // return xmlReqCopy;
51
- // // };
52
-
53
- // TestUtils.scryRenderedComponentsWithTestid = function (dom, name) {
54
- // let componentList = TestUtils.findAllInRenderedTree(dom, (i, j) => {
55
- // if (TestUtils.isDOMComponent(i)) {
56
- // let val = i.getAttribute('data-id');
57
- // if (typeof val !== 'undefined' && val == name) {
58
- // return true;
59
- // }
60
- // return false;
61
- // }
62
- // });
63
- // return componentList;
64
- // };
65
-
66
- // TestUtils.findRenderedComponentsWithTestid = function (dom, name) {
67
- // let list = TestUtils.scryRenderedComponentsWithTestid(dom, name);
68
- // if (list.length !== 1) {
69
- // throw new Error(
70
- // `Did not find exactly one match (found: ${list.length}) ` +
71
- // `for data-id:${name}`
72
- // );
73
- // }
74
- // return list[0];
75
- // };
76
-
77
- // global.render = function (Component, props) {
78
- // const renderedDOM = TestUtils.renderIntoDocument(<Component {...props} />);
79
- // return {
80
- // props,
81
- // renderedDOM
82
- // };
83
- // };
84
-
85
- // global.setup = function (Component, props, state) {
86
- // let router = {
87
- // router: {
88
- // push() { },
89
- // createHref(ob) {
90
- // return ob.pathname;
91
- // },
92
- // isActive() {
93
- // return true;
94
- // },
95
- // replace() { },
96
- // go() { },
97
- // goBack() { },
98
- // goForward() { },
99
- // setRouteLeaveHook() { },
100
- // getState() { }
101
- // },
102
- // store: {
103
- // getState() {
104
- // return state;
105
- // }
106
- // }
107
- // };
108
- // // var store = {
109
- // // store:{
110
- // // getState:function(){return state;}
111
- // // }
112
- // // }
113
- // var Component = higherComponent(Component, router);
114
- // const renderedDOM = TestUtils.renderIntoDocument(
115
- // <Component {...props} />,
116
- // router
117
- // );
118
- // return {
119
- // props,
120
- // renderedDOM
121
- // };
122
- // };
123
-
124
- // function higherComponent(ActualComponent, context) {
125
- // if (context) {
126
- // class HigherComponent extends React.Component {
127
- // constructor() {
128
- // super();
129
- // }
130
-
131
- // getChildContext() {
132
- // return context;
133
- // }
134
-
135
- // render() {
136
- // return <ActualComponent {...this.props} />;
137
- // }
138
- // }
139
-
140
- // HigherComponent.childContextTypes = {
141
- // router: PropTypes.any,
142
- // store: PropTypes.any
143
- // };
144
-
145
- // return HigherComponent;
146
- // }
147
- // return ActualComponent;
148
- // }
149
- // global.window.matchMedia =
150
- // window.matchMedia ||
151
- // function () {
152
- // return {
153
- // matches: false,
154
- // addListener() { },
155
- // removeListener() { }
156
- // };
157
- // };
158
- // // global.renderHTML = function(comp) {
159
- // // return ReactDOM.findDOMNode(comp);
160
- // // };
161
-
162
- // global.TestUtils = TestUtils;
163
- // global.getI18NValue = function (inp) {
164
- // return inp;
165
- // };
@@ -1,61 +0,0 @@
1
- const { spawn } = require('child_process')
2
- const path = require('path');
3
- const getFilePathWithExtension = require('../../utils/getFilePath');
4
- const { chromium } = require('@playwright/test');
5
- const { Logger } = require('../../utils/logger');
6
- const { getBinPath } = require('../../utils/rootPath');
7
-
8
- const userArgs = process.argv.slice(3);
9
-
10
- const playwrightPath = path.resolve(getBinPath(), getFilePathWithExtension('playwright'));
11
- const command = playwrightPath;
12
-
13
- const args = ['codegen'].concat(userArgs);
14
-
15
- function generateCodegen() {
16
- const childProcess = spawn(command, args, { stdio: 'inherit' });
17
-
18
- childProcess.on('error', (error) => {
19
- Logger.log(Logger.FAILURE_TYPE, error);
20
- })
21
-
22
- childProcess.on('exit', (code, signal) => {
23
- Logger.log(Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
24
-
25
- process.exit();
26
- });
27
-
28
- process.on('exit', () => {
29
- Logger.log(Logger.INFO_TYPE, 'Terminating Playwright Process...');
30
- //childProcess.kill();
31
- return;
32
- });
33
-
34
- process.on('SIGINT', () => {
35
- Logger.log(Logger.INFO_TYPE, 'Cleaning up...');
36
- //childProcess.kill();
37
- process.exit();
38
-
39
- });
40
- }
41
-
42
-
43
- // Another way to record. Below way will load the url in autheticated state if present
44
- // function generateCodegen() {
45
- // (async () => {
46
- // // Make sure to run headed.
47
- // const browser = await chromium.launch({ headless: false });
48
-
49
- // // Setup context however you like.
50
- // const context = await browser.newContext({ storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json') });
51
- // await context.route('**/*', route => route.continue());
52
-
53
- // // Pause the page, and start recording manually.
54
- // const page = await context.newPage();
55
- // console.log(userArgs.join(''));
56
- // await page.goto(`https://${userArgs.join('')}`);
57
- // await page.pause();
58
- // })();
59
- // }
60
-
61
- module.exports = generateCodegen;
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- CUSTOM_COMMANDS: ['mode']
3
- }
@@ -1,24 +0,0 @@
1
- const { readFileSync } = require('fs');
2
- const path = require('path');
3
-
4
-
5
-
6
- function initializeEnvConfig(mode = 'dev') {
7
- try {
8
- const configFile = readFileSync(path.resolve(process.cwd(), './uat/config.json'));
9
-
10
- const configJSON = JSON.parse(configFile);
11
- process.env.mode = mode;
12
- for (const key in configJSON[mode]) {
13
- process.env[key] = configJSON[mode][key];
14
- }
15
- } catch (err) {
16
- throw new Error('Config File Not Exists. Please provide a config file to intiailize the environment variables')
17
- }
18
-
19
- }
20
-
21
-
22
- module.exports = {
23
- initializeEnvConfig
24
- };
@@ -1,81 +0,0 @@
1
- const { expect, test: base } = require('@playwright/test');
2
- // function test(descrition, callback) {
3
- // return test(descrition, ({ page }) => {
4
- // const { locator, ...custompage } = page
5
- // callback({ page: custompage })
6
- // })
7
- // }
8
-
9
- // class FilteredPage {
10
- // constructor(page) {
11
- // this.page = page;
12
- // this.allowedMethods = ['getByText', 'getByTitle'];
13
- // this.context = page.context;
14
- // }
15
-
16
- // goto(...args) {
17
- // return this.page['goto'](...args);
18
- // }
19
-
20
-
21
- // getByRole(...args) {
22
- // return this.page['getByRole'](...args);
23
- // }
24
- // }
25
-
26
-
27
- // function FilteredPage(page) {
28
- // return {
29
- // getByRole: () => {
30
- // throw new Error('You cannnot use getByRole property')
31
- // }
32
- // }
33
- // }
34
-
35
- const test = base.extend({
36
- page: async ({ baseURL, page }, use) => {
37
- // const proxyPage = new Proxy(page, {
38
- // get: function (obj, prop) {
39
- // console.log('Gettig Priop', prop);
40
- // let filterMethod = FilteredPage(page)[prop];
41
- // if (filterMethod) {
42
- // return filterMethod;
43
- // } else {
44
- // return obj[prop] ? obj[prop] : 'property does not exist';
45
- // }
46
- // }
47
- // })
48
- page.getBaseUrl = function () {
49
- if (process.env.mode === 'dev') {
50
- return `${process.env.domain}?devURL=${process.env.devUrl}`;
51
- }
52
- return `${process.env.domain}`;
53
- }
54
-
55
- page.getCustomPageUrl = function (url) {
56
- if (process.env.mode === 'dev') {
57
- return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`
58
- }
59
- return `${process.env.domain}/${url}`
60
- }
61
- await use(page);
62
-
63
-
64
- //await use(new FilteredPage(page));
65
-
66
- // await use(async (page) => {
67
- // delete page.getByTestId;
68
- // await page;
69
- // });
70
-
71
- },
72
- context: async ({ context }, use) => {
73
- await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
74
- await use(context);
75
- }
76
- })
77
-
78
- module.exports = {
79
- expect,
80
- test
81
- }
@@ -1,18 +0,0 @@
1
- const { existsSync } = require('fs');
2
- const path = require('path');
3
-
4
- const fileName = 'test.config.js';
5
-
6
- function generateConfigFromFile() {
7
- const filePath = path.resolve(process.cwd(), fileName);
8
-
9
- if (existsSync(filePath)) {
10
- const config = require(filePath);
11
- return config;
12
- }
13
-
14
- return {};
15
- }
16
-
17
-
18
- module.exports = generateConfigFromFile;
@@ -1,44 +0,0 @@
1
- const { spawn } = require('child_process');
2
- const path = require('path');
3
- const { Logger } = require('../../utils/logger');
4
- const getFilePathWithExtension = require('../../utils/getFilePath');
5
- const { getBinPath } = require('../../utils/rootPath');
6
-
7
-
8
- const userArgs = process.argv.slice(3);
9
-
10
- const playwrightPath = path.resolve(getBinPath(), getFilePathWithExtension('playwright'));;
11
- const command = playwrightPath;
12
- const reportPath = path.resolve(process.cwd(), './playwright-report');
13
-
14
-
15
- const args = ['show-report', reportPath].concat(userArgs);
16
-
17
- function generateReport() {
18
- const childProcess = spawn(command, args, { stdio: 'inherit' });
19
- childProcess.on('error', (error) => {
20
- Logger.log(Logger.FAILURE_TYPE, error);
21
- })
22
-
23
- childProcess.on('exit', (code, signal) => {
24
- Logger.log(Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
25
-
26
- process.exit();
27
- });
28
-
29
- process.on('exit', () => {
30
- Logger.log(Logger.INFO_TYPE, 'Terminating Playwright Process...');
31
- childProcess.kill();
32
- return;
33
- });
34
-
35
- process.on('SIGINT', () => {
36
- Logger.log(Logger.INFO_TYPE, 'Cleaning up...');
37
- childProcess.kill();
38
- process.exit();
39
-
40
- });
41
- }
42
-
43
-
44
- module.exports = generateReport;