@zohodesk/testinglibrary 2.9.1 → 3.0.2

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 (136) hide show
  1. package/.gitlab-ci.yml +16 -23
  2. package/README.md +32 -1
  3. package/build/core/playwright/constants/fileMutexConfig.js +11 -0
  4. package/build/core/playwright/fixtures.js +24 -0
  5. package/build/core/playwright/helpers/auth/checkAuthCookies.js +2 -8
  6. package/build/core/playwright/helpers/auth/loginSteps.js +25 -18
  7. package/build/core/playwright/helpers/checkAuthDirectory.js +17 -0
  8. package/build/core/playwright/helpers/fileMutex.js +58 -0
  9. package/build/core/playwright/index.js +10 -23
  10. package/build/core/playwright/setup/config-creator.js +3 -3
  11. package/build/core/playwright/setup/config-utils.js +8 -25
  12. package/build/core/playwright/test-runner.js +1 -1
  13. package/build/decorators.d.ts +1 -1
  14. package/build/decorators.js +1 -1
  15. package/build/setup-folder-structure/samples/actors-index.js +2 -0
  16. package/build/setup-folder-structure/samples/auth-setup-sample.js +14 -66
  17. package/build/setup-folder-structure/samples/editions-index.js +3 -0
  18. package/build/setup-folder-structure/samples/free-sample.json +25 -0
  19. package/build/setup-folder-structure/samples/settings.json +7 -0
  20. package/build/setup-folder-structure/setupProject.js +18 -5
  21. package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +94 -0
  22. package/nobdd/uat/conf/default/actors/index.js +1 -4
  23. package/nobdd/uat/conf/default/settings.json +1 -1
  24. package/nobdd/uat/conf/nobdd/uat.config.js +11 -4
  25. package/nobdd/uat/env-config.json +3 -3
  26. package/nobdd/uat/fixtures/setup.teardown.js +2 -1
  27. package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +3 -3
  28. package/nobdd/uat.config.js +8 -3
  29. package/package.json +8 -7
  30. package/build/bdd-framework/cli/commands/env.js +0 -42
  31. package/build/bdd-framework/cli/commands/export.js +0 -62
  32. package/build/bdd-framework/cli/commands/test.js +0 -64
  33. package/build/bdd-framework/cli/index.js +0 -11
  34. package/build/bdd-framework/cli/options.js +0 -19
  35. package/build/bdd-framework/cli/worker.js +0 -13
  36. package/build/bdd-framework/config/configDir.js +0 -35
  37. package/build/bdd-framework/config/enrichReporterData.js +0 -23
  38. package/build/bdd-framework/config/env.js +0 -50
  39. package/build/bdd-framework/config/index.js +0 -94
  40. package/build/bdd-framework/config/lang.js +0 -14
  41. package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -43
  42. package/build/bdd-framework/cucumber/createTestStep.js +0 -43
  43. package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +0 -126
  44. package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +0 -72
  45. package/build/bdd-framework/cucumber/formatter/PickleParser.js +0 -25
  46. package/build/bdd-framework/cucumber/formatter/durationHelpers.js +0 -13
  47. package/build/bdd-framework/cucumber/formatter/getColorFns.js +0 -57
  48. package/build/bdd-framework/cucumber/formatter/index.js +0 -16
  49. package/build/bdd-framework/cucumber/formatter/locationHelpers.js +0 -16
  50. package/build/bdd-framework/cucumber/loadConfig.js +0 -17
  51. package/build/bdd-framework/cucumber/loadFeatures.js +0 -70
  52. package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
  53. package/build/bdd-framework/cucumber/loadSteps.js +0 -47
  54. package/build/bdd-framework/cucumber/resolveFeaturePaths.js +0 -62
  55. package/build/bdd-framework/cucumber/stepArguments.js +0 -21
  56. package/build/bdd-framework/cucumber/types.js +0 -5
  57. package/build/bdd-framework/cucumber/valueChecker.js +0 -23
  58. package/build/bdd-framework/decorators.js +0 -18
  59. package/build/bdd-framework/gen/fixtures.js +0 -48
  60. package/build/bdd-framework/gen/formatter.js +0 -167
  61. package/build/bdd-framework/gen/i18n.js +0 -39
  62. package/build/bdd-framework/gen/index.js +0 -197
  63. package/build/bdd-framework/gen/specialTags.js +0 -70
  64. package/build/bdd-framework/gen/testFile.js +0 -470
  65. package/build/bdd-framework/gen/testMeta.js +0 -60
  66. package/build/bdd-framework/gen/testNode.js +0 -35
  67. package/build/bdd-framework/gen/testPoms.js +0 -133
  68. package/build/bdd-framework/hooks/scenario.js +0 -130
  69. package/build/bdd-framework/hooks/worker.js +0 -89
  70. package/build/bdd-framework/index.js +0 -52
  71. package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -93
  72. package/build/bdd-framework/playwright/getLocationInFile.js +0 -79
  73. package/build/bdd-framework/playwright/loadConfig.js +0 -42
  74. package/build/bdd-framework/playwright/loadUtils.js +0 -33
  75. package/build/bdd-framework/playwright/testTypeImpl.js +0 -79
  76. package/build/bdd-framework/playwright/transform.js +0 -88
  77. package/build/bdd-framework/playwright/types.js +0 -12
  78. package/build/bdd-framework/playwright/utils.js +0 -56
  79. package/build/bdd-framework/reporter/cucumber/base.js +0 -52
  80. package/build/bdd-framework/reporter/cucumber/custom.js +0 -73
  81. package/build/bdd-framework/reporter/cucumber/helper.js +0 -12
  82. package/build/bdd-framework/reporter/cucumber/html.js +0 -40
  83. package/build/bdd-framework/reporter/cucumber/index.js +0 -74
  84. package/build/bdd-framework/reporter/cucumber/json.js +0 -312
  85. package/build/bdd-framework/reporter/cucumber/junit.js +0 -205
  86. package/build/bdd-framework/reporter/cucumber/message.js +0 -20
  87. package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +0 -82
  88. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +0 -197
  89. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +0 -43
  90. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +0 -52
  91. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +0 -105
  92. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +0 -70
  93. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +0 -45
  94. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +0 -27
  95. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +0 -38
  96. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +0 -128
  97. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +0 -154
  98. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +0 -123
  99. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +0 -67
  100. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +0 -114
  101. package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +0 -30
  102. package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwStepUtils.js +0 -70
  103. package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +0 -35
  104. package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +0 -5
  105. package/build/bdd-framework/run/StepInvoker.js +0 -69
  106. package/build/bdd-framework/run/bddData/index.js +0 -59
  107. package/build/bdd-framework/run/bddData/types.js +0 -5
  108. package/build/bdd-framework/run/bddFixtures.js +0 -192
  109. package/build/bdd-framework/run/bddWorld.js +0 -79
  110. package/build/bdd-framework/run/bddWorldInternal.js +0 -11
  111. package/build/bdd-framework/snippets/index.js +0 -132
  112. package/build/bdd-framework/snippets/snippetSyntax.js +0 -43
  113. package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -26
  114. package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
  115. package/build/bdd-framework/stepDefinitions/createBdd.js +0 -66
  116. package/build/bdd-framework/stepDefinitions/decorators/class.js +0 -68
  117. package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -99
  118. package/build/bdd-framework/stepDefinitions/defineStep.js +0 -62
  119. package/build/bdd-framework/stepDefinitions/stepConfig.js +0 -24
  120. package/build/bdd-framework/steps/createBdd.js +0 -78
  121. package/build/bdd-framework/steps/decorators/class.js +0 -68
  122. package/build/bdd-framework/steps/decorators/steps.js +0 -98
  123. package/build/bdd-framework/steps/defineStep.js +0 -62
  124. package/build/bdd-framework/steps/stepConfig.js +0 -24
  125. package/build/bdd-framework/utils/AutofillMap.js +0 -20
  126. package/build/bdd-framework/utils/exit.js +0 -62
  127. package/build/bdd-framework/utils/index.js +0 -93
  128. package/build/bdd-framework/utils/jsStringWrap.js +0 -44
  129. package/build/bdd-framework/utils/logger.js +0 -30
  130. package/build/bdd-framework/utils/stripAnsiEscapes.js +0 -20
  131. package/build/setup-folder-structure/samples/authUsers-sample.json +0 -9
  132. package/build/setup-folder-structure/samples/env-config-sample.json +0 -21
  133. package/nobdd/uat/conf/default/actors/beta/custom-module.json +0 -24
  134. package/nobdd/uat/conf/default/actors/beta/index.js +0 -6
  135. package/nobdd/uat/conf/default/actors/beta/parent-child.json +0 -24
  136. package/npm-shrinkwrap.json +0 -6475
@@ -1,133 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TestPoms = void 0;
7
- exports.buildFixtureTag = buildFixtureTag;
8
- var _class = require("../steps/decorators/class");
9
- var _exit = require("../utils/exit");
10
- /**
11
- * Track PomNodes used in the particular test.
12
- * To select correct fixture for decorator steps.
13
- *
14
- * Idea: try to use the deepest child fixture for parent steps.
15
- *
16
- * Example inheritance tree:
17
- * A
18
- * / \
19
- * B C
20
- * / \ \
21
- * D E F
22
- *
23
- * If test uses steps from classes A and D:
24
- * -> resolved fixture will be D, even for steps from A.
25
- *
26
- * If test uses steps from classes A, D and C:
27
- * -> error, b/c A has 2 possible fixtures.
28
- *
29
- * If test uses steps from classes A and C, but @fixture tag is D:
30
- * -> error, b/c A has 2 possible fixtures.
31
- */
32
-
33
- const FIXTURE_TAG_PREFIX = '@fixture:';
34
- class TestPoms {
35
- title;
36
- // map of poms used in test
37
- usedPoms = new Map();
38
- constructor(title) {
39
- this.title = title;
40
- }
41
- addByStep(pomNode) {
42
- this.addUsedPom(pomNode, {
43
- byTag: false
44
- });
45
- }
46
- addByFixtureName(fixtureName) {
47
- const pomNode = (0, _class.getPomNodeByFixtureName)(fixtureName);
48
- this.addUsedPom(pomNode, {
49
- byTag: false
50
- });
51
- }
52
- addByTag(tag) {
53
- const fixtureName = extractFixtureName(tag);
54
- if (fixtureName) {
55
- const pomNode = (0, _class.getPomNodeByFixtureName)(fixtureName);
56
- this.addUsedPom(pomNode, {
57
- byTag: true
58
- });
59
- }
60
- }
61
- /**
62
- * Resolve all used pomNodes to fixtures.
63
- * This is needed to handle @fixture: tagged pomNodes
64
- * that does not have steps in the test, but should be considered.
65
- */
66
- resolveFixtures() {
67
- this.usedPoms.forEach((_, pomNode) => {
68
- this.getResolvedFixtures(pomNode);
69
- });
70
- }
71
- /**
72
- * Returns fixtures suitable for particular pomNode (actually for step)
73
- */
74
- getResolvedFixtures(pomNode) {
75
- const usedPom = this.usedPoms.get(pomNode);
76
- if (usedPom !== null && usedPom !== void 0 && usedPom.fixtures) {
77
- return usedPom.fixtures;
78
- }
79
- // Recursively resolve children fixtures, used in test.
80
- let childFixtures = [...pomNode.children].map(child => this.getResolvedFixtures(child)).flat();
81
- if (!usedPom) {
82
- return childFixtures;
83
- }
84
- if (childFixtures.length) {
85
- this.verifyChildFixtures(pomNode, usedPom, childFixtures);
86
- usedPom.fixtures = childFixtures;
87
- } else {
88
- usedPom.fixtures = [{
89
- name: pomNode.fixtureName,
90
- byTag: usedPom.byTag
91
- }];
92
- }
93
- return usedPom.fixtures;
94
- }
95
- addUsedPom(pomNode, {
96
- byTag
97
- }) {
98
- if (!pomNode) {
99
- return;
100
- }
101
- const usedPom = this.usedPoms.get(pomNode);
102
- if (usedPom) {
103
- if (byTag && !usedPom.byTag) {
104
- usedPom.byTag = true;
105
- }
106
- } else {
107
- this.usedPoms.set(pomNode, {
108
- byTag
109
- });
110
- }
111
- }
112
- /**
113
- * For scenarios with @fixture:xxx tags verify that there are no steps from fixtures,
114
- * deeper than xxx.
115
- * @fixture:xxx tag provides maximum fixture that can be used in the scenario.
116
- */
117
- verifyChildFixtures(pomNode, usedPom, childFixtures) {
118
- if (!usedPom.byTag) {
119
- return;
120
- }
121
- const childFixturesBySteps = childFixtures.filter(f => !f.byTag);
122
- if (childFixturesBySteps.length) {
123
- (0, _exit.exit)(`Scenario "${this.title}" contains ${childFixturesBySteps.length} step(s)`, `not compatible with required fixture "${pomNode.fixtureName}"`);
124
- }
125
- }
126
- }
127
- exports.TestPoms = TestPoms;
128
- function extractFixtureName(tag) {
129
- return tag.startsWith(FIXTURE_TAG_PREFIX) ? tag.replace(FIXTURE_TAG_PREFIX, '') : '';
130
- }
131
- function buildFixtureTag(fixtureName) {
132
- return `${FIXTURE_TAG_PREFIX}${fixtureName}`;
133
- }
@@ -1,130 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getScenarioHooksFixtures = getScenarioHooksFixtures;
8
- exports.hasScenarioHooks = hasScenarioHooks;
9
- exports.runScenarioHooks = runScenarioHooks;
10
- exports.scenarioHookFactory = scenarioHookFactory;
11
- var _tagExpressions = _interopRequireDefault(require("@cucumber/tag-expressions"));
12
- var _fixtureParameterNames = require("../playwright/fixtureParameterNames");
13
- var _utils = require("../utils");
14
- var _getLocationInFile = require("../playwright/getLocationInFile");
15
- var _testTypeImpl = require("../playwright/testTypeImpl");
16
- /**
17
- * Scenario level hooks: Before / After.
18
- *
19
- * before(async ({ page }) => {})
20
- */
21
-
22
- const scenarioHooks = [];
23
- let scenarioHooksFixtures;
24
- /**
25
- * Returns Before() / After() functions.
26
- */
27
- function scenarioHookFactory(type) {
28
- return (...args) => {
29
- addHook({
30
- type,
31
- options: getOptionsFromArgs(args),
32
- fn: getFnFromArgs(args),
33
- // offset = 3 b/c this call is 3 steps below the user's code
34
- location: (0, _getLocationInFile.getLocationByOffset)(3)
35
- });
36
- };
37
- }
38
- function hasScenarioHooks() {
39
- return scenarioHooks.length > 0;
40
- }
41
- // eslint-disable-next-line complexity, max-statements
42
- async function runScenarioHooks(type, fixtures) {
43
- let error;
44
- for (const hook of scenarioHooks) {
45
- if (hook.type !== type) {
46
- continue;
47
- }
48
- if (hook.tagsExpression && !hook.tagsExpression.evaluate(fixtures.$tags)) {
49
- continue;
50
- }
51
- try {
52
- const hookFn = wrapHookFn(hook, fixtures);
53
- await (0, _testTypeImpl.runStepWithCustomLocation)(fixtures.$bddWorld.test, hook.options.name || '', hook.location, hookFn);
54
- } catch (e) {
55
- if (type === 'before') {
56
- throw e;
57
- }
58
- if (!error) {
59
- error = e;
60
- }
61
- }
62
- }
63
- if (error) {
64
- throw error;
65
- }
66
- }
67
- function getScenarioHooksFixtures() {
68
- if (!scenarioHooksFixtures) {
69
- const fixturesFakeObj = {
70
- $bddWorld: null,
71
- $tags: null,
72
- $testInfo: null
73
- };
74
- const set = new Set();
75
- scenarioHooks.forEach(hook => {
76
- (0, _fixtureParameterNames.fixtureParameterNames)(hook.fn).filter(fixtureName => !Object.prototype.hasOwnProperty.call(fixturesFakeObj, fixtureName)).forEach(fixtureName => set.add(fixtureName));
77
- });
78
- scenarioHooksFixtures = [...set];
79
- }
80
- return scenarioHooksFixtures;
81
- }
82
- /**
83
- * Wraps hook fn with timeout and waiting Cucumber attachments to fulfill.
84
- */
85
- function wrapHookFn(hook, fixtures) {
86
- const {
87
- timeout
88
- } = hook.options;
89
- const {
90
- $bddWorld
91
- } = fixtures;
92
- return async () => {
93
- await (0, _utils.callWithTimeout)(() => hook.fn.call($bddWorld, fixtures), timeout, getTimeoutMessage(hook));
94
- };
95
- }
96
- function getOptionsFromArgs(args) {
97
- if (typeof args[0] === 'string') {
98
- return {
99
- tags: args[0]
100
- };
101
- }
102
- if (typeof args[0] === 'object') {
103
- return args[0];
104
- }
105
- return {};
106
- }
107
- function getFnFromArgs(args) {
108
- return args.length === 1 ? args[0] : args[1];
109
- }
110
- function setTagsExpression(hook) {
111
- if (hook.options.tags) {
112
- hook.tagsExpression = (0, _tagExpressions.default)(hook.options.tags);
113
- }
114
- }
115
- function addHook(hook) {
116
- setTagsExpression(hook);
117
- if (hook.type === 'before') {
118
- scenarioHooks.push(hook);
119
- } else {
120
- // 'after' hooks run in reverse order
121
- scenarioHooks.unshift(hook);
122
- }
123
- }
124
- function getTimeoutMessage(hook) {
125
- const {
126
- timeout,
127
- name: hookName
128
- } = hook.options;
129
- return `${hook.type} hook ${hookName ? `"${hookName}" ` : ''}timeout (${timeout} ms)`;
130
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getWorkerHooksFixtures = getWorkerHooksFixtures;
7
- exports.runWorkerHooks = runWorkerHooks;
8
- exports.workerHookFactory = workerHookFactory;
9
- var _fixtureParameterNames = require("../playwright/fixtureParameterNames");
10
- var _utils = require("../utils");
11
- /**
12
- * Worker-level hooks: BeforeAll / AfterAll.
13
- */
14
-
15
- const workerHooks = [];
16
- let workerHooksFixtures;
17
- /**
18
- * Returns BeforeAll() / AfterAll() functions.
19
- */
20
- function workerHookFactory(type) {
21
- return (...args) => {
22
- addHook({
23
- type,
24
- options: getOptionsFromArgs(args),
25
- fn: getFnFromArgs(args)
26
- });
27
- };
28
- }
29
- // eslint-disable-next-line complexity
30
- async function runWorkerHooks(type, fixtures) {
31
- let error;
32
- for (const hook of workerHooks) {
33
- if (hook.type !== type) {
34
- continue;
35
- }
36
- const {
37
- timeout
38
- } = hook.options;
39
- try {
40
- await (0, _utils.callWithTimeout)(() => hook.fn(fixtures), timeout, getTimeoutMessage(hook));
41
- } catch (e) {
42
- if (type === 'beforeAll') {
43
- throw e;
44
- }
45
- if (!error) {
46
- error = e;
47
- }
48
- }
49
- }
50
- if (error) {
51
- throw error;
52
- }
53
- }
54
- function getWorkerHooksFixtures() {
55
- if (!workerHooksFixtures) {
56
- const fixturesFakeObj = {
57
- $workerInfo: null
58
- };
59
- const set = new Set();
60
- workerHooks.forEach(hook => {
61
- (0, _fixtureParameterNames.fixtureParameterNames)(hook.fn).filter(fixtureName => !Object.prototype.hasOwnProperty.call(fixturesFakeObj, fixtureName)).forEach(fixtureName => set.add(fixtureName));
62
- });
63
- workerHooksFixtures = [...set];
64
- }
65
- return workerHooksFixtures;
66
- }
67
- function getOptionsFromArgs(args) {
68
- if (typeof args[0] === 'object') {
69
- return args[0];
70
- }
71
- return {};
72
- }
73
- function getFnFromArgs(args) {
74
- return args.length === 1 ? args[0] : args[1];
75
- }
76
- function addHook(hook) {
77
- if (hook.type === 'beforeAll') {
78
- workerHooks.push(hook);
79
- } else {
80
- // 'afterAll' hooks run in reverse order
81
- workerHooks.unshift(hook);
82
- }
83
- }
84
- function getTimeoutMessage(hook) {
85
- const {
86
- timeout
87
- } = hook.options;
88
- return `${hook.type} hook timeout (${timeout} ms)`;
89
- }
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BDDInputConfig", {
7
- enumerable: true,
8
- get: function () {
9
- return _config.BDDInputConfig;
10
- }
11
- });
12
- Object.defineProperty(exports, "BddWorld", {
13
- enumerable: true,
14
- get: function () {
15
- return _bddWorld.BddWorld;
16
- }
17
- });
18
- Object.defineProperty(exports, "BddWorldOptions", {
19
- enumerable: true,
20
- get: function () {
21
- return _bddWorld.BddWorldOptions;
22
- }
23
- });
24
- Object.defineProperty(exports, "createBdd", {
25
- enumerable: true,
26
- get: function () {
27
- return _createBdd.createBdd;
28
- }
29
- });
30
- Object.defineProperty(exports, "cucumberReporter", {
31
- enumerable: true,
32
- get: function () {
33
- return _helper.cucumberReporter;
34
- }
35
- });
36
- Object.defineProperty(exports, "defineBddConfig", {
37
- enumerable: true,
38
- get: function () {
39
- return _config.defineBddConfig;
40
- }
41
- });
42
- Object.defineProperty(exports, "test", {
43
- enumerable: true,
44
- get: function () {
45
- return _bddFixtures.test;
46
- }
47
- });
48
- var _config = require("./config");
49
- var _createBdd = require("./steps/createBdd");
50
- var _bddFixtures = require("./run/bddFixtures");
51
- var _bddWorld = require("./run/bddWorld");
52
- var _helper = require("./reporter/cucumber/helper");
@@ -1,93 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fixtureParameterNames = fixtureParameterNames;
7
- /**
8
- * Extracted from playwright.
9
- * https://github.com/microsoft/playwright/blob/main/packages/playwright-test/src/common/fixtures.ts#L226
10
- */
11
- /* eslint-disable max-statements, complexity, max-len, max-depth */
12
- const signatureSymbol = Symbol('signature');
13
- function fixtureParameterNames(fn) {
14
- if (typeof fn !== 'function') {
15
- return [];
16
- }
17
- if (!fn[signatureSymbol]) {
18
- fn[signatureSymbol] = innerFixtureParameterNames(fn);
19
- }
20
- return fn[signatureSymbol];
21
- }
22
- function innerFixtureParameterNames(fn) {
23
- const text = filterOutComments(fn.toString());
24
- const match = text.match(/(?:async)?(?:\s+function)?[^(]*\(([^)]*)/);
25
- if (!match) {
26
- return [];
27
- }
28
- const trimmedParams = match[1].trim();
29
- if (!trimmedParams) {
30
- return [];
31
- }
32
- const [firstParam] = splitByComma(trimmedParams);
33
- if (firstParam[0] !== '{' || firstParam[firstParam.length - 1] !== '}') {
34
- throw new Error('First argument must use the object destructuring pattern: ' + firstParam + ' ' + fn.toString());
35
- }
36
- const props = splitByComma(firstParam.substring(1, firstParam.length - 1)).map(prop => {
37
- const colon = prop.indexOf(':');
38
- return colon === -1 ? prop.trim() : prop.substring(0, colon).trim();
39
- });
40
- const restProperty = props.find(prop => prop.startsWith('...'));
41
- if (restProperty) {
42
- throw new Error(`Rest property "${restProperty}" is not supported. List all used fixtures explicitly, separated by comma. ${fn.toString()}`);
43
- }
44
- return props;
45
- }
46
- function filterOutComments(s) {
47
- const result = [];
48
- let commentState = 'none';
49
- for (let i = 0; i < s.length; ++i) {
50
- if (commentState === 'singleline') {
51
- if (s[i] === '\n') {
52
- commentState = 'none';
53
- }
54
- } else if (commentState === 'multiline') {
55
- if (s[i - 1] === '*' && s[i] === '/') {
56
- commentState = 'none';
57
- }
58
- } else if (commentState === 'none') {
59
- if (s[i] === '/' && s[i + 1] === '/') {
60
- commentState = 'singleline';
61
- } else if (s[i] === '/' && s[i + 1] === '*') {
62
- commentState = 'multiline';
63
- i += 2;
64
- } else {
65
- result.push(s[i]);
66
- }
67
- }
68
- }
69
- return result.join('');
70
- }
71
- function splitByComma(s) {
72
- const result = [];
73
- const stack = [];
74
- let start = 0;
75
- for (let i = 0; i < s.length; i++) {
76
- if (s[i] === '{' || s[i] === '[') {
77
- stack.push(s[i] === '{' ? '}' : ']');
78
- } else if (s[i] === stack[stack.length - 1]) {
79
- stack.pop();
80
- } else if (!stack.length && s[i] === ',') {
81
- const token = s.substring(start, i).trim();
82
- if (token) {
83
- result.push(token);
84
- }
85
- start = i + 1;
86
- }
87
- }
88
- const lastToken = s.substring(start).trim();
89
- if (lastToken) {
90
- result.push(lastToken);
91
- }
92
- return result;
93
- }
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getLocationByOffset = getLocationByOffset;
8
- exports.getLocationInFile = getLocationInFile;
9
- var _url = _interopRequireDefault(require("url"));
10
- var _utils = require("./utils");
11
- /**
12
- * Finds first frame in the callstack that matches provided file.
13
- * Constructs location object from that frame.
14
- *
15
- * Example:
16
- * Calling getLocationInFile('file-3.js');
17
- * Call stack:
18
- * - at <anonymous> (file-1.js:1:2)
19
- * - at myFunction2 (file-2.js:3:4)
20
- * - at myFunction3 (file-3.js:5:6)
21
- * - at myFunction4 (file-4.js:7:8)
22
- *
23
- * Returned value: { file: 'file-3.js', line: 5, column: 6 }
24
- */
25
- function getLocationInFile(filePath) {
26
- const filePathUrl = _url.default.pathToFileURL(filePath).toString();
27
- return getLocationBy(stackFrames => {
28
- return stackFrames.find(frame => {
29
- const frameFile = frame.getFileName();
30
- return frameFile === filePath || frameFile === filePathUrl;
31
- });
32
- });
33
- }
34
- function getLocationByOffset(offset) {
35
- return getLocationBy(stackFrames => stackFrames[offset]);
36
- }
37
- /**
38
- * Iterates stacktrace of the call of this function
39
- * and finds frame using provided findFrame predicate.
40
- * Constructs location object from the found frame.
41
- *
42
- * This function is based on Playwright's wrapFunctionWithLocation().
43
- * See: https://github.com/microsoft/playwright/blob/main/packages/playwright/src/transform/transform.ts#L261
44
- */
45
- function getLocationBy(findFrame) {
46
- const {
47
- sourceMapSupport
48
- } = (0, _utils.requirePlaywrightModule)('lib/utilsBundle.js');
49
- const oldPrepareStackTrace = Error.prepareStackTrace;
50
- // modify prepareStackTrace to return Location object instead of string
51
- Error.prepareStackTrace = (error, stackFrames) => {
52
- const foundFrame = findFrame(stackFrames);
53
- if (!foundFrame) {
54
- return {
55
- file: '',
56
- line: 0,
57
- column: 0
58
- };
59
- }
60
- const frame = sourceMapSupport.wrapCallSite(foundFrame);
61
- const fileName = frame.getFileName();
62
- // Node error stacks for modules use file:// urls instead of paths.
63
- const file = fileName !== null && fileName !== void 0 && fileName.startsWith('file://') ? _url.default.fileURLToPath(fileName) : fileName;
64
- return {
65
- file,
66
- line: frame.getLineNumber(),
67
- column: frame.getColumnNumber()
68
- };
69
- };
70
- // commented stackTraceLImit modification, todo: check if it has perf impact
71
- // const oldStackTraceLimit = Error.stackTraceLimit;
72
- // Error.stackTraceLimit = level + 1;
73
- const obj = {};
74
- Error.captureStackTrace(obj);
75
- const location = obj.stack;
76
- // Error.stackTraceLimit = oldStackTraceLimit;
77
- Error.prepareStackTrace = oldPrepareStackTrace;
78
- return location;
79
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.loadConfig = loadConfig;
8
- exports.resolveConfigFile = resolveConfigFile;
9
- var _path = _interopRequireDefault(require("path"));
10
- var _fs = _interopRequireDefault(require("fs"));
11
- var _utils = require("./utils");
12
- var _transform = require("./transform");
13
- var _exit = require("../utils/exit");
14
- /**
15
- * Loading Playwright config.
16
- * See: https://github.com/microsoft/playwright/blob/main/packages/playwright-test/src/common/configLoader.ts
17
- */
18
-
19
- async function loadConfig(cliConfigPath) {
20
- const resolvedConfigFile = resolveConfigFile(cliConfigPath);
21
- assertConfigFileExists(resolvedConfigFile, cliConfigPath);
22
- await (0, _transform.requireTransform)().requireOrImport(resolvedConfigFile);
23
- return {
24
- resolvedConfigFile
25
- };
26
- }
27
- function resolveConfigFile(cliConfigPath) {
28
- const {
29
- resolveConfigFile
30
- } = (0, _utils.requirePlaywrightModule)('lib/common/configLoader.js');
31
- const configFileOrDirectory = getConfigFilePath(cliConfigPath);
32
- return resolveConfigFile(configFileOrDirectory) || '';
33
- }
34
- function getConfigFilePath(cliConfigPath) {
35
- return cliConfigPath ? _path.default.resolve(process.cwd(), cliConfigPath) : process.cwd();
36
- }
37
- function assertConfigFileExists(resolvedConfigFile, cliConfigPath) {
38
- if (!resolvedConfigFile || !_fs.default.existsSync(resolvedConfigFile)) {
39
- const configFilePath = getConfigFilePath(cliConfigPath);
40
- (0, _exit.exit)(`Can't find Playwright config file in: ${configFilePath}`);
41
- }
42
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.requireOrImportDefaultFunction = requireOrImportDefaultFunction;
8
- var _path = _interopRequireDefault(require("path"));
9
- var _transform = require("./transform");
10
- /**
11
- * Partial from: https://github.com/microsoft/playwright/blob/main/packages/playwright/src/runner/loadUtils.ts
12
- */
13
- /* eslint-disable complexity */
14
-
15
- async function requireOrImportDefaultFunction(file, expectConstructor) {
16
- let func = await (0, _transform.requireTransform)().requireOrImport(file);
17
- if (func && typeof func === 'object' && 'default' in func) {
18
- func = func['default'];
19
- }
20
- if (typeof func !== 'function') {
21
- throw errorWithFile(file, `file must export a single ${expectConstructor ? 'class' : 'function'}.`);
22
- }
23
- return func;
24
- }
25
- function relativeFilePath(file) {
26
- if (!_path.default.isAbsolute(file)) {
27
- return file;
28
- }
29
- return _path.default.relative(process.cwd(), file);
30
- }
31
- function errorWithFile(file, message) {
32
- return new Error(`${relativeFilePath(file)}: ${message}`);
33
- }