@zohodesk/testinglibrary 0.1.8-exp-bdd-v1 → 0.1.8-exp.1

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 (97) hide show
  1. package/.babelrc +18 -18
  2. package/.eslintrc.js +31 -27
  3. package/.prettierrc +5 -5
  4. package/README.md +17 -17
  5. package/bin/cli.js +2 -2
  6. package/build/bdd-framework/cli/commands/env.js +4 -4
  7. package/build/bdd-framework/cli/commands/test.js +6 -2
  8. package/build/bdd-framework/cli/options.js +4 -4
  9. package/build/bdd-framework/cli/worker.js +3 -3
  10. package/build/bdd-framework/config/dir.js +6 -6
  11. package/build/bdd-framework/config/env.js +5 -4
  12. package/build/bdd-framework/config/index.js +2 -2
  13. package/build/bdd-framework/config/lang.js +14 -0
  14. package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
  15. package/build/bdd-framework/cucumber/loadSnippetBuilder.js +3 -3
  16. package/build/bdd-framework/cucumber/loadSources.js +9 -9
  17. package/build/bdd-framework/cucumber/loadSteps.js +8 -3
  18. package/build/bdd-framework/decorators.js +2 -2
  19. package/build/bdd-framework/gen/fixtures.js +48 -0
  20. package/build/bdd-framework/gen/formatter.js +64 -17
  21. package/build/bdd-framework/gen/i18n.js +9 -5
  22. package/build/bdd-framework/gen/index.js +9 -8
  23. package/build/bdd-framework/gen/testFile.js +121 -55
  24. package/build/bdd-framework/gen/testNode.js +19 -6
  25. package/build/bdd-framework/gen/testPoms.js +49 -39
  26. package/build/bdd-framework/hooks/scenario.js +107 -0
  27. package/build/bdd-framework/hooks/worker.js +83 -0
  28. package/build/bdd-framework/playwright/fixtureParameterNames.js +27 -11
  29. package/build/bdd-framework/playwright/getLocationInFile.js +17 -11
  30. package/build/bdd-framework/playwright/loadConfig.js +3 -3
  31. package/build/bdd-framework/playwright/testTypeImpl.js +19 -15
  32. package/build/bdd-framework/playwright/transform.js +10 -6
  33. package/build/bdd-framework/playwright/utils.js +3 -6
  34. package/build/bdd-framework/run/StepInvoker.js +73 -0
  35. package/build/bdd-framework/run/bddFixtures.js +118 -55
  36. package/build/bdd-framework/run/bddWorld.js +24 -36
  37. package/build/bdd-framework/snippets/index.js +5 -3
  38. package/build/bdd-framework/snippets/snippetSyntax.js +3 -1
  39. package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
  40. package/build/bdd-framework/stepDefinitions/createBdd.js +30 -13
  41. package/build/bdd-framework/stepDefinitions/decorators/{poms.js → class.js} +13 -9
  42. package/build/bdd-framework/stepDefinitions/decorators/steps.js +14 -8
  43. package/build/bdd-framework/stepDefinitions/defineStep.js +5 -4
  44. package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
  45. package/build/bdd-framework/utils/exit.js +26 -18
  46. package/build/bdd-framework/utils/index.js +30 -4
  47. package/build/bdd-framework/utils/jsStringWrap.js +9 -9
  48. package/build/bdd-framework/utils/logger.js +5 -3
  49. package/build/core/playwright/builtInFixtures/addTags.js +19 -0
  50. package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
  51. package/build/core/playwright/builtInFixtures/context.js +15 -0
  52. package/build/core/playwright/builtInFixtures/index.js +26 -0
  53. package/build/core/playwright/builtInFixtures/page.js +51 -0
  54. package/build/core/playwright/clear-caches.js +29 -0
  55. package/build/core/playwright/custom-commands.js +1 -1
  56. package/build/core/playwright/index.js +6 -74
  57. package/build/core/playwright/readConfigFile.js +37 -30
  58. package/build/core/playwright/report-generator.js +2 -1
  59. package/build/core/playwright/setup/config-creator.js +43 -20
  60. package/build/core/playwright/setup/config-utils.js +30 -0
  61. package/build/core/playwright/setup/custom-reporter.js +109 -0
  62. package/build/core/playwright/tag-processor.js +68 -0
  63. package/build/core/playwright/test-runner.js +8 -12
  64. package/build/index.d.ts +60 -5
  65. package/build/index.js +18 -12
  66. package/build/lib/cli.js +10 -1
  67. package/build/parser/sample.feature +34 -34
  68. package/build/parser/sample.spec.js +18 -18
  69. package/build/setup-folder-structure/helper.js +35 -0
  70. package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
  71. package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
  72. package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -72
  73. package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
  74. package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
  75. package/build/setup-folder-structure/samples/git-ignore.sample.js +36 -32
  76. package/build/setup-folder-structure/samples/uat-config-sample.js +44 -43
  77. package/build/setup-folder-structure/setupProject.js +10 -5
  78. package/build/utils/cliArgsToObject.js +29 -25
  79. package/build/utils/fileUtils.js +15 -4
  80. package/changelog.md +137 -74
  81. package/jest.config.js +63 -63
  82. package/npm-shrinkwrap.json +6469 -7781
  83. package/package.json +55 -54
  84. package/playwright.config.js +112 -112
  85. package/build/bdd-framework/cucumber/gherkin.d.ts +0 -45
  86. package/build/bdd-framework/gen/poms.js +0 -46
  87. package/build/bdd-framework/stepDefinitions/createDecorators.js +0 -108
  88. package/build/bdd-poc/core-runner/exportMethods.js +0 -20
  89. package/build/bdd-poc/core-runner/stepDefinitions.js +0 -53
  90. package/build/bdd-poc/main.js +0 -10
  91. package/build/bdd-poc/runner.js +0 -19
  92. package/build/bdd-poc/test/cucumber/featureFileParer.js +0 -81
  93. package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +0 -36
  94. package/build/bdd-poc/test/stepGenerate/stepsnippets.js +0 -43
  95. package/build/bdd-poc/test/testDataMap.js +0 -98
  96. package/build/bdd-poc/test/testStructure.js +0 -83
  97. package/build/bdd-poc/utils/stringManipulation.js +0 -19
package/package.json CHANGED
@@ -1,54 +1,55 @@
1
- {
2
- "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-exp-bdd-v1",
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": "rmdir /s /q 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.39.0",
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
- },
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
- }
54
- }
1
+ {
2
+ "name": "@zohodesk/testinglibrary",
3
+ "version": "0.1.8-exp.1",
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.40.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
+ "playwright": "1.40.1"
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
+ }
@@ -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,45 +0,0 @@
1
- /**
2
- * Copied from @cucumber/cucumber/lib/api/gherkin.d.ts
3
- * Fixes error:
4
- * Return type of exported function has or is using name 'PickleWithDocument'
5
- * from external module "../node_modules/@cucumber/cucumber/lib/api/gherkin"
6
- * but cannot be named
7
- */
8
- import {
9
- Envelope,
10
- GherkinDocument,
11
- IdGenerator,
12
- Location,
13
- ParseError,
14
- Pickle,
15
- } from '@cucumber/messages';
16
- import { ISourcesCoordinates } from '@cucumber/cucumber/lib/api/types';
17
- import { ILogger } from '@cucumber/cucumber/lib/logger';
18
-
19
- declare module '@cucumber/cucumber/lib/api/gherkin' {
20
- export interface PickleWithDocument {
21
- gherkinDocument: GherkinDocument;
22
- location: Location;
23
- pickle: Pickle;
24
- }
25
- export function getFilteredPicklesAndErrors({
26
- newId,
27
- cwd,
28
- logger,
29
- unexpandedFeaturePaths,
30
- featurePaths,
31
- coordinates,
32
- onEnvelope,
33
- }: {
34
- newId: IdGenerator.NewId;
35
- cwd: string;
36
- logger: ILogger;
37
- unexpandedFeaturePaths: string[];
38
- featurePaths: string[];
39
- coordinates: ISourcesCoordinates;
40
- onEnvelope?: (envelope: Envelope) => void;
41
- }): Promise<{
42
- filteredPickles: PickleWithDocument[];
43
- parseErrors: ParseError[];
44
- }>;
45
- }
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.POMS = void 0;
7
- exports.buildFixtureTag = buildFixtureTag;
8
- var _createDecorators = require("../stepDefinitions/createDecorators");
9
- /**
10
- * Handle POMs graph for decorator steps.
11
- */
12
-
13
- const FIXTURE_TAG_PREFIX = '@fixture:';
14
- class POMS {
15
- usedPoms = new Map();
16
- add(pomNode) {
17
- if (pomNode) this.usedPoms.set(pomNode, null);
18
- }
19
- addByFixtureName(fixtureName) {
20
- const pomNode = (0, _createDecorators.getPomNodeByFixtureName)(fixtureName);
21
- if (pomNode) this.add(pomNode);
22
- }
23
- addByTag(tag) {
24
- const fixtureName = extractFixtureName(tag);
25
- if (fixtureName) this.addByFixtureName(fixtureName);
26
- }
27
- resolveFixtureNames(pomNode) {
28
- const resolvedFixtureNames = this.usedPoms.get(pomNode);
29
- if (resolvedFixtureNames) return resolvedFixtureNames;
30
- const fixtureNames = [...pomNode.children].map(child => this.resolveFixtureNames(child)).flat();
31
- if (this.usedPoms.has(pomNode)) {
32
- // if nothing returned from children, use own fixtureName,
33
- // otherwise use what returned from child
34
- if (!fixtureNames.length) fixtureNames.push(pomNode.fixtureName);
35
- this.usedPoms.set(pomNode, fixtureNames);
36
- }
37
- return fixtureNames;
38
- }
39
- }
40
- exports.POMS = POMS;
41
- function extractFixtureName(tag) {
42
- return tag.startsWith(FIXTURE_TAG_PREFIX) ? tag.replace(FIXTURE_TAG_PREFIX, '') : '';
43
- }
44
- function buildFixtureTag(fixtureName) {
45
- return `${FIXTURE_TAG_PREFIX}${fixtureName}`;
46
- }
@@ -1,108 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Fixture = Fixture;
7
- exports.appendDecoratorSteps = appendDecoratorSteps;
8
- exports.createStepDecorator = createStepDecorator;
9
- exports.getPomNodeByFixtureName = getPomNodeByFixtureName;
10
- var _bddFixtures = require("../run/bddFixtures");
11
- var _defineStep = require("./defineStep");
12
- var _buildStepDefinition = require("../cucumber/buildStepDefinition");
13
- /* eslint-disable no-unused-vars */
14
- /**
15
- * Define steps via decorators.
16
- */
17
-
18
- const pomGraph = new Map();
19
- const decoratedStepSymbol = Symbol('decoratedStep');
20
- const decoratedSteps = new Set();
21
- function Fixture(fixtureName) {
22
- // context parameter is required for decorator by TS even though it's not used
23
- return (Ctor, _context) => {
24
- createPomNode(Ctor, fixtureName);
25
- };
26
- }
27
- function createStepDecorator(keyword) {
28
- return pattern => {
29
- // context parameter is required for decorator by TS even though it's not used
30
- return (method, _context) => {
31
- method[decoratedStepSymbol] = {
32
- keyword,
33
- pattern,
34
- fn: method,
35
- hasCustomTest: true,
36
- isDecorator: true
37
- };
38
- };
39
- };
40
- }
41
- function appendDecoratorSteps(supportCodeLibrary) {
42
- decoratedSteps.forEach(stepConfig => {
43
- const {
44
- keyword,
45
- pattern,
46
- fn
47
- } = stepConfig;
48
- stepConfig.fn = (fixturesArg, ...args) => {
49
- const fixture = getFirstNonAutoInjectFixture(fixturesArg, stepConfig);
50
- return fn.call(fixture, ...args);
51
- };
52
- const code = (0, _defineStep.buildCucumberStepFn)(stepConfig);
53
- const stepDefinition = (0, _buildStepDefinition.buildStepDefinition)({
54
- keyword,
55
- pattern,
56
- code,
57
- line: 0,
58
- // not used in playwright-bdd
59
- options: {},
60
- // not used in playwright-bdd
61
- uri: '' // not used in playwright-bdd
62
- }, supportCodeLibrary);
63
- supportCodeLibrary.stepDefinitions.push(stepDefinition);
64
- });
65
- decoratedSteps.clear();
66
- // todo: fill supportCodeLibrary.originalCoordinates as it is used in snippets?
67
- }
68
- function getPomNodeByFixtureName(fixtureName) {
69
- for (const pomNode of pomGraph.values()) {
70
- if (pomNode.fixtureName === fixtureName) return pomNode;
71
- }
72
- }
73
- function createPomNode(Ctor, fixtureName) {
74
- const pomNode = {
75
- fixtureName,
76
- children: new Set()
77
- };
78
- pomGraph.set(Ctor, pomNode);
79
- getDecoratedSteps(Ctor).forEach(stepConfig => {
80
- stepConfig.pomNode = pomNode;
81
- decoratedSteps.add(stepConfig);
82
- });
83
- const parentCtor = Object.getPrototypeOf(Ctor);
84
- if (!parentCtor) return;
85
- const parentPomNode = pomGraph.get(parentCtor) || createPomNode(parentCtor, '');
86
- parentPomNode === null || parentPomNode === void 0 || parentPomNode.children.add(pomNode);
87
- return pomNode;
88
- }
89
- function getDecoratedSteps(Ctor) {
90
- if (!(Ctor !== null && Ctor !== void 0 && Ctor.prototype)) return [];
91
- const propertyDescriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
92
- return Object.keys(propertyDescriptors)
93
- // filter out getters / setters
94
- .filter(methodName => typeof propertyDescriptors[methodName].value === 'function').map(methodName => {
95
- return propertyDescriptors[methodName].value[decoratedStepSymbol];
96
- }).filter(Boolean);
97
- }
98
- function getFirstNonAutoInjectFixture(fixturesArg, stepConfig) {
99
- // there should be exatcly one suitable fixture in fixturesArg
100
- const fixtureNames = Object.keys(fixturesArg).filter(fixtureName => !(0, _bddFixtures.isBddAutoInjectFixture)(fixtureName));
101
- if (fixtureNames.length === 0) {
102
- throw new Error(`No suitable fixtures found for decorator step "${stepConfig.pattern}"`);
103
- }
104
- if (fixtureNames.length > 1) {
105
- throw new Error(`Several suitable fixtures found for decorator step "${stepConfig.pattern}"`);
106
- }
107
- return fixturesArg[fixtureNames[0]];
108
- }
@@ -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,53 +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[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
- console.log(specInput.inputParameter);
31
- var exceedParam = specInput.inputParameter[0];
32
- const extracted = argument.map(element => {
33
- return exceedParam[element];
34
- });
35
- const duplicate = Object.assign({}, specInput);
36
- const extractInput = duplicate.inputParameter.shift();
37
- duplicate.inputParameter.push(extractInput);
38
- globalTestdata.set(description, Object.assign({}, duplicate));
39
- return extracted;
40
- }
41
- return [];
42
- }
43
- const $When = $Given;
44
- const $And = $Given;
45
- const $Then = $Given;
46
- function createNativeBDD() {
47
- return {
48
- $Given,
49
- $When,
50
- $And,
51
- $Then
52
- };
53
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.cucumberBDDtoTestFile = cucumberBDDtoTestFile;
7
- var _stepFileGenerate = require("./test/stepGenerate/stepFileGenerate");
8
- async function cucumberBDDtoTestFile() {
9
- await (0, _stepFileGenerate.generateSpecFiles)();
10
- }
@@ -1,19 +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 _path = _interopRequireDefault(require("path"));
10
- async function stepFileMap() {
11
- const featureFilePath = _path.default.resolve(process.cwd(), 'uat', 'modules', '**', '**', '**', '**', '**', '**', '**', '**', '*.spec.js').split(`\\`).join('/');
12
- await (0, _fastGlob.globSync)(featureFilePath, {
13
- dot: true,
14
- cwd: process.cwd()
15
- }).forEach(FilePath => {
16
- const specFilePath = _path.default.resolve(process.cwd(), FilePath);
17
- require(specFilePath);
18
- });
19
- }