@zohodesk/testinglibrary 0.1.8-exp-bdd-v10 → 0.1.8-exp.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +21 -18
- package/.eslintrc.js +31 -31
- package/.prettierrc +5 -5
- package/README.md +17 -17
- package/bin/cli.js +2 -2
- package/build/bdd-framework/cli/commands/env.js +3 -3
- package/build/bdd-framework/cli/options.js +4 -4
- package/build/bdd-framework/cli/worker.js +3 -3
- package/build/bdd-framework/config/dir.js +6 -6
- package/build/bdd-framework/config/env.js +3 -3
- package/build/bdd-framework/config/index.js +2 -2
- package/build/bdd-framework/config/lang.js +2 -2
- package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +3 -3
- package/build/bdd-framework/cucumber/loadSources.js +9 -9
- package/build/bdd-framework/gen/fixtures.js +8 -8
- package/build/bdd-framework/gen/formatter.js +7 -7
- package/build/bdd-framework/gen/i18n.js +3 -3
- package/build/bdd-framework/gen/index.js +2 -2
- package/build/bdd-framework/gen/testFile.js +16 -16
- package/build/bdd-framework/gen/testNode.js +3 -3
- package/build/bdd-framework/gen/testPoms.js +31 -31
- package/build/bdd-framework/hooks/scenario.js +6 -6
- package/build/bdd-framework/hooks/worker.js +4 -4
- package/build/bdd-framework/playwright/fixtureParameterNames.js +3 -3
- package/build/bdd-framework/playwright/getLocationInFile.js +4 -4
- package/build/bdd-framework/playwright/loadConfig.js +3 -3
- package/build/bdd-framework/playwright/testTypeImpl.js +11 -11
- package/build/bdd-framework/playwright/transform.js +4 -4
- package/build/bdd-framework/playwright/utils.js +2 -2
- package/build/bdd-framework/run/StepInvoker.js +2 -2
- package/build/bdd-framework/run/bddWorld.js +15 -15
- package/build/bdd-framework/snippets/index.js +2 -2
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
- package/build/bdd-framework/stepDefinitions/createBdd.js +2 -2
- package/build/bdd-framework/stepDefinitions/decorators/class.js +7 -7
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +6 -6
- package/build/bdd-framework/stepDefinitions/defineStep.js +3 -3
- package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
- package/build/bdd-framework/utils/exit.js +22 -18
- package/build/bdd-framework/utils/index.js +9 -9
- package/build/bdd-framework/utils/jsStringWrap.js +9 -9
- package/build/bdd-framework/utils/logger.js +2 -2
- package/build/core/playwright/builtInFixtures/addTags.js +1 -1
- package/build/core/playwright/builtInFixtures/context.js +12 -1
- package/build/core/playwright/builtInFixtures/i18N.js +33 -0
- package/build/core/playwright/builtInFixtures/index.js +8 -5
- package/build/core/playwright/builtInFixtures/page.js +53 -39
- package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
- package/build/core/playwright/clear-caches.js +19 -8
- package/build/core/playwright/codegen.js +4 -4
- package/build/core/playwright/constants/browserTypes.js +12 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +10 -6
- package/build/core/playwright/helpers/auth/accountLogin.js +18 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +47 -0
- package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
- package/build/core/playwright/helpers/auth/getUsers.js +72 -0
- package/build/core/playwright/helpers/auth/index.js +58 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +36 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +13 -0
- package/build/core/playwright/helpers/getUserFixtures.js +18 -0
- package/build/core/playwright/helpers/mergeObjects.js +13 -0
- package/build/core/playwright/index.js +68 -7
- package/build/core/playwright/readConfigFile.js +49 -39
- package/build/core/playwright/report-generator.js +7 -7
- package/build/core/playwright/setup/config-creator.js +13 -14
- package/build/core/playwright/setup/config-utils.js +37 -26
- package/build/core/playwright/tag-processor.js +2 -4
- package/build/core/playwright/test-runner.js +37 -42
- package/build/core/playwright/types.js +43 -0
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +16 -2
- package/build/index.d.ts +77 -60
- package/build/index.js +51 -9
- package/build/lib/cli.js +0 -3
- package/build/lib/post-install.js +15 -10
- package/build/parser/sample.feature +34 -34
- package/build/parser/sample.spec.js +18 -18
- package/build/setup-folder-structure/helper.js +2 -0
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +24 -24
- package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -72
- package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
- package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
- package/build/setup-folder-structure/samples/git-ignore.sample.js +36 -36
- package/build/setup-folder-structure/samples/uat-config-sample.js +44 -44
- package/build/utils/cliArgsToObject.js +30 -26
- package/build/utils/fileUtils.js +4 -19
- package/build/utils/getFilePath.js +1 -2
- package/build/utils/rootPath.js +16 -9
- package/changelog.md +139 -131
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +6469 -5980
- package/package.json +55 -54
- package/playwright.config.js +112 -112
- package/build/bdd-poc/core-runner/exportMethods.js +0 -20
- package/build/bdd-poc/core-runner/main.js +0 -10
- package/build/bdd-poc/core-runner/runner.js +0 -21
- package/build/bdd-poc/core-runner/stepDefinitions.js +0 -52
- package/build/bdd-poc/index.js +0 -26
- package/build/bdd-poc/test/cucumber/featureFileParer.js +0 -84
- package/build/bdd-poc/test/cucumber/parserCucumber.js +0 -15
- package/build/bdd-poc/test/stepGenerate/extractTestInputs.js +0 -37
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +0 -39
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +0 -58
- package/build/bdd-poc/test/tagsHandle.js +0 -69
- package/build/bdd-poc/test/testDataMap.js +0 -98
- package/build/bdd-poc/test/testStructure.js +0 -98
- package/build/bdd-poc/utils/stringManipulation.js +0 -26
package/package.json
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.1.8-exp
|
|
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": "
|
|
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/
|
|
25
|
-
"@playwright/test": "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
|
-
"fast-glob": "3.3.1",
|
|
32
|
-
"jest": "29.6.2",
|
|
33
|
-
"jest-environment-jsdom": "29.6.2",
|
|
34
|
-
"msw": "1.2.3"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"react
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"@babel/
|
|
47
|
-
"@babel/
|
|
48
|
-
"@babel/
|
|
49
|
-
"@babel/
|
|
50
|
-
"@babel/
|
|
51
|
-
"@babel/
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@zohodesk/testinglibrary",
|
|
3
|
+
"version": "0.1.8-exp.10",
|
|
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.2.0",
|
|
25
|
+
"@playwright/test": "1.41.2",
|
|
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
|
+
"fast-glob": "3.3.1",
|
|
32
|
+
"jest": "29.6.2",
|
|
33
|
+
"jest-environment-jsdom": "29.6.2",
|
|
34
|
+
"msw": "1.2.3",
|
|
35
|
+
"playwright": "1.41.2"
|
|
36
|
+
},
|
|
37
|
+
"bin": {
|
|
38
|
+
"ZDTestingFramework": "./bin/cli.js"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": "*",
|
|
42
|
+
"react-dom": "*",
|
|
43
|
+
"eslint": "*"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@babel/cli": "7.22.15",
|
|
47
|
+
"@babel/core": "7.22.17",
|
|
48
|
+
"@babel/node": "7.22.15",
|
|
49
|
+
"@babel/plugin-transform-runtime": "7.22.15",
|
|
50
|
+
"@babel/polyfill": "7.12.1",
|
|
51
|
+
"@babel/preset-env": "7.22.15",
|
|
52
|
+
"@babel/runtime": "7.22.15",
|
|
53
|
+
"commander": "^11.0.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
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
|
-
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
|
+
// @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,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBdd = createBdd;
|
|
7
|
-
function Given(description, callback) {
|
|
8
|
-
globalStepMap.set(description, callback);
|
|
9
|
-
}
|
|
10
|
-
const Then = Given;
|
|
11
|
-
const When = Given;
|
|
12
|
-
const And = Given;
|
|
13
|
-
function createBdd() {
|
|
14
|
-
return {
|
|
15
|
-
Given,
|
|
16
|
-
When,
|
|
17
|
-
Then,
|
|
18
|
-
And
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createCucumberBDD = createCucumberBDD;
|
|
7
|
-
var _stepFileGenerate = require("../test/stepGenerate/stepFileGenerate");
|
|
8
|
-
async function createCucumberBDD() {
|
|
9
|
-
await (0, _stepFileGenerate.generateSpecFiles)();
|
|
10
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.stepFileMap = stepFileMap;
|
|
8
|
-
var _fastGlob = require("fast-glob");
|
|
9
|
-
var _stringManipulation = require("../utils/stringManipulation");
|
|
10
|
-
var _getFilePath = require("../../utils/getFilePath");
|
|
11
|
-
var _path = _interopRequireDefault(require("path"));
|
|
12
|
-
async function stepFileMap() {
|
|
13
|
-
const actualSpecPattern = (0, _stringManipulation.filePathPattern)(_path.default.resolve(process.cwd(), 'uat', 'modules', '**', '**', '**', '**', '**', '**', '**', '**', '*.spec.js'), _getFilePath.isWindows);
|
|
14
|
-
await (0, _fastGlob.globSync)(actualSpecPattern, {
|
|
15
|
-
dot: true,
|
|
16
|
-
cwd: process.cwd()
|
|
17
|
-
}).forEach(FilePath => {
|
|
18
|
-
const specFilePath = _path.default.resolve(process.cwd(), FilePath);
|
|
19
|
-
require(specFilePath);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createNativeBDD = createNativeBDD;
|
|
7
|
-
function $Given(description) {
|
|
8
|
-
const stepFunction = globalStepMap.get(description);
|
|
9
|
-
if (stepFunction === undefined) {
|
|
10
|
-
process.exit(1);
|
|
11
|
-
}
|
|
12
|
-
return function (pages, ...argument) {
|
|
13
|
-
const finalInput = getInputArray(description, argument);
|
|
14
|
-
return stepFunction(pages, ...finalInput);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function getInputArray(description, argument) {
|
|
18
|
-
const specInput = globalTestdata.get(description);
|
|
19
|
-
if (specInput.input && specInput.steptable) {
|
|
20
|
-
const stepInput = Object.values(specInput.currentArgument).pop() || 'null';
|
|
21
|
-
return [stepInput, specInput.dataTableStep];
|
|
22
|
-
}
|
|
23
|
-
if (specInput.input) {
|
|
24
|
-
return Object.values(specInput.currentArgument) || [];
|
|
25
|
-
}
|
|
26
|
-
if (specInput.steptable) {
|
|
27
|
-
return [specInput.dataTableStep];
|
|
28
|
-
}
|
|
29
|
-
if (specInput.scenarioTable) {
|
|
30
|
-
var exceedParam = specInput.inputParameter[0];
|
|
31
|
-
const extracted = argument.map(element => {
|
|
32
|
-
return exceedParam[element];
|
|
33
|
-
});
|
|
34
|
-
const duplicate = Object.assign({}, specInput);
|
|
35
|
-
const extractInput = duplicate.inputParameter.shift();
|
|
36
|
-
duplicate.inputParameter.push(extractInput);
|
|
37
|
-
globalTestdata.set(description, Object.assign({}, duplicate));
|
|
38
|
-
return extracted;
|
|
39
|
-
}
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
const $When = $Given;
|
|
43
|
-
const $And = $Given;
|
|
44
|
-
const $Then = $Given;
|
|
45
|
-
function createNativeBDD() {
|
|
46
|
-
return {
|
|
47
|
-
$Given,
|
|
48
|
-
$When,
|
|
49
|
-
$And,
|
|
50
|
-
$Then
|
|
51
|
-
};
|
|
52
|
-
}
|
package/build/bdd-poc/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "createBdd", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _exportMethods.createBdd;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "createCucumberBDD", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _main.createCucumberBDD;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "createNativeBDD", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _stepDefinitions.createNativeBDD;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
var _exportMethods = require("./core-runner/exportMethods");
|
|
25
|
-
var _stepDefinitions = require("./core-runner/stepDefinitions");
|
|
26
|
-
var _main = require("./core-runner/main");
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.parseFeature = parseFeature;
|
|
8
|
-
var _parserCucumber = _interopRequireDefault(require("./parserCucumber"));
|
|
9
|
-
function parseFeature(featureFileContent) {
|
|
10
|
-
var _gherkinDocument$feat;
|
|
11
|
-
var gherkinDocument = (0, _parserCucumber.default)(featureFileContent);
|
|
12
|
-
var currentFeature = {
|
|
13
|
-
feature: "",
|
|
14
|
-
featureTags: [],
|
|
15
|
-
scenarios: [],
|
|
16
|
-
featureBackGround: []
|
|
17
|
-
};
|
|
18
|
-
var isBackgroundExist;
|
|
19
|
-
currentFeature.feature = gherkinDocument.feature.name;
|
|
20
|
-
currentFeature.featureTags = (_gherkinDocument$feat = gherkinDocument.feature) === null || _gherkinDocument$feat === void 0 ? void 0 : _gherkinDocument$feat.tags.map(tag => tag.name);
|
|
21
|
-
gherkinDocument.feature.children.forEach($scenario => {
|
|
22
|
-
var _$scenario$scenario, _$scenario$scenario2, _$scenario$scenario3, _$scenario$scenario4;
|
|
23
|
-
var scenarioSteps = {
|
|
24
|
-
scenariodescription: "",
|
|
25
|
-
steps: [],
|
|
26
|
-
tablebody: false,
|
|
27
|
-
tableheader: false,
|
|
28
|
-
examples: [],
|
|
29
|
-
scenarioTags: [],
|
|
30
|
-
background: []
|
|
31
|
-
};
|
|
32
|
-
scenarioSteps.scenariodescription = (_$scenario$scenario = $scenario.scenario) === null || _$scenario$scenario === void 0 ? void 0 : _$scenario$scenario.name;
|
|
33
|
-
if ($scenario !== null && $scenario !== void 0 && $scenario.background) {
|
|
34
|
-
isBackgroundExist = $scenario.background.steps.map(element => {
|
|
35
|
-
return {
|
|
36
|
-
stepDescription: element.text,
|
|
37
|
-
keyword: element.keyword
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
(_$scenario$scenario2 = $scenario.scenario) === null || _$scenario$scenario2 === void 0 || _$scenario$scenario2.examples.map(example => {
|
|
43
|
-
var _example$tableHeader;
|
|
44
|
-
scenarioSteps.tablebody = example === null || example === void 0 ? void 0 : example.tableBody.map(cell => {
|
|
45
|
-
return cell === null || cell === void 0 ? void 0 : cell.cells.map(example => example.value);
|
|
46
|
-
});
|
|
47
|
-
scenarioSteps.tableheader = example === null || example === void 0 || (_example$tableHeader = example.tableHeader) === null || _example$tableHeader === void 0 ? void 0 : _example$tableHeader.cells.map(exampleHead => {
|
|
48
|
-
return exampleHead.value;
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
if (scenarioSteps.tablebody && scenarioSteps.tableheader) {
|
|
52
|
-
scenarioSteps.examples = testDataExtraction(scenarioSteps.tableheader, scenarioSteps.tablebody);
|
|
53
|
-
} else {
|
|
54
|
-
scenarioSteps.examples = false;
|
|
55
|
-
}
|
|
56
|
-
scenarioSteps.scenarioTags = (_$scenario$scenario3 = $scenario.scenario) === null || _$scenario$scenario3 === void 0 ? void 0 : _$scenario$scenario3.tags.map(tag => tag.name);
|
|
57
|
-
const _scenarioDescription = $scenario === null || $scenario === void 0 || (_$scenario$scenario4 = $scenario.scenario) === null || _$scenario$scenario4 === void 0 ? void 0 : _$scenario$scenario4.steps.map(step => {
|
|
58
|
-
return {
|
|
59
|
-
stepDescription: step.text,
|
|
60
|
-
keyword: step.keyword
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
scenarioSteps.steps = _scenarioDescription;
|
|
64
|
-
scenarioSteps.background = isBackgroundExist || [];
|
|
65
|
-
currentFeature.scenarios.push(scenarioSteps);
|
|
66
|
-
});
|
|
67
|
-
currentFeature.featureBackGround = currentFeature.scenarios[0].background;
|
|
68
|
-
return currentFeature;
|
|
69
|
-
}
|
|
70
|
-
function testDataExtraction(tableHeader, tableBody) {
|
|
71
|
-
const result = [];
|
|
72
|
-
if (tableBody && tableHeader) {
|
|
73
|
-
tableBody.forEach(array => {
|
|
74
|
-
const obj = {};
|
|
75
|
-
array.forEach((item, index) => {
|
|
76
|
-
obj[`<${tableHeader[index]}>`] = item;
|
|
77
|
-
});
|
|
78
|
-
result.push(obj);
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = CucumberParser;
|
|
7
|
-
var _gherkin = require("@cucumber/gherkin");
|
|
8
|
-
var _messages = require("@cucumber/messages");
|
|
9
|
-
function CucumberParser(content) {
|
|
10
|
-
var uuidFn = _messages.IdGenerator.uuid();
|
|
11
|
-
var builder = new _gherkin.AstBuilder(uuidFn);
|
|
12
|
-
var matcher = new _gherkin.GherkinClassicTokenMatcher();
|
|
13
|
-
var parser = new _gherkin.Parser(builder, matcher);
|
|
14
|
-
return parser.parse(content);
|
|
15
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.readStepFile = readStepFile;
|
|
8
|
-
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
9
|
-
var _stringManipulation = require("../../utils/stringManipulation");
|
|
10
|
-
var _fileUtils = require("../../../utils/fileUtils");
|
|
11
|
-
var _path = _interopRequireDefault(require("path"));
|
|
12
|
-
var _getFilePath = require("../../../utils/getFilePath");
|
|
13
|
-
globalThis.inputsParamterMap = new Map();
|
|
14
|
-
async function readStepFile() {
|
|
15
|
-
const stepFilePath = (0, _stringManipulation.filePathPattern)(_path.default.resolve(process.cwd(), 'uat', 'modules', '**', '**', '**', '**', '**', '**', '**', '**', '*.spec.js'), _getFilePath.isWindows);
|
|
16
|
-
const processedSpecFile = [];
|
|
17
|
-
return new Promise(resolve => {
|
|
18
|
-
_fastGlob.default.globSync(stepFilePath, {
|
|
19
|
-
dot: true,
|
|
20
|
-
cwd: process.cwd()
|
|
21
|
-
}).forEach(filePath => {
|
|
22
|
-
processedSpecFile.push(extractBrowserObjects(filePath));
|
|
23
|
-
});
|
|
24
|
-
Promise.all(processedSpecFile);
|
|
25
|
-
resolve(inputsParamterMap);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function extractBrowserObjects(filePath) {
|
|
29
|
-
const code = (0, _fileUtils.readFileContents)(_path.default.resolve(process.cwd(), filePath), 'utf-8');
|
|
30
|
-
code.split('\n').forEach(step => {
|
|
31
|
-
const trimmedStep = step.trim();
|
|
32
|
-
if (trimmedStep.startsWith('Given') || trimmedStep.startsWith('When') || trimmedStep.startsWith('Then') || trimmedStep.startsWith('And') || trimmedStep.startsWith('Step')) {
|
|
33
|
-
var sortedSpecInput = trimmedStep.split(' ').slice(1).join('').match(/\((.*?)\)/)[1].match(/\{(.*?)\}/g) || [];
|
|
34
|
-
inputsParamterMap.set(trimmedStep.replace(/"/g, `'`).match(/'(.*?)'/g).pop(), sortedSpecInput.pop());
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.generateSpecFiles = generateSpecFiles;
|
|
8
|
-
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _featureFileParer = require("../cucumber/featureFileParer");
|
|
11
|
-
var _testStructure = require("../testStructure");
|
|
12
|
-
var _fileUtils = require("../../../utils/fileUtils");
|
|
13
|
-
var _stringManipulation = require("../../utils/stringManipulation");
|
|
14
|
-
var _getFilePath = require("../../../utils/getFilePath");
|
|
15
|
-
var _extractTestInputs = require("./extractTestInputs");
|
|
16
|
-
function stepFileCreation(featureContent, stepFilename, featureFilePath) {
|
|
17
|
-
const stepsFilePath = _path.default.resolve(process.cwd(), 'uat', 'feature-gen', stepFilename);
|
|
18
|
-
const stepsSnippets = (0, _testStructure.testSnippet)(featureContent, featureFilePath);
|
|
19
|
-
(0, _fileUtils.writeFileContents)(stepsFilePath, stepsSnippets);
|
|
20
|
-
}
|
|
21
|
-
async function generateSpecFiles() {
|
|
22
|
-
const featureFilePattern = (0, _stringManipulation.filePathPattern)(_path.default.resolve(process.cwd(), 'uat', 'modules', '**', '**', '**', '**', '**', '**', '**', '**', '*.feature'), _getFilePath.isWindows);
|
|
23
|
-
const generatedFolderPath = _path.default.resolve(process.cwd(), 'uat', 'feature-gen');
|
|
24
|
-
if (!(0, _fileUtils.checkIfFileExists)(generatedFolderPath)) {
|
|
25
|
-
(0, _fileUtils.createFolderSync)(generatedFolderPath, {
|
|
26
|
-
recursive: true
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
await (0, _extractTestInputs.readStepFile)();
|
|
30
|
-
_fastGlob.default.globSync(featureFilePattern, {
|
|
31
|
-
dot: true,
|
|
32
|
-
cwd: process.cwd()
|
|
33
|
-
}).forEach(filePath => {
|
|
34
|
-
const featurefilePath = _path.default.resolve(process.cwd(), filePath);
|
|
35
|
-
const featureContent = (0, _featureFileParer.parseFeature)((0, _fileUtils.readFileContents)(featurefilePath, 'utf-8'));
|
|
36
|
-
const fileName = _path.default.basename(filePath).replace('.feature', '.spec.js');
|
|
37
|
-
stepFileCreation(featureContent, fileName, filePath);
|
|
38
|
-
});
|
|
39
|
-
}
|