@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.
- package/.gitlab-ci.yml +16 -23
- package/README.md +32 -1
- package/build/core/playwright/constants/fileMutexConfig.js +11 -0
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +2 -8
- package/build/core/playwright/helpers/auth/loginSteps.js +25 -18
- package/build/core/playwright/helpers/checkAuthDirectory.js +17 -0
- package/build/core/playwright/helpers/fileMutex.js +58 -0
- package/build/core/playwright/index.js +10 -23
- package/build/core/playwright/setup/config-creator.js +3 -3
- package/build/core/playwright/setup/config-utils.js +8 -25
- package/build/core/playwright/test-runner.js +1 -1
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +1 -1
- package/build/setup-folder-structure/samples/actors-index.js +2 -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/helpers/__tests__/fileMutex.test.js +94 -0
- package/nobdd/uat/conf/default/actors/index.js +1 -4
- package/nobdd/uat/conf/default/settings.json +1 -1
- package/nobdd/uat/conf/nobdd/uat.config.js +11 -4
- package/nobdd/uat/env-config.json +3 -3
- package/nobdd/uat/fixtures/setup.teardown.js +2 -1
- package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +3 -3
- package/nobdd/uat.config.js +8 -3
- package/package.json +8 -7
- 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/setup-folder-structure/samples/authUsers-sample.json +0 -9
- package/build/setup-folder-structure/samples/env-config-sample.json +0 -21
- package/nobdd/uat/conf/default/actors/beta/custom-module.json +0 -24
- package/nobdd/uat/conf/default/actors/beta/index.js +0 -6
- package/nobdd/uat/conf/default/actors/beta/parent-child.json +0 -24
- package/npm-shrinkwrap.json +0 -6475
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SpecialTags = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Special tags.
|
|
9
|
-
*/
|
|
10
|
-
class SpecialTags {
|
|
11
|
-
ownTags;
|
|
12
|
-
allTags;
|
|
13
|
-
only;
|
|
14
|
-
skip;
|
|
15
|
-
fixme;
|
|
16
|
-
fail;
|
|
17
|
-
retries;
|
|
18
|
-
timeout;
|
|
19
|
-
mode;
|
|
20
|
-
constructor(ownTags, allTags) {
|
|
21
|
-
this.ownTags = ownTags;
|
|
22
|
-
this.allTags = allTags;
|
|
23
|
-
this.extractFlags();
|
|
24
|
-
this.extractRetries();
|
|
25
|
-
this.extractTimeout();
|
|
26
|
-
this.extractMode();
|
|
27
|
-
}
|
|
28
|
-
extractFlags() {
|
|
29
|
-
// order is important
|
|
30
|
-
const flags = ['only', 'fail', 'skip', 'fixme'];
|
|
31
|
-
for (const flag of flags) {
|
|
32
|
-
if (this.ownTags.includes(`@${flag}`)) {
|
|
33
|
-
this[flag] = true;
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// describe.fail is not supported, so mark all nested tests as failed instead
|
|
38
|
-
if (this.allTags.includes(`@fail`)) {
|
|
39
|
-
this.fail = true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
extractRetries() {
|
|
43
|
-
for (const tag of this.ownTags.reverse()) {
|
|
44
|
-
const match = tag.match(/@retries:(\d+)/i);
|
|
45
|
-
if (match) {
|
|
46
|
-
this.retries = Number(match[1]);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
extractTimeout() {
|
|
52
|
-
for (const tag of this.ownTags.reverse()) {
|
|
53
|
-
const match = tag.match(/@timeout:(\d+)/i);
|
|
54
|
-
if (match) {
|
|
55
|
-
this.timeout = Number(match[1]);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
extractMode() {
|
|
61
|
-
for (const tag of this.ownTags.reverse()) {
|
|
62
|
-
const match = tag.match(/@mode:(default|parallel|serial)/i);
|
|
63
|
-
if (match) {
|
|
64
|
-
this.mode = match[1];
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.SpecialTags = SpecialTags;
|
|
@@ -1,470 +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.TestFile = void 0;
|
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _formatter = require("./formatter");
|
|
11
|
-
var _i18n = require("./i18n");
|
|
12
|
-
var _loadSteps = require("../cucumber/loadSteps");
|
|
13
|
-
var _index = require("@cucumber/cucumber/lib/formatter/helpers/index");
|
|
14
|
-
var _utils = require("../utils");
|
|
15
|
-
var _testPoms = require("./testPoms");
|
|
16
|
-
var _testNode = require("./testNode");
|
|
17
|
-
var _stepConfig = require("../steps/stepConfig");
|
|
18
|
-
var _exit = require("../utils/exit");
|
|
19
|
-
var _fixtures = require("./fixtures");
|
|
20
|
-
var _scenario = require("../hooks/scenario");
|
|
21
|
-
var _worker = require("../hooks/worker");
|
|
22
|
-
var _lang = require("../config/lang");
|
|
23
|
-
var _testMeta = require("./testMeta");
|
|
24
|
-
/**
|
|
25
|
-
* Generate Playwright test file for feature.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
class TestFile {
|
|
29
|
-
options;
|
|
30
|
-
lines = [];
|
|
31
|
-
i18nKeywordsMap;
|
|
32
|
-
formatter;
|
|
33
|
-
testMetaBuilder;
|
|
34
|
-
hasCucumberStyle = false;
|
|
35
|
-
hasCustomTest = false;
|
|
36
|
-
undefinedSteps = [];
|
|
37
|
-
featureUri;
|
|
38
|
-
usedStepDefinitions = new Set();
|
|
39
|
-
constructor(options) {
|
|
40
|
-
this.options = options;
|
|
41
|
-
this.formatter = new _formatter.Formatter(options.config);
|
|
42
|
-
this.testMetaBuilder = new _testMeta.TestMetaBuilder();
|
|
43
|
-
this.featureUri = this.getFeatureUri();
|
|
44
|
-
}
|
|
45
|
-
get gherkinDocument() {
|
|
46
|
-
return this.options.gherkinDocument;
|
|
47
|
-
}
|
|
48
|
-
get pickles() {
|
|
49
|
-
return this.gherkinDocument.pickles;
|
|
50
|
-
}
|
|
51
|
-
get content() {
|
|
52
|
-
return this.lines.join('\n');
|
|
53
|
-
}
|
|
54
|
-
get language() {
|
|
55
|
-
var _this$gherkinDocument;
|
|
56
|
-
return ((_this$gherkinDocument = this.gherkinDocument.feature) === null || _this$gherkinDocument === void 0 ? void 0 : _this$gherkinDocument.language) || _lang.LANG_EN;
|
|
57
|
-
}
|
|
58
|
-
get isEnglish() {
|
|
59
|
-
return (0, _lang.isEnglish)(this.language);
|
|
60
|
-
}
|
|
61
|
-
get config() {
|
|
62
|
-
return this.options.config;
|
|
63
|
-
}
|
|
64
|
-
get outputPath() {
|
|
65
|
-
return this.options.outputPath;
|
|
66
|
-
}
|
|
67
|
-
get testCount() {
|
|
68
|
-
return this.testMetaBuilder.testCount;
|
|
69
|
-
}
|
|
70
|
-
build() {
|
|
71
|
-
if (!this.pickles.length) {
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
this.loadI18nKeywords();
|
|
75
|
-
this.lines = [...this.getFileHeader(),
|
|
76
|
-
// prettier-ignore
|
|
77
|
-
...this.getRootSuite(), ...this.getTechnicalSection()];
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
save() {
|
|
81
|
-
const dir = _path.default.dirname(this.outputPath);
|
|
82
|
-
if (!_fs.default.existsSync(dir)) {
|
|
83
|
-
_fs.default.mkdirSync(dir, {
|
|
84
|
-
recursive: true
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
_fs.default.writeFileSync(this.outputPath, this.content);
|
|
88
|
-
}
|
|
89
|
-
getFileHeader() {
|
|
90
|
-
const importTestFrom = this.getRelativeImportTestFrom();
|
|
91
|
-
return this.formatter.fileHeader(this.featureUri, importTestFrom);
|
|
92
|
-
}
|
|
93
|
-
loadI18nKeywords() {
|
|
94
|
-
if (!this.isEnglish) {
|
|
95
|
-
this.i18nKeywordsMap = (0, _i18n.getKeywordsMap)(this.language);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
getFeatureUri() {
|
|
99
|
-
const {
|
|
100
|
-
uri
|
|
101
|
-
} = this.gherkinDocument;
|
|
102
|
-
if (!uri) {
|
|
103
|
-
var _this$gherkinDocument2;
|
|
104
|
-
throw new Error(`Document without uri: ${(_this$gherkinDocument2 = this.gherkinDocument.feature) === null || _this$gherkinDocument2 === void 0 ? void 0 : _this$gherkinDocument2.name}`);
|
|
105
|
-
}
|
|
106
|
-
return uri;
|
|
107
|
-
}
|
|
108
|
-
getRelativeImportTestFrom() {
|
|
109
|
-
const {
|
|
110
|
-
importTestFrom
|
|
111
|
-
} = this.config;
|
|
112
|
-
if (!importTestFrom) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const {
|
|
116
|
-
file,
|
|
117
|
-
varName
|
|
118
|
-
} = importTestFrom;
|
|
119
|
-
const dir = _path.default.dirname(this.outputPath);
|
|
120
|
-
return {
|
|
121
|
-
file: _path.default.relative(dir, file),
|
|
122
|
-
varName
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
getTechnicalSection() {
|
|
126
|
-
return this.formatter.technicalSection(this.testMetaBuilder, this.featureUri, [...(!this.isEnglish ? this.formatter.langFixture(this.language) : []), ...((0, _scenario.hasScenarioHooks)() || this.hasCucumberStyle ? this.formatter.bddWorldFixtures() : []), ...this.formatter.scenarioHookFixtures((0, _scenario.getScenarioHooksFixtures)()), ...this.formatter.workerHookFixtures((0, _worker.getWorkerHooksFixtures)())]);
|
|
127
|
-
}
|
|
128
|
-
getRootSuite() {
|
|
129
|
-
const {
|
|
130
|
-
feature
|
|
131
|
-
} = this.gherkinDocument;
|
|
132
|
-
if (!feature) {
|
|
133
|
-
throw new Error(`Document without feature.`);
|
|
134
|
-
}
|
|
135
|
-
return this.getSuite(feature);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Generate test.describe suite for root Feature or Rule
|
|
139
|
-
*/
|
|
140
|
-
getSuite(feature, parent) {
|
|
141
|
-
const node = new _testNode.TestNode(feature, parent);
|
|
142
|
-
if (node.isSkipped()) {
|
|
143
|
-
return this.formatter.describe(node, []);
|
|
144
|
-
}
|
|
145
|
-
const lines = [];
|
|
146
|
-
feature.children.forEach(child => lines.push(...this.getSuiteChild(child, node)));
|
|
147
|
-
return this.formatter.describe(node, lines);
|
|
148
|
-
}
|
|
149
|
-
getSuiteChild(child, parent) {
|
|
150
|
-
if ('rule' in child && child.rule) {
|
|
151
|
-
return this.getSuite(child.rule, parent);
|
|
152
|
-
}
|
|
153
|
-
if (child.background) {
|
|
154
|
-
return this.getBeforeEach(child.background, parent);
|
|
155
|
-
}
|
|
156
|
-
if (child.scenario) {
|
|
157
|
-
return this.getScenarioLines(child.scenario, parent);
|
|
158
|
-
}
|
|
159
|
-
throw new Error(`Empty child: ${JSON.stringify(child)}`);
|
|
160
|
-
}
|
|
161
|
-
getScenarioLines(scenario, parent) {
|
|
162
|
-
return this.isOutline(scenario) ? this.getOutlineSuite(scenario, parent) : this.getTest(scenario, parent);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Generate test.beforeEach for Background
|
|
166
|
-
*/
|
|
167
|
-
getBeforeEach(bg, parent) {
|
|
168
|
-
const node = new _testNode.TestNode({
|
|
169
|
-
name: 'background',
|
|
170
|
-
tags: []
|
|
171
|
-
}, parent);
|
|
172
|
-
const {
|
|
173
|
-
fixtures,
|
|
174
|
-
lines
|
|
175
|
-
} = this.getSteps(bg, node.tags);
|
|
176
|
-
return this.formatter.beforeEach(fixtures, lines);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Generate test.describe suite for Scenario Outline
|
|
180
|
-
*/
|
|
181
|
-
getOutlineSuite(scenario, parent) {
|
|
182
|
-
const node = new _testNode.TestNode(scenario, parent);
|
|
183
|
-
if (node.isSkipped()) {
|
|
184
|
-
return this.formatter.describe(node, []);
|
|
185
|
-
}
|
|
186
|
-
const lines = [];
|
|
187
|
-
let exampleIndex = 0;
|
|
188
|
-
scenario.examples.forEach(examples => {
|
|
189
|
-
const titleFormat = this.getExamplesTitleFormat(scenario, examples);
|
|
190
|
-
examples.tableBody.forEach(exampleRow => {
|
|
191
|
-
const testTitle = this.getOutlineTestTitle(titleFormat, examples, exampleRow, ++exampleIndex);
|
|
192
|
-
const testLines = this.getOutlineTest(scenario, examples, exampleRow, testTitle, node);
|
|
193
|
-
lines.push(...testLines);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
return this.formatter.describe(node, lines);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Generate test from Examples row of Scenario Outline
|
|
200
|
-
*/
|
|
201
|
-
// eslint-disable-next-line max-params
|
|
202
|
-
getOutlineTest(scenario, examples, exampleRow, title, parent) {
|
|
203
|
-
const node = new _testNode.TestNode({
|
|
204
|
-
name: title,
|
|
205
|
-
tags: examples.tags
|
|
206
|
-
}, parent);
|
|
207
|
-
if (this.skipByTagsExpression(node)) {
|
|
208
|
-
return [];
|
|
209
|
-
}
|
|
210
|
-
const pickle = this.findPickle(scenario, exampleRow);
|
|
211
|
-
this.testMetaBuilder.registerTest(node, pickle);
|
|
212
|
-
if (node.isSkipped()) {
|
|
213
|
-
return this.formatter.test(node, new Set(), []);
|
|
214
|
-
}
|
|
215
|
-
const {
|
|
216
|
-
fixtures,
|
|
217
|
-
lines
|
|
218
|
-
} = this.getSteps(scenario, node.tags, exampleRow.id);
|
|
219
|
-
return this.formatter.test(node, fixtures, lines);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Generate test from Scenario
|
|
223
|
-
*/
|
|
224
|
-
getTest(scenario, parent) {
|
|
225
|
-
const node = new _testNode.TestNode(scenario, parent);
|
|
226
|
-
if (this.skipByTagsExpression(node)) {
|
|
227
|
-
return [];
|
|
228
|
-
}
|
|
229
|
-
const pickle = this.findPickle(scenario);
|
|
230
|
-
this.testMetaBuilder.registerTest(node, pickle);
|
|
231
|
-
if (node.isSkipped()) {
|
|
232
|
-
return this.formatter.test(node, new Set(), []);
|
|
233
|
-
}
|
|
234
|
-
const {
|
|
235
|
-
fixtures,
|
|
236
|
-
lines
|
|
237
|
-
} = this.getSteps(scenario, node.tags);
|
|
238
|
-
return this.formatter.test(node, fixtures, lines);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Generate test steps
|
|
242
|
-
*/
|
|
243
|
-
getSteps(scenario, tags, outlineExampleRowId) {
|
|
244
|
-
const testFixtureNames = new Set();
|
|
245
|
-
const testPoms = new _testPoms.TestPoms(scenario.name || 'Background');
|
|
246
|
-
const decoratorSteps = [];
|
|
247
|
-
let previousKeywordType = undefined;
|
|
248
|
-
const lines = scenario.steps.map((step, index) => {
|
|
249
|
-
const {
|
|
250
|
-
keyword,
|
|
251
|
-
keywordType,
|
|
252
|
-
fixtureNames: stepFixtureNames,
|
|
253
|
-
line,
|
|
254
|
-
pickleStep,
|
|
255
|
-
stepConfig
|
|
256
|
-
} = this.getStep(step, previousKeywordType, outlineExampleRowId);
|
|
257
|
-
previousKeywordType = keywordType;
|
|
258
|
-
testFixtureNames.add(keyword);
|
|
259
|
-
stepFixtureNames.forEach(fixtureName => testFixtureNames.add(fixtureName));
|
|
260
|
-
if ((0, _stepConfig.isDecorator)(stepConfig)) {
|
|
261
|
-
testPoms.addByStep(stepConfig.pomNode);
|
|
262
|
-
decoratorSteps.push({
|
|
263
|
-
index,
|
|
264
|
-
keyword,
|
|
265
|
-
pickleStep,
|
|
266
|
-
pomNode: stepConfig.pomNode
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return line;
|
|
270
|
-
});
|
|
271
|
-
// decorator steps handled in second pass to guess fixtures
|
|
272
|
-
if (decoratorSteps.length) {
|
|
273
|
-
testFixtureNames.forEach(fixtureName => testPoms.addByFixtureName(fixtureName));
|
|
274
|
-
tags === null || tags === void 0 || tags.forEach(tag => testPoms.addByTag(tag));
|
|
275
|
-
testPoms.resolveFixtures();
|
|
276
|
-
decoratorSteps.forEach(step => {
|
|
277
|
-
const {
|
|
278
|
-
line,
|
|
279
|
-
fixtureName
|
|
280
|
-
} = this.getDecoratorStep(step, testPoms);
|
|
281
|
-
lines[step.index] = line;
|
|
282
|
-
testFixtureNames.add(fixtureName);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
286
|
-
fixtures: testFixtureNames,
|
|
287
|
-
lines
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Generate step for Given, When, Then
|
|
292
|
-
*/
|
|
293
|
-
// eslint-disable-next-line max-statements, complexity
|
|
294
|
-
getStep(step, previousKeywordType, outlineExampleRowId) {
|
|
295
|
-
const pickleStep = this.findPickleStep(step, outlineExampleRowId);
|
|
296
|
-
const stepDefinition = (0, _loadSteps.findStepDefinition)(this.options.supportCodeLibrary, pickleStep.text, this.featureUri);
|
|
297
|
-
const keywordType = (0, _index.getStepKeywordType)({
|
|
298
|
-
keyword: step.keyword,
|
|
299
|
-
language: this.language,
|
|
300
|
-
previousKeywordType
|
|
301
|
-
});
|
|
302
|
-
const enKeyword = this.getStepEnglishKeyword(step);
|
|
303
|
-
if (!stepDefinition) {
|
|
304
|
-
this.undefinedSteps.push({
|
|
305
|
-
keywordType,
|
|
306
|
-
step,
|
|
307
|
-
pickleStep
|
|
308
|
-
});
|
|
309
|
-
return this.getMissingStep(enKeyword, keywordType, pickleStep);
|
|
310
|
-
}
|
|
311
|
-
this.usedStepDefinitions.add(stepDefinition);
|
|
312
|
-
// for cucumber-style stepConfig is undefined
|
|
313
|
-
const stepConfig = (0, _stepConfig.getStepConfig)(stepDefinition);
|
|
314
|
-
if (stepConfig !== null && stepConfig !== void 0 && stepConfig.hasCustomTest) {
|
|
315
|
-
this.hasCustomTest = true;
|
|
316
|
-
}
|
|
317
|
-
if (!(0, _stepConfig.isPlaywrightStyle)(stepConfig)) {
|
|
318
|
-
this.hasCucumberStyle = true;
|
|
319
|
-
}
|
|
320
|
-
const fixtureNames = this.getStepFixtureNames(stepDefinition);
|
|
321
|
-
const line = (0, _stepConfig.isDecorator)(stepConfig) ? '' : this.formatter.step(enKeyword, pickleStep.text, pickleStep.argument, fixtureNames);
|
|
322
|
-
return {
|
|
323
|
-
keyword: enKeyword,
|
|
324
|
-
keywordType,
|
|
325
|
-
fixtureNames,
|
|
326
|
-
line,
|
|
327
|
-
pickleStep,
|
|
328
|
-
stepConfig
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
getMissingStep(keyword, keywordType, pickleStep) {
|
|
332
|
-
return {
|
|
333
|
-
keyword,
|
|
334
|
-
keywordType,
|
|
335
|
-
fixtureNames: [],
|
|
336
|
-
line: this.formatter.missingStep(keyword, pickleStep.text),
|
|
337
|
-
pickleStep,
|
|
338
|
-
stepConfig: undefined
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Returns pickle for scenario.
|
|
343
|
-
* Pickle is executable entity including background and steps with example values.
|
|
344
|
-
*/
|
|
345
|
-
findPickle(scenario, exampleRow) {
|
|
346
|
-
const pickle = this.pickles.find(pickle => {
|
|
347
|
-
const hasScenarioId = pickle.astNodeIds.includes(scenario.id);
|
|
348
|
-
const hasExampleRowId = !exampleRow || pickle.astNodeIds.includes(exampleRow.id);
|
|
349
|
-
return hasScenarioId && hasExampleRowId;
|
|
350
|
-
});
|
|
351
|
-
if (!pickle) {
|
|
352
|
-
throw new Error(`Pickle not found for scenario: ${scenario.name}`);
|
|
353
|
-
}
|
|
354
|
-
return pickle;
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Returns pickleStep for ast step.
|
|
358
|
-
* PickleStep contains step text with inserted example values.
|
|
359
|
-
*
|
|
360
|
-
* Note:
|
|
361
|
-
* When searching for pickleStep iterate all pickles in a file
|
|
362
|
-
* b/c for background steps there is no own pickle.
|
|
363
|
-
* This can be optimized: pass optional 'pickle' parameter
|
|
364
|
-
* and search only inside it if it exists.
|
|
365
|
-
* But this increases code complexity, and performance impact seems to be minimal
|
|
366
|
-
* b/c number of pickles inside feature file is not very big.
|
|
367
|
-
*/
|
|
368
|
-
findPickleStep(step, exampleRowId) {
|
|
369
|
-
for (const pickle of this.pickles) {
|
|
370
|
-
const pickleStep = pickle.steps.find(({
|
|
371
|
-
astNodeIds
|
|
372
|
-
}) => {
|
|
373
|
-
const hasStepId = astNodeIds.includes(step.id);
|
|
374
|
-
const hasRowId = !exampleRowId || astNodeIds.includes(exampleRowId);
|
|
375
|
-
return hasStepId && hasRowId;
|
|
376
|
-
});
|
|
377
|
-
if (pickleStep) {
|
|
378
|
-
return pickleStep;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
throw new Error(`Pickle step not found for step: ${step.text}`);
|
|
382
|
-
}
|
|
383
|
-
getStepEnglishKeyword(step) {
|
|
384
|
-
const nativeKeyword = step.keyword.trim();
|
|
385
|
-
const enKeyword = nativeKeyword === '*' ? 'And' : this.getEnglishKeyword(nativeKeyword);
|
|
386
|
-
if (!enKeyword) {
|
|
387
|
-
throw new Error(`Keyword not found: ${nativeKeyword}`);
|
|
388
|
-
}
|
|
389
|
-
return enKeyword;
|
|
390
|
-
}
|
|
391
|
-
getStepFixtureNames(stepDefinition) {
|
|
392
|
-
const stepConfig = (0, _stepConfig.getStepConfig)(stepDefinition);
|
|
393
|
-
if ((0, _stepConfig.isPlaywrightStyle)(stepConfig)) {
|
|
394
|
-
// for decorator steps fixtureNames are defined later in second pass
|
|
395
|
-
return (0, _stepConfig.isDecorator)(stepConfig) ? [] : (0, _fixtures.extractFixtureNames)(stepConfig.fn);
|
|
396
|
-
} else {
|
|
397
|
-
return (0, _fixtures.extractFixtureNamesFromFnBodyMemo)(stepDefinition.code);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
getDecoratorStep(step, testPoms) {
|
|
401
|
-
const {
|
|
402
|
-
keyword,
|
|
403
|
-
pickleStep,
|
|
404
|
-
pomNode
|
|
405
|
-
} = step;
|
|
406
|
-
const resolvedFixtures = testPoms.getResolvedFixtures(pomNode);
|
|
407
|
-
if (resolvedFixtures.length !== 1) {
|
|
408
|
-
const suggestedTags = resolvedFixtures.filter(f => !f.byTag).map(f => (0, _testPoms.buildFixtureTag)(f.name)).join(', ');
|
|
409
|
-
const suggestedTagsStr = suggestedTags.length ? ` or set one of the following tags: ${suggestedTags}` : '.';
|
|
410
|
-
(0, _exit.exit)(`Can't guess fixture for decorator step "${pickleStep.text}" in file: ${this.featureUri}.`, `Please refactor your Page Object classes${suggestedTagsStr}`);
|
|
411
|
-
}
|
|
412
|
-
const fixtureName = resolvedFixtures[0].name;
|
|
413
|
-
return {
|
|
414
|
-
fixtureName,
|
|
415
|
-
line: this.formatter.step(keyword, pickleStep.text, pickleStep.argument, [fixtureName])
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
getOutlineTestTitle(titleFormat, examples, exampleRow, exampleIndex) {
|
|
419
|
-
const params = {
|
|
420
|
-
_index_: exampleIndex
|
|
421
|
-
};
|
|
422
|
-
exampleRow.cells.forEach((cell, index) => {
|
|
423
|
-
var _examples$tableHeader;
|
|
424
|
-
const colName = (_examples$tableHeader = examples.tableHeader) === null || _examples$tableHeader === void 0 || (_examples$tableHeader = _examples$tableHeader.cells[index]) === null || _examples$tableHeader === void 0 ? void 0 : _examples$tableHeader.value;
|
|
425
|
-
if (colName) {
|
|
426
|
-
params[colName] = cell.value;
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
return (0, _utils.template)(titleFormat, params);
|
|
430
|
-
}
|
|
431
|
-
getExamplesTitleFormat(scenario, examples) {
|
|
432
|
-
return this.getExamplesTitleFormatFromComment(examples) || this.getExamplesTitleFormatFromScenarioName(scenario, examples) || this.config.examplesTitleFormat;
|
|
433
|
-
}
|
|
434
|
-
getExamplesTitleFormatFromComment(examples) {
|
|
435
|
-
var _comment$text;
|
|
436
|
-
const {
|
|
437
|
-
line
|
|
438
|
-
} = examples.location;
|
|
439
|
-
const titleFormatCommentLine = line - 1;
|
|
440
|
-
const comment = this.gherkinDocument.comments.find(c => {
|
|
441
|
-
return c.location.line === titleFormatCommentLine;
|
|
442
|
-
});
|
|
443
|
-
const commentText = comment === null || comment === void 0 || (_comment$text = comment.text) === null || _comment$text === void 0 ? void 0 : _comment$text.trim();
|
|
444
|
-
const prefix = '# title-format:';
|
|
445
|
-
return commentText !== null && commentText !== void 0 && commentText.startsWith(prefix) ? commentText.replace(prefix, '').trim() : '';
|
|
446
|
-
}
|
|
447
|
-
getExamplesTitleFormatFromScenarioName(scenario, examples) {
|
|
448
|
-
var _examples$tableHeader2;
|
|
449
|
-
const columnsInScenarioName = (0, _utils.extractTemplateParams)(scenario.name);
|
|
450
|
-
const hasColumnsFromExamples = columnsInScenarioName.length && ((_examples$tableHeader2 = examples.tableHeader) === null || _examples$tableHeader2 === void 0 || (_examples$tableHeader2 = _examples$tableHeader2.cells) === null || _examples$tableHeader2 === void 0 ? void 0 : _examples$tableHeader2.some(cell => {
|
|
451
|
-
return cell.value && columnsInScenarioName.includes(cell.value);
|
|
452
|
-
}));
|
|
453
|
-
return hasColumnsFromExamples ? scenario.name : '';
|
|
454
|
-
}
|
|
455
|
-
skipByTagsExpression(node) {
|
|
456
|
-
// see: https://github.com/cucumber/tag-expressions/tree/main/javascript
|
|
457
|
-
const {
|
|
458
|
-
tagsExpression
|
|
459
|
-
} = this.options;
|
|
460
|
-
return tagsExpression && !tagsExpression.evaluate(node.tags);
|
|
461
|
-
}
|
|
462
|
-
isOutline(scenario) {
|
|
463
|
-
const keyword = this.getEnglishKeyword(scenario.keyword);
|
|
464
|
-
return keyword === 'ScenarioOutline' || keyword === 'Scenario Outline' || keyword === 'Scenario Template';
|
|
465
|
-
}
|
|
466
|
-
getEnglishKeyword(keyword) {
|
|
467
|
-
return this.i18nKeywordsMap ? this.i18nKeywordsMap.get(keyword) : keyword;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
exports.TestFile = TestFile;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TestMetaBuilder = void 0;
|
|
7
|
-
exports.getTestMeta = getTestMeta;
|
|
8
|
-
var _utils = require("../utils");
|
|
9
|
-
/**
|
|
10
|
-
* Class to build and print testMeta object containing meta info about each test.
|
|
11
|
-
* Tests are identified by special key constructed from title path.
|
|
12
|
-
*
|
|
13
|
-
* Example:
|
|
14
|
-
* const testMeta = {
|
|
15
|
-
* "Simple scenario": { pickleLocation: "3:10", tags: ["@foo"] },
|
|
16
|
-
* "Scenario with examples|Example #1": { pickleLocation: "8:26", tags: [] },
|
|
17
|
-
* "Rule 1|Scenario with examples|Example #1": { pickleLocation: "9:42", tags: [] },
|
|
18
|
-
* };
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
const TEST_KEY_SEPARATOR = '|';
|
|
22
|
-
class TestMetaBuilder {
|
|
23
|
-
tests = [];
|
|
24
|
-
get testCount() {
|
|
25
|
-
return this.tests.length;
|
|
26
|
-
}
|
|
27
|
-
registerTest(node, pickle) {
|
|
28
|
-
const testMeta = {
|
|
29
|
-
pickleLocation: (0, _utils.stringifyLocation)(pickle.location),
|
|
30
|
-
tags: node.tags.length ? node.tags : undefined
|
|
31
|
-
};
|
|
32
|
-
this.tests.push({
|
|
33
|
-
node,
|
|
34
|
-
testMeta
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
getObjectLines() {
|
|
38
|
-
// build object line by line to have each test on a separate line,
|
|
39
|
-
// but value should be in one line.
|
|
40
|
-
return this.tests.map(test => {
|
|
41
|
-
const testKey = this.getTestKey(test.node);
|
|
42
|
-
return `${JSON.stringify(testKey)}: ${JSON.stringify(test.testMeta)},`;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
getTestKey(node) {
|
|
46
|
-
// .slice(1) -> b/c we remove top describe title (it's same for all tests)
|
|
47
|
-
return node.titlePath.slice(1).join(TEST_KEY_SEPARATOR);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.TestMetaBuilder = TestMetaBuilder;
|
|
51
|
-
function getTestMeta(testMetaMap, testInfo) {
|
|
52
|
-
// .slice(2) -> b/c we remove filename and top describe title
|
|
53
|
-
const key = testInfo.titlePath.slice(2).join(TEST_KEY_SEPARATOR);
|
|
54
|
-
const testMeta = testMetaMap[key];
|
|
55
|
-
if (!testMeta) {
|
|
56
|
-
// throw new Error(`Can't find testMeta for key "${key}"`);
|
|
57
|
-
return {};
|
|
58
|
-
}
|
|
59
|
-
return testMeta;
|
|
60
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TestNode = void 0;
|
|
7
|
-
var _utils = require("../utils");
|
|
8
|
-
var _specialTags = require("./specialTags");
|
|
9
|
-
/**
|
|
10
|
-
* Universal TestNode class representing test or suite in a test file.
|
|
11
|
-
* Holds parent-child links.
|
|
12
|
-
* Allows to inherit tags and titles path.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
class TestNode {
|
|
16
|
-
title;
|
|
17
|
-
titlePath;
|
|
18
|
-
ownTags;
|
|
19
|
-
tags;
|
|
20
|
-
specialTags;
|
|
21
|
-
constructor(gherkinNode, parent) {
|
|
22
|
-
this.title = gherkinNode.name;
|
|
23
|
-
this.titlePath = ((parent === null || parent === void 0 ? void 0 : parent.titlePath) || []).concat([this.title]);
|
|
24
|
-
this.ownTags = (0, _utils.removeDuplicates)(getTagNames(gherkinNode.tags));
|
|
25
|
-
this.tags = (0, _utils.removeDuplicates)(((parent === null || parent === void 0 ? void 0 : parent.tags) || []).concat(this.ownTags));
|
|
26
|
-
this.specialTags = new _specialTags.SpecialTags(this.ownTags, this.tags);
|
|
27
|
-
}
|
|
28
|
-
isSkipped() {
|
|
29
|
-
return this.specialTags.skip || this.specialTags.fixme;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.TestNode = TestNode;
|
|
33
|
-
function getTagNames(tags) {
|
|
34
|
-
return tags.map(tag => tag.name);
|
|
35
|
-
}
|