@zohodesk/testinglibrary 0.0.5-exp.20 → 0.0.5-exp.22
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/parser/verifier.js +11 -11
- package/build/utils/fileUtils.js +5 -5
- package/changelog.md +8 -0
- package/package.json +1 -1
package/build/parser/verifier.js
CHANGED
|
@@ -28,8 +28,8 @@ function verifyIfMultipleStepsExists(steps) {
|
|
|
28
28
|
});
|
|
29
29
|
return isMultipleStepsFound;
|
|
30
30
|
}
|
|
31
|
-
function extractExamplesToSeperateFile(examples, scenarioIndex, filePath) {
|
|
32
|
-
let exampleFileContent = `export const
|
|
31
|
+
function extractExamplesToSeperateFile(examples, scenarioIndex, filePath, featureName) {
|
|
32
|
+
let exampleFileContent = `export const ${featureName.toUpperCase()}_SCENARIO_${scenarioIndex} = ${JSON.stringify(examples, null, 2)};\r\n`;
|
|
33
33
|
try {
|
|
34
34
|
(0, _fileUtils.writeFileContents)(filePath, exampleFileContent, {
|
|
35
35
|
flag: 'a'
|
|
@@ -50,6 +50,7 @@ function verifyFeatureFileWithSpecFile() {
|
|
|
50
50
|
// Construct the corresponding .spec.js filename
|
|
51
51
|
const specFile = featureFile.replace(/\.feature$/, '.spec.js').replace(/\/feature-files\//, '/steps/');
|
|
52
52
|
let featureFileNameExtract = featureFile.split('/').pop();
|
|
53
|
+
let featurePrefixName = featureFileNameExtract.split('.')[0];
|
|
53
54
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `parsing feature file ${featureFileNameExtract}...`);
|
|
54
55
|
// Check if the .spec.js file exists
|
|
55
56
|
|
|
@@ -64,16 +65,14 @@ function verifyFeatureFileWithSpecFile() {
|
|
|
64
65
|
if (specContents.includes(featureName)) {
|
|
65
66
|
const scenarios = featureJSON.feature.scenarios;
|
|
66
67
|
const specLines = specContents.split('\n'); // Split specContents into lines
|
|
67
|
-
|
|
68
|
+
let testDataFilePath = featureFile.replace(/\/feature-files\//, '/test-data/').replace(/\.feature$/, '.data.js');
|
|
69
|
+
// Examples to test data conversion. we are deleting the existing test data file and create a new file.
|
|
70
|
+
(0, _fileUtils.deleteFile)(testDataFilePath);
|
|
68
71
|
for (let i = 0; i < scenarios.length; i++) {
|
|
69
72
|
let scenario = scenarios[i];
|
|
70
|
-
let testDataFilePath = featureFile.replace(/\/feature-files\//, '/test-data/').replace(/\.feature$/, '.data.js');
|
|
71
73
|
const scenarioName = scenario.name;
|
|
72
74
|
const scenarioExamples = scenario.examples;
|
|
73
|
-
|
|
74
|
-
// Examples to test data conversion. we are deleting the existing test data file and create a new file.
|
|
75
|
-
(0, _fileUtils.deleteFile)(testDataFilePath);
|
|
76
|
-
extractExamplesToSeperateFile(scenarioExamples, i, testDataFilePath);
|
|
75
|
+
extractExamplesToSeperateFile(scenarioExamples, i, testDataFilePath, featurePrefixName);
|
|
77
76
|
|
|
78
77
|
// spec file check
|
|
79
78
|
if (!specLines.some(line => line.includes(scenarioName))) {
|
|
@@ -84,7 +83,7 @@ function verifyFeatureFileWithSpecFile() {
|
|
|
84
83
|
if (!allStepsFound[step]) {
|
|
85
84
|
allStepsFound[step] = [specFile];
|
|
86
85
|
} else {
|
|
87
|
-
|
|
86
|
+
allStepsFound[step].push(specFile);
|
|
88
87
|
}
|
|
89
88
|
if (!specLines.some(line => line.includes(step))) {
|
|
90
89
|
errorCount++;
|
|
@@ -106,8 +105,9 @@ function verifyFeatureFileWithSpecFile() {
|
|
|
106
105
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `No corresponding .spec.js file found for ${featureFile}`);
|
|
107
106
|
}
|
|
108
107
|
});
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
// Multiple steps found warning
|
|
109
|
+
verifyIfMultipleStepsExists(allStepsFound);
|
|
110
|
+
if (errorCount > 0) {
|
|
111
111
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Total Number of Errors found - ${errorCount}`);
|
|
112
112
|
throw new Error('Error while parsing feature files. Please fix the above issues before running test cases');
|
|
113
113
|
}
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -44,10 +44,10 @@ function writeFileContents(filePath, content, writeOptions = {}) {
|
|
|
44
44
|
}
|
|
45
45
|
function deleteFile(filePath) {
|
|
46
46
|
if (checkIfFileExists(filePath)) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}
|
|
47
|
+
try {
|
|
48
|
+
_fs.default.unlinkSync(filePath);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
throw new Error(`Error while deleting the test data file: ${filePath}`);
|
|
51
|
+
}
|
|
52
52
|
}
|
|
53
53
|
}
|
package/changelog.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
4
|
|
|
5
|
+
# 0.0.5-exp.22
|
|
6
|
+
|
|
7
|
+
- Bug fixes while creating examples file
|
|
8
|
+
|
|
9
|
+
# 0.0.5-exp.21
|
|
10
|
+
|
|
11
|
+
- Bug fixes while creating examples file
|
|
12
|
+
|
|
5
13
|
# 0.0.5-exp.20
|
|
6
14
|
|
|
7
15
|
- Fix error if directory does not exist while writing file
|