@zohodesk/testinglibrary 0.0.5-exp.31 → 0.0.5-exp.33
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/build/core/playwright/index.js +1 -12
- package/build/core/playwright/test-runner.js +4 -7
- package/build/parser/parser.js +2 -3
- package/build/parser/verifier.js +8 -3
- package/build/utils/logger.js +3 -3
- package/build/utils/stepDefinitionsFormatter.js +12 -0
- package/changelog.md +11 -2
- package/package.json +1 -1
|
@@ -54,19 +54,8 @@ const {
|
|
|
54
54
|
additionalPages = {},
|
|
55
55
|
bddMode
|
|
56
56
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
57
|
-
|
|
58
|
-
// let base = bddMode ? bddBase : playwrightBase;
|
|
59
|
-
let base = _test.test;
|
|
60
|
-
let mainBddFunction = (title, callback) => {
|
|
61
|
-
return async function () {
|
|
62
|
-
await callback();
|
|
63
|
-
};
|
|
64
|
-
};
|
|
57
|
+
let base = bddMode ? _bddFramework.test : _test.test;
|
|
65
58
|
const test = base.extend({
|
|
66
|
-
Given: base.step,
|
|
67
|
-
When: base.step,
|
|
68
|
-
Then: base.step,
|
|
69
|
-
And: base.step,
|
|
70
59
|
page: async ({
|
|
71
60
|
page
|
|
72
61
|
}, use) => {
|
|
@@ -57,17 +57,14 @@ function createTestRunner() {
|
|
|
57
57
|
const bddGenPath = _path.default.resolve(_path.default.join(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js'));
|
|
58
58
|
const beforeArgs = [bddGenPath, '-c', configPath];
|
|
59
59
|
const preprocessingPromise = new Promise((resolve, reject) => {
|
|
60
|
-
const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs
|
|
61
|
-
|
|
62
|
-
// Handle the output and errors for the first command
|
|
63
|
-
childProcessForPreprocessing.stdout.on('data', data => {
|
|
64
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, data);
|
|
60
|
+
const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
|
|
61
|
+
stdio: 'inherit'
|
|
65
62
|
});
|
|
66
|
-
childProcessForPreprocessing.
|
|
63
|
+
childProcessForPreprocessing.on('error', data => {
|
|
67
64
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
68
65
|
reject();
|
|
69
66
|
});
|
|
70
|
-
childProcessForPreprocessing.on('
|
|
67
|
+
childProcessForPreprocessing.on('exit', code => {
|
|
71
68
|
if (code === 0) {
|
|
72
69
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
|
|
73
70
|
resolve();
|
package/build/parser/parser.js
CHANGED
|
@@ -13,6 +13,7 @@ var _logger = require("../utils/logger");
|
|
|
13
13
|
var _cliArgsToObject = require("../utils/cliArgsToObject");
|
|
14
14
|
var _fileUtils = require("../utils/fileUtils");
|
|
15
15
|
var _readConfigFile = require("../core/playwright/readConfigFile");
|
|
16
|
+
var _stepDefinitionsFormatter = require("../utils/stepDefinitionsFormatter");
|
|
16
17
|
function parseFeature(featureContent) {
|
|
17
18
|
const lines = featureContent.split('\n');
|
|
18
19
|
let currentFeature = null;
|
|
@@ -78,8 +79,6 @@ function generateSpecFileContent({
|
|
|
78
79
|
feature
|
|
79
80
|
}) {
|
|
80
81
|
let specContent = 'import { test } from "@zohodesk/testinglibrary";\n\n';
|
|
81
|
-
// Array of delimiters
|
|
82
|
-
let delimiters = ["Given", "When", "Then", "And"];
|
|
83
82
|
if (feature && feature.scenarios && feature.scenarios.length > 0) {
|
|
84
83
|
//specContent += `test.describe('${feature.name}', () => {\n`;
|
|
85
84
|
specContent += `// Feature: ${feature.name} \n`;
|
|
@@ -96,7 +95,7 @@ function generateSpecFileContent({
|
|
|
96
95
|
//specContent += ` // Your implementation here\n`;
|
|
97
96
|
if (scenario.steps && scenario.steps.length > 0) {
|
|
98
97
|
scenario.steps.forEach(step => {
|
|
99
|
-
let foundDelimiter =
|
|
98
|
+
let foundDelimiter = (0, _stepDefinitionsFormatter.findDelimiterFromStep)(step);
|
|
100
99
|
if (foundDelimiter) {
|
|
101
100
|
// Wrap the part of the string after the delimiter with a function call
|
|
102
101
|
let splitResult = step.split(foundDelimiter);
|
package/build/parser/verifier.js
CHANGED
|
@@ -7,6 +7,7 @@ var _parser = require("./parser");
|
|
|
7
7
|
var _logger = require("../utils/logger");
|
|
8
8
|
var _fileUtils = require("../utils/fileUtils");
|
|
9
9
|
var _readConfigFile = require("../core/playwright/readConfigFile");
|
|
10
|
+
var _stepDefinitionsFormatter = require("../utils/stepDefinitionsFormatter");
|
|
10
11
|
// Specify the directory where you want to search for .feature and .spec.js files
|
|
11
12
|
const directoryPath = './uat';
|
|
12
13
|
|
|
@@ -91,9 +92,13 @@ function verifyFeatureFileWithSpecFile() {
|
|
|
91
92
|
} else {
|
|
92
93
|
allStepsFound[step].push(specFile);
|
|
93
94
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const foundDelimiter = (0, _stepDefinitionsFormatter.findDelimiterFromStep)(step);
|
|
96
|
+
if (foundDelimiter) {
|
|
97
|
+
let splitResult = step.split(foundDelimiter);
|
|
98
|
+
if (!specLines.some(line => line.includes(splitResult[1].trim().replace(/"/g, '\\"')))) {
|
|
99
|
+
errorCount++;
|
|
100
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Scenario: ${scenarioName} \n Step: ${step} is missing in the spec file ${specFile}`);
|
|
101
|
+
}
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
}
|
package/build/utils/logger.js
CHANGED
|
@@ -34,10 +34,10 @@ exports.Logger = void 0;
|
|
|
34
34
|
// }
|
|
35
35
|
|
|
36
36
|
class LoggerImpl {
|
|
37
|
-
SUCCESS_TYPE = 'success';
|
|
38
|
-
FAILURE_TYPE = 'failure';
|
|
39
|
-
INFO_TYPE = 'info';
|
|
40
37
|
constructor() {
|
|
38
|
+
this.SUCCESS_TYPE = 'success';
|
|
39
|
+
this.FAILURE_TYPE = 'failure';
|
|
40
|
+
this.INFO_TYPE = 'info';
|
|
41
41
|
this.colors = {
|
|
42
42
|
'success': ['\x1b[36m', '\x1b[0m'],
|
|
43
43
|
'failure': ['\x1b[31m', '\x1b[0m'],
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.delimiters = void 0;
|
|
7
|
+
exports.findDelimiterFromStep = findDelimiterFromStep;
|
|
8
|
+
const delimiters = ["Given", "When", "Then", "And"];
|
|
9
|
+
exports.delimiters = delimiters;
|
|
10
|
+
function findDelimiterFromStep(step) {
|
|
11
|
+
return delimiters.find(delimiter => step.includes(delimiter));
|
|
12
|
+
}
|
package/changelog.md
CHANGED
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
4
|
|
|
5
|
-
# 0.0.5-exp.
|
|
5
|
+
# 0.0.5-exp.33
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Reverted back to playwright-bdd
|
|
8
|
+
- Logger bugfix
|
|
9
|
+
|
|
10
|
+
# 0.0.5-exp.32
|
|
11
|
+
|
|
12
|
+
- Bug fix while running test cases
|
|
8
13
|
|
|
9
14
|
# 0.0.5-exp.31
|
|
10
15
|
|
|
@@ -18,6 +23,10 @@
|
|
|
18
23
|
|
|
19
24
|
- Added --update option to the generateSpecFile command to update the spec file
|
|
20
25
|
|
|
26
|
+
# 0.0.5-exp.28
|
|
27
|
+
|
|
28
|
+
- Bug fix while creating spec file
|
|
29
|
+
|
|
21
30
|
# 0.0.5-exp.27
|
|
22
31
|
|
|
23
32
|
- Added config for feature files and step definitions folder name
|