@zohodesk/testinglibrary 0.1.8-exp-bdd-v2 → 0.1.8-exp-bdd-v4

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 (81) hide show
  1. package/.eslintrc.js +5 -1
  2. package/build/bdd-framework/cli/commands/env.js +2 -3
  3. package/build/bdd-framework/cli/commands/export.js +1 -2
  4. package/build/bdd-framework/cli/commands/test.js +7 -4
  5. package/build/bdd-framework/cli/options.js +1 -2
  6. package/build/bdd-framework/config/env.js +2 -1
  7. package/build/bdd-framework/config/index.js +1 -2
  8. package/build/bdd-framework/config/lang.js +14 -0
  9. package/build/bdd-framework/cucumber/loadSteps.js +8 -3
  10. package/build/bdd-framework/decorators.js +6 -10
  11. package/build/bdd-framework/gen/fixtures.js +48 -0
  12. package/build/bdd-framework/gen/formatter.js +57 -10
  13. package/build/bdd-framework/gen/i18n.js +6 -2
  14. package/build/bdd-framework/gen/index.js +7 -6
  15. package/build/bdd-framework/gen/testFile.js +105 -39
  16. package/build/bdd-framework/gen/testNode.js +16 -3
  17. package/build/bdd-framework/gen/testPoms.js +18 -8
  18. package/build/bdd-framework/hooks/scenario.js +107 -0
  19. package/build/bdd-framework/hooks/worker.js +83 -0
  20. package/build/bdd-framework/playwright/fixtureParameterNames.js +24 -8
  21. package/build/bdd-framework/playwright/getLocationInFile.js +13 -7
  22. package/build/bdd-framework/playwright/testTypeImpl.js +11 -7
  23. package/build/bdd-framework/playwright/transform.js +6 -2
  24. package/build/bdd-framework/playwright/utils.js +1 -4
  25. package/build/bdd-framework/run/StepInvoker.js +73 -0
  26. package/build/bdd-framework/run/bddFixtures.js +119 -57
  27. package/build/bdd-framework/run/bddWorld.js +24 -36
  28. package/build/bdd-framework/snippets/index.js +3 -2
  29. package/build/bdd-framework/snippets/snippetSyntax.js +3 -1
  30. package/build/bdd-framework/stepDefinitions/createBdd.js +28 -11
  31. package/build/bdd-framework/stepDefinitions/decorators/{poms.js → class.js} +7 -3
  32. package/build/bdd-framework/stepDefinitions/decorators/steps.js +8 -3
  33. package/build/bdd-framework/stepDefinitions/defineStep.js +2 -1
  34. package/build/bdd-framework/utils/exit.js +8 -4
  35. package/build/bdd-framework/utils/index.js +27 -1
  36. package/build/bdd-framework/utils/logger.js +4 -3
  37. package/build/bdd-poc/core-runner/main.js +10 -0
  38. package/build/bdd-poc/core-runner/stepDefinitions.js +0 -1
  39. package/build/bdd-poc/index.js +26 -0
  40. package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +6 -6
  41. package/build/bdd-poc/test/stepGenerate/stepsnippets.js +1 -2
  42. package/build/bdd-poc/test/testDataMap.js +5 -5
  43. package/build/core/jest/preprocessor/jsPreprocessor.js +2 -3
  44. package/build/core/playwright/builtInFixtures/addTags.js +19 -0
  45. package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
  46. package/build/core/playwright/builtInFixtures/context.js +15 -0
  47. package/build/core/playwright/builtInFixtures/index.js +26 -0
  48. package/build/core/playwright/builtInFixtures/page.js +51 -0
  49. package/build/core/playwright/clear-caches.js +29 -0
  50. package/build/core/playwright/custom-commands.js +1 -2
  51. package/build/core/playwright/index.js +12 -93
  52. package/build/core/playwright/readConfigFile.js +12 -6
  53. package/build/core/playwright/report-generator.js +2 -1
  54. package/build/core/playwright/setup/config-creator.js +23 -17
  55. package/build/core/playwright/setup/config-utils.js +43 -11
  56. package/build/core/playwright/setup/custom-reporter.js +109 -0
  57. package/build/core/playwright/tag-processor.js +68 -0
  58. package/build/core/playwright/test-runner.js +40 -36
  59. package/build/decorators.d.ts +1 -1
  60. package/build/decorators.js +2 -16
  61. package/build/index.d.ts +59 -4
  62. package/build/index.js +10 -9
  63. package/build/lib/cli.js +10 -1
  64. package/build/parser/parser.js +0 -1
  65. package/build/setup-folder-structure/helper.js +34 -0
  66. package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
  67. package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
  68. package/build/setup-folder-structure/samples/git-ignore.sample.js +8 -4
  69. package/build/setup-folder-structure/samples/uat-config-sample.js +3 -2
  70. package/build/setup-folder-structure/setupProject.js +10 -5
  71. package/build/utils/fileUtils.js +15 -4
  72. package/build/utils/logger.js +1 -2
  73. package/build/utils/stepDefinitionsFormatter.js +1 -2
  74. package/changelog.md +57 -0
  75. package/npm-shrinkwrap.json +1426 -2172
  76. package/package.json +5 -4
  77. package/build/bdd-framework/cucumber/gherkin.d.ts +0 -45
  78. package/build/bdd-framework/gen/poms.js +0 -46
  79. package/build/bdd-framework/stepDefinitions/createDecorators.js +0 -109
  80. package/build/bdd-poc/main.js +0 -10
  81. /package/build/bdd-poc/{runner.js → core-runner/runner.js} +0 -0
@@ -5,11 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.getProjects = getProjects;
8
- exports.getTestDir = getTestDir;
8
+ exports.getTestUseOptions = getTestUseOptions;
9
9
  var _test = require("@playwright/test");
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
  var _readConfigFile = require("../readConfigFile");
12
- var _bddFramework = require("../../../bdd-framework");
12
+ // import { defineBddConfig } from '../../../bdd-framework';
13
+
14
+ /**
15
+ ** Playwright project configuration
16
+ * @returns {import('@playwright/test').Project}
17
+ */
13
18
  function getBrowserConfig({
14
19
  browserName,
15
20
  isAuthMode,
@@ -81,6 +86,12 @@ function getBrowserConfig({
81
86
  return false;
82
87
  }
83
88
  }
89
+
90
+ /**
91
+ *
92
+ * @param {*} param0
93
+ * @returns {import('@playwright/test').Project[]}
94
+ */
84
95
  function getProjects({
85
96
  browsers,
86
97
  isAuthMode,
@@ -98,14 +109,35 @@ function getProjects({
98
109
  viewport
99
110
  })).filter(Boolean);
100
111
  }
101
- function getTestDir(bddMode, cwd, {
102
- stepDefinitionsFolder
112
+
113
+ // function getTestDir(bddMode, cwd, { stepDefinitionsFolder }) {
114
+ // return bddMode
115
+ // ? defineBddConfig({
116
+ // paths: [path.join(cwd, 'uat', '**', '*.feature')],
117
+ // import: [path.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js')],
118
+ // featuresRoot: path.join(cwd, 'uat'),
119
+ // outputDir: path.join(cwd, 'uat', '.features-gen'),
120
+ // publish: true,
121
+ // })
122
+ // : path.join(cwd, 'uat');
123
+ // }
124
+
125
+ function getTestUseOptions({
126
+ viewport,
127
+ trace,
128
+ video,
129
+ testIdAttribute
103
130
  }) {
104
- return bddMode ? (0, _bddFramework.defineBddConfig)({
105
- paths: [_path.default.join(cwd, 'uat', '**', '*.feature')],
106
- import: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js')],
107
- featuresRoot: _path.default.join(cwd, 'uat'),
108
- outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
109
- publish: true
110
- }) : _path.default.join(cwd, 'uat');
131
+ let defaultTestuseOptions = {
132
+ viewport,
133
+ testIdAttribute,
134
+ trace: trace ? 'on' : 'off',
135
+ video: video ? {
136
+ mode: 'on',
137
+ size: {
138
+ ...viewport
139
+ }
140
+ } : 'off'
141
+ };
142
+ return defaultTestuseOptions;
111
143
  }
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _readline = _interopRequireDefault(require("readline"));
10
+ var _fileUtils = require("../../../utils/fileUtils");
11
+ var _readConfigFile = require("../readConfigFile");
12
+ var _logger = require("../../../utils/logger");
13
+ class JSONSummaryReporter {
14
+ constructor() {
15
+ this.durationInMS = -1;
16
+ this.passed = [];
17
+ this.skipped = [];
18
+ this.failed = [];
19
+ this.warned = [];
20
+ this.interrupted = [];
21
+ this.timedOut = [];
22
+ this.flakey = [];
23
+ this.failedSteps = [];
24
+ this.status = 'unknown';
25
+ this.startedAt = 0;
26
+ this._open = (0, _readConfigFile.generateConfigFromFile)().openReportOn;
27
+ }
28
+ onBegin() {
29
+ this.startedAt = Date.now();
30
+ }
31
+ onTestEnd(test, result) {
32
+ const title = [];
33
+ const fileName = [];
34
+ let clean = true;
35
+ for (const s of test.titlePath()) {
36
+ if (s === '' && clean) {
37
+ continue;
38
+ }
39
+ clean = false;
40
+ title.push(s);
41
+ if (s.includes('.ts') || s.includes('.js')) {
42
+ fileName.push(s);
43
+ }
44
+ }
45
+ // This will publish the file name + line number test begins on
46
+ const z = `${fileName[0]}:${test.location.line}:${test.location.column}`;
47
+ // Using the t variable in the push will push a full test name + test description
48
+ const t = title.join(' > ');
49
+ // Set the status
50
+ const stepTitleList = result.steps.map(step => ({
51
+ title: step.title,
52
+ error: step.error,
53
+ testTitle: t
54
+ })).filter(step => step.error !== undefined);
55
+ if (stepTitleList.length > 0) {
56
+ this.failedSteps = [...this.failedSteps, ...stepTitleList];
57
+ }
58
+ const status = !['passed', 'skipped'].includes(result.status) && t.includes('@warn') ? 'warned' : result.status;
59
+ // Logic to push the results into the correct array
60
+ if (result.status === 'passed' && result.retry >= 1) {
61
+ this.flakey.push(z);
62
+ } else {
63
+ this[status].push(z);
64
+ }
65
+ this[status].push(z);
66
+ }
67
+ onEnd(result) {
68
+ this.durationInMS = Date.now() - this.startedAt;
69
+ this.status = result.status;
70
+ // removing duplicate tests from passed array
71
+ this.passed = this.passed.filter((element, index) => {
72
+ return this.passed.indexOf(element) === index;
73
+ });
74
+ // removing duplicate tests from the failed array
75
+ this.failed = this.failed.filter((element, index) => {
76
+ if (!this.passed.includes(element)) {
77
+ return this.failed.indexOf(element) === index;
78
+ }
79
+ });
80
+ // removing duplicate tests from the skipped array
81
+ this.skipped = this.skipped.filter((element, index) => {
82
+ return this.skipped.indexOf(element) === index;
83
+ });
84
+ // removing duplicate tests from the timedOut array
85
+ this.timedOut = this.timedOut.filter((element, index) => {
86
+ return this.timedOut.indexOf(element) === index;
87
+ });
88
+ // removing duplicate tests from the interrupted array
89
+ this.interrupted = this.interrupted.filter((element, index) => {
90
+ return this.interrupted.indexOf(element) === index;
91
+ });
92
+ // fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));
93
+ let {
94
+ reportPath
95
+ } = (0, _readConfigFile.generateConfigFromFile)();
96
+ (0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', 'test-summary.json'), JSON.stringify(this, null, ' '));
97
+ }
98
+ onExit() {
99
+ const shouldClearLastLine = this._open !== 'always' || this._open !== 'on-failure';
100
+ if (shouldClearLastLine) {
101
+ /**Below code is to replace the playwright default report commond with abstraction tool command */
102
+ _readline.default.moveCursor(process.stdout, 0, -2); // up two line
103
+ _readline.default.clearLine(process.stdout, 1); // from cursor to end
104
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'npx ZDTestingFramework report or npm run uat-report');
105
+ return;
106
+ }
107
+ }
108
+ }
109
+ var _default = exports.default = JSONSummaryReporter;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tagProcessor = tagProcessor;
7
+ var _logger = require("../../utils/logger");
8
+ /* eslint-disable dot-notation */
9
+
10
+ function getTagsString(tags, editionTags) {
11
+ return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
12
+ }
13
+ function getEdition(edition) {
14
+ if (edition.startsWith('<=')) {
15
+ return ['<=', edition.slice(2)];
16
+ } else if (edition.startsWith('>=')) {
17
+ return ['>=', edition.slice(2)];
18
+ } else if (edition.startsWith('<')) {
19
+ return ['<', edition.slice(1)];
20
+ } else if (edition.startsWith('>')) {
21
+ return ['>', edition.slice(1)];
22
+ }
23
+ return [null, edition];
24
+ }
25
+ function editionPreprocessing(editionOrder, selectedEdition) {
26
+ const [operator, editionToBeSearched] = getEdition(selectedEdition.toLowerCase());
27
+ const index = editionOrder.findIndex(edition => edition.toLowerCase() === editionToBeSearched);
28
+ if (index !== -1) {
29
+ let resultArray;
30
+ if (operator === '<=') {
31
+ resultArray = editionOrder.slice(index + 1);
32
+ } else if (operator === '>=') {
33
+ resultArray = editionOrder.slice(0, index);
34
+ } else if (operator === '<') {
35
+ resultArray = editionOrder.slice(index);
36
+ } else if (operator === '>') {
37
+ resultArray = editionOrder.slice(0, index + 1);
38
+ } else {
39
+ resultArray = editionOrder.filter((_, order) => order !== index);
40
+ }
41
+ return resultArray;
42
+ }
43
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
44
+ return [];
45
+ }
46
+ function buildEditionTags(editionArgs, operator) {
47
+ return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
48
+ }
49
+ function tagProcessor(userArgsObject, editionOrder) {
50
+ let tagArgs = userArgsObject['tags'];
51
+ const edition = userArgsObject['edition'] || null;
52
+ if (edition !== null) {
53
+ let editionsArray = edition.split(',');
54
+ if (editionsArray.length === 1) {
55
+ const editionArgs = editionPreprocessing(editionOrder, edition);
56
+ if (editionArgs && editionArgs.length > 0) {
57
+ const editionTags = buildEditionTags(editionArgs, 'or');
58
+ tagArgs = `${getTagsString(tagArgs, editionTags)}`;
59
+ }
60
+ } else {
61
+ // More than one edition given
62
+ const filteredEditions = editionOrder.filter(edition => !editionsArray.includes(edition));
63
+ const editionTags = buildEditionTags(filteredEditions, 'or');
64
+ tagArgs = `${getTagsString(tagArgs, editionTags)}`;
65
+ }
66
+ }
67
+ return tagArgs;
68
+ }
@@ -13,7 +13,8 @@ var _envInitializer = require("./env-initializer");
13
13
  var _logger = require("../../utils/logger");
14
14
  var _readConfigFile = require("./readConfigFile");
15
15
  var _rootPath = require("../../utils/rootPath");
16
- var _main = require("../../bdd-poc/main");
16
+ var _tagProcessor = require("./tag-processor");
17
+ var _bddPoc = require("../../bdd-poc");
17
18
  function parseUserArgs() {
18
19
  return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
19
20
  }
@@ -31,32 +32,36 @@ function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
31
32
  }
32
33
  return playwrightArgs;
33
34
  }
34
- function runPreprocessing(tagArgs, configPath) {
35
- const beforeCommand = 'node';
36
- const bddGenPath = _path.default.resolve(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js');
37
- const beforeArgs = [bddGenPath, '-c', configPath];
38
- if (tagArgs) {
39
- beforeArgs.push('--tags');
40
- beforeArgs.push(tagArgs);
41
- }
42
- return new Promise((resolve, reject) => {
43
- const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
44
- stdio: 'inherit'
45
- });
46
- childProcessForPreprocessing.on('error', data => {
47
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
48
- reject();
49
- });
50
- childProcessForPreprocessing.on('exit', code => {
51
- if (code === 0) {
52
- _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
53
- resolve();
54
- } else {
55
- reject(`BddGen exited with code ${code}`);
56
- }
57
- });
58
- });
59
- }
35
+
36
+ // function runPreprocessing(tagArgs, configPath) {
37
+ // const beforeCommand = 'node';
38
+ // const bddGenPath = path.resolve(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js');
39
+ // const beforeArgs = [bddGenPath, '-c', configPath];
40
+
41
+ // if (tagArgs) {
42
+ // beforeArgs.push('--tags');
43
+ // beforeArgs.push(tagArgs);
44
+ // }
45
+
46
+ // return new Promise((resolve, reject) => {
47
+ // const childProcessForPreprocessing = spawn(beforeCommand, beforeArgs, { stdio: 'inherit' });
48
+
49
+ // childProcessForPreprocessing.on('error', (data) => {
50
+ // Logger.log(Logger.FAILURE_TYPE, data);
51
+ // reject();
52
+ // });
53
+
54
+ // childProcessForPreprocessing.on('exit', (code) => {
55
+ // if (code === 0) {
56
+ // Logger.log(Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
57
+ // resolve();
58
+ // } else {
59
+ // reject(`BddGen exited with code ${code}`);
60
+ // }
61
+ // });
62
+ // });
63
+ // }
64
+
60
65
  function runPlaywright(command, args) {
61
66
  return new Promise((resolve, reject) => {
62
67
  const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
@@ -67,7 +72,6 @@ function runPlaywright(command, args) {
67
72
  });
68
73
  childProcessForRunningPlaywright.on('exit', (code, signal) => {
69
74
  if (code !== 0) {
70
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
71
75
  reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
72
76
  } else {
73
77
  _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
@@ -75,11 +79,11 @@ function runPlaywright(command, args) {
75
79
  }
76
80
  });
77
81
  process.on('exit', () => {
78
- //childProcessForRunningPlaywright.kill();
82
+ childProcessForRunningPlaywright.kill();
79
83
  reject('Terminating Playwright Process...');
80
84
  });
81
85
  process.on('SIGINT', () => {
82
- //childProcessForRunningPlaywright.kill();
86
+ childProcessForRunningPlaywright.kill();
83
87
  reject('Cleaning up...');
84
88
  });
85
89
  });
@@ -87,13 +91,15 @@ function runPlaywright(command, args) {
87
91
  function main() {
88
92
  const userArgsObject = parseUserArgs();
89
93
  // eslint-disable-next-line
90
- const tagArgs = userArgsObject['tags'];
94
+
91
95
  const {
92
96
  debug,
93
97
  mode = 'dev',
94
98
  bddMode = false,
95
- headless = false
99
+ headless = false,
100
+ editionOrder
96
101
  } = (0, _readConfigFile.generateConfigFromFile)();
102
+ const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
97
103
  const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
98
104
  (0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
99
105
  const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
@@ -102,14 +108,12 @@ function main() {
102
108
  const args = ['test', '--config', configPath].concat(playwrightArgs);
103
109
  let promises = [];
104
110
  if (bddMode) {
105
- (0, _main.cucumberBDDtoTestFile)();
111
+ (0, _bddPoc.createCucumberBDD)();
106
112
  // promises.push(runPreprocessing(tagArgs, configPath));
107
113
  }
108
-
109
114
  Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
110
115
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, err);
111
116
  process.exit();
112
117
  });
113
118
  }
114
- var _default = main;
115
- exports.default = _default;
119
+ var _default = exports.default = main;
@@ -1 +1 @@
1
- export * from './bdd-framework/decorators';
1
+ // export * from './bdd-framework/decorators';
@@ -1,16 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _decorators = require("./bdd-framework/decorators");
7
- Object.keys(_decorators).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _decorators[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _decorators[key];
14
- }
15
- });
16
- });
1
+ // export * from './bdd-framework/decorators';
2
+ "use strict";
package/build/index.d.ts CHANGED
@@ -1,5 +1,60 @@
1
- import { Given, Then, When, Step, expect, test, createBdd } from './core/playwright/index';
2
- import { fireEvent, render } from '@testing-library/react';
1
+ // import { expect, test } from './core/playwright/index';
2
+ // import { fireEvent, render } from '@testing-library/react';
3
+ // import {
4
+ // PlaywrightTestArgs,
5
+ // PlaywrightTestOptions,
6
+ // PlaywrightWorkerArgs,
7
+ // PlaywrightWorkerOptions,
8
+ // TestType,
9
+ // Page
10
+ // } from '@playwright/test';
11
+ // import { DefineStepPattern } from '@cucumber/cucumber/lib/support_code_library_builder/types';
3
12
 
4
- export { Given, Then, When, Step, expect, test, createBdd, fireEvent, render };
5
- export * from '@playwright/test/types/test';
13
+ // export type KeyValue = { [key: string]: any };
14
+
15
+ // export type BuiltInFixturesWorker = PlaywrightWorkerArgs &
16
+ // PlaywrightWorkerOptions;
17
+ // export type BuiltInFixtures = PlaywrightTestArgs &
18
+ // PlaywrightTestOptions &
19
+ // BuiltInFixturesWorker;
20
+
21
+ // export type FixturesArg<T extends KeyValue = {}, W extends KeyValue = {}> = T &
22
+ // W &
23
+ // BuiltInFixtures;
24
+
25
+ // export declare let hasCustomTest: boolean;
26
+
27
+ // export declare function createBdd<
28
+ // T extends KeyValue = BuiltInFixtures,
29
+ // W extends KeyValue = BuiltInFixturesWorker,
30
+ // World
31
+ // >(
32
+ // customTest?: TestType<T, W> | null,
33
+ // _CustomWorld?: new (...args: any[]) => World
34
+ // ): {
35
+ // Given: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
36
+ // When: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
37
+ // Then: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
38
+ // And: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
39
+ // But: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
40
+ // Step: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
41
+ // Before: any;
42
+ // After: any;
43
+ // BeforeAll: any;
44
+ // AfterAll: any;
45
+ // };
46
+
47
+ // type StepFunctionFixturesArg<
48
+ // T extends KeyValue,
49
+ // W extends KeyValue
50
+ // > = FixturesArg<T, W>;
51
+ // type StepFunction<T extends KeyValue, W extends KeyValue> = (
52
+ // fixtures: StepFunctionFixturesArg<T, W>,
53
+ // ...args: any[]
54
+ // ) => unknown;
55
+
56
+ // const { Given, Then, When, Step, And, But } = createBdd();
57
+
58
+ // export { Given, Then, When, Step, And, But, expect, test, createBdd, Page };
59
+
60
+ // export * from '@playwright/test/types/test';
package/build/index.js CHANGED
@@ -3,17 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.When = exports.Then = exports.Step = exports.Given = void 0;
6
+ exports.When = exports.Then = exports.Step = exports.Given = exports.But = exports.And = void 0;
7
7
  Object.defineProperty(exports, "createBdd", {
8
8
  enumerable: true,
9
9
  get: function () {
10
- return _exportMethods.createBdd;
10
+ return _bddPoc.createBdd;
11
11
  }
12
12
  });
13
13
  Object.defineProperty(exports, "createNativeBDD", {
14
14
  enumerable: true,
15
15
  get: function () {
16
- return _stepDefinitions.createNativeBDD;
16
+ return _bddPoc.createNativeBDD;
17
17
  }
18
18
  });
19
19
  Object.defineProperty(exports, "expect", {
@@ -29,16 +29,17 @@ Object.defineProperty(exports, "test", {
29
29
  }
30
30
  });
31
31
  var _index = require("./core/playwright/index");
32
- var _exportMethods = require("./bdd-poc/core-runner/exportMethods");
33
- var _stepDefinitions = require("./bdd-poc/core-runner/stepDefinitions");
32
+ var _bddPoc = require("./bdd-poc");
34
33
  // import { fireEvent, render } from '@testing-library/react';
35
34
  const {
36
35
  Given,
37
36
  Then,
38
37
  When,
39
- Step
40
- } = (0, _exportMethods.createBdd)();
41
- exports.Step = Step;
38
+ And
39
+ } = (0, _bddPoc.createBdd)();
40
+ exports.And = And;
42
41
  exports.When = When;
43
42
  exports.Then = Then;
44
- exports.Given = Given;
43
+ exports.Given = Given;
44
+ const Step = exports.Step = Then;
45
+ const But = exports.But = Then;
package/build/lib/cli.js CHANGED
@@ -7,6 +7,8 @@ var _codegen = _interopRequireDefault(require("../core/playwright/codegen"));
7
7
  var _logger = require("../utils/logger");
8
8
  var _setupProject = _interopRequireDefault(require("../setup-folder-structure/setupProject"));
9
9
  var _parser = require("../parser/parser");
10
+ var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-caches"));
11
+ var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
10
12
  // import createJestRunner from '../core/jest/runner/jest-runner';
11
13
 
12
14
  const [,, option, ...otherOptions] = process.argv;
@@ -46,9 +48,16 @@ switch (option) {
46
48
  (0, _parser.generateSpecCodeForFeatureFile)(otherOptions);
47
49
  break;
48
50
  }
51
+ case 'clearCaches':
52
+ {
53
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Clearing caches...');
54
+ (0, _clearCaches.default)();
55
+ break;
56
+ }
57
+ case 'help':
49
58
  default:
50
59
  {
51
- _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Supported Commands test and report');
60
+ (0, _helper.default)();
52
61
  break;
53
62
  }
54
63
  }
@@ -108,7 +108,6 @@ function generateSpecFileContent({
108
108
  });
109
109
  //specContent += `});\n\n`;
110
110
  }
111
-
112
111
  return specContent;
113
112
  }
114
113
  function updateExistingSpecFile({
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _commander = require("commander");
9
+ var _fs = require("fs");
10
+ var _path = _interopRequireDefault(require("path"));
11
+ var _logger = require("../utils/logger");
12
+ function helpercmd() {
13
+ const packageJsonPath = _path.default.resolve(process.cwd(), './package.json');
14
+ if ((0, _fs.existsSync)(packageJsonPath) && process.argv.includes('--version')) {
15
+ const {
16
+ dependencies
17
+ } = require(packageJsonPath);
18
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `zohodesk/testinglibrary Version : ${dependencies['@zohodesk/testinglibrary']}`);
19
+ _commander.program.version(dependencies['@zohodesk/testinglibrary'] || '0.0.1');
20
+ return;
21
+ }
22
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Supported Commands...');
23
+ _commander.program.name('npx ZDTestingFramework');
24
+ _commander.program.command('test').description('This command is used to execute tests');
25
+ _commander.program.command('init').description('This command will initialize Project');
26
+ _commander.program.command('report').description('This command is used to generate a report summarizing the results of executed tests.');
27
+ _commander.program.command('codegen').description('This command is used to assist developer to write test case');
28
+ _commander.program.option('--headed', 'Run tests with a headed browser.');
29
+ _commander.program.option('--debug', 'This command is used to initiate a debugging session');
30
+ _commander.program.option('--tags', 'Run specific test case with mentioned tags (Usage: -- --tags="@live")');
31
+ _commander.program.option('--workers', 'Specify number of workers to run the test case parallely (Usage: -- --workers=2)');
32
+ _commander.program.parse(process.argv);
33
+ }
34
+ var _default = exports.default = helpercmd;
@@ -0,0 +1,25 @@
1
+ <script>
2
+ function sortEdition(event) {
3
+ var currentURL = window.location.href;
4
+ const endPointCount = window.location.href.indexOf('#');
5
+ if (!(endPointCount == -1)) {
6
+ window.history.pushState({}, '', currentURL.slice(0, endPointCount));
7
+ currentURL = currentURL.slice(0, endPointCount);
8
+ }
9
+ console.log(currentURL);
10
+ window.open(`${currentURL}#?q=@edition_${event.target.value}`, '_self');
11
+ }
12
+ </script>
13
+ <div class="mainContainer" style="margin-left: 20px; display: flex;">
14
+ <div class="selectEditionContainer" style="padding: 20px;">
15
+ <select class="selectEdition" style="padding: 5px; width: 100px; border-radius: 6px; border: 1px solid var(--color-border-default);" onchange="sortEdition(event)">
16
+ <option value="EnterPrise">EnterPrise</option>
17
+ <option value="Professional">Professional</option>
18
+ <option value="Express">Express</option>
19
+ <option value="Standard">Standard</option>
20
+ <option value="Free">Free</option>
21
+ </select>
22
+ </div>
23
+ </div>
24
+
25
+
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.preProcessReport = preProcessReport;
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _logger = require("./../../utils/logger");
10
+ var _path = _interopRequireDefault(require("path"));
11
+ const htmlFilePath = _path.default.resolve(process.cwd(), 'uat', 'playwright-report', 'index.html');
12
+ const fileHtml = _fs.default.readFileSync(htmlFilePath, 'utf-8');
13
+ const addOnHtml = _fs.default.readFileSync(_path.default.resolve(__filename, '../', 'addonScript.html'), 'utf-8');
14
+ const splitedHTML = fileHtml.split('\n');
15
+ const toAdd = addOnHtml.split('\n');
16
+ function preProcessReport() {
17
+ if (_fs.default.existsSync(htmlFilePath)) {
18
+ const modifiedContent = [...splitedHTML.slice(0, 55), ...toAdd, ...splitedHTML.slice(56)].join('').toString();
19
+ _fs.default.writeFileSync(htmlFilePath, modifiedContent);
20
+ return;
21
+ } else {
22
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Report is not generated Properly ...');
23
+ }
24
+ return null;
25
+ }
@@ -2,15 +2,19 @@ import { existsSync, readFileSync, writeFileSync } from 'fs';
2
2
  import path from 'path';
3
3
  import { Logger } from '../utils/logger';
4
4
  import { generateConfigFromFile } from '../core/playwright/readConfigFile';
5
-
5
+ const gitIgnoreAbsolutePath = path.resolve(process.cwd(), '../', '../')
6
6
 
7
7
  const { reportPath = path.resolve(process.cwd(), 'uat', 'playwright-reports') } = generateConfigFromFile();
8
8
  const testResultsPath = path.resolve(process.cwd(), 'uat', 'test-results');
9
9
 
10
- const testResultsRelativepath = path.relative(path.resolve(process.cwd(), '../', '../'), testResultsPath)
11
- const reportRelativepath = path.relative(path.resolve(process.cwd(), '../', '../'), reportPath)
10
+ const testResultsRelativepath = path.relative(gitIgnoreAbsolutePath, testResultsPath)
11
+ const reportRelativepath = path.relative(gitIgnoreAbsolutePath, reportPath)
12
+
13
+
14
+ const absolutePathfeaturegen = path.resolve(process.cwd(), 'uat', '.features-gen');
15
+ const featuregenRelativePath = path.relative(gitIgnoreAbsolutePath,absolutePathfeaturegen)
12
16
 
13
- const dirpathtoIgnore = `${testResultsRelativepath}\n${reportRelativepath}`
17
+ const dirpathtoIgnore = `${testResultsRelativepath}\n${reportRelativepath}\n${featuregenRelativePath}`
14
18
 
15
19
  function updateGitIgnore() {
16
20
  if (existsSync(path.resolve(process.cwd(), '../', '../', '.gitignore'))) {