@zohodesk/testinglibrary 0.1.6 → 0.1.7-exp.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/.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/builtInFixtures/addTags.js +19 -0
- package/build/core/playwright/builtInFixtures/cacheLayer.js +12 -0
- package/build/core/playwright/builtInFixtures/context.js +15 -0
- package/build/core/playwright/builtInFixtures/index.js +26 -0
- package/build/core/playwright/builtInFixtures/page.js +51 -0
- package/build/core/playwright/index.js +6 -80
- package/build/core/playwright/report-generator.js +2 -1
- package/build/core/playwright/setup/config-creator.js +5 -0
- package/build/core/playwright/setup/custom-reporter.js +9 -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/build/utils/fileUtils.js +3 -4
- 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
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.tagProcessor = tagProcessor;
|
|
7
|
+
var _logger = require("../../utils/logger");
|
|
8
|
+
/* eslint-disable dot-notation */
|
|
9
|
+
|
|
7
10
|
function getTagsString(tags, editionTags) {
|
|
8
11
|
return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
|
|
9
12
|
}
|
|
@@ -37,7 +40,7 @@ function editionPreprocessing(editionOrder, selectedEdition) {
|
|
|
37
40
|
}
|
|
38
41
|
return resultArray;
|
|
39
42
|
}
|
|
40
|
-
Logger.log(Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
|
|
43
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
|
|
41
44
|
return [];
|
|
42
45
|
}
|
|
43
46
|
function buildEditionTags(editionArgs, operator) {
|
|
@@ -56,7 +59,8 @@ function tagProcessor(userArgsObject, editionOrder) {
|
|
|
56
59
|
}
|
|
57
60
|
} else {
|
|
58
61
|
// More than one edition given
|
|
59
|
-
const
|
|
62
|
+
const filteredEditions = editionOrder.filter(edition => !editionsArray.includes(edition));
|
|
63
|
+
const editionTags = buildEditionTags(filteredEditions, 'or');
|
|
60
64
|
tagArgs = `${getTagsString(tagArgs, editionTags)}`;
|
|
61
65
|
}
|
|
62
66
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
function sortEdition(event) {
|
|
3
|
+
var currentURL = window.location.href;
|
|
4
|
+
const endPointCount = window.location.href.indexOf('#');
|
|
5
|
+
if (!(endPointCount == -1)) {
|
|
6
|
+
window.history.pushState({}, '', currentURL.slice(0, endPointCount));
|
|
7
|
+
currentURL = currentURL.slice(0, endPointCount);
|
|
8
|
+
}
|
|
9
|
+
console.log(currentURL);
|
|
10
|
+
window.open(`${currentURL}#?q=@edition_${event.target.value}`, '_self');
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
<div class="mainContainer" style="margin-left: 20px; display: flex;">
|
|
14
|
+
<div class="selectEditionContainer" style="padding: 20px;">
|
|
15
|
+
<select class="selectEdition" style="padding: 5px; width: 100px; border-radius: 6px; border: 1px solid var(--color-border-default);" onchange="sortEdition(event)">
|
|
16
|
+
<option value="EnterPrise">EnterPrise</option>
|
|
17
|
+
<option value="Professional">Professional</option>
|
|
18
|
+
<option value="Express">Express</option>
|
|
19
|
+
<option value="Standard">Standard</option>
|
|
20
|
+
<option value="Free">Free</option>
|
|
21
|
+
</select>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.preProcessReport = preProcessReport;
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
var _logger = require("./../../utils/logger");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
const htmlFilePath = _path.default.resolve(process.cwd(), 'uat', 'playwright-report', 'index.html');
|
|
12
|
+
const fileHtml = _fs.default.readFileSync(htmlFilePath, 'utf-8');
|
|
13
|
+
const addOnHtml = _fs.default.readFileSync(_path.default.resolve(__filename, '../', 'addonScript.html'), 'utf-8');
|
|
14
|
+
const splitedHTML = fileHtml.split('\n');
|
|
15
|
+
const toAdd = addOnHtml.split('\n');
|
|
16
|
+
function preProcessReport() {
|
|
17
|
+
if (_fs.default.existsSync(htmlFilePath)) {
|
|
18
|
+
const modifiedContent = [...splitedHTML.slice(0, 55), ...toAdd, ...splitedHTML.slice(56)].join('').toString();
|
|
19
|
+
_fs.default.writeFileSync(htmlFilePath, modifiedContent);
|
|
20
|
+
return;
|
|
21
|
+
} else {
|
|
22
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Report is not generated Properly ...');
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.deleteFolder = deleteFolder;
|
|
|
10
10
|
exports.readFileContents = readFileContents;
|
|
11
11
|
exports.writeFileContents = writeFileContents;
|
|
12
12
|
var _fs = _interopRequireDefault(require("fs"));
|
|
13
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
14
|
function checkIfFileExists(file) {
|
|
14
15
|
try {
|
|
15
16
|
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|
|
@@ -27,9 +28,7 @@ function readFileContents(filePath) {
|
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
function writeFileContents(filePath, content, writeOptions = {}) {
|
|
30
|
-
|
|
31
|
-
let fileName = filePaths.pop();
|
|
32
|
-
let directoryPath = filePaths.join('/');
|
|
31
|
+
const directoryPath = _path.default.dirname(filePath);
|
|
33
32
|
|
|
34
33
|
// Check if the directory exists
|
|
35
34
|
if (!_fs.default.existsSync(directoryPath)) {
|
|
@@ -38,7 +37,7 @@ function writeFileContents(filePath, content, writeOptions = {}) {
|
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
39
|
try {
|
|
41
|
-
_fs.default.writeFileSync(`${
|
|
40
|
+
_fs.default.writeFileSync(`${filePath}`, content, writeOptions);
|
|
42
41
|
} catch (err) {
|
|
43
42
|
throw new Error(err);
|
|
44
43
|
}
|
package/changelog.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
4
|
|
|
5
|
+
# 0.1.7
|
|
6
|
+
**Enhancements**
|
|
7
|
+
- Added option to run teardown logic.
|
|
8
|
+
- Added support for tag based filtering.
|
|
9
|
+
- Playwright-bdd version updated to 5.6.0.
|
|
10
|
+
- New fixture added to add tag as annotations in test report
|
|
11
|
+
|
|
12
|
+
**Issue Fixes**
|
|
13
|
+
- Edition command option. Fixed the edition tags not generated properly
|
|
14
|
+
|
|
5
15
|
# 0.1.6
|
|
6
16
|
|
|
7
17
|
**Enhancements**
|
package/npm-shrinkwrap.json
CHANGED
package/package.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copied from @cucumber/cucumber/lib/api/gherkin.d.ts
|
|
3
|
-
* Fixes error:
|
|
4
|
-
* Return type of exported function has or is using name 'PickleWithDocument'
|
|
5
|
-
* from external module "../node_modules/@cucumber/cucumber/lib/api/gherkin"
|
|
6
|
-
* but cannot be named
|
|
7
|
-
*/
|
|
8
|
-
import {
|
|
9
|
-
Envelope,
|
|
10
|
-
GherkinDocument,
|
|
11
|
-
IdGenerator,
|
|
12
|
-
Location,
|
|
13
|
-
ParseError,
|
|
14
|
-
Pickle,
|
|
15
|
-
} from '@cucumber/messages';
|
|
16
|
-
import { ISourcesCoordinates } from '@cucumber/cucumber/lib/api/types';
|
|
17
|
-
import { ILogger } from '@cucumber/cucumber/lib/logger';
|
|
18
|
-
|
|
19
|
-
declare module '@cucumber/cucumber/lib/api/gherkin' {
|
|
20
|
-
export interface PickleWithDocument {
|
|
21
|
-
gherkinDocument: GherkinDocument;
|
|
22
|
-
location: Location;
|
|
23
|
-
pickle: Pickle;
|
|
24
|
-
}
|
|
25
|
-
export function getFilteredPicklesAndErrors({
|
|
26
|
-
newId,
|
|
27
|
-
cwd,
|
|
28
|
-
logger,
|
|
29
|
-
unexpandedFeaturePaths,
|
|
30
|
-
featurePaths,
|
|
31
|
-
coordinates,
|
|
32
|
-
onEnvelope,
|
|
33
|
-
}: {
|
|
34
|
-
newId: IdGenerator.NewId;
|
|
35
|
-
cwd: string;
|
|
36
|
-
logger: ILogger;
|
|
37
|
-
unexpandedFeaturePaths: string[];
|
|
38
|
-
featurePaths: string[];
|
|
39
|
-
coordinates: ISourcesCoordinates;
|
|
40
|
-
onEnvelope?: (envelope: Envelope) => void;
|
|
41
|
-
}): Promise<{
|
|
42
|
-
filteredPickles: PickleWithDocument[];
|
|
43
|
-
parseErrors: ParseError[];
|
|
44
|
-
}>;
|
|
45
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.POMS = void 0;
|
|
7
|
-
exports.buildFixtureTag = buildFixtureTag;
|
|
8
|
-
var _createDecorators = require("../stepDefinitions/createDecorators");
|
|
9
|
-
/**
|
|
10
|
-
* Handle POMs graph for decorator steps.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const FIXTURE_TAG_PREFIX = '@fixture:';
|
|
14
|
-
class POMS {
|
|
15
|
-
usedPoms = new Map();
|
|
16
|
-
add(pomNode) {
|
|
17
|
-
if (pomNode) this.usedPoms.set(pomNode, null);
|
|
18
|
-
}
|
|
19
|
-
addByFixtureName(fixtureName) {
|
|
20
|
-
const pomNode = (0, _createDecorators.getPomNodeByFixtureName)(fixtureName);
|
|
21
|
-
if (pomNode) this.add(pomNode);
|
|
22
|
-
}
|
|
23
|
-
addByTag(tag) {
|
|
24
|
-
const fixtureName = extractFixtureName(tag);
|
|
25
|
-
if (fixtureName) this.addByFixtureName(fixtureName);
|
|
26
|
-
}
|
|
27
|
-
resolveFixtureNames(pomNode) {
|
|
28
|
-
const resolvedFixtureNames = this.usedPoms.get(pomNode);
|
|
29
|
-
if (resolvedFixtureNames) return resolvedFixtureNames;
|
|
30
|
-
const fixtureNames = [...pomNode.children].map(child => this.resolveFixtureNames(child)).flat();
|
|
31
|
-
if (this.usedPoms.has(pomNode)) {
|
|
32
|
-
// if nothing returned from children, use own fixtureName,
|
|
33
|
-
// otherwise use what returned from child
|
|
34
|
-
if (!fixtureNames.length) fixtureNames.push(pomNode.fixtureName);
|
|
35
|
-
this.usedPoms.set(pomNode, fixtureNames);
|
|
36
|
-
}
|
|
37
|
-
return fixtureNames;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.POMS = POMS;
|
|
41
|
-
function extractFixtureName(tag) {
|
|
42
|
-
return tag.startsWith(FIXTURE_TAG_PREFIX) ? tag.replace(FIXTURE_TAG_PREFIX, '') : '';
|
|
43
|
-
}
|
|
44
|
-
function buildFixtureTag(fixtureName) {
|
|
45
|
-
return `${FIXTURE_TAG_PREFIX}${fixtureName}`;
|
|
46
|
-
}
|
|
@@ -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
|
-
}
|