@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
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ // function test(descrition, callback) {
8
+ // return test(descrition, ({ page }) => {
9
+ // const { locator, ...custompage } = page
10
+ // callback({ page: custompage })
11
+ // })
12
+ // }
13
+ // class FilteredPage {
14
+ // constructor(page) {
15
+ // this.page = page;
16
+ // this.allowedMethods = ['getByText', 'getByTitle'];
17
+ // this.context = page.context;
18
+ // }
19
+ // goto(...args) {
20
+ // return this.page['goto'](...args);
21
+ // }
22
+ // getByRole(...args) {
23
+ // return this.page['getByRole'](...args);
24
+ // }
25
+ // }
26
+ // function FilteredPage(page) {
27
+ // return {
28
+ // getByRole: () => {
29
+ // throw new Error('You cannnot use getByRole property')
30
+ // }
31
+ // }
32
+ // }
33
+ var _default = exports.default = {
34
+ page: async ({
35
+ page
36
+ }, use) => {
37
+ page.getBaseUrl = function () {
38
+ if (process.env.mode === 'dev') {
39
+ return `${process.env.domain}?devURL=${process.env.devUrl}`;
40
+ }
41
+ return `${process.env.domain}`;
42
+ };
43
+ page.getCustomPageUrl = function (url) {
44
+ if (process.env.mode === 'dev') {
45
+ return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`;
46
+ }
47
+ return `${process.env.domain}/${url}`;
48
+ };
49
+ await use(page);
50
+ }
51
+ };
@@ -0,0 +1,29 @@
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 _fileUtils = require("../../utils/fileUtils");
10
+ var _logger = require("../../utils/logger");
11
+ var _readConfigFile = require("./readConfigFile");
12
+ function clearCaches() {
13
+ try {
14
+ const {
15
+ authFilePath,
16
+ reportPath
17
+ } = (0, _readConfigFile.generateConfigFromFile)();
18
+ authFilePath.split('/').pop();
19
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting auth files present in ${authFilePath}`);
20
+ (0, _fileUtils.deleteFolder)(_path.default.resolve(process.cwd(), authFilePath));
21
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting Playwright report ${reportPath}`);
22
+ (0, _fileUtils.deleteFolder)(reportPath);
23
+ (0, _fileUtils.deleteFolder)(_path.default.resolve(process.cwd(), 'uat', '.features-gen'));
24
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Caches Cleared');
25
+ } catch (err) {
26
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error While clearing cookies');
27
+ }
28
+ }
29
+ var _default = exports.default = clearCaches;
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.CUSTOM_COMMANDS = void 0;
7
- const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags'];
7
+ const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers'];
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -20,85 +21,16 @@ exports.test = void 0;
20
21
  var _bddFramework = require("../../bdd-framework");
21
22
  var _test = require("@playwright/test");
22
23
  var _readConfigFile = require("./readConfigFile");
23
- // function test(descrition, callback) {
24
- // return test(descrition, ({ page }) => {
25
- // const { locator, ...custompage } = page
26
- // callback({ page: custompage })
27
- // })
28
- // }
29
-
30
- // class FilteredPage {
31
- // constructor(page) {
32
- // this.page = page;
33
- // this.allowedMethods = ['getByText', 'getByTitle'];
34
- // this.context = page.context;
35
- // }
36
-
37
- // goto(...args) {
38
- // return this.page['goto'](...args);
39
- // }
40
-
41
- // getByRole(...args) {
42
- // return this.page['getByRole'](...args);
43
- // }
44
- // }
45
-
46
- // function FilteredPage(page) {
47
- // return {
48
- // getByRole: () => {
49
- // throw new Error('You cannnot use getByRole property')
50
- // }
51
- // }
52
- // }
24
+ var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
53
25
  const {
54
- additionalPages,
26
+ additionalPages: userFixtures,
55
27
  bddMode
56
28
  } = (0, _readConfigFile.generateConfigFromFile)();
57
29
  let base = bddMode ? _bddFramework.test : _test.test;
30
+ const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
58
31
  const test = exports.test = base.extend({
59
- page: async ({
60
- page
61
- }, use) => {
62
- // const proxyPage = new Proxy(page, {
63
- // get: function (obj, prop) {
64
- // console.log('Gettig Priop', prop);
65
- // let filterMethod = FilteredPage(page)[prop];
66
- // if (filterMethod) {
67
- // return filterMethod;
68
- // } else {
69
- // return obj[prop] ? obj[prop] : 'property does not exist';
70
- // }
71
- // }
72
- // })
73
- page.getBaseUrl = function () {
74
- if (process.env.mode === 'dev') {
75
- return `${process.env.domain}?devURL=${process.env.devUrl}`;
76
- }
77
- return `${process.env.domain}`;
78
- };
79
- page.getCustomPageUrl = function (url) {
80
- if (process.env.mode === 'dev') {
81
- return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`;
82
- }
83
- return `${process.env.domain}/${url}`;
84
- };
85
- await use(page);
86
-
87
- //await use(new FilteredPage(page));
88
-
89
- // await use(async (page) => {
90
- // delete page.getByTestId;
91
- // await page;
92
- // });
93
- },
94
- context: async ({
95
- context
96
- }, use) => {
97
- // eslint-disable-next-line no-undef
98
- await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
99
- await use(context);
100
- },
101
- ...additionalPages
32
+ ...buildInFixtures,
33
+ ...userFixtures
102
34
  });
103
35
  const {
104
36
  Given,
@@ -14,6 +14,7 @@ var _logger = require("../../utils/logger");
14
14
  const fileName = exports.fileName = 'uat.config.js';
15
15
  function getDefaultConfig() {
16
16
  return {
17
+ headless: false,
17
18
  browsers: ['Chrome'],
18
19
  trace: false,
19
20
  video: false,
@@ -30,7 +31,11 @@ function getDefaultConfig() {
30
31
  },
31
32
  debug: false,
32
33
  mode: 'dev',
33
- additionalPages: {}
34
+ additionalPages: {},
35
+ featureFilesFolder: 'feature-files',
36
+ stepDefinitionsFolder: 'steps',
37
+ testIdAttribute: 'data-testid',
38
+ editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
34
39
  };
35
40
  }
36
41
  function combineDefaultConfigWithUserConfig(userConfiguration) {
@@ -38,7 +43,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
38
43
  let configurationObj = {};
39
44
  Object.keys(userConfiguration).forEach(configKey => {
40
45
  let configValue = userConfiguration[configKey];
41
- if (configValue && configValue !== null) {
46
+ if (configValue !== null && configValue !== undefined) {
42
47
  configurationObj[configKey] = configValue;
43
48
  } else if (defaultConfig[configKey]) {
44
49
  configurationObj[configKey] = defaultConfig[configKey];
@@ -52,38 +57,40 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
52
57
  };
53
58
  }
54
59
 
55
- /**
56
- * @typedef {Object|null} viewportConfig
57
- * @property {number} width - width of the viewport
58
- * @property {number} height - height of the viewport
60
+ /**
61
+ * @typedef {Object|null} viewportConfig
62
+ * @property {number} width - width of the viewport
63
+ * @property {number} height - height of the viewport
59
64
  */
60
65
 
61
- /**
62
- * Represents the user configuration object.
63
- * @typedef {Object} UserConfig
64
- * @property {string} headless - Headless Browsers mode.
65
- * @property {number} trace - trace for test cases.
66
- * @property {boolean} video - video for test cases,
67
- * @property {boolean} debug - debug mode
68
- * @property {string} mode: mode in which the test cases needs to run
69
- * @property {boolean} isAuthMode - Auth Mode
70
- * @property {string} authFilePath - File Path where the cookies stored
71
- * @property {any} browsers: List of browsers
72
- * @property {string} openReportOn: default Option value (never, on-failure and always)
73
- * @property {any} reportPath : directory where report is generate
74
- * @property {boolean} bddMode: Feature files needs to be processed
75
- * @property {number} expectTimeout: time in milliseconds which the expect condition should fail
76
- * @property {number} testTimeout: time in milliseconds which the test should fail
77
- * @property {Object} additionalPages: custom pages configuration
78
- * @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
79
- * @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
80
- * @property {viewportConfig} viewport: viewport configuration
66
+ /**
67
+ * Represents the user configuration object.
68
+ * @typedef {Object} UserConfig
69
+ * @property {string} headless - Headless Browsers mode.
70
+ * @property {number} trace - trace for test cases.
71
+ * @property {boolean} video - video for test cases,
72
+ * @property {boolean} debug - debug mode
73
+ * @property {string} mode: mode in which the test cases needs to run
74
+ * @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
75
+ * @property {string} authFilePath - File Path where the cookies stored
76
+ * @property {any} browsers: List of browsers
77
+ * @property {string} openReportOn: default Option value (never, on-failure and always)
78
+ * @property {any} reportPath : directory where report is generate
79
+ * @property {boolean} bddMode: Feature files needs to be processed
80
+ * @property {number} expectTimeout: time in milliseconds which the expect condition should fail
81
+ * @property {number} testTimeout: time in milliseconds which the test should fail
82
+ * @property {Object} additionalPages: custom pages configuration
83
+ * @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
84
+ * @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
85
+ * @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
86
+ * @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
87
+ * @property {Array} editionOrder: Order in the form of larger editions in the back. Edition with the most privelages should be last
81
88
  */
82
89
 
83
- /**
84
- * Generates a configuration object from a file, if it exists.
85
- *
86
- * @returns {UserConfig}
90
+ /**
91
+ * Generates a configuration object from a file, if it exists.
92
+ *
93
+ * @returns {UserConfig}
87
94
  */
88
95
  function generateConfigFromFile() {
89
96
  const filePath = _path.default.resolve(process.cwd(), fileName);
@@ -17,7 +17,8 @@ const {
17
17
  reportPath: htmlPath
18
18
  } = (0, _readConfigFile.generateConfigFromFile)();
19
19
  const args = ['show-report', htmlPath].concat(userArgs);
20
- function generateReport() {
20
+ async function generateReport() {
21
+ // await preProcessReport()
21
22
  const childProcess = (0, _child_process.spawn)(command, args, {
22
23
  stdio: 'inherit'
23
24
  });
@@ -9,8 +9,22 @@ var _test = require("@playwright/test");
9
9
  var _path = _interopRequireDefault(require("path"));
10
10
  var _readConfigFile = require("../readConfigFile");
11
11
  var _configUtils = require("./config-utils");
12
- var _testDataMap = require("../../../bdd-poc/test/testDataMap");
13
- var _runner = require("../../../bdd-poc/runner");
12
+ var _cliArgsToObject = require("../../../utils/cliArgsToObject");
13
+ var _logger = require("../../../utils/logger");
14
+ function getBrowsersList(browserFromArgs, browsersFromConfig) {
15
+ if (browserFromArgs) {
16
+ if (typeof browserFromArgs === 'string') {
17
+ let listOfbrowsers = browserFromArgs.split(',').map(browser => browser.trim().toLowerCase());
18
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, 'using browsers from user args');
19
+ return listOfbrowsers;
20
+ } else {
21
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `--browsers option should be of type 'string' splitted by ','\n\t --browsers='chrome,firefox,safari'`);
22
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, 'Using browsers from uat.config.js');
23
+ return browsersFromConfig;
24
+ }
25
+ }
26
+ return browsersFromConfig;
27
+ }
14
28
  const {
15
29
  browsers,
16
30
  trace,
@@ -24,10 +38,16 @@ const {
24
38
  authFilePath,
25
39
  viewport,
26
40
  featureFilesFolder,
27
- stepDefinitionsFolder
41
+ stepDefinitionsFolder,
42
+ testIdAttribute
28
43
  } = (0, _readConfigFile.generateConfigFromFile)();
44
+ const userArgs = (0, _cliArgsToObject.parseUserArgs)();
45
+ const {
46
+ browsersFromArgs = null
47
+ } = userArgs;
48
+ let listOfbrowsers = getBrowsersList(browsersFromArgs, browsers);
29
49
  const projects = (0, _configUtils.getProjects)({
30
- browsers,
50
+ listOfbrowsers,
31
51
  isAuthMode,
32
52
  authFilePath,
33
53
  expectTimeout,
@@ -38,12 +58,19 @@ const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd(), {
38
58
  featureFilesFolder,
39
59
  stepDefinitionsFolder
40
60
  });
61
+ const testOptions = (0, _configUtils.getTestUseOptions)({
62
+ trace,
63
+ video,
64
+ viewport,
65
+ testIdAttribute
66
+ });
67
+
68
+ /**
69
+ * Playwright configuration object
70
+ *
71
+ * @returns {import('@playwright/test').PlaywrightTestConfig}
72
+ */
41
73
  function getPlaywrightConfig() {
42
- globalThis.globalStepMap = new Map();
43
- (0, _runner.stepFileMap)();
44
- (0, _testDataMap.testDataCreation)().then(inputs => {
45
- globalThis.globalTestdata = inputs;
46
- });
47
74
  return {
48
75
  testDir,
49
76
  outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
@@ -54,24 +81,20 @@ function getPlaywrightConfig() {
54
81
  reporter: [['html', {
55
82
  outputFolder: reportPath,
56
83
  open: openReportOn
57
- }]],
84
+ }], ['list'], ['./custom-reporter.js']],
58
85
  timeout: testTimeout,
59
86
  expect: {
60
87
  timeout: expectTimeout
61
88
  },
62
- use: {
63
- viewport,
64
- trace: trace ? 'on' : 'off',
65
- video: video ? {
66
- mode: 'on',
67
- size: {
68
- ...viewport
69
- }
70
- } : 'off'
71
- },
89
+ use: testOptions,
72
90
  projects: isAuthMode ? [{
73
91
  name: 'setup',
74
92
  testMatch: /.*\.setup\.js/,
93
+ testDir: _path.default.join(process.cwd(), 'uat'),
94
+ teardown: 'cleanup'
95
+ }, {
96
+ name: 'cleanup',
97
+ testMatch: /.*\.teardown\.js/,
75
98
  testDir: _path.default.join(process.cwd(), 'uat')
76
99
  }, ...projects] : [...projects]
77
100
  };
@@ -6,10 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getProjects = getProjects;
8
8
  exports.getTestDir = getTestDir;
9
+ exports.getTestUseOptions = getTestUseOptions;
9
10
  var _test = require("@playwright/test");
10
11
  var _path = _interopRequireDefault(require("path"));
11
12
  var _readConfigFile = require("../readConfigFile");
12
13
  var _bddFramework = require("../../../bdd-framework");
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,
@@ -108,4 +119,23 @@ function getTestDir(bddMode, cwd, {
108
119
  outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
109
120
  publish: true
110
121
  }) : _path.default.join(cwd, 'uat');
122
+ }
123
+ function getTestUseOptions({
124
+ viewport,
125
+ trace,
126
+ video,
127
+ testIdAttribute
128
+ }) {
129
+ let defaultTestuseOptions = {
130
+ viewport,
131
+ testIdAttribute,
132
+ trace: trace ? 'on' : 'off',
133
+ video: video ? {
134
+ mode: 'on',
135
+ size: {
136
+ ...viewport
137
+ }
138
+ } : 'off'
139
+ };
140
+ return defaultTestuseOptions;
111
141
  }
@@ -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
+ }