@zohodesk/testinglibrary 0.4.19-experimental → 0.4.21-experimental

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 (148) hide show
  1. package/.gitlab-ci.yml +19 -1
  2. package/README.md +27 -1
  3. package/build/core/playwright/builtInFixtures/page.js +7 -0
  4. package/build/core/playwright/constants/fileMutexConfig.js +3 -3
  5. package/build/core/playwright/fixtures.js +24 -0
  6. package/build/core/playwright/helpers/fileMutex.js +11 -13
  7. package/build/core/playwright/index.js +10 -23
  8. package/build/core/playwright/runner/Runner.js +22 -0
  9. package/build/core/playwright/runner/RunnerHelper.js +43 -0
  10. package/build/core/playwright/runner/RunnerTypes.js +17 -0
  11. package/build/core/playwright/runner/SpawnRunner.js +110 -0
  12. package/build/core/playwright/setup/config-creator.js +3 -3
  13. package/build/core/playwright/setup/config-utils.js +8 -25
  14. package/build/core/playwright/tagProcessor.js +18 -28
  15. package/build/core/playwright/test-runner.js +9 -35
  16. package/build/decorators.d.ts +1 -1
  17. package/build/decorators.js +1 -1
  18. package/build/setup-folder-structure/samples/auth-setup-sample.js +14 -66
  19. package/build/setup-folder-structure/samples/editions-index.js +3 -0
  20. package/build/setup-folder-structure/samples/free-sample.json +25 -0
  21. package/{nobdd/uat/conf/default → build/setup-folder-structure/samples}/settings.json +4 -3
  22. package/build/setup-folder-structure/setupProject.js +18 -5
  23. package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +45 -68
  24. package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +16 -0
  25. package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +27 -0
  26. package/npm-shrinkwrap.json +2003 -1404
  27. package/package.json +8 -8
  28. package/build/bdd-framework/cli/commands/env.js +0 -42
  29. package/build/bdd-framework/cli/commands/export.js +0 -62
  30. package/build/bdd-framework/cli/commands/test.js +0 -64
  31. package/build/bdd-framework/cli/index.js +0 -11
  32. package/build/bdd-framework/cli/options.js +0 -19
  33. package/build/bdd-framework/cli/worker.js +0 -13
  34. package/build/bdd-framework/config/configDir.js +0 -35
  35. package/build/bdd-framework/config/enrichReporterData.js +0 -23
  36. package/build/bdd-framework/config/env.js +0 -50
  37. package/build/bdd-framework/config/index.js +0 -94
  38. package/build/bdd-framework/config/lang.js +0 -14
  39. package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -43
  40. package/build/bdd-framework/cucumber/createTestStep.js +0 -43
  41. package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +0 -126
  42. package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +0 -72
  43. package/build/bdd-framework/cucumber/formatter/PickleParser.js +0 -25
  44. package/build/bdd-framework/cucumber/formatter/durationHelpers.js +0 -13
  45. package/build/bdd-framework/cucumber/formatter/getColorFns.js +0 -57
  46. package/build/bdd-framework/cucumber/formatter/index.js +0 -16
  47. package/build/bdd-framework/cucumber/formatter/locationHelpers.js +0 -16
  48. package/build/bdd-framework/cucumber/loadConfig.js +0 -17
  49. package/build/bdd-framework/cucumber/loadFeatures.js +0 -70
  50. package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
  51. package/build/bdd-framework/cucumber/loadSteps.js +0 -47
  52. package/build/bdd-framework/cucumber/resolveFeaturePaths.js +0 -62
  53. package/build/bdd-framework/cucumber/stepArguments.js +0 -21
  54. package/build/bdd-framework/cucumber/types.js +0 -5
  55. package/build/bdd-framework/cucumber/valueChecker.js +0 -23
  56. package/build/bdd-framework/decorators.js +0 -18
  57. package/build/bdd-framework/gen/fixtures.js +0 -48
  58. package/build/bdd-framework/gen/formatter.js +0 -167
  59. package/build/bdd-framework/gen/i18n.js +0 -39
  60. package/build/bdd-framework/gen/index.js +0 -197
  61. package/build/bdd-framework/gen/specialTags.js +0 -70
  62. package/build/bdd-framework/gen/testFile.js +0 -470
  63. package/build/bdd-framework/gen/testMeta.js +0 -60
  64. package/build/bdd-framework/gen/testNode.js +0 -35
  65. package/build/bdd-framework/gen/testPoms.js +0 -133
  66. package/build/bdd-framework/hooks/scenario.js +0 -130
  67. package/build/bdd-framework/hooks/worker.js +0 -89
  68. package/build/bdd-framework/index.js +0 -52
  69. package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -93
  70. package/build/bdd-framework/playwright/getLocationInFile.js +0 -79
  71. package/build/bdd-framework/playwright/loadConfig.js +0 -42
  72. package/build/bdd-framework/playwright/loadUtils.js +0 -33
  73. package/build/bdd-framework/playwright/testTypeImpl.js +0 -79
  74. package/build/bdd-framework/playwright/transform.js +0 -88
  75. package/build/bdd-framework/playwright/types.js +0 -12
  76. package/build/bdd-framework/playwright/utils.js +0 -56
  77. package/build/bdd-framework/reporter/cucumber/base.js +0 -52
  78. package/build/bdd-framework/reporter/cucumber/custom.js +0 -73
  79. package/build/bdd-framework/reporter/cucumber/helper.js +0 -12
  80. package/build/bdd-framework/reporter/cucumber/html.js +0 -40
  81. package/build/bdd-framework/reporter/cucumber/index.js +0 -74
  82. package/build/bdd-framework/reporter/cucumber/json.js +0 -312
  83. package/build/bdd-framework/reporter/cucumber/junit.js +0 -205
  84. package/build/bdd-framework/reporter/cucumber/message.js +0 -20
  85. package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +0 -82
  86. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +0 -197
  87. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +0 -43
  88. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +0 -52
  89. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +0 -105
  90. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +0 -70
  91. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +0 -45
  92. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +0 -27
  93. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +0 -38
  94. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +0 -128
  95. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +0 -154
  96. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +0 -123
  97. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +0 -67
  98. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +0 -114
  99. package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +0 -30
  100. package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwStepUtils.js +0 -70
  101. package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +0 -35
  102. package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +0 -5
  103. package/build/bdd-framework/run/StepInvoker.js +0 -69
  104. package/build/bdd-framework/run/bddData/index.js +0 -59
  105. package/build/bdd-framework/run/bddData/types.js +0 -5
  106. package/build/bdd-framework/run/bddFixtures.js +0 -192
  107. package/build/bdd-framework/run/bddWorld.js +0 -79
  108. package/build/bdd-framework/run/bddWorldInternal.js +0 -11
  109. package/build/bdd-framework/snippets/index.js +0 -132
  110. package/build/bdd-framework/snippets/snippetSyntax.js +0 -43
  111. package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -26
  112. package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
  113. package/build/bdd-framework/stepDefinitions/createBdd.js +0 -66
  114. package/build/bdd-framework/stepDefinitions/decorators/class.js +0 -68
  115. package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -99
  116. package/build/bdd-framework/stepDefinitions/defineStep.js +0 -62
  117. package/build/bdd-framework/stepDefinitions/stepConfig.js +0 -24
  118. package/build/bdd-framework/steps/createBdd.js +0 -78
  119. package/build/bdd-framework/steps/decorators/class.js +0 -68
  120. package/build/bdd-framework/steps/decorators/steps.js +0 -98
  121. package/build/bdd-framework/steps/defineStep.js +0 -62
  122. package/build/bdd-framework/steps/stepConfig.js +0 -24
  123. package/build/bdd-framework/utils/AutofillMap.js +0 -20
  124. package/build/bdd-framework/utils/exit.js +0 -62
  125. package/build/bdd-framework/utils/index.js +0 -93
  126. package/build/bdd-framework/utils/jsStringWrap.js +0 -44
  127. package/build/bdd-framework/utils/logger.js +0 -30
  128. package/build/bdd-framework/utils/stripAnsiEscapes.js +0 -20
  129. package/build/setup-folder-structure/samples/authUsers-sample.json +0 -9
  130. package/build/setup-folder-structure/samples/env-config-sample.json +0 -21
  131. package/nobdd/README.md +0 -1
  132. package/nobdd/package.json +0 -17
  133. package/nobdd/src/App.js +0 -7
  134. package/nobdd/uat/conf/default/actors/editions/enterprise.json +0 -24
  135. package/nobdd/uat/conf/default/actors/editions/index.js +0 -4
  136. package/nobdd/uat/conf/nobdd/uat.config.js +0 -36
  137. package/nobdd/uat/env-config.json +0 -20
  138. package/nobdd/uat/fixtures/auth.setup.js +0 -44
  139. package/nobdd/uat/fixtures/setup.teardown.js +0 -33
  140. package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +0 -16
  141. package/nobdd/uat/shared/commands/_index-custom-fixtures.js +0 -9
  142. package/nobdd/uat/shared/commands/i18n.js +0 -25
  143. package/nobdd/uat/shared/commands/unauthenticatedPage.js +0 -8
  144. package/nobdd/uat/shared/index.js +0 -7
  145. package/nobdd/uat/shared/onboardings/onboardingUpdate.js +0 -44
  146. package/nobdd/uat/shared/url-helpers/getUrlOrigin.js +0 -6
  147. package/nobdd/uat.config.js +0 -36
  148. /package/{nobdd/uat/conf/default/actors/index.js → build/setup-folder-structure/samples/actors-index.js} +0 -0
package/.gitlab-ci.yml CHANGED
@@ -1,4 +1,4 @@
1
- image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v2
1
+ image: repository.desk.csez.zohocorpin.com/base-image/testing-framework-gitlab-runne-base:v3
2
2
 
3
3
  workflow:
4
4
  rules:
@@ -86,6 +86,24 @@ uat-profile:
86
86
  paths:
87
87
  - examples/uat/playwright-report
88
88
 
89
+
90
+ uat-unauth:
91
+ stage: uat
92
+ script:
93
+ - cd examples
94
+ - npm install $(npm pack ../../testing-framework | tail -1)
95
+ - output=$(npm run uatunauth)
96
+ - echo "$output"
97
+ - if [[ "$output" == *"failed"* ]]; then
98
+ - exit 1
99
+ - fi
100
+
101
+
102
+ artifacts:
103
+ when: always
104
+ paths:
105
+ - examples/uat/playwright-report
106
+
89
107
  uat-nobdd:
90
108
  stage: uat
91
109
  script:
package/README.md CHANGED
@@ -26,13 +26,39 @@
26
26
  ### Bug fix
27
27
  - Updated the custom-reported to include the errors in tests during the executions. It will help us avoid the stage passed without the actual test execution.
28
28
 
29
- ### v0.2.9 - 24-10-2024
29
+
30
+ ## Version History
31
+
32
+ ### v0.2.9 - 25-10-2024
30
33
 
31
34
  #### Feature
32
35
  - Added support for scenario level tag support
33
36
  - Added a new cli optin like uat-validate to validate the feature files using playwright-bdd
34
37
  - Mode based configuration implementations
35
38
  - @only option enabled in dev pipeline
39
+ - Latest setup related configuration changed for init option
40
+
41
+ ### v0.3.0 - 25-10-2024
42
+
43
+ #### Features
44
+ - Added support for scenario level tag support
45
+ - Updated the configuration for `video` and `trace` to accept Playwright-specific values instead of boolean values.
46
+ - Below package versions are updated in this release.
47
+ - playwright - 1.48.0,
48
+ - playwright-bdd - 7.5.0,
49
+ - @playwright/test - 1.48.0,
50
+ - @cucumber/cucumber - 11.0.1
51
+ - From this version, We adopt the playwright-bdd as library instead of modified source
52
+ - Published on 11-11-2024
53
+
54
+ #### Deprecations
55
+ - **Deprecated**: Passing `video` and `trace` as boolean (`true`/`false`) in project configuration.
56
+ - **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
57
+
58
+ ### v0.3.1 - 13-11-2024
59
+
60
+ #### Issue Fix
61
+ - Adding bddmode to get the fixtures.
36
62
 
37
63
  ### v0.2.9.1 - 14-11-2024
38
64
 
@@ -70,6 +70,13 @@ var _default = exports.default = {
70
70
  await use(page);
71
71
  return;
72
72
  }
73
+
74
+ //This block is used to skip the login process if the @unauthenticated tag is added to the script
75
+ if ($tags.includes('@unauthenticated')) {
76
+ await context.clearCookies();
77
+ await use(page);
78
+ return;
79
+ }
73
80
  const testPortalDetails = getCustomAccountDetails($tags);
74
81
  if (testPortalDetails === null) {
75
82
  await performDefaultPageSteps({
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.LOGIN_MUTEX_TIMEOUT = void 0;
7
7
  const LOGIN_MUTEX_TIMEOUT = exports.LOGIN_MUTEX_TIMEOUT = {
8
- stale: 90000,
8
+ stale: 100000,
9
9
  retries: {
10
10
  retries: 10,
11
11
  factor: 1,
12
- minTimeout: 20000,
13
- maxTimeout: 40000
12
+ minTimeout: 10000,
13
+ maxTimeout: 20000
14
14
  }
15
15
  };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _test = require("@playwright/test");
5
+ var _playwrightBdd = require("playwright-bdd");
6
+ var _readConfigFile = require("./readConfigFile");
7
+ var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
8
+ var _getUserFixtures = _interopRequireDefault(require("./helpers/getUserFixtures"));
9
+ const {
10
+ bddMode
11
+ } = (0, _readConfigFile.generateConfigFromFile)();
12
+ let base = bddMode ? _playwrightBdd.test : _test.test;
13
+ const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
14
+ const buildInFixturesTest = base.extend({
15
+ ...buildInFixtures
16
+ });
17
+ const userFixtures = (0, _getUserFixtures.default)();
18
+ const userFixturesTest = base.extend({
19
+ ...userFixtures
20
+ });
21
+ const test = (0, _test.mergeTests)(buildInFixturesTest, userFixturesTest);
22
+ module.exports = {
23
+ test
24
+ };
@@ -8,44 +8,42 @@ exports.default = void 0;
8
8
  var _path = _interopRequireDefault(require("path"));
9
9
  var _properLockfile = _interopRequireDefault(require("proper-lockfile"));
10
10
  var _fs = require("fs");
11
- function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
12
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
13
- function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
14
- var _getLockFilePath = /*#__PURE__*/new WeakSet();
15
- var _createDirectoryIfNotExist = /*#__PURE__*/new WeakSet();
11
+ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
12
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
13
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
14
+ var _FileMutex_brand = /*#__PURE__*/new WeakSet();
16
15
  class FileMutex {
17
16
  constructor(directory, lockFileName, options = {}) {
18
- _classPrivateMethodInitSpec(this, _createDirectoryIfNotExist);
19
- _classPrivateMethodInitSpec(this, _getLockFilePath);
17
+ _classPrivateMethodInitSpec(this, _FileMutex_brand);
20
18
  this.directory = directory;
21
19
  this.lockFileName = lockFileName + ".lock";
22
20
  this.options = options;
23
21
  }
24
22
  async acquire() {
25
- _classPrivateMethodGet(this, _createDirectoryIfNotExist, _createDirectoryIfNotExist2).call(this);
23
+ _assertClassBrand(_FileMutex_brand, this, _createDirectoryIfNotExist).call(this);
26
24
  const lockFilePath = _path.default.resolve(this.directory, this.lockFileName);
27
25
  try {
28
26
  if (!(0, _fs.existsSync)(lockFilePath)) {
29
- console.warn(`[DEBUG] Creating missing lock file:`, this.lockFileName);
27
+ console.log(`[DEBUG] Creating missing lock file:`, this.lockFileName);
30
28
  (0, _fs.writeFileSync)(lockFilePath, 'locked');
31
29
  }
32
- await _properLockfile.default.lock(_classPrivateMethodGet(this, _getLockFilePath, _getLockFilePath2).call(this), this.options);
30
+ await _properLockfile.default.lock(_assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this), this.options);
33
31
  } catch (err) {
34
32
  throw new Error(`Failed to acquire lock after ${this.options.retries.retries} attempts: ${err.message}`);
35
33
  }
36
34
  }
37
35
  async release() {
38
36
  try {
39
- await _properLockfile.default.unlock(_classPrivateMethodGet(this, _getLockFilePath, _getLockFilePath2).call(this));
37
+ await _properLockfile.default.unlock(_assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this));
40
38
  } catch (err) {
41
39
  throw new Error(`Failed to release lock: ${err.message}`);
42
40
  }
43
41
  }
44
42
  }
45
- function _getLockFilePath2() {
43
+ function _getLockFilePath() {
46
44
  return _path.default.resolve(_path.default.join(this.directory, this.lockFileName));
47
45
  }
48
- function _createDirectoryIfNotExist2() {
46
+ function _createDirectoryIfNotExist() {
49
47
  if (!(0, _fs.existsSync)(this.directory)) {
50
48
  (0, _fs.mkdirSync)(this.directory, {
51
49
  recursive: true
@@ -1,37 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- Object.defineProperty(exports, "createBdd", {
6
+ exports.createBdd = void 0;
7
+ Object.defineProperty(exports, "expect", {
8
8
  enumerable: true,
9
9
  get: function () {
10
- return _bddFramework.createBdd;
10
+ return _test.expect;
11
11
  }
12
12
  });
13
- Object.defineProperty(exports, "expect", {
13
+ Object.defineProperty(exports, "test", {
14
14
  enumerable: true,
15
15
  get: function () {
16
- return _test.expect;
16
+ return _playwrightBdd.test;
17
17
  }
18
18
  });
19
- exports.test = void 0;
20
- var _bddFramework = require("../../bdd-framework");
19
+ var _playwrightBdd = require("playwright-bdd");
21
20
  var _test = require("@playwright/test");
22
- var _readConfigFile = require("./readConfigFile");
23
- var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
24
- var _getUserFixtures = _interopRequireDefault(require("./helpers/getUserFixtures"));
25
- const {
26
- bddMode
27
- } = (0, _readConfigFile.generateConfigFromFile)();
28
- let base = bddMode ? _bddFramework.test : _test.test;
29
- const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
30
- const buildInFixturesTest = base.extend({
31
- ...buildInFixtures
32
- });
33
- const userFixtures = (0, _getUserFixtures.default)();
34
- const userFixturesTest = base.extend({
35
- ...userFixtures
36
- });
37
- const test = exports.test = (0, _test.mergeTests)(buildInFixturesTest, userFixturesTest);
21
+ let createBdd = function () {
22
+ return (0, _playwrightBdd.createBdd)(_playwrightBdd.test);
23
+ };
24
+ exports.createBdd = createBdd;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ class Runner {
4
+ constructor(config) {
5
+ this.tagArgs = "";
6
+ this.userArgs = "";
7
+ this.config = config;
8
+ }
9
+ setUserArgs(userArgs) {
10
+ this.userArgs = userArgs;
11
+ }
12
+ setTagArgs(tagArgs) {
13
+ this.tagArgs = tagArgs;
14
+ }
15
+ setConfig(config) {
16
+ this.config = config;
17
+ }
18
+ run() {
19
+ throw new Error("Method 'run()' must be implemented.");
20
+ }
21
+ }
22
+ module.exports = Runner;
@@ -0,0 +1,43 @@
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 _RunnerTypes = _interopRequireDefault(require("./RunnerTypes"));
9
+ var _configUtils = require("../setup/config-utils");
10
+ var _cliArgsToObject = require("../../../utils/cliArgsToObject");
11
+ var _browserTypes = require("../constants/browserTypes");
12
+ var _customCommands = require("../custom-commands");
13
+ class RunnerHelper {
14
+ static createRunner(type, runnerObj) {
15
+ const runnerClass = _RunnerTypes.default.getRunnerClass(type, runnerObj);
16
+ if (!runnerClass) {
17
+ throw new Error("Invalid runner type");
18
+ }
19
+ return runnerClass;
20
+ }
21
+ static getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
22
+ const {
23
+ browsers = null
24
+ } = userArgsObject;
25
+ let browserList = (0, _configUtils.getBrowsersList)(browsers);
26
+ const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
27
+ if (debug) {
28
+ playwrightArgs.push('--debug');
29
+ }
30
+ if (!bddMode && tagArgs) {
31
+ playwrightArgs.push('--grep');
32
+ playwrightArgs.push(tagArgs);
33
+ }
34
+ if (!headless && !userArgsObject.headed) {
35
+ playwrightArgs.push('--headed');
36
+ }
37
+ if (browserList && browserList.length > 0) {
38
+ browserList.map(browser => playwrightArgs.push(`--project=${_browserTypes.BROWSER_PROJECT_MAPPING[browser.toUpperCase()]}`));
39
+ }
40
+ return playwrightArgs;
41
+ }
42
+ }
43
+ var _default = exports.default = RunnerHelper;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _SpawnRunner = _interopRequireDefault(require("./SpawnRunner"));
5
+ class RunnerTypes {
6
+ static getRunnerClass(type, runnerObj) {
7
+ const RunnerClass = this.runnerTypes[type];
8
+ if (!RunnerClass) {
9
+ throw new Error("Invalid runner type");
10
+ }
11
+ return new RunnerClass(runnerObj);
12
+ }
13
+ static runnerTypes = {
14
+ spawn: _SpawnRunner.default //require("./SpawnRunner"), // used lazy loading to reduce circular dependencies
15
+ };
16
+ }
17
+ module.exports = RunnerTypes;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _readConfigFile = require("../readConfigFile");
5
+ var _rootPath = require("../../../utils/rootPath");
6
+ var _path = _interopRequireDefault(require("path"));
7
+ var _logger = require("../../../utils/logger");
8
+ var _child_process = require("child_process");
9
+ var _RunnerHelper = _interopRequireDefault(require("./RunnerHelper"));
10
+ var _Runner = _interopRequireDefault(require("./Runner"));
11
+ class SpawnRunner extends _Runner.default {
12
+ constructor(runnerObj) {
13
+ super(runnerObj);
14
+ this.runnerObj = runnerObj;
15
+ }
16
+ run() {
17
+ const {
18
+ config
19
+ } = this.runnerObj;
20
+ let promises = [];
21
+ const {
22
+ bddMode
23
+ } = config.getAll();
24
+ if (bddMode) {
25
+ promises.push(this.runPreprocessing());
26
+ }
27
+ Promise.all(promises).then(() => this.runPlaywright()).catch(err => {
28
+ _logger.Logger.error(err);
29
+ process.exit();
30
+ });
31
+ }
32
+ runPreprocessing() {
33
+ const {
34
+ tagArgs
35
+ } = this.runnerObj;
36
+ const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve('../', '../', '../', '../', 'playwrightConfig.js');
37
+ const beforeCommand = 'node';
38
+ const bddGenPath = _path.default.resolve(__dirname, '../', '../', '../', 'bdd-framework', 'cli', 'index.js');
39
+ const beforeArgs = [bddGenPath, '-c', require.resolve(configPath)];
40
+ if (tagArgs) {
41
+ beforeArgs.push('--tags');
42
+ beforeArgs.push(tagArgs);
43
+ }
44
+ return new Promise((resolve, reject) => {
45
+ const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
46
+ stdio: 'inherit',
47
+ env: {
48
+ ...process.env
49
+ }
50
+ });
51
+ childProcessForPreprocessing.on('error', data => {
52
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
53
+ reject(data);
54
+ });
55
+ childProcessForPreprocessing.on('exit', code => {
56
+ if (code === 0) {
57
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
58
+ resolve();
59
+ } else {
60
+ reject(`BddGen exited with code ${code}`);
61
+ }
62
+ });
63
+ });
64
+ }
65
+ runPlaywright() {
66
+ const {
67
+ tagArgs,
68
+ config,
69
+ userArgs
70
+ } = this.runnerObj;
71
+ const {
72
+ debug,
73
+ bddMode = false,
74
+ headless = false
75
+ } = config.getAll();
76
+ const playwrightArgs = _RunnerHelper.default.getPlaywrightArgs(userArgs, debug, bddMode, tagArgs, headless);
77
+ const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
78
+ const command = playwrightPath;
79
+ const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? _path.default.resolve(__dirname, '../', 'setup', 'config-creator.js') : _path.default.resolve('../', '../', '../', '../', 'playwrightConfig.js');
80
+ const args = ['test', '--config', require.resolve(configPath)].concat(playwrightArgs);
81
+ return new Promise((resolve, reject) => {
82
+ const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
83
+ stdio: 'inherit',
84
+ env: {
85
+ ...process.env
86
+ }
87
+ });
88
+ childProcessForRunningPlaywright.on('error', error => {
89
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
90
+ });
91
+ childProcessForRunningPlaywright.on('exit', (code, signal) => {
92
+ if (code !== 0) {
93
+ reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
94
+ } else {
95
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
96
+ resolve();
97
+ }
98
+ });
99
+ process.on('exit', () => {
100
+ childProcessForRunningPlaywright.kill();
101
+ reject('Terminating Playwright Process...');
102
+ });
103
+ process.on('SIGINT', () => {
104
+ childProcessForRunningPlaywright.kill();
105
+ reject('Cleaning up...');
106
+ });
107
+ });
108
+ }
109
+ }
110
+ module.exports = SpawnRunner;
@@ -39,12 +39,12 @@ const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd(), {
39
39
  featureFilesFolder,
40
40
  stepDefinitionsFolder
41
41
  });
42
- const testOptions = (0, _configUtils.getTestUseOptions)({
42
+ const use = {
43
43
  trace,
44
44
  video,
45
45
  viewport,
46
46
  testIdAttribute
47
- });
47
+ };
48
48
 
49
49
  /**
50
50
  * Playwright configuration object
@@ -65,7 +65,7 @@ function getPlaywrightConfig() {
65
65
  expect: {
66
66
  timeout: expectTimeout
67
67
  },
68
- use: testOptions,
68
+ use,
69
69
  projects: isAuthMode ? [{
70
70
  name: 'setup',
71
71
  testMatch: /.*\.setup\.js/,
@@ -7,14 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.getBrowsersList = getBrowsersList;
8
8
  exports.getProjects = getProjects;
9
9
  exports.getTestDir = getTestDir;
10
- exports.getTestUseOptions = getTestUseOptions;
11
10
  var _test = require("@playwright/test");
12
11
  var _path = _interopRequireDefault(require("path"));
13
12
  var _readConfigFile = require("../readConfigFile");
14
- var _bddFramework = require("../../../bdd-framework");
13
+ var _playwrightBdd = require("playwright-bdd");
15
14
  var _logger = require("../../../utils/logger");
16
15
  var _browserTypes = require("../constants/browserTypes");
17
- var _configFileNameProvider = require("../helpers/configFileNameProvider");
18
16
  var _fileUtils = require("../../../utils/fileUtils");
19
17
  /**
20
18
  ** Playwright project configuration
@@ -148,30 +146,15 @@ function getPathsForFeatureFiles(cwd) {
148
146
  function getTestDir(bddMode, cwd, {
149
147
  stepDefinitionsFolder
150
148
  }) {
151
- return bddMode ? (0, _bddFramework.defineBddConfig)({
152
- paths: getPathsForFeatureFiles(cwd),
153
- import: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js')],
149
+ return bddMode ? (0, _playwrightBdd.defineBddConfig)({
150
+ features: getPathsForFeatureFiles(cwd),
151
+ steps: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js'), require.resolve('../fixtures.js')],
152
+ importTestFrom: require.resolve('../fixtures.js'),
154
153
  featuresRoot: _path.default.join(cwd, 'uat'),
155
154
  outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
155
+ disableWarnings: {
156
+ importTestFrom: true
157
+ },
156
158
  publish: true
157
159
  }) : _path.default.join(cwd, 'uat');
158
- }
159
- function getTestUseOptions({
160
- viewport,
161
- trace,
162
- video,
163
- testIdAttribute
164
- }) {
165
- let defaultTestuseOptions = {
166
- viewport,
167
- testIdAttribute,
168
- trace: trace ? 'on' : 'off',
169
- video: video ? {
170
- mode: 'on',
171
- size: {
172
- ...viewport
173
- }
174
- } : 'off'
175
- };
176
- return defaultTestuseOptions;
177
160
  }
@@ -1,23 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _logger = require("../../utils/logger");
4
- function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
5
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
6
- function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
7
- var _buildTagsString = /*#__PURE__*/new WeakSet();
8
- var _parseEdition = /*#__PURE__*/new WeakSet();
9
- var _processSingleEdition = /*#__PURE__*/new WeakSet();
10
- var _processMultipleEditions = /*#__PURE__*/new WeakSet();
11
- var _getEditionArgs = /*#__PURE__*/new WeakSet();
12
- var _buildEditionTags = /*#__PURE__*/new WeakSet();
4
+ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
5
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
6
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
7
+ var _TagProcessor_brand = /*#__PURE__*/new WeakSet();
13
8
  class TagProcessor {
14
9
  constructor(editionOrder) {
15
- _classPrivateMethodInitSpec(this, _buildEditionTags);
16
- _classPrivateMethodInitSpec(this, _getEditionArgs);
17
- _classPrivateMethodInitSpec(this, _processMultipleEditions);
18
- _classPrivateMethodInitSpec(this, _processSingleEdition);
19
- _classPrivateMethodInitSpec(this, _parseEdition);
20
- _classPrivateMethodInitSpec(this, _buildTagsString);
10
+ _classPrivateMethodInitSpec(this, _TagProcessor_brand);
21
11
  this.editionOrder = editionOrder;
22
12
  }
23
13
  processTags(userArgs) {
@@ -25,36 +15,36 @@ class TagProcessor {
25
15
  const edition = userArgs['edition'] || null;
26
16
  if (!edition) return tagArgs;
27
17
  const editionsArray = edition.split(',');
28
- const editionTags = editionsArray.length === 1 ? _classPrivateMethodGet(this, _processSingleEdition, _processSingleEdition2).call(this, editionsArray[0], tagArgs) : _classPrivateMethodGet(this, _processMultipleEditions, _processMultipleEditions2).call(this, editionsArray, tagArgs);
18
+ const editionTags = editionsArray.length === 1 ? _assertClassBrand(_TagProcessor_brand, this, _processSingleEdition).call(this, editionsArray[0], tagArgs) : _assertClassBrand(_TagProcessor_brand, this, _processMultipleEditions).call(this, editionsArray, tagArgs);
29
19
  return editionTags;
30
20
  }
31
21
  }
32
- function _buildTagsString2(tags, editionTags) {
22
+ function _buildTagsString(tags, editionTags) {
33
23
  return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
34
24
  }
35
- function _parseEdition2(edition) {
25
+ function _parseEdition(edition) {
36
26
  if (edition.startsWith('<=')) return ['<=', edition.slice(2)];
37
27
  if (edition.startsWith('>=')) return ['>=', edition.slice(2)];
38
28
  if (edition.startsWith('<')) return ['<', edition.slice(1)];
39
29
  if (edition.startsWith('>')) return ['>', edition.slice(1)];
40
30
  return [null, edition];
41
31
  }
42
- function _processSingleEdition2(selectedEdition, tagArgs) {
43
- const editionArgs = _classPrivateMethodGet(this, _getEditionArgs, _getEditionArgs2).call(this, selectedEdition);
32
+ function _processSingleEdition(selectedEdition, tagArgs) {
33
+ const editionArgs = _assertClassBrand(_TagProcessor_brand, this, _getEditionArgs).call(this, selectedEdition);
44
34
  if (editionArgs && editionArgs.length > 0) {
45
- const editionTags = _classPrivateMethodGet(this, _buildEditionTags, _buildEditionTags2).call(this, editionArgs, 'or');
46
- return _classPrivateMethodGet(this, _buildTagsString, _buildTagsString2).call(this, tagArgs, editionTags);
35
+ const editionTags = _assertClassBrand(_TagProcessor_brand, this, _buildEditionTags).call(this, editionArgs, 'or');
36
+ return _assertClassBrand(_TagProcessor_brand, this, _buildTagsString).call(this, tagArgs, editionTags);
47
37
  }
48
38
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
49
39
  return tagArgs;
50
40
  }
51
- function _processMultipleEditions2(editionsArray, tagArgs) {
41
+ function _processMultipleEditions(editionsArray, tagArgs) {
52
42
  const filteredEditions = this.editionOrder.filter(edition => !editionsArray.includes(edition));
53
- const editionTags = _classPrivateMethodGet(this, _buildEditionTags, _buildEditionTags2).call(this, filteredEditions, 'or');
54
- return _classPrivateMethodGet(this, _buildTagsString, _buildTagsString2).call(this, tagArgs, editionTags);
43
+ const editionTags = _assertClassBrand(_TagProcessor_brand, this, _buildEditionTags).call(this, filteredEditions, 'or');
44
+ return _assertClassBrand(_TagProcessor_brand, this, _buildTagsString).call(this, tagArgs, editionTags);
55
45
  }
56
- function _getEditionArgs2(selectedEdition) {
57
- const [operator, editionValue] = _classPrivateMethodGet(this, _parseEdition, _parseEdition2).call(this, selectedEdition.toLowerCase());
46
+ function _getEditionArgs(selectedEdition) {
47
+ const [operator, editionValue] = _assertClassBrand(_TagProcessor_brand, this, _parseEdition).call(this, selectedEdition.toLowerCase());
58
48
  const index = this.editionOrder.findIndex(edition => edition.toLowerCase() === editionValue);
59
49
  if (index === -1) {
60
50
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
@@ -73,7 +63,7 @@ function _getEditionArgs2(selectedEdition) {
73
63
  return this.editionOrder.filter((_, i) => i !== index);
74
64
  }
75
65
  }
76
- function _buildEditionTags2(editionArgs, operator = 'or') {
66
+ function _buildEditionTags(editionArgs, operator = 'or') {
77
67
  return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
78
68
  }
79
69
  module.exports = TagProcessor;
@@ -20,30 +20,11 @@ var _browserTypes = require("./constants/browserTypes");
20
20
  var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
21
21
  var _Configuration = _interopRequireDefault(require("./configuration/Configuration"));
22
22
  var _UserArgs = _interopRequireDefault(require("./configuration/UserArgs"));
23
- function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
24
- const {
25
- browsers = null
26
- } = userArgsObject;
27
- let browserList = (0, _configUtils.getBrowsersList)(browsers);
28
- const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
29
- if (debug) {
30
- playwrightArgs.push('--debug');
31
- }
32
- if (!bddMode && tagArgs) {
33
- playwrightArgs.push('--grep');
34
- playwrightArgs.push(tagArgs);
35
- }
36
- if (!headless && !userArgsObject.headed) {
37
- playwrightArgs.push('--headed');
38
- }
39
- if (browserList && browserList.length > 0) {
40
- browserList.map(browser => playwrightArgs.push(`--project=${_browserTypes.BROWSER_PROJECT_MAPPING[browser.toUpperCase()]}`));
41
- }
42
- return playwrightArgs;
43
- }
23
+ var _RunnerHelper = _interopRequireDefault(require("./runner/RunnerHelper"));
24
+ var _Runner = _interopRequireDefault(require("./runner/Runner"));
44
25
  function runPreprocessing(tagArgs, configPath) {
45
26
  const beforeCommand = 'node';
46
- const bddGenPath = _path.default.resolve(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js');
27
+ const bddGenPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('bddgen'));
47
28
  const beforeArgs = [bddGenPath, '-c', configPath];
48
29
  if (tagArgs) {
49
30
  beforeArgs.push('--tags');
@@ -124,18 +105,11 @@ function main() {
124
105
  const userArgsObject = userArgConfig.getAll();
125
106
  const tagProcessor = new _tagProcessor.default(editionOrder);
126
107
  const tagArgs = tagProcessor.processTags(userArgsObject);
127
- const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
128
- const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
129
- const command = playwrightPath;
130
- const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
131
- const args = ['test', '--config', configPath].concat(playwrightArgs);
132
- let promises = [];
133
- if (bddMode) {
134
- promises.push(runPreprocessing(tagArgs, configPath));
135
- }
136
- Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
137
- _logger.Logger.error(err);
138
- process.exit();
139
- });
108
+ const runnerObj = new _Runner.default();
109
+ runnerObj.setTagArgs(tagArgs);
110
+ runnerObj.setUserArgs(userArgsObject);
111
+ runnerObj.setConfig(uatConfig);
112
+ const runner = _RunnerHelper.default.createRunner('spawn', runnerObj);
113
+ runner.run();
140
114
  }
141
115
  var _default = exports.default = main;
@@ -1 +1 @@
1
- export * from './bdd-framework/decorators';
1
+ export * from 'playwright-bdd/decorators';