@zohodesk/testinglibrary 0.3.0-experimental → 0.3.0
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.
- package/.gitlab-ci.yml +111 -0
- package/README.md +39 -1
- package/build/core/playwright/builtInFixtures/page.js +1 -1
- package/build/core/playwright/configuration/Configuration.js +25 -0
- package/build/core/playwright/configuration/ConfigurationHelper.js +43 -0
- package/build/core/playwright/configuration/UserArgs.js +12 -0
- package/build/core/playwright/env-initializer.js +0 -1
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/auth/getUsers.js +23 -11
- package/build/core/playwright/helpers/configFileNameProvider.js +9 -3
- package/build/core/playwright/helpers/parseUserArgs.js +2 -3
- package/build/core/playwright/index.js +10 -23
- package/build/core/playwright/readConfigFile.js +23 -21
- package/build/core/playwright/setup/config-creator.js +9 -8
- package/build/core/playwright/setup/config-utils.js +8 -25
- package/build/core/playwright/setup/custom-reporter.js +39 -13
- package/build/core/playwright/tagProcessor.js +69 -0
- package/build/core/playwright/test-runner.js +28 -12
- package/build/core/playwright/validateFeature.js +28 -0
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +1 -1
- package/build/lib/cli.js +6 -0
- package/build/setup-folder-structure/samples/actors-index.js +3 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +14 -66
- package/build/setup-folder-structure/samples/editions-index.js +3 -0
- package/build/setup-folder-structure/samples/free-sample.json +25 -0
- package/build/setup-folder-structure/samples/settings.json +7 -0
- package/build/setup-folder-structure/setupProject.js +18 -5
- package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
- package/build/test/core/playwright/__tests__/validateFeature.test.js +69 -0
- package/build/test/core/playwright/configuration/__tests__/Configuration.test.js +53 -0
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +34 -0
- package/build/utils/cliArgsToObject.js +3 -0
- package/jest.config.js +19 -9
- package/nobdd/README.md +1 -0
- package/nobdd/package.json +17 -0
- package/nobdd/uat/conf/default/actors/beta/custom-module.json +24 -0
- package/nobdd/uat/conf/default/actors/beta/index.js +6 -0
- package/nobdd/uat/conf/default/actors/beta/parent-child.json +24 -0
- package/nobdd/uat/conf/default/actors/editions/enterprise.json +24 -0
- package/nobdd/uat/conf/default/actors/editions/index.js +4 -0
- package/nobdd/uat/conf/default/actors/index.js +5 -0
- package/nobdd/uat/conf/default/settings.json +6 -0
- package/nobdd/uat/conf/nobdd/uat.config.js +28 -0
- package/nobdd/uat/env-config.json +20 -0
- package/nobdd/uat/fixtures/auth.setup.js +44 -0
- package/nobdd/uat/fixtures/setup.teardown.js +32 -0
- package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +16 -0
- package/nobdd/uat/shared/commands/_index-custom-fixtures.js +9 -0
- package/nobdd/uat/shared/commands/i18n.js +25 -0
- package/nobdd/uat/shared/commands/unauthenticatedPage.js +8 -0
- package/nobdd/uat/shared/index.js +7 -0
- package/nobdd/uat/shared/onboardings/onboardingUpdate.js +44 -0
- package/nobdd/uat/shared/url-helpers/getUrlOrigin.js +6 -0
- package/nobdd/uat.config.js +30 -0
- package/npm-shrinkwrap.json +5795 -2145
- package/package.json +7 -7
- package/playwright.config.js +1 -1
- package/build/bdd-framework/cli/commands/env.js +0 -42
- package/build/bdd-framework/cli/commands/export.js +0 -62
- package/build/bdd-framework/cli/commands/test.js +0 -64
- package/build/bdd-framework/cli/index.js +0 -11
- package/build/bdd-framework/cli/options.js +0 -19
- package/build/bdd-framework/cli/worker.js +0 -13
- package/build/bdd-framework/config/configDir.js +0 -35
- package/build/bdd-framework/config/enrichReporterData.js +0 -23
- package/build/bdd-framework/config/env.js +0 -50
- package/build/bdd-framework/config/index.js +0 -94
- package/build/bdd-framework/config/lang.js +0 -14
- package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -43
- package/build/bdd-framework/cucumber/createTestStep.js +0 -43
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +0 -126
- package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +0 -72
- package/build/bdd-framework/cucumber/formatter/PickleParser.js +0 -25
- package/build/bdd-framework/cucumber/formatter/durationHelpers.js +0 -13
- package/build/bdd-framework/cucumber/formatter/getColorFns.js +0 -57
- package/build/bdd-framework/cucumber/formatter/index.js +0 -16
- package/build/bdd-framework/cucumber/formatter/locationHelpers.js +0 -16
- package/build/bdd-framework/cucumber/loadConfig.js +0 -17
- package/build/bdd-framework/cucumber/loadFeatures.js +0 -70
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
- package/build/bdd-framework/cucumber/loadSteps.js +0 -47
- package/build/bdd-framework/cucumber/resolveFeaturePaths.js +0 -62
- package/build/bdd-framework/cucumber/stepArguments.js +0 -21
- package/build/bdd-framework/cucumber/types.js +0 -5
- package/build/bdd-framework/cucumber/valueChecker.js +0 -23
- package/build/bdd-framework/decorators.js +0 -18
- package/build/bdd-framework/gen/fixtures.js +0 -48
- package/build/bdd-framework/gen/formatter.js +0 -167
- package/build/bdd-framework/gen/i18n.js +0 -39
- package/build/bdd-framework/gen/index.js +0 -197
- package/build/bdd-framework/gen/specialTags.js +0 -70
- package/build/bdd-framework/gen/testFile.js +0 -470
- package/build/bdd-framework/gen/testMeta.js +0 -60
- package/build/bdd-framework/gen/testNode.js +0 -35
- package/build/bdd-framework/gen/testPoms.js +0 -133
- package/build/bdd-framework/hooks/scenario.js +0 -130
- package/build/bdd-framework/hooks/worker.js +0 -89
- package/build/bdd-framework/index.js +0 -52
- package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -93
- package/build/bdd-framework/playwright/getLocationInFile.js +0 -79
- package/build/bdd-framework/playwright/loadConfig.js +0 -42
- package/build/bdd-framework/playwright/loadUtils.js +0 -33
- package/build/bdd-framework/playwright/testTypeImpl.js +0 -79
- package/build/bdd-framework/playwright/transform.js +0 -88
- package/build/bdd-framework/playwright/types.js +0 -12
- package/build/bdd-framework/playwright/utils.js +0 -56
- package/build/bdd-framework/reporter/cucumber/base.js +0 -52
- package/build/bdd-framework/reporter/cucumber/custom.js +0 -73
- package/build/bdd-framework/reporter/cucumber/helper.js +0 -12
- package/build/bdd-framework/reporter/cucumber/html.js +0 -40
- package/build/bdd-framework/reporter/cucumber/index.js +0 -74
- package/build/bdd-framework/reporter/cucumber/json.js +0 -312
- package/build/bdd-framework/reporter/cucumber/junit.js +0 -205
- package/build/bdd-framework/reporter/cucumber/message.js +0 -20
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +0 -82
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +0 -197
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +0 -43
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +0 -52
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +0 -105
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +0 -70
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +0 -45
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +0 -27
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +0 -38
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +0 -128
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +0 -154
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +0 -123
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +0 -67
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +0 -114
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +0 -30
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwStepUtils.js +0 -70
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +0 -35
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +0 -5
- package/build/bdd-framework/run/StepInvoker.js +0 -69
- package/build/bdd-framework/run/bddData/index.js +0 -59
- package/build/bdd-framework/run/bddData/types.js +0 -5
- package/build/bdd-framework/run/bddFixtures.js +0 -192
- package/build/bdd-framework/run/bddWorld.js +0 -79
- package/build/bdd-framework/run/bddWorldInternal.js +0 -11
- package/build/bdd-framework/snippets/index.js +0 -132
- package/build/bdd-framework/snippets/snippetSyntax.js +0 -43
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -26
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
- package/build/bdd-framework/stepDefinitions/createBdd.js +0 -66
- package/build/bdd-framework/stepDefinitions/decorators/class.js +0 -68
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -99
- package/build/bdd-framework/stepDefinitions/defineStep.js +0 -62
- package/build/bdd-framework/stepDefinitions/stepConfig.js +0 -24
- package/build/bdd-framework/steps/createBdd.js +0 -78
- package/build/bdd-framework/steps/decorators/class.js +0 -68
- package/build/bdd-framework/steps/decorators/steps.js +0 -98
- package/build/bdd-framework/steps/defineStep.js +0 -62
- package/build/bdd-framework/steps/stepConfig.js +0 -24
- package/build/bdd-framework/utils/AutofillMap.js +0 -20
- package/build/bdd-framework/utils/exit.js +0 -62
- package/build/bdd-framework/utils/index.js +0 -93
- package/build/bdd-framework/utils/jsStringWrap.js +0 -44
- package/build/bdd-framework/utils/logger.js +0 -30
- package/build/bdd-framework/utils/stripAnsiEscapes.js +0 -20
- package/build/core/playwright/tag-processor.js +0 -68
- package/build/setup-folder-structure/samples/authUsers-sample.json +0 -9
- package/build/setup-folder-structure/samples/env-config-sample.json +0 -21
|
@@ -18,6 +18,7 @@ class JSONSummaryReporter {
|
|
|
18
18
|
this.skipped = [];
|
|
19
19
|
this.failed = [];
|
|
20
20
|
this.warned = [];
|
|
21
|
+
this.errored = [];
|
|
21
22
|
this.interrupted = [];
|
|
22
23
|
this.timedOut = [];
|
|
23
24
|
this.flakey = [];
|
|
@@ -29,7 +30,7 @@ class JSONSummaryReporter {
|
|
|
29
30
|
onBegin() {
|
|
30
31
|
this.startedAt = Date.now();
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
getTitle(test) {
|
|
33
34
|
const title = [];
|
|
34
35
|
const fileName = [];
|
|
35
36
|
let clean = true;
|
|
@@ -39,35 +40,52 @@ class JSONSummaryReporter {
|
|
|
39
40
|
}
|
|
40
41
|
clean = false;
|
|
41
42
|
title.push(s);
|
|
42
|
-
if (s.
|
|
43
|
+
if (s.endsWith('.ts') || s.endsWith('.js')) {
|
|
43
44
|
fileName.push(s);
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
|
|
48
|
+
//Using the fullTitle variable in the push will push a full test name + test description
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
fullTitle: title.join(' > '),
|
|
52
|
+
fileName: fileName[0] || ''
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
onTestEnd(test, result) {
|
|
56
|
+
const {
|
|
57
|
+
fullTitle,
|
|
58
|
+
fileName
|
|
59
|
+
} = this.getTitle(test);
|
|
60
|
+
|
|
50
61
|
// Set the status
|
|
51
|
-
const stepTitleList = result.steps.map(step => ({
|
|
62
|
+
const stepTitleList = result.steps.filter(step => step.error).map(step => ({
|
|
52
63
|
title: step.title,
|
|
53
64
|
error: step.error,
|
|
54
|
-
testTitle:
|
|
55
|
-
}))
|
|
65
|
+
testTitle: fullTitle
|
|
66
|
+
}));
|
|
56
67
|
if (stepTitleList.length > 0) {
|
|
57
68
|
this.failedSteps = [...this.failedSteps, ...stepTitleList];
|
|
58
69
|
}
|
|
59
|
-
const status = !['passed', 'skipped'].includes(result.status) &&
|
|
70
|
+
const status = !['passed', 'skipped'].includes(result.status) && fullTitle.includes('@warn') ? 'warned' : result.status;
|
|
60
71
|
// Logic to push the results into the correct array
|
|
61
72
|
if (result.status === 'passed' && result.retry >= 1) {
|
|
62
|
-
this.flakey.push(
|
|
73
|
+
this.flakey.push(fileName);
|
|
63
74
|
} else {
|
|
64
|
-
this[status].push(
|
|
75
|
+
this[status].push(fileName);
|
|
65
76
|
}
|
|
66
|
-
this[status].push(
|
|
77
|
+
this[status].push(fileName);
|
|
78
|
+
}
|
|
79
|
+
onError(error) {
|
|
80
|
+
this.errored.push({
|
|
81
|
+
error: error.message,
|
|
82
|
+
stack: error.stack
|
|
83
|
+
});
|
|
67
84
|
}
|
|
68
85
|
onEnd(result) {
|
|
69
86
|
this.durationInMS = Date.now() - this.startedAt;
|
|
70
87
|
this.status = result.status;
|
|
88
|
+
|
|
71
89
|
// removing duplicate tests from passed array
|
|
72
90
|
this.passed = this.passed.filter((element, index) => {
|
|
73
91
|
return this.passed.indexOf(element) === index;
|
|
@@ -90,6 +108,14 @@ class JSONSummaryReporter {
|
|
|
90
108
|
this.interrupted = this.interrupted.filter((element, index) => {
|
|
91
109
|
return this.interrupted.indexOf(element) === index;
|
|
92
110
|
});
|
|
111
|
+
this.errored = this.errored.filter((element, index) => {
|
|
112
|
+
return this.errored.indexOf(element) === index;
|
|
113
|
+
});
|
|
114
|
+
if (this.errored.length > 0) {
|
|
115
|
+
// Reflect setup failures in the final report status
|
|
116
|
+
this.status = "failed";
|
|
117
|
+
}
|
|
118
|
+
|
|
93
119
|
// fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));
|
|
94
120
|
let {
|
|
95
121
|
reportPath
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _logger = require("../../utils/logger");
|
|
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();
|
|
8
|
+
class TagProcessor {
|
|
9
|
+
constructor(editionOrder) {
|
|
10
|
+
_classPrivateMethodInitSpec(this, _TagProcessor_brand);
|
|
11
|
+
this.editionOrder = editionOrder;
|
|
12
|
+
}
|
|
13
|
+
processTags(userArgs) {
|
|
14
|
+
const tagArgs = userArgs['tags'] || '';
|
|
15
|
+
const edition = userArgs['edition'] || null;
|
|
16
|
+
if (!edition) return tagArgs;
|
|
17
|
+
const editionsArray = edition.split(',');
|
|
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);
|
|
19
|
+
return editionTags;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function _buildTagsString(tags, editionTags) {
|
|
23
|
+
return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
|
|
24
|
+
}
|
|
25
|
+
function _parseEdition(edition) {
|
|
26
|
+
if (edition.startsWith('<=')) return ['<=', edition.slice(2)];
|
|
27
|
+
if (edition.startsWith('>=')) return ['>=', edition.slice(2)];
|
|
28
|
+
if (edition.startsWith('<')) return ['<', edition.slice(1)];
|
|
29
|
+
if (edition.startsWith('>')) return ['>', edition.slice(1)];
|
|
30
|
+
return [null, edition];
|
|
31
|
+
}
|
|
32
|
+
function _processSingleEdition(selectedEdition, tagArgs) {
|
|
33
|
+
const editionArgs = _assertClassBrand(_TagProcessor_brand, this, _getEditionArgs).call(this, selectedEdition);
|
|
34
|
+
if (editionArgs && editionArgs.length > 0) {
|
|
35
|
+
const editionTags = _assertClassBrand(_TagProcessor_brand, this, _buildEditionTags).call(this, editionArgs, 'or');
|
|
36
|
+
return _assertClassBrand(_TagProcessor_brand, this, _buildTagsString).call(this, tagArgs, editionTags);
|
|
37
|
+
}
|
|
38
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
|
|
39
|
+
return tagArgs;
|
|
40
|
+
}
|
|
41
|
+
function _processMultipleEditions(editionsArray, tagArgs) {
|
|
42
|
+
const filteredEditions = this.editionOrder.filter(edition => !editionsArray.includes(edition));
|
|
43
|
+
const editionTags = _assertClassBrand(_TagProcessor_brand, this, _buildEditionTags).call(this, filteredEditions, 'or');
|
|
44
|
+
return _assertClassBrand(_TagProcessor_brand, this, _buildTagsString).call(this, tagArgs, editionTags);
|
|
45
|
+
}
|
|
46
|
+
function _getEditionArgs(selectedEdition) {
|
|
47
|
+
const [operator, editionValue] = _assertClassBrand(_TagProcessor_brand, this, _parseEdition).call(this, selectedEdition.toLowerCase());
|
|
48
|
+
const index = this.editionOrder.findIndex(edition => edition.toLowerCase() === editionValue);
|
|
49
|
+
if (index === -1) {
|
|
50
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
switch (operator) {
|
|
54
|
+
case '<=':
|
|
55
|
+
return this.editionOrder.slice(index + 1);
|
|
56
|
+
case '>=':
|
|
57
|
+
return this.editionOrder.slice(0, index);
|
|
58
|
+
case '<':
|
|
59
|
+
return this.editionOrder.slice(index);
|
|
60
|
+
case '>':
|
|
61
|
+
return this.editionOrder.slice(0, index + 1);
|
|
62
|
+
default:
|
|
63
|
+
return this.editionOrder.filter((_, i) => i !== index);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function _buildEditionTags(editionArgs, operator = 'or') {
|
|
67
|
+
return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
|
|
68
|
+
}
|
|
69
|
+
module.exports = TagProcessor;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
exports.runPreprocessing = runPreprocessing;
|
|
8
9
|
var _child_process = require("child_process");
|
|
9
10
|
var _path = _interopRequireDefault(require("path"));
|
|
10
11
|
var _customCommands = require("./custom-commands");
|
|
@@ -13,10 +14,12 @@ var _envInitializer = require("./env-initializer");
|
|
|
13
14
|
var _logger = require("../../utils/logger");
|
|
14
15
|
var _readConfigFile = require("./readConfigFile");
|
|
15
16
|
var _rootPath = require("../../utils/rootPath");
|
|
16
|
-
var _tagProcessor = require("./
|
|
17
|
+
var _tagProcessor = _interopRequireDefault(require("./tagProcessor"));
|
|
17
18
|
var _configUtils = require("./setup/config-utils");
|
|
18
19
|
var _browserTypes = require("./constants/browserTypes");
|
|
19
|
-
var
|
|
20
|
+
var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
|
|
21
|
+
var _Configuration = _interopRequireDefault(require("./configuration/Configuration"));
|
|
22
|
+
var _UserArgs = _interopRequireDefault(require("./configuration/UserArgs"));
|
|
20
23
|
function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
21
24
|
const {
|
|
22
25
|
browsers = null
|
|
@@ -40,7 +43,7 @@ function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
|
40
43
|
}
|
|
41
44
|
function runPreprocessing(tagArgs, configPath) {
|
|
42
45
|
const beforeCommand = 'node';
|
|
43
|
-
const bddGenPath = _path.default.resolve(
|
|
46
|
+
const bddGenPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('bddgen'));
|
|
44
47
|
const beforeArgs = [bddGenPath, '-c', configPath];
|
|
45
48
|
if (tagArgs) {
|
|
46
49
|
beforeArgs.push('--tags');
|
|
@@ -55,7 +58,7 @@ function runPreprocessing(tagArgs, configPath) {
|
|
|
55
58
|
});
|
|
56
59
|
childProcessForPreprocessing.on('error', data => {
|
|
57
60
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
58
|
-
reject();
|
|
61
|
+
reject(data);
|
|
59
62
|
});
|
|
60
63
|
childProcessForPreprocessing.on('exit', code => {
|
|
61
64
|
if (code === 0) {
|
|
@@ -97,17 +100,30 @@ function runPlaywright(command, args) {
|
|
|
97
100
|
});
|
|
98
101
|
}
|
|
99
102
|
function main() {
|
|
100
|
-
|
|
101
|
-
const uatConfig = (0, _readConfigFile.
|
|
103
|
+
// Getting the default config's from framework
|
|
104
|
+
const uatConfig = new _Configuration.default((0, _readConfigFile.getDefaultConfig)());
|
|
105
|
+
|
|
106
|
+
// overriding the application config's from project
|
|
107
|
+
|
|
108
|
+
const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
|
|
109
|
+
const mode = userArgConfig.get("mode");
|
|
110
|
+
uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(mode)));
|
|
111
|
+
|
|
112
|
+
// overriding the user config's from CLI
|
|
113
|
+
uatConfig.addAll(userArgConfig);
|
|
102
114
|
const {
|
|
115
|
+
isAuthMode,
|
|
116
|
+
editionOrder,
|
|
103
117
|
debug,
|
|
104
118
|
bddMode = false,
|
|
105
|
-
headless = false
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
119
|
+
headless = false
|
|
120
|
+
} = uatConfig.getAll();
|
|
121
|
+
(0, _envInitializer.initializeEnvConfig)(mode, isAuthMode);
|
|
122
|
+
|
|
123
|
+
//This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
|
|
124
|
+
const userArgsObject = userArgConfig.getAll();
|
|
125
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
126
|
+
const tagArgs = tagProcessor.processTags(userArgsObject);
|
|
111
127
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
112
128
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
113
129
|
const command = playwrightPath;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 _parseUserArgs = _interopRequireDefault(require("./helpers/parseUserArgs"));
|
|
9
|
+
var _readConfigFile = require("./readConfigFile");
|
|
10
|
+
var _tagProcessor = _interopRequireDefault(require("./tagProcessor"));
|
|
11
|
+
var _testRunner = require("./test-runner");
|
|
12
|
+
var _logger = require("../../utils/logger");
|
|
13
|
+
const validateFeatureFiles = () => {
|
|
14
|
+
const userArgsObject = (0, _parseUserArgs.default)();
|
|
15
|
+
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
16
|
+
const {
|
|
17
|
+
editionOrder
|
|
18
|
+
} = uatConfig;
|
|
19
|
+
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
|
|
20
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
21
|
+
const tagArgs = tagProcessor.processTags(userArgsObject);
|
|
22
|
+
(0, _testRunner.runPreprocessing)(tagArgs, configPath).then(() => {
|
|
23
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature files validated successfully.');
|
|
24
|
+
}).catch(error => {
|
|
25
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error while validating the feature files - ${error}`);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var _default = exports.default = validateFeatureFiles;
|
package/build/decorators.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from 'playwright-bdd/decorators';
|
package/build/decorators.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var _decorators = require("
|
|
6
|
+
var _decorators = require("playwright-bdd/decorators");
|
|
7
7
|
Object.keys(_decorators).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
9
|
if (key in exports && exports[key] === _decorators[key]) return;
|
package/build/lib/cli.js
CHANGED
|
@@ -10,6 +10,7 @@ var _parser = require("../parser/parser");
|
|
|
10
10
|
var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-caches"));
|
|
11
11
|
var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
|
|
12
12
|
var _parseUserArgs = _interopRequireDefault(require("../core/playwright/helpers/parseUserArgs"));
|
|
13
|
+
var _validateFeature = _interopRequireDefault(require("../core/playwright/validateFeature"));
|
|
13
14
|
// import createJestRunner from '../core/jest/runner/jest-runner';
|
|
14
15
|
|
|
15
16
|
const [,, option, ...otherOptions] = process.argv;
|
|
@@ -21,6 +22,11 @@ switch (option) {
|
|
|
21
22
|
//createJestRunner();
|
|
22
23
|
break;
|
|
23
24
|
}
|
|
25
|
+
case 'validate':
|
|
26
|
+
{
|
|
27
|
+
(0, _validateFeature.default)();
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
24
30
|
case 're-run-failed':
|
|
25
31
|
{
|
|
26
32
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Running Failed Tests..');
|
|
@@ -1,73 +1,21 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { test as setup, expect } from '@zohodesk/testinglibrary';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
performLoginSteps,
|
|
5
|
+
getDefaultActor
|
|
6
|
+
} from '@zohodesk/testinglibrary/helpers';
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const user = getDefaultActor();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function convertCookiesToParse(cookies, authFilePath) {
|
|
16
|
-
try {
|
|
17
|
-
return JSON.parse(cookies);
|
|
18
|
-
} catch (err) {
|
|
19
|
-
Logger.error(err);
|
|
20
|
-
throw new Error(
|
|
21
|
-
` Error while parsing cookies ${err} \n${path.resolve(
|
|
22
|
-
process.cwd(),
|
|
23
|
-
authFilePath
|
|
24
|
-
)} File is Empty`
|
|
25
|
-
);
|
|
26
|
-
// process.exit()
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const authDirectory = getAuthFileDirectory(); //path.resolve(process.cwd(), 'uat', 'playwright', '.auth');
|
|
30
|
-
if (!existsSync(authDirectory)) {
|
|
31
|
-
console.log('Creating auth directory for the first time setup...');
|
|
32
|
-
mkdirSync(authDirectory, { recursive: true });
|
|
10
|
+
async function verifyPageIsLoaded(page) {
|
|
11
|
+
//Implement your validation steps here
|
|
12
|
+
//Refer desk_client_app auth.setup.js
|
|
13
|
+
return true;
|
|
33
14
|
}
|
|
34
15
|
|
|
35
|
-
|
|
36
|
-
const authFile = path.resolve(path.join(authDirectory, `${data.filename}`));
|
|
37
|
-
if (!existsSync(authFile)) {
|
|
38
|
-
console.log('creating auth file..');
|
|
39
|
-
writeFileSync(authFile, JSON.stringify(authContent, null, 2));
|
|
40
|
-
}
|
|
41
|
-
setup(data.description, async ({ page }) => {
|
|
42
|
-
try {
|
|
43
|
-
const cookies = readFileSync(authFile);
|
|
44
|
-
const parsedCookies = convertCookiesToParse(cookies, authFile);
|
|
45
|
-
await page
|
|
46
|
-
.context()
|
|
47
|
-
.addCookies(
|
|
48
|
-
parsedCookies.cookies === undefined ? [] : parsedCookies.cookies
|
|
49
|
-
);
|
|
50
|
-
await page.goto(page.getBaseUrl());
|
|
51
|
-
await page.waitForLoadState();
|
|
52
|
-
if (await page.url().includes(process.env.domain)) {
|
|
53
|
-
await page.waitForSelector(data.locator);
|
|
54
|
-
} else {
|
|
55
|
-
throw new Error(LOGIN_ERR_MESSAGE);
|
|
56
|
-
}
|
|
57
|
-
} catch (err) {
|
|
58
|
-
if (err.message === LOGIN_ERR_MESSAGE) {
|
|
59
|
-
await expect(page.locator('.load-bg')).toBeHidden();
|
|
60
|
-
await page.locator('#login_id').type(data.useremail);
|
|
61
|
-
await page.locator('#nextbtn').click();
|
|
62
|
-
await page.locator('#password').type(data.password);
|
|
63
|
-
await page.locator('#nextbtn').click();
|
|
64
|
-
|
|
65
|
-
await page.waitForLoadState('networkidle');
|
|
66
|
-
|
|
67
|
-
await page.waitForSelector(data.locator);
|
|
16
|
+
setup(`${user.edition} - Authentication`, async ({ page }) => {
|
|
68
17
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
18
|
+
//Implement performLoginSteps here
|
|
19
|
+
const { email, password } = user;
|
|
20
|
+
await performLoginSteps({ },verifyPageIsLoaded );
|
|
21
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "1",
|
|
4
|
+
"edition": "free",
|
|
5
|
+
"orgName": "orgFree",
|
|
6
|
+
"profiles": [
|
|
7
|
+
{
|
|
8
|
+
"profile": "admin",
|
|
9
|
+
"email": "admin+free@zohotest.com",
|
|
10
|
+
"password": "password@0987"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"profile": "agent",
|
|
14
|
+
"email": "agent@zohotest.com",
|
|
15
|
+
"password": "password@12345"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"profile": "lightagent",
|
|
19
|
+
"email": "lightagent@zohotest.com",
|
|
20
|
+
"password": "password@12345"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
|
|
@@ -10,8 +10,9 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
10
10
|
var _logger = require("../utils/logger");
|
|
11
11
|
function getScriptsToBeAdded() {
|
|
12
12
|
return {
|
|
13
|
-
"uat": "ZDTestingFramework test --mode=
|
|
14
|
-
"uat-debug": "ZDTestingFramework test --mode=
|
|
13
|
+
"uat": "ZDTestingFramework test --mode=dev --headed",
|
|
14
|
+
"uat-debug": "ZDTestingFramework test --mode=dev --debug",
|
|
15
|
+
"uat-validate": "ZDTestingFramework validate",
|
|
15
16
|
"uat-report": "ZDTestingFramework report --port=9009",
|
|
16
17
|
"codegen": "ZDTestingFramework codegen deskclientapp.localzoho.com/agent"
|
|
17
18
|
};
|
|
@@ -71,7 +72,6 @@ function createAuthenticationFile() {
|
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'auth.setup.js'), getSetupFileAsString('auth-setup-sample.js'), null, 2);
|
|
74
|
-
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'authUsers.json'), getSetupFileAsString('authUsers-sample.json'), null, 2);
|
|
75
75
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
|
|
76
76
|
} catch (err) {
|
|
77
77
|
_logger.Logger.error(err);
|
|
@@ -84,8 +84,21 @@ function createAuthenticationFile() {
|
|
|
84
84
|
function createConfigJson() {
|
|
85
85
|
const uatFolder = _path.default.resolve(process.cwd(), 'uat');
|
|
86
86
|
if ((0, _fs.existsSync)(uatFolder)) {
|
|
87
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating
|
|
88
|
-
(0, _fs.
|
|
87
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating settings.json file inside UAT Folder');
|
|
88
|
+
if (!(0, _fs.existsSync)(_path.default.resolve(uatFolder, 'conf', 'default'))) {
|
|
89
|
+
(0, _fs.mkdirSync)(_path.default.resolve(uatFolder, 'conf', 'default'), {
|
|
90
|
+
recursive: true
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, 'conf', 'default', './settings.json'), getSetupFileAsString('settings.json'), null, 2);
|
|
94
|
+
if (!(0, _fs.existsSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'editions'))) {
|
|
95
|
+
(0, _fs.mkdirSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'editions'), {
|
|
96
|
+
recursive: true
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'editions', 'free.json'), getSetupFileAsString('free-sample.json'), null, 2);
|
|
100
|
+
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'editions', 'index.js'), getSetupFileAsString('editions-index.js'), null, 2);
|
|
101
|
+
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'index.js'), getSetupFileAsString('actors-index.js'), null, 2);
|
|
89
102
|
} else {
|
|
90
103
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Something went wrong. Please re-initialize the @zohodesk/testinglibrary');
|
|
91
104
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _tagProcessor = _interopRequireDefault(require("../../../../../src/core/playwright/tagProcessor"));
|
|
5
|
+
var _logger = require("../../../../utils/logger");
|
|
6
|
+
jest.mock('../../../../utils/logger');
|
|
7
|
+
describe('TagProcessor', () => {
|
|
8
|
+
const editionOrder = ['edition1', 'edition2', 'edition3', 'edition4'];
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
jest.clearAllMocks();
|
|
11
|
+
});
|
|
12
|
+
test('should return tagArgs if no edition is provided', () => {
|
|
13
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
14
|
+
const userArgs = {
|
|
15
|
+
tags: 'tag1',
|
|
16
|
+
edition: null
|
|
17
|
+
};
|
|
18
|
+
const result = tagProcessor.processTags(userArgs);
|
|
19
|
+
expect(result).toBe('tag1');
|
|
20
|
+
});
|
|
21
|
+
test('should handle a single edition with <= operator', () => {
|
|
22
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
23
|
+
const userArgs = {
|
|
24
|
+
tags: 'tag1',
|
|
25
|
+
edition: '<=edition2'
|
|
26
|
+
};
|
|
27
|
+
const result = tagProcessor.processTags(userArgs);
|
|
28
|
+
expect(result).toBe('tag1 and not (@edition_edition3 or @edition_edition4)');
|
|
29
|
+
});
|
|
30
|
+
test('should handle a single edition with >= operator', () => {
|
|
31
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
32
|
+
const userArgs = {
|
|
33
|
+
tags: 'tag1',
|
|
34
|
+
edition: '>=edition2'
|
|
35
|
+
};
|
|
36
|
+
const result = tagProcessor.processTags(userArgs);
|
|
37
|
+
expect(result).toBe('tag1 and not (@edition_edition1)');
|
|
38
|
+
});
|
|
39
|
+
test('should handle a single edition with < operator', () => {
|
|
40
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
41
|
+
const userArgs = {
|
|
42
|
+
tags: 'tag1',
|
|
43
|
+
edition: '<edition3'
|
|
44
|
+
};
|
|
45
|
+
const result = tagProcessor.processTags(userArgs);
|
|
46
|
+
expect(result).toBe('tag1 and not (@edition_edition3 or @edition_edition4)');
|
|
47
|
+
});
|
|
48
|
+
test('should handle a single edition with > operator', () => {
|
|
49
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
50
|
+
const userArgs = {
|
|
51
|
+
tags: 'tag1',
|
|
52
|
+
edition: '>edition1'
|
|
53
|
+
};
|
|
54
|
+
const result = tagProcessor.processTags(userArgs);
|
|
55
|
+
expect(result).toBe('tag1 and not (@edition_edition1)');
|
|
56
|
+
});
|
|
57
|
+
test('should handle a single edition with no operator', () => {
|
|
58
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
59
|
+
const userArgs = {
|
|
60
|
+
tags: 'tag1',
|
|
61
|
+
edition: 'edition2'
|
|
62
|
+
};
|
|
63
|
+
const result = tagProcessor.processTags(userArgs);
|
|
64
|
+
expect(result).toBe('tag1 and not (@edition_edition1 or @edition_edition3 or @edition_edition4)');
|
|
65
|
+
});
|
|
66
|
+
test('should log a message if edition is not found', () => {
|
|
67
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
68
|
+
const userArgs = {
|
|
69
|
+
tags: 'tag1',
|
|
70
|
+
edition: 'nonexistentEdition'
|
|
71
|
+
};
|
|
72
|
+
const result = tagProcessor.processTags(userArgs);
|
|
73
|
+
expect(result).toBe('tag1');
|
|
74
|
+
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.INFO_TYPE, expect.stringContaining('No matching editions for nonexistentEdition found.'));
|
|
75
|
+
});
|
|
76
|
+
test('should handle multiple editions', () => {
|
|
77
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
78
|
+
const userArgs = {
|
|
79
|
+
tags: 'tag1',
|
|
80
|
+
edition: 'edition1,edition3'
|
|
81
|
+
};
|
|
82
|
+
const result = tagProcessor.processTags(userArgs);
|
|
83
|
+
expect(result).toBe('tag1 and not (@edition_edition2 or @edition_edition4)');
|
|
84
|
+
});
|
|
85
|
+
test('should build tags correctly when tags are empty', () => {
|
|
86
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
87
|
+
const userArgs = {
|
|
88
|
+
tags: '',
|
|
89
|
+
edition: 'edition1'
|
|
90
|
+
};
|
|
91
|
+
const result = tagProcessor.processTags(userArgs);
|
|
92
|
+
expect(result).toBe('not (@edition_edition2 or @edition_edition3 or @edition_edition4)');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _validateFeature = _interopRequireDefault(require("../../../../core/playwright/validateFeature"));
|
|
5
|
+
var _parseUserArgs = _interopRequireDefault(require("../../../../core/playwright/helpers/parseUserArgs"));
|
|
6
|
+
var _readConfigFile = require("../../../../core/playwright/readConfigFile");
|
|
7
|
+
var _tagProcessor = _interopRequireDefault(require("../../../../core/playwright/tagProcessor"));
|
|
8
|
+
var _testRunner = require("../../../../core/playwright/test-runner");
|
|
9
|
+
var _logger = require("../../../../utils/logger");
|
|
10
|
+
jest.mock('../../../../core/playwright/helpers/parseUserArgs', () => ({
|
|
11
|
+
__esModule: true,
|
|
12
|
+
default: jest.fn()
|
|
13
|
+
}));
|
|
14
|
+
jest.mock('../../../../core/playwright/readConfigFile');
|
|
15
|
+
jest.mock('../../../../core/playwright/tagProcessor');
|
|
16
|
+
jest.mock('../../../../core/playwright/test-runner');
|
|
17
|
+
jest.mock('../../../../utils/logger', () => ({
|
|
18
|
+
__esModule: true,
|
|
19
|
+
Logger: {
|
|
20
|
+
log: jest.fn(),
|
|
21
|
+
SUCCESS_TYPE: 'success',
|
|
22
|
+
FAILURE_TYPE: 'failure'
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
describe('validateFeatureFiles', () => {
|
|
26
|
+
let tagProcessorInstance;
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
jest.clearAllMocks();
|
|
29
|
+
tagProcessorInstance = {
|
|
30
|
+
processTags: jest.fn()
|
|
31
|
+
};
|
|
32
|
+
_tagProcessor.default.mockImplementation(() => tagProcessorInstance);
|
|
33
|
+
});
|
|
34
|
+
test('runPreprocessing with correct arguments and log success', async () => {
|
|
35
|
+
const mockUserArgs = {
|
|
36
|
+
mode: 'dev'
|
|
37
|
+
};
|
|
38
|
+
_parseUserArgs.default.mockReturnValue(mockUserArgs);
|
|
39
|
+
const mockConfig = {
|
|
40
|
+
editionOrder: ["beta", "enterprice"]
|
|
41
|
+
};
|
|
42
|
+
_readConfigFile.generateConfigFromFile.mockReturnValue(mockConfig);
|
|
43
|
+
_readConfigFile.isUserConfigFileAvailable.mockReturnValue(true);
|
|
44
|
+
const mockTagArgs = ['@beta_admin'];
|
|
45
|
+
tagProcessorInstance.processTags.mockReturnValue(mockTagArgs);
|
|
46
|
+
_testRunner.runPreprocessing.mockResolvedValueOnce();
|
|
47
|
+
await (0, _validateFeature.default)();
|
|
48
|
+
expect(_parseUserArgs.default).toHaveBeenCalled();
|
|
49
|
+
expect(_readConfigFile.generateConfigFromFile).toHaveBeenCalled();
|
|
50
|
+
expect(_readConfigFile.isUserConfigFileAvailable).toHaveBeenCalled();
|
|
51
|
+
expect(tagProcessorInstance.processTags).toHaveBeenCalledWith(mockUserArgs);
|
|
52
|
+
expect(_testRunner.runPreprocessing).toHaveBeenCalledWith(mockTagArgs, expect.stringContaining('config-creator.js'));
|
|
53
|
+
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.SUCCESS_TYPE, 'Feature files validated successfully.');
|
|
54
|
+
});
|
|
55
|
+
test('runPreprocessing with playwright conf', async () => {
|
|
56
|
+
const mockTagArgs = ['@beta_admin'];
|
|
57
|
+
tagProcessorInstance.processTags.mockReturnValue(mockTagArgs);
|
|
58
|
+
_readConfigFile.isUserConfigFileAvailable.mockReturnValue(false);
|
|
59
|
+
_testRunner.runPreprocessing.mockResolvedValueOnce();
|
|
60
|
+
await (0, _validateFeature.default)();
|
|
61
|
+
expect(_testRunner.runPreprocessing).toHaveBeenCalledWith(mockTagArgs, expect.stringContaining('playwright.config.js'));
|
|
62
|
+
});
|
|
63
|
+
test('error when runPreprocessing fails', async () => {
|
|
64
|
+
const mockError = new Error('Test error');
|
|
65
|
+
_testRunner.runPreprocessing.mockRejectedValueOnce(mockError);
|
|
66
|
+
await await (0, _validateFeature.default)();
|
|
67
|
+
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.FAILURE_TYPE, `Error while validating the feature files - ${mockError}`);
|
|
68
|
+
});
|
|
69
|
+
});
|