@zohodesk/testinglibrary 0.0.4 → 0.0.5-exp.2

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 (88) hide show
  1. package/.babelrc +6 -0
  2. package/bin/cli.js +1 -1
  3. package/bin/postinstall.js +1 -16
  4. package/build/bdd-framework/cli/commands/env.js +44 -0
  5. package/build/bdd-framework/cli/commands/export.js +95 -0
  6. package/build/bdd-framework/cli/commands/test.js +98 -0
  7. package/build/bdd-framework/cli/index.js +11 -0
  8. package/build/bdd-framework/cli/options.js +21 -0
  9. package/build/bdd-framework/cli/worker.js +27 -0
  10. package/build/bdd-framework/config/dir.js +27 -0
  11. package/build/bdd-framework/config/env.js +49 -0
  12. package/build/bdd-framework/config/index.js +91 -0
  13. package/build/bdd-framework/cucumber/buildStepDefinition.js +44 -0
  14. package/build/bdd-framework/cucumber/gherkin.d.ts +45 -0
  15. package/build/bdd-framework/cucumber/loadConfig.js +32 -0
  16. package/build/bdd-framework/cucumber/loadFeatures.js +55 -0
  17. package/build/bdd-framework/cucumber/loadSnippetBuilder.js +33 -0
  18. package/build/bdd-framework/cucumber/loadSources.js +89 -0
  19. package/build/bdd-framework/cucumber/loadSteps.js +66 -0
  20. package/build/bdd-framework/decorators.js +21 -0
  21. package/build/bdd-framework/gen/formatter.js +124 -0
  22. package/build/bdd-framework/gen/i18n.js +46 -0
  23. package/build/bdd-framework/gen/index.js +322 -0
  24. package/build/bdd-framework/gen/poms.js +68 -0
  25. package/build/bdd-framework/gen/testFile.js +422 -0
  26. package/build/bdd-framework/gen/testNode.js +64 -0
  27. package/build/bdd-framework/index.js +33 -0
  28. package/build/bdd-framework/playwright/fixtureParameterNames.js +109 -0
  29. package/build/bdd-framework/playwright/getLocationInFile.js +51 -0
  30. package/build/bdd-framework/playwright/loadConfig.js +56 -0
  31. package/build/bdd-framework/playwright/testTypeImpl.js +48 -0
  32. package/build/bdd-framework/playwright/transform.js +86 -0
  33. package/build/bdd-framework/playwright/utils.js +25 -0
  34. package/build/bdd-framework/run/bddFixtures.js +166 -0
  35. package/build/bdd-framework/run/bddWorld.js +166 -0
  36. package/build/bdd-framework/snippets/index.js +184 -0
  37. package/build/bdd-framework/snippets/snippetSyntax.js +61 -0
  38. package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +42 -0
  39. package/build/bdd-framework/snippets/snippetSyntaxTs.js +37 -0
  40. package/build/bdd-framework/stepDefinitions/createBdd.js +54 -0
  41. package/build/bdd-framework/stepDefinitions/createDecorators.js +123 -0
  42. package/build/bdd-framework/stepDefinitions/defineStep.js +64 -0
  43. package/build/bdd-framework/utils/index.js +59 -0
  44. package/build/bdd-framework/utils/jsStringWrap.js +45 -0
  45. package/build/bdd-framework/utils/logger.js +23 -0
  46. package/build/core/jest/preprocessor/jsPreprocessor.js +13 -0
  47. package/{src → build}/core/jest/runner/jest-runner.js +18 -17
  48. package/build/core/jest/setup/index.js +9 -0
  49. package/build/core/playwright/codegen.js +56 -0
  50. package/build/core/playwright/custom-commands.js +8 -0
  51. package/build/core/playwright/env-initializer.js +22 -0
  52. package/build/core/playwright/index.js +117 -0
  53. package/build/core/playwright/readConfigFile.js +61 -0
  54. package/build/core/playwright/report-generator.js +43 -0
  55. package/build/core/playwright/setup/config-creator.js +107 -0
  56. package/build/core/playwright/test-runner.js +102 -0
  57. package/build/index.js +37 -0
  58. package/build/lib/cli.js +47 -0
  59. package/build/lib/post-install.js +17 -0
  60. package/build/lint/index.js +6 -0
  61. package/build/setup-folder-structure/env-config-sample.json +17 -0
  62. package/build/setup-folder-structure/setupProject.js +102 -0
  63. package/build/setup-folder-structure/uat-config-sample.js +27 -0
  64. package/build/setup-folder-structure/user-example.json +3 -0
  65. package/build/utils/cliArgsToObject.js +64 -0
  66. package/build/utils/getFilePath.js +11 -0
  67. package/build/utils/logger.js +66 -0
  68. package/build/utils/rootPath.js +46 -0
  69. package/changelog.md +14 -0
  70. package/npm-shrinkwrap.json +2097 -147
  71. package/package.json +18 -4
  72. package/playwright.config.js +1 -1
  73. package/src/core/jest/preprocessor/jsPreprocessor.js +0 -9
  74. package/src/core/jest/setup/index.js +0 -165
  75. package/src/core/playwright/codegen.js +0 -60
  76. package/src/core/playwright/custom-commands.js +0 -3
  77. package/src/core/playwright/env-initializer.js +0 -24
  78. package/src/core/playwright/index.js +0 -82
  79. package/src/core/playwright/readConfigFile.js +0 -30
  80. package/src/core/playwright/report-generator.js +0 -43
  81. package/src/core/playwright/setup/config-creator.js +0 -77
  82. package/src/core/playwright/test-runner.js +0 -64
  83. package/src/index.js +0 -9
  84. package/src/lib/cli.js +0 -35
  85. package/src/utils/cliArgsToObject.js +0 -35
  86. package/src/utils/getFilePath.js +0 -9
  87. package/src/utils/logger.js +0 -28
  88. package/src/utils/rootPath.js +0 -51
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.0.4",
3
+ "version": "0.0.5-exp.2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
7
7
  "postinstall": "node bin/postinstall.js",
8
- "test": "echo \"Error: no test specified\" && exit 1"
8
+ "test": "echo \"Error: no test specified\" && exit 1",
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"
9
12
  },
10
13
  "keywords": [],
11
14
  "author": "",
12
15
  "license": "ISC",
13
16
  "dependencies": {
14
- "@babel/preset-env": "^7.22.9",
15
17
  "@babel/preset-react": "^7.22.5",
18
+ "@cucumber/cucumber": "^9.5.1",
16
19
  "@playwright/test": "^1.37.1",
17
20
  "@testing-library/jest-dom": "^5.11.9",
18
21
  "@testing-library/react": "^11.2.7",
@@ -23,9 +26,20 @@
23
26
  "jest-environment-jsdom": "^29.6.2",
24
27
  "msw": "^1.2.3",
25
28
  "react": "16.13.1",
26
- "react-dom": "16.13.1"
29
+ "react-dom": "16.13.1",
30
+ "commander": "^11.0.0",
31
+ "fast-glob": "^3.3.1"
27
32
  },
28
33
  "bin": {
29
34
  "ZDTestingFramework": "./bin/cli.js"
35
+ },
36
+ "devDependencies": {
37
+ "@babel/cli": "^7.22.15",
38
+ "@babel/core": "^7.22.17",
39
+ "@babel/node": "^7.22.15",
40
+ "@babel/plugin-transform-runtime": "^7.22.15",
41
+ "@babel/polyfill": "^7.12.1",
42
+ "@babel/preset-env": "^7.22.15",
43
+ "@babel/runtime": "^7.22.15"
30
44
  }
31
45
  }
@@ -12,7 +12,7 @@ const numCPUs = require('os').cpus().length;
12
12
  /**
13
13
  * @see https://playwright.dev/docs/test-configuration
14
14
  */
15
- module.exports = defineConfig({
15
+ export default defineConfig({
16
16
  testDir: path.join(path.resolve(process.cwd()), 'uat'),
17
17
  outputDir: path.join(process.cwd(), 'test-results'),
18
18
  /* Run tests in files in parallel */
@@ -1,9 +0,0 @@
1
- const babelJest = require('babel-jest');
2
-
3
- module.exports = babelJest.createTransformer({
4
- presets: [
5
- require.resolve('@babel/preset-env'),
6
- require.resolve('@babel/preset-react')
7
- ],
8
- plugins: [require.resolve('babel-plugin-transform-dynamic-import')]
9
- });
@@ -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,60 +0,0 @@
1
- const { spawn } = require('child_process')
2
- const path = require('path');
3
- const { chromium } = require('@playwright/test');
4
- const { Logger } = require('../../utils/logger');
5
- const { getExecutableBinaryPath } = require('../../utils/rootPath');
6
-
7
- const userArgs = process.argv.slice(3);
8
-
9
- const playwrightPath = path.resolve(getExecutableBinaryPath('playwright'));
10
- const command = playwrightPath;
11
-
12
- const args = ['codegen'].concat(userArgs);
13
-
14
- function generateCodegen() {
15
- const childProcess = spawn(command, args, { stdio: 'inherit' });
16
-
17
- childProcess.on('error', (error) => {
18
- Logger.log(Logger.FAILURE_TYPE, error);
19
- })
20
-
21
- childProcess.on('exit', (code, signal) => {
22
- Logger.log(Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
23
-
24
- process.exit();
25
- });
26
-
27
- process.on('exit', () => {
28
- Logger.log(Logger.INFO_TYPE, 'Terminating Playwright Process...');
29
- //childProcess.kill();
30
- return;
31
- });
32
-
33
- process.on('SIGINT', () => {
34
- Logger.log(Logger.INFO_TYPE, 'Cleaning up...');
35
- //childProcess.kill();
36
- process.exit();
37
-
38
- });
39
- }
40
-
41
-
42
- // Another way to record. Below way will load the url in autheticated state if present
43
- // function generateCodegen() {
44
- // (async () => {
45
- // // Make sure to run headed.
46
- // const browser = await chromium.launch({ headless: false });
47
-
48
- // // Setup context however you like.
49
- // const context = await browser.newContext({ storageState: path.resolve(process.cwd(), 'playwright/.auth/user.json') });
50
- // await context.route('**/*', route => route.continue());
51
-
52
- // // Pause the page, and start recording manually.
53
- // const page = await context.newPage();
54
- // console.log(userArgs.join(''));
55
- // await page.goto(`https://${userArgs.join('')}`);
56
- // await page.pause();
57
- // })();
58
- // }
59
-
60
- 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,82 +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
-
79
- module.exports = {
80
- expect,
81
- test
82
- }
@@ -1,30 +0,0 @@
1
- const { existsSync } = require('fs');
2
- const path = require('path');
3
-
4
- const fileName = 'uat.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
- function isUserConfigFileAvailable() {
18
- const filePath = path.resolve(process.cwd(), fileName);
19
- if (existsSync(filePath)) {
20
- return true;
21
- }
22
- return false;
23
- }
24
-
25
-
26
- module.exports = {
27
- fileName,
28
- isUserConfigFileAvailable,
29
- generateConfigFromFile
30
- };
@@ -1,43 +0,0 @@
1
- const { spawn } = require('child_process');
2
- const path = require('path');
3
- const { Logger } = require('../../utils/logger');
4
- const { getExecutableBinaryPath } = require('../../utils/rootPath');
5
-
6
-
7
- const userArgs = process.argv.slice(3);
8
-
9
- const playwrightPath = path.resolve(getExecutableBinaryPath('playwright'));;
10
- const command = playwrightPath;
11
- const reportPath = path.resolve(process.cwd(), './playwright-report');
12
-
13
-
14
- const args = ['show-report', reportPath].concat(userArgs);
15
-
16
- function generateReport() {
17
- const childProcess = spawn(command, args, { stdio: 'inherit' });
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
- module.exports = generateReport;
@@ -1,77 +0,0 @@
1
- // @ts-check
2
- const { defineConfig, devices } = require('@playwright/test');
3
- const path = require('path');
4
- const { generateConfigFromFile } = require('../readConfigFile');
5
- const numCPUs = require('os').cpus().length;
6
-
7
- const defaultBrowser = ['Chrome']
8
-
9
- const { browsers = defaultBrowser, isAuthMode, trace = false, video = false } = generateConfigFromFile();
10
-
11
-
12
- let projects = browsers.map(browser => {
13
- if (browser === 'Chrome') {
14
- return {
15
- name: 'chromium',
16
- use: {
17
- ...devices['Desktop Chrome'],
18
- storageState: isAuthMode ? path.resolve(process.cwd(), 'playwright/.auth/user.json') : {}
19
- },
20
- dependencies: isAuthMode ? ['setup'] : [],
21
- };
22
- } else if (browser === 'Firefox') {
23
- return {
24
- name: 'firefox',
25
- timeout: 4 * 60 * 1000,
26
- expect: {
27
- timeout: 80 * 1000,
28
- },
29
- use: {
30
- ...devices['Desktop Firefox'],
31
- storageState: isAuthMode ? path.resolve(process.cwd(), 'playwright/.auth/user.json') : {}
32
- },
33
- dependencies: isAuthMode ? ['setup'] : [],
34
- };
35
- } else if (browser === 'safari') {
36
- return {
37
- name: 'webkit',
38
- timeout: 2 * 60 * 1000,
39
- expect: {
40
- timeout: 80 * 1000,
41
- },
42
- use: {
43
- ...devices['Desktop Safari'],
44
- storageState: isAuthMode ? path.resolve(process.cwd(), 'playwright/.auth/user.json') : {}
45
- },
46
- dependencies: isAuthMode ? ['setup'] : null,
47
- }
48
- }
49
- }).filter(Boolean);
50
-
51
- module.exports = defineConfig({
52
- testDir: path.join(path.resolve(process.cwd()), 'uat'),
53
- outputDir: path.join(process.cwd(), 'test-results'),
54
- fullyParallel: true,
55
- forbidOnly: !!process.env.CI,
56
- retries: process.env.CI ? 2 : 0,
57
- workers: process.env.CI ? 1 : 1,
58
- reporter: [['html', { outputFolder: path.join(process.cwd(), 'playwright-report'), open: "always" }]],
59
- timeout: 60 * 1000,
60
- expect: {
61
- timeout: 5 * 1000,
62
- },
63
-
64
- use: {
65
- trace: trace ? 'on' : 'off',
66
- video: video ? {
67
- mode: 'on',
68
- size: { width: 640, height: 480 }
69
- } : 'off'
70
- },
71
-
72
- projects: isAuthMode ? [
73
- { name: 'setup', testMatch: /.*\.setup\.js/ },
74
- ...projects
75
- ] : [...projects]
76
- });
77
-
@@ -1,64 +0,0 @@
1
- const { spawn } = require('child_process');
2
- const path = require('path');
3
- const { CUSTOM_COMMANDS } = require('./custom-commands');
4
- const { cliArgsToObject, objectToCliArgs } = require('../../utils/cliArgsToObject');
5
- const { initializeEnvConfig } = require('./env-initializer');
6
- const { Logger } = require('../../utils/logger');
7
- const { isUserConfigFileAvailable } = require('./readConfigFile');
8
- const { getExecutableBinaryPath } = require('../../utils/rootPath');
9
-
10
-
11
-
12
- // Access the command line arguments
13
- const userArgs = process.argv.slice(2);
14
-
15
- const userArgsObject = cliArgsToObject(userArgs);
16
-
17
-
18
- // Environment variables Initialization
19
- initializeEnvConfig(userArgsObject.mode ? userArgsObject.mode : 'dev');
20
-
21
-
22
- const playwrightArgs = objectToCliArgs(userArgsObject, (key) => !CUSTOM_COMMANDS.includes(key));
23
-
24
- // Command and arguments for npx playwright test
25
- const playwrightPath = path.resolve(getExecutableBinaryPath('playwright'));
26
-
27
- const command = playwrightPath;
28
-
29
- const configPath = isUserConfigFileAvailable() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
30
-
31
- const args = ['test', '--config', configPath].concat(playwrightArgs);
32
-
33
-
34
- function createTestRunner() {
35
- // Spawn the child process
36
-
37
- const childProcess = spawn(command, args, { stdio: 'inherit' });
38
-
39
- childProcess.on('error', (error) => {
40
- Logger.log(Logger.FAILURE_TYPE, error);
41
- })
42
-
43
- childProcess.on('exit', (code, signal) => {
44
- Logger.log(Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
45
-
46
- process.exit();
47
- });
48
-
49
- process.on('exit', () => {
50
- Logger.log(Logger.INFO_TYPE, 'Terminating Playwright Process...');
51
- //childProcess.kill();
52
- return;
53
- });
54
-
55
- process.on('SIGINT', () => {
56
- Logger.log(Logger.INFO_TYPE, 'Cleaning up...');
57
- //childProcess.kill();
58
- process.exit();
59
-
60
- });
61
- }
62
-
63
-
64
- module.exports = createTestRunner;
package/src/index.js DELETED
@@ -1,9 +0,0 @@
1
- const { expect, test } = require('./core/playwright/index');
2
- const { fireEvent, render } = require('@testing-library/react');
3
-
4
- module.exports = {
5
- expect,
6
- test,
7
- fireEvent,
8
- render
9
- }
package/src/lib/cli.js DELETED
@@ -1,35 +0,0 @@
1
- const createTestRunner = require("../core/playwright/test-runner");
2
- const createJestRunner = require('../core/jest/runner/jest-runner');
3
- const generateReport = require("../core/playwright/report-generator");
4
- const generateCodegen = require('../core/playwright/codegen')
5
- const { Logger } = require("../utils/logger");
6
-
7
- const [, , option] = process.argv;
8
- const args = process.argv.slice(3);
9
- const appPath = process.cwd();
10
-
11
-
12
- switch (option) {
13
- case 'test': {
14
- Logger.log(Logger.SUCCESS_TYPE, 'Running Tests..');
15
- createTestRunner();
16
- //createJestRunner();
17
- break;
18
- }
19
- case 'report': {
20
- // console.log('\x1b[36mGenerating Reports...\x1b[0m');
21
- Logger.log(Logger.SUCCESS_TYPE, 'Generating Reports...');
22
- generateReport();
23
- break;
24
- }
25
- case 'codegen': {
26
- Logger.log(Logger.INFO_TYPE, 'The purpose of codegen is to assist developer .....')
27
- generateCodegen();
28
- break;
29
- }
30
-
31
- default: {
32
- console.log('Supported Commands test and report')
33
- break;
34
- }
35
- }