@zohodesk/testinglibrary 0.1.6 → 0.1.7
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/.eslintrc.js +5 -1
- package/build/bdd-framework/cli/commands/env.js +1 -1
- package/build/bdd-framework/cli/commands/test.js +9 -3
- package/build/bdd-framework/config/env.js +2 -1
- package/build/bdd-framework/config/lang.js +14 -0
- package/build/bdd-framework/cucumber/loadSteps.js +8 -3
- package/build/bdd-framework/decorators.js +2 -2
- package/build/bdd-framework/gen/fixtures.js +48 -0
- package/build/bdd-framework/gen/formatter.js +57 -10
- package/build/bdd-framework/gen/i18n.js +6 -2
- package/build/bdd-framework/gen/index.js +7 -6
- package/build/bdd-framework/gen/testFile.js +105 -39
- package/build/bdd-framework/gen/testNode.js +16 -3
- package/build/bdd-framework/gen/testPoms.js +18 -8
- package/build/bdd-framework/hooks/scenario.js +107 -0
- package/build/bdd-framework/hooks/worker.js +83 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +24 -8
- package/build/bdd-framework/playwright/getLocationInFile.js +13 -7
- package/build/bdd-framework/playwright/testTypeImpl.js +11 -7
- package/build/bdd-framework/playwright/transform.js +6 -2
- package/build/bdd-framework/run/StepInvoker.js +73 -0
- package/build/bdd-framework/run/bddFixtures.js +118 -55
- package/build/bdd-framework/run/bddWorld.js +24 -36
- package/build/bdd-framework/snippets/index.js +3 -1
- package/build/bdd-framework/snippets/snippetSyntax.js +3 -1
- package/build/bdd-framework/stepDefinitions/createBdd.js +28 -11
- package/build/bdd-framework/stepDefinitions/decorators/{poms.js → class.js} +7 -3
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +8 -2
- package/build/bdd-framework/stepDefinitions/defineStep.js +2 -1
- package/build/bdd-framework/utils/exit.js +14 -4
- package/build/bdd-framework/utils/index.js +27 -1
- package/build/bdd-framework/utils/logger.js +3 -1
- package/build/core/playwright/index.js +12 -3
- package/build/core/playwright/report-generator.js +2 -1
- package/build/core/playwright/setup/config-creator.js +5 -0
- package/build/core/playwright/tag-processor.js +6 -2
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
- package/changelog.md +10 -0
- package/npm-shrinkwrap.json +1 -1
- package/package.json +1 -1
- package/build/bdd-framework/cucumber/gherkin.d.ts +0 -45
- package/build/bdd-framework/gen/poms.js +0 -46
- package/build/bdd-framework/stepDefinitions/createDecorators.js +0 -108
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Fixture = Fixture;
|
|
7
|
-
exports.appendDecoratorSteps = appendDecoratorSteps;
|
|
8
|
-
exports.createStepDecorator = createStepDecorator;
|
|
9
|
-
exports.getPomNodeByFixtureName = getPomNodeByFixtureName;
|
|
10
|
-
var _bddFixtures = require("../run/bddFixtures");
|
|
11
|
-
var _defineStep = require("./defineStep");
|
|
12
|
-
var _buildStepDefinition = require("../cucumber/buildStepDefinition");
|
|
13
|
-
/* eslint-disable no-unused-vars */
|
|
14
|
-
/**
|
|
15
|
-
* Define steps via decorators.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const pomGraph = new Map();
|
|
19
|
-
const decoratedStepSymbol = Symbol('decoratedStep');
|
|
20
|
-
const decoratedSteps = new Set();
|
|
21
|
-
function Fixture(fixtureName) {
|
|
22
|
-
// context parameter is required for decorator by TS even though it's not used
|
|
23
|
-
return (Ctor, _context) => {
|
|
24
|
-
createPomNode(Ctor, fixtureName);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function createStepDecorator(keyword) {
|
|
28
|
-
return pattern => {
|
|
29
|
-
// context parameter is required for decorator by TS even though it's not used
|
|
30
|
-
return (method, _context) => {
|
|
31
|
-
method[decoratedStepSymbol] = {
|
|
32
|
-
keyword,
|
|
33
|
-
pattern,
|
|
34
|
-
fn: method,
|
|
35
|
-
hasCustomTest: true,
|
|
36
|
-
isDecorator: true
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function appendDecoratorSteps(supportCodeLibrary) {
|
|
42
|
-
decoratedSteps.forEach(stepConfig => {
|
|
43
|
-
const {
|
|
44
|
-
keyword,
|
|
45
|
-
pattern,
|
|
46
|
-
fn
|
|
47
|
-
} = stepConfig;
|
|
48
|
-
stepConfig.fn = (fixturesArg, ...args) => {
|
|
49
|
-
const fixture = getFirstNonAutoInjectFixture(fixturesArg, stepConfig);
|
|
50
|
-
return fn.call(fixture, ...args);
|
|
51
|
-
};
|
|
52
|
-
const code = (0, _defineStep.buildCucumberStepFn)(stepConfig);
|
|
53
|
-
const stepDefinition = (0, _buildStepDefinition.buildStepDefinition)({
|
|
54
|
-
keyword,
|
|
55
|
-
pattern,
|
|
56
|
-
code,
|
|
57
|
-
line: 0,
|
|
58
|
-
// not used in playwright-bdd
|
|
59
|
-
options: {},
|
|
60
|
-
// not used in playwright-bdd
|
|
61
|
-
uri: '' // not used in playwright-bdd
|
|
62
|
-
}, supportCodeLibrary);
|
|
63
|
-
supportCodeLibrary.stepDefinitions.push(stepDefinition);
|
|
64
|
-
});
|
|
65
|
-
decoratedSteps.clear();
|
|
66
|
-
// todo: fill supportCodeLibrary.originalCoordinates as it is used in snippets?
|
|
67
|
-
}
|
|
68
|
-
function getPomNodeByFixtureName(fixtureName) {
|
|
69
|
-
for (const pomNode of pomGraph.values()) {
|
|
70
|
-
if (pomNode.fixtureName === fixtureName) return pomNode;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function createPomNode(Ctor, fixtureName) {
|
|
74
|
-
const pomNode = {
|
|
75
|
-
fixtureName,
|
|
76
|
-
children: new Set()
|
|
77
|
-
};
|
|
78
|
-
pomGraph.set(Ctor, pomNode);
|
|
79
|
-
getDecoratedSteps(Ctor).forEach(stepConfig => {
|
|
80
|
-
stepConfig.pomNode = pomNode;
|
|
81
|
-
decoratedSteps.add(stepConfig);
|
|
82
|
-
});
|
|
83
|
-
const parentCtor = Object.getPrototypeOf(Ctor);
|
|
84
|
-
if (!parentCtor) return;
|
|
85
|
-
const parentPomNode = pomGraph.get(parentCtor) || createPomNode(parentCtor, '');
|
|
86
|
-
parentPomNode === null || parentPomNode === void 0 || parentPomNode.children.add(pomNode);
|
|
87
|
-
return pomNode;
|
|
88
|
-
}
|
|
89
|
-
function getDecoratedSteps(Ctor) {
|
|
90
|
-
if (!(Ctor !== null && Ctor !== void 0 && Ctor.prototype)) return [];
|
|
91
|
-
const propertyDescriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
|
|
92
|
-
return Object.keys(propertyDescriptors)
|
|
93
|
-
// filter out getters / setters
|
|
94
|
-
.filter(methodName => typeof propertyDescriptors[methodName].value === 'function').map(methodName => {
|
|
95
|
-
return propertyDescriptors[methodName].value[decoratedStepSymbol];
|
|
96
|
-
}).filter(Boolean);
|
|
97
|
-
}
|
|
98
|
-
function getFirstNonAutoInjectFixture(fixturesArg, stepConfig) {
|
|
99
|
-
// there should be exatcly one suitable fixture in fixturesArg
|
|
100
|
-
const fixtureNames = Object.keys(fixturesArg).filter(fixtureName => !(0, _bddFixtures.isBddAutoInjectFixture)(fixtureName));
|
|
101
|
-
if (fixtureNames.length === 0) {
|
|
102
|
-
throw new Error(`No suitable fixtures found for decorator step "${stepConfig.pattern}"`);
|
|
103
|
-
}
|
|
104
|
-
if (fixtureNames.length > 1) {
|
|
105
|
-
throw new Error(`Several suitable fixtures found for decorator step "${stepConfig.pattern}"`);
|
|
106
|
-
}
|
|
107
|
-
return fixturesArg[fixtureNames[0]];
|
|
108
|
-
}
|