@zohodesk/testinglibrary 0.0.5 → 0.0.6
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.
- package/.babelrc +19 -0
- package/.eslintrc.js +27 -0
- package/.prettierrc +6 -0
- package/{changelog.md → Changelog.md} +38 -25
- package/README.md +17 -17
- package/bin/cli.js +2 -2
- package/bin/postinstall.js +1 -16
- package/build/bdd-framework/cli/commands/env.js +43 -0
- package/build/bdd-framework/cli/commands/export.js +48 -0
- package/build/bdd-framework/cli/commands/test.js +59 -0
- package/build/bdd-framework/cli/index.js +11 -0
- package/build/bdd-framework/cli/options.js +20 -0
- package/build/bdd-framework/cli/worker.js +13 -0
- package/build/bdd-framework/config/dir.js +27 -0
- package/build/bdd-framework/config/env.js +49 -0
- package/build/bdd-framework/config/index.js +91 -0
- package/build/bdd-framework/cucumber/buildStepDefinition.js +43 -0
- package/build/bdd-framework/cucumber/gherkin.d.js +5 -0
- package/build/bdd-framework/cucumber/gherkin.d.ts +45 -0
- package/build/bdd-framework/cucumber/loadConfig.js +17 -0
- package/build/bdd-framework/cucumber/loadFeatures.js +39 -0
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +20 -0
- package/build/bdd-framework/cucumber/loadSources.js +57 -0
- package/build/bdd-framework/cucumber/loadSteps.js +35 -0
- package/build/bdd-framework/decorators.js +22 -0
- package/build/bdd-framework/gen/formatter.js +88 -0
- package/build/bdd-framework/gen/i18n.js +35 -0
- package/build/bdd-framework/gen/index.js +160 -0
- package/build/bdd-framework/gen/poms.js +46 -0
- package/build/bdd-framework/gen/testFile.js +356 -0
- package/build/bdd-framework/gen/testNode.js +48 -0
- package/build/bdd-framework/gen/testPoms.js +123 -0
- package/build/bdd-framework/index.js +45 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +77 -0
- package/build/bdd-framework/playwright/getLocationInFile.js +46 -0
- package/build/bdd-framework/playwright/loadConfig.js +42 -0
- package/build/bdd-framework/playwright/testTypeImpl.js +41 -0
- package/build/bdd-framework/playwright/transform.js +80 -0
- package/build/bdd-framework/playwright/types.js +5 -0
- package/build/bdd-framework/playwright/utils.js +34 -0
- package/build/bdd-framework/run/bddFixtures.js +108 -0
- package/build/bdd-framework/run/bddWorld.js +87 -0
- package/build/bdd-framework/snippets/index.js +131 -0
- package/build/bdd-framework/snippets/snippetSyntax.js +41 -0
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +26 -0
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +18 -0
- package/build/bdd-framework/stepDefinitions/createBdd.js +49 -0
- package/build/bdd-framework/stepDefinitions/createDecorators.js +109 -0
- package/build/bdd-framework/stepDefinitions/decorators/poms.js +50 -0
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +94 -0
- package/build/bdd-framework/stepDefinitions/defineStep.js +61 -0
- package/build/bdd-framework/stepDefinitions/stepConfig.js +24 -0
- package/build/bdd-framework/utils/index.js +50 -0
- package/build/bdd-framework/utils/jsStringWrap.js +44 -0
- package/build/bdd-framework/utils/logger.js +29 -0
- package/build/core/jest/preprocessor/jsPreprocessor.js +13 -0
- package/{src → build}/core/jest/runner/jest-runner.js +46 -44
- package/build/core/jest/setup/index.js +9 -0
- package/build/core/playwright/codegen.js +55 -0
- package/build/core/playwright/custom-commands.js +8 -0
- package/build/core/playwright/env-initializer.js +21 -0
- package/{src → build}/core/playwright/index.js +112 -82
- package/build/core/playwright/readConfigFile.js +69 -0
- package/build/core/playwright/report-generator.js +41 -0
- package/build/core/playwright/setup/config-creator.js +117 -0
- package/build/core/playwright/test-runner.js +132 -0
- package/build/decorators.d.ts +1 -0
- package/build/decorators.js +16 -0
- package/build/index.d.ts +5 -0
- package/build/index.js +59 -0
- package/build/lib/cli.js +54 -0
- package/build/lib/post-install.js +17 -0
- package/build/lint/index.js +4 -0
- package/build/parser/parser.js +206 -0
- package/build/parser/sample.feature +34 -0
- package/build/parser/sample.spec.js +37 -0
- package/build/parser/verifier.js +130 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -0
- package/build/setup-folder-structure/samples/authUsers-sample.json +9 -0
- package/build/setup-folder-structure/samples/env-config-sample.json +21 -0
- package/build/setup-folder-structure/samples/git-ignore.sample.js +33 -0
- package/build/setup-folder-structure/samples/uat-config-sample.js +35 -0
- package/build/setup-folder-structure/setupProject.js +100 -0
- package/{src → build}/utils/cliArgsToObject.js +65 -63
- package/build/utils/fileUtils.js +53 -0
- package/build/utils/getFilePath.js +11 -0
- package/build/utils/logger.js +58 -0
- package/build/utils/rootPath.js +46 -0
- package/build/utils/stepDefinitionsFormatter.js +12 -0
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +8790 -5772
- package/package.json +51 -30
- package/playwright.config.js +112 -112
- package/src/core/jest/preprocessor/jsPreprocessor.js +0 -9
- package/src/core/jest/setup/index.js +0 -165
- package/src/core/playwright/codegen.js +0 -60
- package/src/core/playwright/custom-commands.js +0 -3
- package/src/core/playwright/env-initializer.js +0 -24
- package/src/core/playwright/readConfigFile.js +0 -63
- package/src/core/playwright/report-generator.js +0 -45
- package/src/core/playwright/setup/config-creator.js +0 -77
- package/src/core/playwright/test-runner.js +0 -67
- package/src/index.js +0 -9
- package/src/lib/cli.js +0 -42
- package/src/setup-folder-structure/env-config-sample.json +0 -17
- package/src/setup-folder-structure/setupProject.js +0 -99
- package/src/setup-folder-structure/uat-config-sample.js +0 -22
- package/src/setup-folder-structure/user-example.json +0 -3
- package/src/utils/getFilePath.js +0 -9
- package/src/utils/logger.js +0 -28
- package/src/utils/rootPath.js +0 -51
package/package.json
CHANGED
|
@@ -1,31 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "./
|
|
6
|
-
"scripts": {
|
|
7
|
-
"postinstall": "node bin/postinstall.js",
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@zohodesk/testinglibrary",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./build/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node bin/postinstall.js",
|
|
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",
|
|
12
|
+
"prepare": "npm run build",
|
|
13
|
+
"lint": "eslint src/* --fix"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./build/index.js",
|
|
17
|
+
"./decorators": "./build/decorators.js"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@babel/preset-react": "^7.22.5",
|
|
24
|
+
"@cucumber/cucumber": "^9.5.1",
|
|
25
|
+
"@playwright/test": "^1.37.1",
|
|
26
|
+
"@testing-library/jest-dom": "^5.11.9",
|
|
27
|
+
"@testing-library/react": "^11.2.7",
|
|
28
|
+
"@testing-library/react-hooks": "^7.0.2",
|
|
29
|
+
"babel-jest": "^29.6.2",
|
|
30
|
+
"babel-plugin-transform-dynamic-import": "^2.1.0",
|
|
31
|
+
"commander": "^11.0.0",
|
|
32
|
+
"fast-glob": "^3.3.1",
|
|
33
|
+
"jest": "^29.6.2",
|
|
34
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
35
|
+
"msw": "^1.2.3",
|
|
36
|
+
"react": "16.13.1",
|
|
37
|
+
"react-dom": "16.13.1"
|
|
38
|
+
},
|
|
39
|
+
"bin": {
|
|
40
|
+
"ZDTestingFramework": "./bin/cli.js"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@babel/cli": "^7.22.15",
|
|
44
|
+
"@babel/core": "^7.22.17",
|
|
45
|
+
"@babel/node": "^7.22.15",
|
|
46
|
+
"@babel/plugin-transform-runtime": "^7.22.15",
|
|
47
|
+
"@babel/polyfill": "^7.12.1",
|
|
48
|
+
"@babel/preset-env": "^7.22.15",
|
|
49
|
+
"@babel/runtime": "^7.22.15",
|
|
50
|
+
"eslint": "^8.50.0"
|
|
51
|
+
}
|
|
31
52
|
}
|
package/playwright.config.js
CHANGED
|
@@ -1,112 +1,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
|
-
/**
|
|
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
|
-
|
|
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
|
+
/**
|
|
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
|
+
export default defineConfig({
|
|
16
|
+
testDir: path.join(path.resolve(process.cwd()), 'uat'),
|
|
17
|
+
outputDir: path.join(process.cwd(), 'uat', '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(), 'uat', '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(), 'uat', '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(), 'uat', '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(), 'uat', '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,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,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/env-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,63 +0,0 @@
|
|
|
1
|
-
const { existsSync } = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { Logger } = require('../../utils/logger');
|
|
4
|
-
|
|
5
|
-
const fileName = 'uat.config.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents the user configuration object.
|
|
9
|
-
* @typedef {Object} UserConfig
|
|
10
|
-
* @property {string} headless - Headless Browsers mode.
|
|
11
|
-
* @property {number} trace - trace for test cases.
|
|
12
|
-
* @property {boolean} video - video for test cases,
|
|
13
|
-
* @property {boolean} debug - debug mode
|
|
14
|
-
* @property {string} mode: mode in which the test cases needs to run
|
|
15
|
-
* @property {boolean} isAuthMode - Auth Mode
|
|
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
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Generates a configuration object from a file, if it exists.
|
|
24
|
-
*
|
|
25
|
-
* @returns {UserConfig}
|
|
26
|
-
*/
|
|
27
|
-
function generateConfigFromFile() {
|
|
28
|
-
const filePath = path.resolve(process.cwd(), fileName);
|
|
29
|
-
|
|
30
|
-
if (existsSync(filePath)) {
|
|
31
|
-
/** @type {UserConfig} */
|
|
32
|
-
const config = require(filePath);
|
|
33
|
-
return config;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function isUserConfigFileAvailable() {
|
|
40
|
-
const filePath = path.resolve(process.cwd(), fileName);
|
|
41
|
-
if (existsSync(filePath)) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function getAuthFilePath(filePath){
|
|
48
|
-
try{
|
|
49
|
-
if(existsSync(filePath)){
|
|
50
|
-
return filePath
|
|
51
|
-
}
|
|
52
|
-
}catch(err){
|
|
53
|
-
Logger.log(Logger.FAILURE_TYPE,`Founded Path - ${filePath} Authetication file not Exist ...`)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
module.exports = {
|
|
59
|
-
fileName,
|
|
60
|
-
isUserConfigFileAvailable,
|
|
61
|
-
generateConfigFromFile,
|
|
62
|
-
getAuthFilePath
|
|
63
|
-
};
|