@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,197 +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.MessagesBuilder = void 0;
|
|
8
|
-
var _TestCaseRun = require("./TestCaseRun");
|
|
9
|
-
var _TestCase = require("./TestCase");
|
|
10
|
-
var _Meta = require("./Meta");
|
|
11
|
-
var _timing = require("./timing");
|
|
12
|
-
var _events = _interopRequireDefault(require("events"));
|
|
13
|
-
var _EventDataCollector = _interopRequireDefault(require("../../../cucumber/formatter/EventDataCollector"));
|
|
14
|
-
var _AutofillMap = require("../../../utils/AutofillMap");
|
|
15
|
-
var _GherkinDocuments = require("./GherkinDocuments");
|
|
16
|
-
var _Pickles = require("./Pickles");
|
|
17
|
-
class MessagesBuilder {
|
|
18
|
-
report = {
|
|
19
|
-
meta: null,
|
|
20
|
-
source: [],
|
|
21
|
-
gherkinDocument: [],
|
|
22
|
-
pickle: [],
|
|
23
|
-
stepDefinition: [],
|
|
24
|
-
hook: [],
|
|
25
|
-
testRunStarted: null,
|
|
26
|
-
testCase: [],
|
|
27
|
-
testCaseRuns: [],
|
|
28
|
-
testRunFinished: null
|
|
29
|
-
};
|
|
30
|
-
fullResult;
|
|
31
|
-
onTestEnds = [];
|
|
32
|
-
testCaseRuns = [];
|
|
33
|
-
testCases = new _AutofillMap.AutofillMap();
|
|
34
|
-
hooks = new _AutofillMap.AutofillMap();
|
|
35
|
-
gherkinDocuments = new _GherkinDocuments.GherkinDocuments();
|
|
36
|
-
fullResultTiming;
|
|
37
|
-
onEndPromise;
|
|
38
|
-
onEndPromiseResolve = () => {};
|
|
39
|
-
buildMessagesPromise;
|
|
40
|
-
eventDataCollectorEmitter = new _events.default();
|
|
41
|
-
eventDataCollector = new _EventDataCollector.default(this.eventDataCollectorEmitter);
|
|
42
|
-
constructor() {
|
|
43
|
-
this.onEndPromise = new Promise(resolve => this.onEndPromiseResolve = resolve);
|
|
44
|
-
}
|
|
45
|
-
onTestEnd(test, result) {
|
|
46
|
-
// For skipped tests Playwright doesn't run fixtures
|
|
47
|
-
// and we don't have bddData attachment -> don't know feature uri.
|
|
48
|
-
// Don't add such test run to report.
|
|
49
|
-
if (test.expectedStatus === 'skipped') {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
// Important to create TestCaseRun here,
|
|
53
|
-
// b/c test properties can change after retries (e.g. annotations)
|
|
54
|
-
const testCaseRun = new _TestCaseRun.TestCaseRun(test, result, this.hooks);
|
|
55
|
-
this.testCaseRuns.push(testCaseRun);
|
|
56
|
-
}
|
|
57
|
-
onEnd(fullResult) {
|
|
58
|
-
this.fullResult = fullResult;
|
|
59
|
-
this.onEndPromiseResolve();
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Builds Cucumber messages.
|
|
63
|
-
* Note: wrapped into promise to build messages once for all reporters.
|
|
64
|
-
*/
|
|
65
|
-
async buildMessages() {
|
|
66
|
-
if (!this.buildMessagesPromise) {
|
|
67
|
-
this.buildMessagesPromise = this.doBuildMessages();
|
|
68
|
-
}
|
|
69
|
-
return this.buildMessagesPromise;
|
|
70
|
-
}
|
|
71
|
-
// eslint-disable-next-line max-statements
|
|
72
|
-
async doBuildMessages() {
|
|
73
|
-
await this.onEndPromise;
|
|
74
|
-
// order here is important
|
|
75
|
-
// this.createTestCaseRuns();
|
|
76
|
-
await this.loadFeatures();
|
|
77
|
-
this.createTestCases();
|
|
78
|
-
this.addMeta();
|
|
79
|
-
this.addSourcesAndDocuments();
|
|
80
|
-
this.addPickles();
|
|
81
|
-
this.addHooks();
|
|
82
|
-
this.addTestRunStarted();
|
|
83
|
-
this.addTestCases();
|
|
84
|
-
this.addTestCaseRuns();
|
|
85
|
-
this.addTestRunFinished();
|
|
86
|
-
this.buildEventDataCollector();
|
|
87
|
-
}
|
|
88
|
-
emitMessages(eventBroadcaster) {
|
|
89
|
-
Object.values(this.report).forEach(value => {
|
|
90
|
-
if (!value) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const messages = Array.isArray(value) ? value : [value];
|
|
94
|
-
messages.forEach(message => eventBroadcaster.emit('envelope', message));
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
createTestCases() {
|
|
98
|
-
this.testCaseRuns.forEach(testCaseRun => {
|
|
99
|
-
const testId = testCaseRun.test.id;
|
|
100
|
-
const gherkinDocsForProject = this.gherkinDocuments.getDocumentsForProject(testCaseRun.projectInfo);
|
|
101
|
-
const testCase = this.testCases.getOrCreate(testId, () => new _TestCase.TestCase(testId, gherkinDocsForProject));
|
|
102
|
-
testCase.addRun(testCaseRun);
|
|
103
|
-
testCaseRun.testCase = testCase;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
async loadFeatures() {
|
|
107
|
-
await this.gherkinDocuments.load(this.testCaseRuns);
|
|
108
|
-
}
|
|
109
|
-
// private createTestCaseRuns() {
|
|
110
|
-
// this.onTestEnds.forEach(({ test, result }) => {
|
|
111
|
-
// // For skipped tests Playwright doesn't run fixtures
|
|
112
|
-
// // and we don't have bddData attachment -> don't know feature uri.
|
|
113
|
-
// // Don't add such test run to report.
|
|
114
|
-
// if (test.expectedStatus === 'skipped') return;
|
|
115
|
-
// const testCaseRun = new TestCaseRun(test, result, this.hooks);
|
|
116
|
-
// this.testCaseRuns.push(testCaseRun);
|
|
117
|
-
// });
|
|
118
|
-
// }
|
|
119
|
-
addMeta() {
|
|
120
|
-
this.report.meta = new _Meta.Meta().buildMessage();
|
|
121
|
-
}
|
|
122
|
-
addSourcesAndDocuments() {
|
|
123
|
-
const {
|
|
124
|
-
sources,
|
|
125
|
-
gherkinDocuments
|
|
126
|
-
} = this.gherkinDocuments.buildMessages();
|
|
127
|
-
this.report.source = sources;
|
|
128
|
-
this.report.gherkinDocument = gherkinDocuments;
|
|
129
|
-
}
|
|
130
|
-
addPickles() {
|
|
131
|
-
this.report.pickle = new _Pickles.Pickles().buildMessages(this.testCases);
|
|
132
|
-
}
|
|
133
|
-
addHooks() {
|
|
134
|
-
this.hooks.forEach(hook => {
|
|
135
|
-
const message = hook.buildMessage();
|
|
136
|
-
this.report.hook.push(message);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
addTestCases() {
|
|
140
|
-
this.testCases.forEach(testCase => {
|
|
141
|
-
const message = testCase.buildMessage();
|
|
142
|
-
this.report.testCase.push(message);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
addTestCaseRuns() {
|
|
146
|
-
this.testCaseRuns.map(testCaseRun => {
|
|
147
|
-
const messages = testCaseRun.buildMessages();
|
|
148
|
-
this.report.testCaseRuns.push(...messages);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
addTestRunStarted() {
|
|
152
|
-
const {
|
|
153
|
-
startTime
|
|
154
|
-
} = this.getFullResultTiming();
|
|
155
|
-
const testRunStarted = {
|
|
156
|
-
timestamp: (0, _timing.toCucumberTimestamp)(startTime.getTime())
|
|
157
|
-
};
|
|
158
|
-
this.report.testRunStarted = {
|
|
159
|
-
testRunStarted
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
addTestRunFinished() {
|
|
163
|
-
const {
|
|
164
|
-
startTime,
|
|
165
|
-
duration
|
|
166
|
-
} = this.getFullResultTiming();
|
|
167
|
-
const testRunFinished = {
|
|
168
|
-
success: this.fullResult.status === 'passed',
|
|
169
|
-
timestamp: (0, _timing.toCucumberTimestamp)(startTime.getTime() + duration)
|
|
170
|
-
};
|
|
171
|
-
this.report.testRunFinished = {
|
|
172
|
-
testRunFinished
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
buildEventDataCollector() {
|
|
176
|
-
this.emitMessages(this.eventDataCollectorEmitter);
|
|
177
|
-
}
|
|
178
|
-
getFullResultTiming() {
|
|
179
|
-
if (this.fullResultTiming) {
|
|
180
|
-
return this.fullResultTiming;
|
|
181
|
-
}
|
|
182
|
-
// result.startTime and result.duration were added in pw 1.37
|
|
183
|
-
// see: https://github.com/microsoft/playwright/pull/26760
|
|
184
|
-
if ('startTime' in this.fullResult && 'duration' in this.fullResult) {
|
|
185
|
-
this.fullResultTiming = {
|
|
186
|
-
startTime: this.fullResult.startTime,
|
|
187
|
-
duration: this.fullResult.duration
|
|
188
|
-
};
|
|
189
|
-
} else {
|
|
190
|
-
// Calculate overall startTime and duration based on test timings
|
|
191
|
-
const items = this.testCaseRuns.map(t => t.result);
|
|
192
|
-
this.fullResultTiming = (0, _timing.calcMinMaxByArray)(items);
|
|
193
|
-
}
|
|
194
|
-
return this.fullResultTiming;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
exports.MessagesBuilder = MessagesBuilder;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GherkinDocumentMessage = void 0;
|
|
7
|
-
var _utils = require("../../../utils");
|
|
8
|
-
var _Projects = require("./Projects");
|
|
9
|
-
const gherkinDocumentMetaSymbol = Symbol('gherkinDocumentMeta');
|
|
10
|
-
class GherkinDocumentMessage {
|
|
11
|
-
projectInfo;
|
|
12
|
-
gherkinDocument;
|
|
13
|
-
static extractMeta(gherkinDocument) {
|
|
14
|
-
return gherkinDocument[gherkinDocumentMetaSymbol];
|
|
15
|
-
}
|
|
16
|
-
constructor(projectInfo, gherkinDocument) {
|
|
17
|
-
this.projectInfo = projectInfo;
|
|
18
|
-
this.gherkinDocument = gherkinDocument;
|
|
19
|
-
}
|
|
20
|
-
build() {
|
|
21
|
-
const gherkinDocument = this.copyDocumentWithoutPickles();
|
|
22
|
-
this.setUriWithProject(gherkinDocument);
|
|
23
|
-
this.setMeta(gherkinDocument);
|
|
24
|
-
return {
|
|
25
|
-
gherkinDocument
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
copyDocumentWithoutPickles() {
|
|
29
|
-
return (0, _utils.omit)(this.gherkinDocument, 'pickles');
|
|
30
|
-
}
|
|
31
|
-
setUriWithProject(gherkinDocument) {
|
|
32
|
-
gherkinDocument.uri = (0, _Projects.getFeatureUriWithProject)(this.projectInfo, this.gherkinDocument.uri);
|
|
33
|
-
}
|
|
34
|
-
setMeta(gherkinDocument) {
|
|
35
|
-
var _this$projectInfo, _this$projectInfo2;
|
|
36
|
-
gherkinDocument[gherkinDocumentMetaSymbol] = {
|
|
37
|
-
originalUri: this.gherkinDocument.uri || '',
|
|
38
|
-
projectName: (_this$projectInfo = this.projectInfo) === null || _this$projectInfo === void 0 ? void 0 : _this$projectInfo.projectName,
|
|
39
|
-
browserName: (_this$projectInfo2 = this.projectInfo) === null || _this$projectInfo2 === void 0 ? void 0 : _this$projectInfo2.browserName
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.GherkinDocumentMessage = GherkinDocumentMessage;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GherkinDocumentClone = void 0;
|
|
7
|
-
var _crypto = require("crypto");
|
|
8
|
-
var _AutofillMap = require("../../../utils/AutofillMap");
|
|
9
|
-
/**
|
|
10
|
-
* Creates gherkin document copy with re-generated ast node IDs,
|
|
11
|
-
* pickle IDs and pickle steps IDs.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
class GherkinDocumentClone {
|
|
15
|
-
gherkinDocument;
|
|
16
|
-
oldNewIds = new _AutofillMap.AutofillMap();
|
|
17
|
-
constructor(gherkinDocument) {
|
|
18
|
-
this.gherkinDocument = gherkinDocument;
|
|
19
|
-
}
|
|
20
|
-
getClone() {
|
|
21
|
-
const copiedDoc = this.getDocumentCopyWithNewIds();
|
|
22
|
-
this.remapPickleAstNodeIds(copiedDoc);
|
|
23
|
-
return copiedDoc;
|
|
24
|
-
}
|
|
25
|
-
getDocumentCopyWithNewIds() {
|
|
26
|
-
return JSON.parse(JSON.stringify(this.gherkinDocument, (key, value) => {
|
|
27
|
-
return key === 'id' ? this.getOrGenerateNewId(value) : value;
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
remapPickleAstNodeIds(copiedDoc) {
|
|
31
|
-
copiedDoc.pickles.forEach(pickle => {
|
|
32
|
-
pickle.astNodeIds = pickle.astNodeIds.map(oldId => this.getNewId(oldId));
|
|
33
|
-
this.remapPickleStepsAstNodeIds(pickle);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
remapPickleStepsAstNodeIds(pickle) {
|
|
37
|
-
pickle.steps.forEach(step => {
|
|
38
|
-
step.astNodeIds = step.astNodeIds.map(oldId => this.getNewId(oldId));
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
getOrGenerateNewId(oldId) {
|
|
42
|
-
return this.oldNewIds.getOrCreate(oldId, () => (0, _crypto.randomUUID)());
|
|
43
|
-
}
|
|
44
|
-
getNewId(oldId) {
|
|
45
|
-
const newId = this.oldNewIds.get(oldId);
|
|
46
|
-
if (!newId) {
|
|
47
|
-
throw new Error(`New ID is not found for old ID: ${oldId}`);
|
|
48
|
-
}
|
|
49
|
-
return newId;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.GherkinDocumentClone = GherkinDocumentClone;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GherkinDocuments = void 0;
|
|
7
|
-
var _AutofillMap = require("../../../utils/AutofillMap");
|
|
8
|
-
var _loadFeatures = require("../../../cucumber/loadFeatures");
|
|
9
|
-
var _configDir = require("../../../config/configDir");
|
|
10
|
-
var _GherkinDocumentClone = require("./GherkinDocumentClone");
|
|
11
|
-
var _GherkinDocument = require("./GherkinDocument");
|
|
12
|
-
var _Projects = require("./Projects");
|
|
13
|
-
var _env = require("../../../config/env");
|
|
14
|
-
var _lang = require("../../../config/lang");
|
|
15
|
-
class GherkinDocuments {
|
|
16
|
-
featuresLoader = new _loadFeatures.FeaturesLoader();
|
|
17
|
-
projectsPerFeaturePath = new _AutofillMap.AutofillMap();
|
|
18
|
-
gherkinDocumentsPerProject = new _AutofillMap.AutofillMap();
|
|
19
|
-
constructor() {}
|
|
20
|
-
async load(testCaseRuns) {
|
|
21
|
-
this.fillProjectsPerFeaturePath(testCaseRuns);
|
|
22
|
-
const cwd = (0, _configDir.getPlaywrightConfigDir)();
|
|
23
|
-
const featurePaths = [...this.projectsPerFeaturePath.keys()];
|
|
24
|
-
await this.featuresLoader.load(featurePaths, {
|
|
25
|
-
relativeTo: cwd,
|
|
26
|
-
defaultDialect: this.getFeaturesLang()
|
|
27
|
-
});
|
|
28
|
-
this.fillGherkinDocumentsPerProject();
|
|
29
|
-
}
|
|
30
|
-
getDocumentsForProject(projectInfo) {
|
|
31
|
-
const docs = this.gherkinDocumentsPerProject.get(projectInfo);
|
|
32
|
-
if (!docs) {
|
|
33
|
-
throw new Error(`No gherkin docs for project ${projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.projectName}`);
|
|
34
|
-
}
|
|
35
|
-
return docs;
|
|
36
|
-
}
|
|
37
|
-
buildMessages() {
|
|
38
|
-
const sources = [];
|
|
39
|
-
const gherkinDocuments = [];
|
|
40
|
-
this.gherkinDocumentsPerProject.forEach((docs, project) => {
|
|
41
|
-
docs.forEach(doc => {
|
|
42
|
-
sources.push(this.buildSourceMessage(project, doc));
|
|
43
|
-
gherkinDocuments.push(new _GherkinDocument.GherkinDocumentMessage(project, doc).build());
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
return {
|
|
47
|
-
sources,
|
|
48
|
-
gherkinDocuments
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
fillProjectsPerFeaturePath(testCaseRuns) {
|
|
52
|
-
testCaseRuns.forEach(testCaseRun => {
|
|
53
|
-
const projects = this.projectsPerFeaturePath.getOrCreate(testCaseRun.bddData.uri, () => new Set());
|
|
54
|
-
projects.add(testCaseRun.projectInfo);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
fillGherkinDocumentsPerProject() {
|
|
58
|
-
this.featuresLoader.getDocumentsWithPickles().forEach(gherkinDocument => {
|
|
59
|
-
if (!gherkinDocument.uri) {
|
|
60
|
-
throw new Error(`Feature without uri`);
|
|
61
|
-
}
|
|
62
|
-
const projects = this.projectsPerFeaturePath.get(gherkinDocument.uri);
|
|
63
|
-
if (!projects) {
|
|
64
|
-
throw new Error(`Feature without projects: ${gherkinDocument.uri}`);
|
|
65
|
-
}
|
|
66
|
-
projects.forEach(project => {
|
|
67
|
-
this.addGherkinDocumentToProject(project, gherkinDocument);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
addGherkinDocumentToProject(projectInfo, gherkinDocument) {
|
|
72
|
-
const projectDocs = this.gherkinDocumentsPerProject.getOrCreate(projectInfo, () => []);
|
|
73
|
-
const clonedDocument = new _GherkinDocumentClone.GherkinDocumentClone(gherkinDocument).getClone();
|
|
74
|
-
projectDocs.push(clonedDocument);
|
|
75
|
-
}
|
|
76
|
-
buildSourceMessage(projectInfo, doc) {
|
|
77
|
-
if (!doc.uri) {
|
|
78
|
-
throw new Error(`Doc without uri`);
|
|
79
|
-
}
|
|
80
|
-
const originalSource = this.featuresLoader.gherkinQuery.getSource(doc.uri);
|
|
81
|
-
if (!originalSource) {
|
|
82
|
-
throw new Error(`No source`);
|
|
83
|
-
}
|
|
84
|
-
const source = {
|
|
85
|
-
...originalSource,
|
|
86
|
-
uri: (0, _Projects.getFeatureUriWithProject)(projectInfo, doc.uri)
|
|
87
|
-
};
|
|
88
|
-
return {
|
|
89
|
-
source
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
getFeaturesLang() {
|
|
93
|
-
const langsSet = new Set();
|
|
94
|
-
const envConfigs = (0, _env.getEnvConfigs)();
|
|
95
|
-
Object.values(envConfigs).forEach(config => {
|
|
96
|
-
langsSet.add(config.language || _lang.LANG_EN);
|
|
97
|
-
});
|
|
98
|
-
const langs = [...langsSet];
|
|
99
|
-
if (langs.length > 1) {
|
|
100
|
-
throw new Error([`Multi-language features are not supported yet.`, `Detected languages: ${langs.join(', ')}`].join(' '));
|
|
101
|
-
}
|
|
102
|
-
return langs[0];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.GherkinDocuments = GherkinDocuments;
|
|
@@ -1,70 +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.Hook = void 0;
|
|
8
|
-
var _crypto = require("crypto");
|
|
9
|
-
var _configDir = require("../../../config/configDir");
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
/**
|
|
12
|
-
* Hook that can be used in different test cases.
|
|
13
|
-
* Builds Cucumber's hook message.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
class Hook {
|
|
17
|
-
internalId;
|
|
18
|
-
static getInternalId(pwStep) {
|
|
19
|
-
const {
|
|
20
|
-
file,
|
|
21
|
-
line,
|
|
22
|
-
column
|
|
23
|
-
} = pwStep.location || {};
|
|
24
|
-
return [pwStep.category, ...pwStep.titlePath(), file, line, column].join('|');
|
|
25
|
-
}
|
|
26
|
-
id;
|
|
27
|
-
name;
|
|
28
|
-
sourceReference;
|
|
29
|
-
constructor(internalId, /* one of pwSteps for this hook */
|
|
30
|
-
pwStep) {
|
|
31
|
-
this.internalId = internalId;
|
|
32
|
-
this.id = (0, _crypto.randomUUID)();
|
|
33
|
-
this.name = this.getName(pwStep);
|
|
34
|
-
this.sourceReference = this.getSourceReference(pwStep);
|
|
35
|
-
}
|
|
36
|
-
buildMessage() {
|
|
37
|
-
const hook = {
|
|
38
|
-
id: this.id,
|
|
39
|
-
name: this.name,
|
|
40
|
-
sourceReference: this.sourceReference
|
|
41
|
-
};
|
|
42
|
-
return {
|
|
43
|
-
hook
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
getName(pwStep) {
|
|
47
|
-
// These fixture names are for anonymous hooks
|
|
48
|
-
// created with Before() / After() functions.
|
|
49
|
-
// Keep name empty for them to be consistent with Cucumber.
|
|
50
|
-
// const bddSystemFixtures = ['fixture: $before', 'fixture: $after'];
|
|
51
|
-
// if (!pwStep.title || bddSystemFixtures.includes(pwStep.title)) return undefined;
|
|
52
|
-
return pwStep.title;
|
|
53
|
-
}
|
|
54
|
-
getSourceReference(pwStep) {
|
|
55
|
-
const {
|
|
56
|
-
file,
|
|
57
|
-
line,
|
|
58
|
-
column
|
|
59
|
-
} = pwStep.location || {};
|
|
60
|
-
const uri = file ? _path.default.relative((0, _configDir.getPlaywrightConfigDir)(), file) : undefined;
|
|
61
|
-
return {
|
|
62
|
-
uri,
|
|
63
|
-
location: line ? {
|
|
64
|
-
line,
|
|
65
|
-
column
|
|
66
|
-
} : undefined
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.Hook = Hook;
|
|
@@ -1,45 +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.Meta = void 0;
|
|
8
|
-
var _os = _interopRequireDefault(require("os"));
|
|
9
|
-
var messages = _interopRequireWildcard(require("@cucumber/messages"));
|
|
10
|
-
var _utils = require("../../../utils");
|
|
11
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
-
/**
|
|
14
|
-
* Builds meta message.
|
|
15
|
-
* See: https://github.com/cucumber/cucumber-js/blob/main/src/cli/helpers.ts#L100
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
class Meta {
|
|
19
|
-
buildMessage() {
|
|
20
|
-
const playwrightBddVersion = (0, _utils.getPackageVersion)('playwright-bdd');
|
|
21
|
-
const playwrightVersion = (0, _utils.getPackageVersion)('@playwright/test');
|
|
22
|
-
const meta = {
|
|
23
|
-
protocolVersion: messages.version,
|
|
24
|
-
implementation: {
|
|
25
|
-
version: `${playwrightBddVersion} (playwright ${playwrightVersion})`,
|
|
26
|
-
name: 'playwright-bdd'
|
|
27
|
-
},
|
|
28
|
-
cpu: {
|
|
29
|
-
name: _os.default.arch()
|
|
30
|
-
},
|
|
31
|
-
os: {
|
|
32
|
-
name: _os.default.platform(),
|
|
33
|
-
version: _os.default.release()
|
|
34
|
-
},
|
|
35
|
-
runtime: {
|
|
36
|
-
name: 'node.js',
|
|
37
|
-
version: process.versions.node
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
return {
|
|
41
|
-
meta
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.Meta = Meta;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Pickles = void 0;
|
|
7
|
-
var _utils = require("../../../utils");
|
|
8
|
-
var _Projects = require("./Projects");
|
|
9
|
-
class Pickles {
|
|
10
|
-
buildMessages(testCases) {
|
|
11
|
-
const messages = [];
|
|
12
|
-
testCases.forEach(testCase => {
|
|
13
|
-
messages.push(this.buildPickleMessage(testCase));
|
|
14
|
-
});
|
|
15
|
-
return messages;
|
|
16
|
-
}
|
|
17
|
-
buildPickleMessage(testCase) {
|
|
18
|
-
const pickle = {
|
|
19
|
-
...(0, _utils.omit)(testCase.pickle, 'location'),
|
|
20
|
-
uri: (0, _Projects.getFeatureUriWithProject)(testCase.projectInfo, testCase.pickle.uri)
|
|
21
|
-
};
|
|
22
|
-
return {
|
|
23
|
-
pickle
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.Pickles = Pickles;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TITLE_SEPARATOR = void 0;
|
|
7
|
-
exports.getFeatureNameWithProject = getFeatureNameWithProject;
|
|
8
|
-
exports.getFeatureUriWithProject = getFeatureUriWithProject;
|
|
9
|
-
exports.getProjectInfo = getProjectInfo;
|
|
10
|
-
var _AutofillMap = require("../../../utils/AutofillMap");
|
|
11
|
-
// title separator used in Playwright
|
|
12
|
-
const TITLE_SEPARATOR = exports.TITLE_SEPARATOR = ' › ';
|
|
13
|
-
const projectsMap = new _AutofillMap.AutofillMap();
|
|
14
|
-
function getProjectInfo(test) {
|
|
15
|
-
const project = test.parent.project();
|
|
16
|
-
const projectId = project === null || project === void 0 ? void 0 : project.name;
|
|
17
|
-
return projectsMap.getOrCreate(projectId, () => {
|
|
18
|
-
return {
|
|
19
|
-
projectName: project === null || project === void 0 ? void 0 : project.name,
|
|
20
|
-
// browserName will be empty if not defined in project
|
|
21
|
-
// todo: get browser info from bddData
|
|
22
|
-
browserName: (project === null || project === void 0 ? void 0 : project.use.browserName) || (project === null || project === void 0 ? void 0 : project.use.defaultBrowserType)
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Returns URI prepended with project name.
|
|
28
|
-
* It allows to separate PW projects runs of the same feature file.
|
|
29
|
-
*
|
|
30
|
-
* Now result should not contain spaces as Cucumber HTML report uses it as uuid.
|
|
31
|
-
* See: https://github.com/cucumber/react-components/issues/344
|
|
32
|
-
*/
|
|
33
|
-
function getFeatureUriWithProject(projectInfo, uri) {
|
|
34
|
-
return projectInfo !== null && projectInfo !== void 0 && projectInfo.projectName && uri ? `[${projectInfo.projectName}]:${uri}` : uri;
|
|
35
|
-
}
|
|
36
|
-
function getFeatureNameWithProject(projectName, featureName) {
|
|
37
|
-
return projectName ? `${projectName}${TITLE_SEPARATOR}${featureName}` : featureName;
|
|
38
|
-
}
|