@zohodesk/testinglibrary 0.1.8-stb-bdd-v26 → 0.1.9
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/.babelrc +21 -18
- package/.eslintrc.js +31 -31
- package/.prettierrc +5 -5
- package/README.md +17 -17
- package/bin/cli.js +2 -2
- package/build/bdd-framework/cli/commands/env.js +42 -0
- package/build/bdd-framework/cli/commands/export.js +47 -0
- package/build/bdd-framework/cli/commands/test.js +64 -0
- package/build/bdd-framework/cli/index.js +11 -0
- package/build/bdd-framework/cli/options.js +19 -0
- package/build/bdd-framework/cli/worker.js +13 -0
- package/build/bdd-framework/config/configDir.js +35 -0
- package/build/bdd-framework/config/enrichReporterData.js +23 -0
- package/build/bdd-framework/config/env.js +50 -0
- package/build/bdd-framework/config/index.js +94 -0
- package/build/bdd-framework/config/lang.js +14 -0
- package/build/bdd-framework/cucumber/buildStepDefinition.js +43 -0
- package/build/bdd-framework/cucumber/createTestStep.js +43 -0
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +126 -0
- package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +72 -0
- package/build/bdd-framework/cucumber/formatter/PickleParser.js +25 -0
- package/build/bdd-framework/cucumber/formatter/durationHelpers.js +13 -0
- package/build/bdd-framework/cucumber/formatter/getColorFns.js +57 -0
- package/build/bdd-framework/cucumber/formatter/index.js +16 -0
- package/build/bdd-framework/cucumber/formatter/locationHelpers.js +16 -0
- package/build/bdd-framework/cucumber/loadConfig.js +17 -0
- package/build/bdd-framework/cucumber/loadFeatures.js +70 -0
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +20 -0
- package/build/bdd-framework/cucumber/loadSteps.js +47 -0
- package/build/bdd-framework/cucumber/resolveFeaturePaths.js +62 -0
- package/build/bdd-framework/cucumber/stepArguments.js +21 -0
- package/build/bdd-framework/cucumber/types.js +5 -0
- package/build/bdd-framework/cucumber/valueChecker.js +23 -0
- package/build/bdd-framework/decorators.js +18 -0
- package/build/bdd-framework/gen/fixtures.js +48 -0
- package/build/bdd-framework/gen/formatter.js +123 -0
- package/build/bdd-framework/gen/i18n.js +39 -0
- package/build/bdd-framework/gen/index.js +185 -0
- package/build/bdd-framework/gen/testFile.js +465 -0
- package/build/bdd-framework/gen/testMeta.js +60 -0
- package/build/bdd-framework/gen/testNode.js +60 -0
- package/build/bdd-framework/gen/testPoms.js +133 -0
- package/build/bdd-framework/hooks/scenario.js +130 -0
- package/build/bdd-framework/hooks/worker.js +89 -0
- package/build/bdd-framework/index.js +52 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +93 -0
- package/build/bdd-framework/playwright/getLocationInFile.js +79 -0
- package/build/bdd-framework/playwright/loadConfig.js +42 -0
- package/build/bdd-framework/playwright/loadUtils.js +33 -0
- package/build/bdd-framework/playwright/testTypeImpl.js +61 -0
- package/build/bdd-framework/playwright/transform.js +88 -0
- package/build/bdd-framework/playwright/types.js +5 -0
- package/build/bdd-framework/playwright/utils.js +34 -0
- package/build/bdd-framework/reporter/cucumber/base.js +57 -0
- package/build/bdd-framework/reporter/cucumber/custom.js +73 -0
- package/build/bdd-framework/reporter/cucumber/helper.js +12 -0
- package/build/bdd-framework/reporter/cucumber/html.js +35 -0
- package/build/bdd-framework/reporter/cucumber/index.js +74 -0
- package/build/bdd-framework/reporter/cucumber/json.js +312 -0
- package/build/bdd-framework/reporter/cucumber/junit.js +205 -0
- package/build/bdd-framework/reporter/cucumber/message.js +20 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +64 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +196 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +43 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +52 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +105 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +70 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +45 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +27 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +38 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +128 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +126 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +102 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +50 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +88 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +30 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwUtils.js +51 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +35 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +5 -0
- package/build/bdd-framework/run/StepInvoker.js +68 -0
- package/build/bdd-framework/run/bddDataAttachment.js +46 -0
- package/build/bdd-framework/run/bddFixtures.js +191 -0
- package/build/bdd-framework/run/bddWorld.js +79 -0
- package/build/bdd-framework/run/bddWorldInternal.js +15 -0
- package/build/bdd-framework/snippets/index.js +132 -0
- package/build/bdd-framework/snippets/snippetSyntax.js +43 -0
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +26 -0
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +18 -0
- package/build/bdd-framework/stepDefinitions/createBdd.js +66 -0
- package/build/bdd-framework/stepDefinitions/decorators/class.js +68 -0
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +99 -0
- package/build/bdd-framework/stepDefinitions/defineStep.js +62 -0
- package/build/bdd-framework/stepDefinitions/stepConfig.js +24 -0
- package/build/bdd-framework/utils/AutofillMap.js +20 -0
- package/build/bdd-framework/utils/exit.js +62 -0
- package/build/bdd-framework/utils/index.js +93 -0
- package/build/bdd-framework/utils/jsStringWrap.js +44 -0
- package/build/bdd-framework/utils/logger.js +30 -0
- package/build/bdd-framework/utils/stripAnsiEscapes.js +20 -0
- package/build/core/playwright/builtInFixtures/addTags.js +1 -1
- package/build/core/playwright/builtInFixtures/context.js +18 -1
- package/build/core/playwright/builtInFixtures/i18N.js +33 -0
- package/build/core/playwright/builtInFixtures/index.js +19 -7
- package/build/core/playwright/builtInFixtures/page.js +69 -39
- package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
- package/build/core/playwright/clear-caches.js +19 -8
- package/build/core/playwright/codegen.js +4 -4
- package/build/core/playwright/constants/browserTypes.js +12 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +10 -6
- package/build/core/playwright/helpers/auth/accountLogin.js +18 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +47 -0
- package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
- package/build/core/playwright/helpers/auth/getUsers.js +72 -0
- package/build/core/playwright/helpers/auth/index.js +58 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +36 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +17 -0
- package/build/core/playwright/helpers/getUserFixtures.js +23 -0
- package/build/core/playwright/helpers/mergeObjects.js +13 -0
- package/build/core/playwright/helpers/parseUserArgs.js +11 -0
- package/build/core/playwright/index.js +69 -15
- package/build/core/playwright/readConfigFile.js +50 -39
- package/build/core/playwright/report-generator.js +7 -7
- package/build/core/playwright/setup/config-creator.js +15 -16
- package/build/core/playwright/setup/config-utils.js +60 -26
- package/build/core/playwright/setup/custom-reporter.js +3 -2
- package/build/core/playwright/tag-processor.js +12 -23
- package/build/core/playwright/test-runner.js +49 -63
- package/build/core/playwright/types.js +43 -0
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +16 -2
- package/build/index.d.ts +79 -12
- package/build/index.js +51 -9
- package/build/lib/cli.js +12 -3
- package/build/lib/post-install.js +18 -10
- package/build/parser/sample.feature +34 -34
- package/build/parser/sample.spec.js +18 -18
- package/build/setup-folder-structure/helper.js +3 -0
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +24 -24
- package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -72
- package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
- package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
- package/build/setup-folder-structure/samples/git-ignore.sample.js +36 -36
- package/build/setup-folder-structure/samples/uat-config-sample.js +44 -44
- package/build/utils/cliArgsToObject.js +30 -26
- package/build/utils/fileUtils.js +4 -19
- package/build/utils/getFilePath.js +1 -2
- package/build/utils/rootPath.js +16 -9
- package/changelog.md +144 -131
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +6475 -5994
- package/package.json +57 -56
- package/playwright.config.js +112 -112
- package/build/bdd-poc/config/pathConfig.js +0 -22
- package/build/bdd-poc/core-runner/exportMethods.js +0 -22
- package/build/bdd-poc/core-runner/main.js +0 -15
- package/build/bdd-poc/core-runner/stepDefinitions.js +0 -157
- package/build/bdd-poc/core-runner/stepRunner.js +0 -25
- package/build/bdd-poc/errors/throwError.js +0 -23
- package/build/bdd-poc/index.js +0 -26
- package/build/bdd-poc/test/cucumber/featureFileParer.js +0 -84
- package/build/bdd-poc/test/cucumber/parserCucumber.js +0 -15
- package/build/bdd-poc/test/stepGenerate/extractTestInputs.js +0 -65
- package/build/bdd-poc/test/stepGenerate/parserSteps.js +0 -81
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +0 -40
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +0 -61
- package/build/bdd-poc/test/tagsHandle.js +0 -70
- package/build/bdd-poc/test/testData.js +0 -125
- package/build/bdd-poc/test/testStructure.js +0 -92
- package/build/bdd-poc/utils/stringManipulation.js +0 -26
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BddData = void 0;
|
|
7
|
+
exports.getBddDataFromTestResult = getBddDataFromTestResult;
|
|
8
|
+
exports.isBddDataAttachment = isBddDataAttachment;
|
|
9
|
+
var _createTestStep = require("../cucumber/createTestStep");
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
const BDD_DATA_ATTACHMENT_NAME = '__bddData';
|
|
12
|
+
class BddData {
|
|
13
|
+
world;
|
|
14
|
+
steps = [];
|
|
15
|
+
constructor(world) {
|
|
16
|
+
this.world = world;
|
|
17
|
+
}
|
|
18
|
+
registerStep(stepDefinition, stepText, pwStepLocation) {
|
|
19
|
+
const step = (0, _createTestStep.createTestStep)(stepDefinition, stepText);
|
|
20
|
+
this.steps.push({
|
|
21
|
+
pwStepLocation: (0, _utils.stringifyLocation)(pwStepLocation),
|
|
22
|
+
stepMatchArgumentsLists: step.stepMatchArgumentsLists || []
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async attach(testMeta, uri) {
|
|
26
|
+
const attachment = {
|
|
27
|
+
uri,
|
|
28
|
+
pickleLocation: testMeta.pickleLocation,
|
|
29
|
+
steps: this.steps
|
|
30
|
+
};
|
|
31
|
+
await this.world.testInfo.attach(BDD_DATA_ATTACHMENT_NAME, {
|
|
32
|
+
contentType: 'application/json',
|
|
33
|
+
body: JSON.stringify(attachment)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BddData = BddData;
|
|
38
|
+
function getBddDataFromTestResult(result) {
|
|
39
|
+
var _attachment$body;
|
|
40
|
+
const attachment = result.attachments.find(isBddDataAttachment);
|
|
41
|
+
const attachmentBody = attachment === null || attachment === void 0 || (_attachment$body = attachment.body) === null || _attachment$body === void 0 ? void 0 : _attachment$body.toString();
|
|
42
|
+
return attachmentBody ? JSON.parse(attachmentBody) : undefined;
|
|
43
|
+
}
|
|
44
|
+
function isBddDataAttachment(attachment) {
|
|
45
|
+
return attachment.name === BDD_DATA_ATTACHMENT_NAME;
|
|
46
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isBddAutoInjectFixture = isBddAutoInjectFixture;
|
|
7
|
+
exports.test = void 0;
|
|
8
|
+
var _test = require("@playwright/test");
|
|
9
|
+
var _loadConfig = require("../cucumber/loadConfig");
|
|
10
|
+
var _loadSteps = require("../cucumber/loadSteps");
|
|
11
|
+
var _bddWorld = require("./bddWorld");
|
|
12
|
+
var _config = require("../config");
|
|
13
|
+
var _env = require("../config/env");
|
|
14
|
+
var _steps = require("../stepDefinitions/decorators/steps");
|
|
15
|
+
var _configDir = require("../config/configDir");
|
|
16
|
+
var _scenario = require("../hooks/scenario");
|
|
17
|
+
var _worker = require("../hooks/worker");
|
|
18
|
+
var _StepInvoker = require("./StepInvoker");
|
|
19
|
+
var _testMeta = require("../gen/testMeta");
|
|
20
|
+
var _logger = require("../utils/logger");
|
|
21
|
+
var _enrichReporterData = require("../config/enrichReporterData");
|
|
22
|
+
const test = exports.test = _test.test.extend({
|
|
23
|
+
// load cucumber once per worker (auto-fixture)
|
|
24
|
+
// todo: maybe remove caching in cucumber/loadConfig.ts and cucumber/loadSteps.ts
|
|
25
|
+
// as we call it once per worker. Check generation phase.
|
|
26
|
+
$cucumber: [async ({}, use, workerInfo) => {
|
|
27
|
+
const config = (0, _env.getConfigFromEnv)(workerInfo.project.testDir);
|
|
28
|
+
const environment = {
|
|
29
|
+
cwd: (0, _configDir.getPlaywrightConfigDir)()
|
|
30
|
+
};
|
|
31
|
+
const {
|
|
32
|
+
runConfiguration
|
|
33
|
+
} = await (0, _loadConfig.loadConfig)({
|
|
34
|
+
provided: (0, _config.extractCucumberConfig)(config)
|
|
35
|
+
}, environment);
|
|
36
|
+
const supportCodeLibrary = await (0, _loadSteps.loadSteps)(runConfiguration, environment);
|
|
37
|
+
(0, _steps.appendDecoratorSteps)(supportCodeLibrary);
|
|
38
|
+
const World = (0, _bddWorld.getWorldConstructor)(supportCodeLibrary);
|
|
39
|
+
await use({
|
|
40
|
+
runConfiguration,
|
|
41
|
+
supportCodeLibrary,
|
|
42
|
+
World,
|
|
43
|
+
config
|
|
44
|
+
});
|
|
45
|
+
}, {
|
|
46
|
+
auto: true,
|
|
47
|
+
scope: 'worker'
|
|
48
|
+
}],
|
|
49
|
+
// $lang fixture can be overwritten in test file
|
|
50
|
+
$lang: ({}, use) => use(''),
|
|
51
|
+
// init $bddWorldFixtures with empty object, will be owerwritten in test file for cucumber-style
|
|
52
|
+
$bddWorldFixtures: ({}, use) => use({}),
|
|
53
|
+
$bddWorld: async ({
|
|
54
|
+
$tags,
|
|
55
|
+
$test,
|
|
56
|
+
$bddWorldFixtures,
|
|
57
|
+
$cucumber,
|
|
58
|
+
$lang,
|
|
59
|
+
$testMeta,
|
|
60
|
+
$uri
|
|
61
|
+
}, use, testInfo) => {
|
|
62
|
+
const {
|
|
63
|
+
runConfiguration,
|
|
64
|
+
supportCodeLibrary,
|
|
65
|
+
World,
|
|
66
|
+
config
|
|
67
|
+
} = $cucumber;
|
|
68
|
+
const world = new World({
|
|
69
|
+
testInfo,
|
|
70
|
+
supportCodeLibrary,
|
|
71
|
+
$tags,
|
|
72
|
+
$test,
|
|
73
|
+
$bddWorldFixtures,
|
|
74
|
+
lang: $lang,
|
|
75
|
+
parameters: runConfiguration.runtime.worldParameters || {},
|
|
76
|
+
log: () => _logger.logger.warn(`world.log() is noop, please use world.testInfo.attach()`),
|
|
77
|
+
attach: async () => _logger.logger.warn(`world.attach() is noop, please use world.testInfo.attach()`)
|
|
78
|
+
});
|
|
79
|
+
await world.init();
|
|
80
|
+
await use(world);
|
|
81
|
+
await world.destroy();
|
|
82
|
+
if ((0, _enrichReporterData.getEnrichReporterData)(config)) {
|
|
83
|
+
await world.$internal.bddData.attach($testMeta, $uri);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
Given: ({
|
|
87
|
+
$bddWorld
|
|
88
|
+
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'Given').invoke),
|
|
89
|
+
When: ({
|
|
90
|
+
$bddWorld
|
|
91
|
+
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'When').invoke),
|
|
92
|
+
Then: ({
|
|
93
|
+
$bddWorld
|
|
94
|
+
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'Then').invoke),
|
|
95
|
+
And: ({
|
|
96
|
+
$bddWorld
|
|
97
|
+
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'And').invoke),
|
|
98
|
+
But: ({
|
|
99
|
+
$bddWorld
|
|
100
|
+
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'But').invoke),
|
|
101
|
+
// init $testMetaMap with empty object, will be overwritten in each test file
|
|
102
|
+
$testMetaMap: ({}, use) => use({}),
|
|
103
|
+
// concrete test meta
|
|
104
|
+
$testMeta: ({
|
|
105
|
+
$testMetaMap
|
|
106
|
+
}, use, testInfo) => use((0, _testMeta.getTestMeta)($testMetaMap, testInfo)),
|
|
107
|
+
// concrete test tags
|
|
108
|
+
$tags: ({
|
|
109
|
+
$testMeta
|
|
110
|
+
}, use) => use($testMeta.tags || []),
|
|
111
|
+
// init $test with base test, but it will be overwritten in test file
|
|
112
|
+
$test: ({}, use) => use(_test.test),
|
|
113
|
+
// feature file uri, relative to configDir, will be overwritten in test file
|
|
114
|
+
$uri: ({}, use) => use(''),
|
|
115
|
+
// can be owerwritten in test file if there are scenario hooks
|
|
116
|
+
$scenarioHookFixtures: ({}, use) => use({}),
|
|
117
|
+
$before: [
|
|
118
|
+
// Unused dependencies are important:
|
|
119
|
+
// 1. $beforeAll / $afterAll: in pw < 1.39 worker-scoped auto-fixtures were called after test-scoped
|
|
120
|
+
// 2. $after: to call after hooks in case of errors in before hooks
|
|
121
|
+
async ({
|
|
122
|
+
$scenarioHookFixtures,
|
|
123
|
+
$bddWorld,
|
|
124
|
+
$tags,
|
|
125
|
+
$beforeAll,
|
|
126
|
+
$afterAll,
|
|
127
|
+
$after
|
|
128
|
+
}, use, $testInfo) => {
|
|
129
|
+
await (0, _scenario.runScenarioHooks)('before', {
|
|
130
|
+
$bddWorld,
|
|
131
|
+
$tags,
|
|
132
|
+
$testInfo,
|
|
133
|
+
...$scenarioHookFixtures
|
|
134
|
+
});
|
|
135
|
+
await use();
|
|
136
|
+
}, {
|
|
137
|
+
auto: true
|
|
138
|
+
}],
|
|
139
|
+
$after: [async ({
|
|
140
|
+
$scenarioHookFixtures,
|
|
141
|
+
$bddWorld,
|
|
142
|
+
$tags
|
|
143
|
+
}, use, $testInfo) => {
|
|
144
|
+
await use();
|
|
145
|
+
await (0, _scenario.runScenarioHooks)('after', {
|
|
146
|
+
$bddWorld,
|
|
147
|
+
$tags,
|
|
148
|
+
$testInfo,
|
|
149
|
+
...$scenarioHookFixtures
|
|
150
|
+
});
|
|
151
|
+
}, {
|
|
152
|
+
auto: true
|
|
153
|
+
}],
|
|
154
|
+
// can be owerwritten in test file if there are worker hooks
|
|
155
|
+
$workerHookFixtures: [({}, use) => use({}), {
|
|
156
|
+
scope: 'worker'
|
|
157
|
+
}],
|
|
158
|
+
$beforeAll: [
|
|
159
|
+
// Important unused dependencies:
|
|
160
|
+
// 1. $afterAll: in pw < 1.39 worker-scoped auto-fixtures are called in incorrect order
|
|
161
|
+
// 2. $cucumber: to load hooks before this fixtures
|
|
162
|
+
async ({
|
|
163
|
+
$workerHookFixtures,
|
|
164
|
+
$cucumber
|
|
165
|
+
}, use, $workerInfo) => {
|
|
166
|
+
await (0, _worker.runWorkerHooks)('beforeAll', {
|
|
167
|
+
$workerInfo,
|
|
168
|
+
...$workerHookFixtures
|
|
169
|
+
});
|
|
170
|
+
await use();
|
|
171
|
+
}, {
|
|
172
|
+
auto: true,
|
|
173
|
+
scope: 'worker'
|
|
174
|
+
}],
|
|
175
|
+
$afterAll: [async ({
|
|
176
|
+
$workerHookFixtures
|
|
177
|
+
}, use, $workerInfo) => {
|
|
178
|
+
await use();
|
|
179
|
+
await (0, _worker.runWorkerHooks)('afterAll', {
|
|
180
|
+
$workerInfo,
|
|
181
|
+
...$workerHookFixtures
|
|
182
|
+
});
|
|
183
|
+
}, {
|
|
184
|
+
auto: true,
|
|
185
|
+
scope: 'worker'
|
|
186
|
+
}]
|
|
187
|
+
});
|
|
188
|
+
const BDD_AUTO_INJECT_FIXTURES = ['$testInfo', '$test', '$tags'];
|
|
189
|
+
function isBddAutoInjectFixture(name) {
|
|
190
|
+
return BDD_AUTO_INJECT_FIXTURES.includes(name);
|
|
191
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BddWorld = void 0;
|
|
7
|
+
exports.getWorldConstructor = getWorldConstructor;
|
|
8
|
+
var _cucumber = require("@cucumber/cucumber");
|
|
9
|
+
var _bddWorldInternal = require("./bddWorldInternal");
|
|
10
|
+
class BddWorld extends _cucumber.World {
|
|
11
|
+
options;
|
|
12
|
+
// special property to hold internal bdd related methods, must be public.
|
|
13
|
+
$internal;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options);
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.$internal = new _bddWorldInternal.BddWorldInternal(this);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Use particular fixture in cucumber-style steps.
|
|
21
|
+
*
|
|
22
|
+
* Note: TS does not support partial generic inference,
|
|
23
|
+
* that's why we can't use this.useFixture<typeof test>('xxx');
|
|
24
|
+
* The solution is to pass TestType as a generic to BddWorld
|
|
25
|
+
* and call useFixture without explicit generic params.
|
|
26
|
+
* Finally, it looks even better as there is no need to pass `typeof test`
|
|
27
|
+
* in every `this.useFixture` call.
|
|
28
|
+
*
|
|
29
|
+
* The downside - it's impossible to pass fixtures type directly to `this.useFixture`
|
|
30
|
+
* like it's done in @Fixture decorator.
|
|
31
|
+
*
|
|
32
|
+
* See: https://stackoverflow.com/questions/45509621/specify-only-first-type-argument
|
|
33
|
+
* See: https://github.com/Microsoft/TypeScript/pull/26349
|
|
34
|
+
*/
|
|
35
|
+
useFixture(fixtureName) {
|
|
36
|
+
return this.$internal.currentStepFixtures[fixtureName];
|
|
37
|
+
}
|
|
38
|
+
get page() {
|
|
39
|
+
return this.options.$bddWorldFixtures.page;
|
|
40
|
+
}
|
|
41
|
+
get context() {
|
|
42
|
+
return this.options.$bddWorldFixtures.context;
|
|
43
|
+
}
|
|
44
|
+
get browser() {
|
|
45
|
+
return this.options.$bddWorldFixtures.browser;
|
|
46
|
+
}
|
|
47
|
+
get browserName() {
|
|
48
|
+
return this.options.$bddWorldFixtures.browserName;
|
|
49
|
+
}
|
|
50
|
+
get request() {
|
|
51
|
+
return this.options.$bddWorldFixtures.request;
|
|
52
|
+
}
|
|
53
|
+
get testInfo() {
|
|
54
|
+
return this.options.testInfo;
|
|
55
|
+
}
|
|
56
|
+
get tags() {
|
|
57
|
+
return this.options.$tags;
|
|
58
|
+
}
|
|
59
|
+
get test() {
|
|
60
|
+
return this.options.$test;
|
|
61
|
+
}
|
|
62
|
+
async init() {
|
|
63
|
+
// async setup before each test
|
|
64
|
+
}
|
|
65
|
+
async destroy() {
|
|
66
|
+
// async teardown after each test
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.BddWorld = BddWorld;
|
|
70
|
+
function getWorldConstructor(supportCodeLibrary) {
|
|
71
|
+
// setWorldConstructor was not called
|
|
72
|
+
if (supportCodeLibrary.World === _cucumber.World) {
|
|
73
|
+
return BddWorld;
|
|
74
|
+
}
|
|
75
|
+
if (!Object.prototype.isPrototypeOf.call(BddWorld, supportCodeLibrary.World)) {
|
|
76
|
+
throw new Error(`CustomWorld should inherit from playwright-bdd World`);
|
|
77
|
+
}
|
|
78
|
+
return supportCodeLibrary.World;
|
|
79
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BddWorldInternal = void 0;
|
|
7
|
+
var _bddDataAttachment = require("./bddDataAttachment");
|
|
8
|
+
class BddWorldInternal {
|
|
9
|
+
currentStepFixtures = {};
|
|
10
|
+
bddData;
|
|
11
|
+
constructor(world) {
|
|
12
|
+
this.bddData = new _bddDataAttachment.BddData(world);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.BddWorldInternal = BddWorldInternal;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Snippets = void 0;
|
|
7
|
+
var _url = require("url");
|
|
8
|
+
var _loadSnippetBuilder = require("../cucumber/loadSnippetBuilder");
|
|
9
|
+
var _logger = require("../utils/logger");
|
|
10
|
+
var _stepConfig = require("../stepDefinitions/stepConfig");
|
|
11
|
+
/**
|
|
12
|
+
* Generate and show snippets for undefined steps
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
class Snippets {
|
|
16
|
+
files;
|
|
17
|
+
runConfiguration;
|
|
18
|
+
supportCodeLibrary;
|
|
19
|
+
snippetBuilder;
|
|
20
|
+
bddBuiltInSyntax = false;
|
|
21
|
+
constructor(files, runConfiguration, supportCodeLibrary) {
|
|
22
|
+
this.files = files;
|
|
23
|
+
this.runConfiguration = runConfiguration;
|
|
24
|
+
this.supportCodeLibrary = supportCodeLibrary;
|
|
25
|
+
}
|
|
26
|
+
async print() {
|
|
27
|
+
this.snippetBuilder = await this.createSnippetBuilder();
|
|
28
|
+
const snippets = this.getSnippets();
|
|
29
|
+
this.printHeader();
|
|
30
|
+
this.printSnippets(snippets);
|
|
31
|
+
this.printFooter(snippets);
|
|
32
|
+
// exit();
|
|
33
|
+
}
|
|
34
|
+
async createSnippetBuilder() {
|
|
35
|
+
const snippetInterface = this.runConfiguration.formats.options.snippetInterface;
|
|
36
|
+
const snippetSyntax = this.getSnippetSyntax();
|
|
37
|
+
return (0, _loadSnippetBuilder.loadSnippetBuilder)(this.supportCodeLibrary, snippetInterface, snippetSyntax);
|
|
38
|
+
}
|
|
39
|
+
getSnippetSyntax() {
|
|
40
|
+
const snippetSyntax = this.runConfiguration.formats.options.snippetSyntax;
|
|
41
|
+
if (!snippetSyntax && this.isPlaywrightStyle()) {
|
|
42
|
+
this.bddBuiltInSyntax = true;
|
|
43
|
+
const filePath = this.isDecorators() ? require.resolve('./snippetSyntaxDecorators.js') : this.isTypeScript() ? require.resolve('./snippetSyntaxTs.js') : require.resolve('./snippetSyntax.js');
|
|
44
|
+
return (0, _url.pathToFileURL)(filePath).toString();
|
|
45
|
+
} else {
|
|
46
|
+
return snippetSyntax;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
getSnippets() {
|
|
50
|
+
const snippetsSet = new Set();
|
|
51
|
+
const snippets = [];
|
|
52
|
+
this.files.forEach(file => {
|
|
53
|
+
file.undefinedSteps.forEach(undefinedStep => {
|
|
54
|
+
const {
|
|
55
|
+
snippet,
|
|
56
|
+
snippetWithLocation
|
|
57
|
+
} = this.getSnippet(file, snippets.length + 1, undefinedStep);
|
|
58
|
+
if (!snippetsSet.has(snippet)) {
|
|
59
|
+
snippetsSet.add(snippet);
|
|
60
|
+
snippets.push(snippetWithLocation);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
return snippets;
|
|
65
|
+
}
|
|
66
|
+
getSnippet(file, index, undefinedStep) {
|
|
67
|
+
const snippet = this.snippetBuilder.build({
|
|
68
|
+
keywordType: undefinedStep.keywordType,
|
|
69
|
+
pickleStep: undefinedStep.pickleStep
|
|
70
|
+
});
|
|
71
|
+
const {
|
|
72
|
+
line,
|
|
73
|
+
column
|
|
74
|
+
} = undefinedStep.step.location;
|
|
75
|
+
const snippetWithLocation = [`// ${index}. Missing step definition for "${file.featureUri}:${line}:${column}"`, snippet].join('\n');
|
|
76
|
+
return {
|
|
77
|
+
snippet,
|
|
78
|
+
snippetWithLocation
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
isTypeScript() {
|
|
82
|
+
const {
|
|
83
|
+
requirePaths,
|
|
84
|
+
importPaths
|
|
85
|
+
} = this.supportCodeLibrary.originalCoordinates;
|
|
86
|
+
return requirePaths.some(p => p.endsWith('.ts')) || importPaths.some(p => p.endsWith('.ts'));
|
|
87
|
+
}
|
|
88
|
+
isPlaywrightStyle() {
|
|
89
|
+
const {
|
|
90
|
+
stepDefinitions
|
|
91
|
+
} = this.supportCodeLibrary;
|
|
92
|
+
return stepDefinitions.length > 0 ? stepDefinitions.some(step => (0, _stepConfig.isPlaywrightStyle)((0, _stepConfig.getStepConfig)(step))) : true;
|
|
93
|
+
}
|
|
94
|
+
isDecorators() {
|
|
95
|
+
const {
|
|
96
|
+
stepDefinitions
|
|
97
|
+
} = this.supportCodeLibrary;
|
|
98
|
+
const decoratorSteps = stepDefinitions.filter(step => (0, _stepConfig.isDecorator)((0, _stepConfig.getStepConfig)(step)));
|
|
99
|
+
return decoratorSteps.length > stepDefinitions.length / 2;
|
|
100
|
+
}
|
|
101
|
+
printHeader() {
|
|
102
|
+
const lines = [`Missing steps found. Use snippets below:`];
|
|
103
|
+
if (this.bddBuiltInSyntax) {
|
|
104
|
+
if (this.isDecorators()) {
|
|
105
|
+
lines.push(`import { Fixture, Given, When, Then } from 'playwright-bdd/decorators';\n`);
|
|
106
|
+
} else {
|
|
107
|
+
lines.push(`import { createBdd } from '@zohodesk/testinglibrary';`, `const { Given, When, Then } = createBdd();\n`);
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
lines.push(`import { Given, When, Then } from '@cucumber/cucumber';\n`);
|
|
111
|
+
}
|
|
112
|
+
_logger.logger.error(lines.join('\n\n'));
|
|
113
|
+
}
|
|
114
|
+
printSnippets(snippets) {
|
|
115
|
+
_logger.logger.error(snippets.concat(['']).join('\n\n'));
|
|
116
|
+
}
|
|
117
|
+
printFooter(snippets) {
|
|
118
|
+
_logger.logger.error(`Missing step definitions (${snippets.length}).`, `Use snippets above to create them.`);
|
|
119
|
+
this.printWarningOnZeroScannedFiles();
|
|
120
|
+
}
|
|
121
|
+
printWarningOnZeroScannedFiles() {
|
|
122
|
+
const {
|
|
123
|
+
requirePaths,
|
|
124
|
+
importPaths
|
|
125
|
+
} = this.supportCodeLibrary.originalCoordinates;
|
|
126
|
+
const scannedFilesCount = requirePaths.length + importPaths.length;
|
|
127
|
+
if (scannedFilesCount === 0 && !this.isDecorators()) {
|
|
128
|
+
_logger.logger.error(`Note that 0 step definition files found, check the config.`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.Snippets = Snippets;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
// todo: custom cucumber parameters
|
|
8
|
+
// See: https://github.com/cucumber/cucumber-expressions#custom-parameter-types
|
|
9
|
+
class _default {
|
|
10
|
+
isTypescript = false;
|
|
11
|
+
build({
|
|
12
|
+
generatedExpressions,
|
|
13
|
+
functionName,
|
|
14
|
+
stepParameterNames
|
|
15
|
+
}) {
|
|
16
|
+
// Always take only first generatedExpression
|
|
17
|
+
// Other expressions are for int/float combinations
|
|
18
|
+
const generatedExpression = generatedExpressions[0];
|
|
19
|
+
const expressionParameters = generatedExpression.parameterNames.map((name, i) => {
|
|
20
|
+
const argName = `arg${i === 0 ? '' : i}`;
|
|
21
|
+
const type = name.startsWith('string') ? 'string' : 'number';
|
|
22
|
+
return this.isTypescript ? `${argName}: ${type}` : argName;
|
|
23
|
+
});
|
|
24
|
+
const stepParameters = stepParameterNames.map(argName => {
|
|
25
|
+
const type = argName === 'dataTable' ? 'DataTable' : 'string';
|
|
26
|
+
return this.isTypescript ? `${argName}: ${type}` : argName;
|
|
27
|
+
});
|
|
28
|
+
const allParameterNames = ['{}', ...expressionParameters, ...stepParameters];
|
|
29
|
+
const functionSignature = `${functionName}('${this.escapeSpecialCharacters(generatedExpression)}', async (${allParameterNames.join(', ')}) => {`;
|
|
30
|
+
return [functionSignature,
|
|
31
|
+
// prettier-ignore
|
|
32
|
+
` // ...`, '});'].join('\n');
|
|
33
|
+
}
|
|
34
|
+
escapeSpecialCharacters(generatedExpression) {
|
|
35
|
+
let source = generatedExpression.source;
|
|
36
|
+
// double up any backslashes because we're in a javascript string
|
|
37
|
+
source = source.replace(/\\/g, '\\\\');
|
|
38
|
+
// escape any single quotes because that's our quote delimiter
|
|
39
|
+
source = source.replace(/'/g, "\\'");
|
|
40
|
+
return source;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
class _default {
|
|
8
|
+
build({
|
|
9
|
+
generatedExpressions,
|
|
10
|
+
functionName
|
|
11
|
+
}) {
|
|
12
|
+
// Always take only first generatedExpression
|
|
13
|
+
// Other expressions are for int/float combinations
|
|
14
|
+
const generatedExpression = generatedExpressions[0];
|
|
15
|
+
return `@${functionName}('${this.escapeSpecialCharacters(generatedExpression)}')`;
|
|
16
|
+
}
|
|
17
|
+
escapeSpecialCharacters(generatedExpression) {
|
|
18
|
+
let source = generatedExpression.source;
|
|
19
|
+
// double up any backslashes because we're in a javascript string
|
|
20
|
+
source = source.replace(/\\/g, '\\\\');
|
|
21
|
+
// escape any single quotes because that's our quote delimiter
|
|
22
|
+
source = source.replace(/'/g, "\\'");
|
|
23
|
+
return source;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 _snippetSyntax = _interopRequireDefault(require("./snippetSyntax"));
|
|
9
|
+
/**
|
|
10
|
+
* Playwright-style snippet syntax for typescript.
|
|
11
|
+
* Important to use separate file as it's simplest way to distinguish between js/ts
|
|
12
|
+
* without hooking into cucumber machinery.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
class _default extends _snippetSyntax.default {
|
|
16
|
+
isTypescript = true;
|
|
17
|
+
}
|
|
18
|
+
exports.default = _default;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createBdd = createBdd;
|
|
7
|
+
exports.hasCustomTest = void 0;
|
|
8
|
+
var _bddFixtures = require("../run/bddFixtures");
|
|
9
|
+
var _testTypeImpl = require("../playwright/testTypeImpl");
|
|
10
|
+
var _defineStep = require("./defineStep");
|
|
11
|
+
var _exit = require("../utils/exit");
|
|
12
|
+
var _scenario = require("../hooks/scenario");
|
|
13
|
+
var _worker = require("../hooks/worker");
|
|
14
|
+
/**
|
|
15
|
+
* Stuff related to writing steps in Playwright-style.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Global flag showing that custom test was passed.
|
|
19
|
+
// Used when checking 'importTestFrom' config option.
|
|
20
|
+
// todo: https://github.com/vitalets/playwright-bdd/issues/46
|
|
21
|
+
let hasCustomTest = exports.hasCustomTest = false;
|
|
22
|
+
function createBdd(customTest) {
|
|
23
|
+
if (!hasCustomTest) {
|
|
24
|
+
exports.hasCustomTest = hasCustomTest = isCustomTest(customTest);
|
|
25
|
+
}
|
|
26
|
+
const Given = defineStepCtor('Given', hasCustomTest);
|
|
27
|
+
const When = defineStepCtor('When', hasCustomTest);
|
|
28
|
+
const Then = defineStepCtor('Then', hasCustomTest);
|
|
29
|
+
const Step = defineStepCtor('Unknown', hasCustomTest);
|
|
30
|
+
const Before = (0, _scenario.scenarioHookFactory)('before');
|
|
31
|
+
const After = (0, _scenario.scenarioHookFactory)('after');
|
|
32
|
+
const BeforeAll = (0, _worker.workerHookFactory)('beforeAll');
|
|
33
|
+
const AfterAll = (0, _worker.workerHookFactory)('afterAll');
|
|
34
|
+
return {
|
|
35
|
+
Given,
|
|
36
|
+
When,
|
|
37
|
+
Then,
|
|
38
|
+
Step,
|
|
39
|
+
Before,
|
|
40
|
+
After,
|
|
41
|
+
BeforeAll,
|
|
42
|
+
AfterAll
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function defineStepCtor(keyword, hasCustomTest) {
|
|
46
|
+
return (pattern, fn) => {
|
|
47
|
+
(0, _defineStep.defineStep)({
|
|
48
|
+
keyword,
|
|
49
|
+
pattern,
|
|
50
|
+
fn,
|
|
51
|
+
hasCustomTest
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function isCustomTest(customTest) {
|
|
56
|
+
if (!customTest || customTest === _bddFixtures.test) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
assertTestHasBddFixtures(customTest);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
function assertTestHasBddFixtures(customTest) {
|
|
63
|
+
if (!(0, _testTypeImpl.isTestContainsSubtest)(customTest, _bddFixtures.test)) {
|
|
64
|
+
(0, _exit.exit)(`createBdd() should use 'test' extended from "playwright-bdd"`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Fixture = Fixture;
|
|
7
|
+
exports.getPomNodeByFixtureName = getPomNodeByFixtureName;
|
|
8
|
+
var _steps = require("./steps");
|
|
9
|
+
var _exit = require("../../utils/exit");
|
|
10
|
+
/**
|
|
11
|
+
* Class level @Fixture decorator.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Graph of POM class inheritance.
|
|
16
|
+
* Allows to guess correct fixture by step text.
|
|
17
|
+
*/
|
|
18
|
+
const pomGraph = new Map();
|
|
19
|
+
/**
|
|
20
|
+
* @Fixture decorator.
|
|
21
|
+
*/
|
|
22
|
+
function Fixture(fixtureName) {
|
|
23
|
+
// context parameter is required for decorator by TS even though it's not used
|
|
24
|
+
return Ctor => {
|
|
25
|
+
createPomNode(Ctor, fixtureName);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function createPomNode(Ctor, fixtureName) {
|
|
29
|
+
const pomNode = {
|
|
30
|
+
fixtureName,
|
|
31
|
+
className: Ctor.name,
|
|
32
|
+
children: new Set()
|
|
33
|
+
};
|
|
34
|
+
ensureUniqueFixtureName(pomNode);
|
|
35
|
+
pomGraph.set(Ctor, pomNode);
|
|
36
|
+
(0, _steps.linkStepsWithPomNode)(Ctor, pomNode);
|
|
37
|
+
linkParentWithPomNode(Ctor, pomNode);
|
|
38
|
+
return pomNode;
|
|
39
|
+
}
|
|
40
|
+
function ensureUniqueFixtureName({
|
|
41
|
+
fixtureName,
|
|
42
|
+
className
|
|
43
|
+
}) {
|
|
44
|
+
if (!fixtureName) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const existingPom = getPomNodeByFixtureName(fixtureName);
|
|
48
|
+
if (existingPom) {
|
|
49
|
+
(0, _exit.exit)(`Duplicate fixture name "${fixtureName}"`, `defined for classes: ${existingPom.className}, ${className}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function linkParentWithPomNode(Ctor, pomNode) {
|
|
53
|
+
const parentCtor = Object.getPrototypeOf(Ctor);
|
|
54
|
+
if (!parentCtor) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// if parentCtor is not in pomGraph, add it.
|
|
58
|
+
// Case: parent class is not marked with @Fixture, but has decorator steps (base class)
|
|
59
|
+
const parentPomNode = pomGraph.get(parentCtor) || createPomNode(parentCtor, '');
|
|
60
|
+
parentPomNode.children.add(pomNode);
|
|
61
|
+
}
|
|
62
|
+
function getPomNodeByFixtureName(fixtureName) {
|
|
63
|
+
for (const pomNode of pomGraph.values()) {
|
|
64
|
+
if (pomNode.fixtureName === fixtureName) {
|
|
65
|
+
return pomNode;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|