@zohodesk/testinglibrary 3.2.8 → 3.2.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/.gitlab-ci.yml +16 -0
- package/build/core/dataGenerator/DataGenerator.js +17 -3
- package/build/core/dataGenerator/DataGeneratorError.js +50 -0
- package/build/core/dataGenerator/DataGeneratorHelper.js +1 -1
- package/build/test/Test.js +13 -0
- package/npm-shrinkwrap.json +401 -400
- package/package.json +1 -1
- package/test-results/.last-run.json +0 -4
- package/unit_reports/unit-report.html +0 -260
package/.gitlab-ci.yml
CHANGED
|
@@ -173,3 +173,19 @@ uat-multiactor:
|
|
|
173
173
|
when: always
|
|
174
174
|
paths:
|
|
175
175
|
- examples/uat/playwright-report
|
|
176
|
+
|
|
177
|
+
uat-data_generator:
|
|
178
|
+
stage: uat
|
|
179
|
+
script:
|
|
180
|
+
- cd examples
|
|
181
|
+
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
182
|
+
- output=$(npm run uat-data_generator)
|
|
183
|
+
- echo "$output"
|
|
184
|
+
- node ../ValidateUATReport.js examples
|
|
185
|
+
|
|
186
|
+
artifacts:
|
|
187
|
+
when: always
|
|
188
|
+
paths:
|
|
189
|
+
- examples/uat/playwright-report
|
|
190
|
+
|
|
191
|
+
|
|
@@ -10,6 +10,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
10
10
|
var _logger = require("../../utils/logger");
|
|
11
11
|
var _DataGeneratorHelper = require("./DataGeneratorHelper");
|
|
12
12
|
var _helpers = require("@zohodesk/testinglibrary/helpers");
|
|
13
|
+
var _DataGeneratorError = require("./DataGeneratorError");
|
|
13
14
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
14
15
|
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
15
16
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
@@ -32,6 +33,16 @@ class DataGenerator {
|
|
|
32
33
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Generated response for the generator: ${generatorName} for scenario: ${scenarioName}, Response: ${JSON.stringify(response)}`);
|
|
33
34
|
return response;
|
|
34
35
|
} catch (error) {
|
|
36
|
+
if (error instanceof _DataGeneratorError.DataGeneratorError) {
|
|
37
|
+
console.error(error.getMessage());
|
|
38
|
+
console.error("Stack trace:", error.stack);
|
|
39
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error.getMessage());
|
|
40
|
+
} else {
|
|
41
|
+
console.error("Error Type:", error.constructor.name);
|
|
42
|
+
console.error("Error Message:", error.message);
|
|
43
|
+
console.error("Stack trace:", error.stack);
|
|
44
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `${error.constructor.name} - Message: ${error.message}`);
|
|
45
|
+
}
|
|
35
46
|
console.error('Data Generation failed for the generator: ', generatorName, "\n\nError response :", error);
|
|
36
47
|
throw error;
|
|
37
48
|
}
|
|
@@ -58,7 +69,7 @@ async function _getGenerator(testInfo, generatorName) {
|
|
|
58
69
|
}
|
|
59
70
|
}
|
|
60
71
|
if (!generator) {
|
|
61
|
-
throw new
|
|
72
|
+
throw new _DataGeneratorError.GeneratorError(`Generator "${generatorName}" could not be found in the path located at "${generatorFilePath}"`);
|
|
62
73
|
}
|
|
63
74
|
return generator;
|
|
64
75
|
}
|
|
@@ -71,11 +82,14 @@ async function _generateAPIGenerator(operationId) {
|
|
|
71
82
|
}];
|
|
72
83
|
}
|
|
73
84
|
async function _constructApiPayload(scenarioName, processedGenerators, actorInfo) {
|
|
74
|
-
const
|
|
85
|
+
const dataGeneratorObj = actorInfo['data-generator'];
|
|
86
|
+
if (!dataGeneratorObj) {
|
|
87
|
+
throw new _DataGeneratorError.DataGeneratorConfigurationError(`Data Generator configuration is missing for the profile: ${actorInfo['profile']}`);
|
|
88
|
+
}
|
|
75
89
|
const apiPayload = {
|
|
76
90
|
scenario_name: scenarioName,
|
|
77
91
|
data_generation_templates: processedGenerators,
|
|
78
|
-
...
|
|
92
|
+
...dataGeneratorObj
|
|
79
93
|
};
|
|
80
94
|
const account = apiPayload.account;
|
|
81
95
|
if (account) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GeneratorError = exports.DataGeneratorError = exports.DataGeneratorConfigurationError = void 0;
|
|
7
|
+
class DataGeneratorError extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'DataGeneratorError';
|
|
11
|
+
|
|
12
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
|
13
|
+
if (Error.captureStackTrace) {
|
|
14
|
+
Error.captureStackTrace(this, DataGeneratorError);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get formatted error message with error type and message
|
|
20
|
+
* @returns {string} Formatted error message
|
|
21
|
+
*/
|
|
22
|
+
getMessage() {
|
|
23
|
+
return `\n\n ${this.name} ::: \n\n Error Message: ${this.message} \n\n `;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Specific error for Data Generator configuration issues
|
|
28
|
+
exports.DataGeneratorError = DataGeneratorError;
|
|
29
|
+
class DataGeneratorConfigurationError extends DataGeneratorError {
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = 'DataGeneratorConfigurationError';
|
|
33
|
+
if (Error.captureStackTrace) {
|
|
34
|
+
Error.captureStackTrace(this, DataGeneratorConfigurationError);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Specific error for Generator related issues
|
|
40
|
+
exports.DataGeneratorConfigurationError = DataGeneratorConfigurationError;
|
|
41
|
+
class GeneratorError extends DataGeneratorError {
|
|
42
|
+
constructor(message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = 'GeneratorError';
|
|
45
|
+
if (Error.captureStackTrace) {
|
|
46
|
+
Error.captureStackTrace(this, GeneratorError);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.GeneratorError = GeneratorError;
|
|
@@ -15,7 +15,7 @@ async function processGenerator(generators, dataTable) {
|
|
|
15
15
|
dataTable.forEach(row => {
|
|
16
16
|
const generatorName = row.DG_API_NAME;
|
|
17
17
|
if (generatorName === generator.name) {
|
|
18
|
-
generator.params = generator.params ? generator.params :
|
|
18
|
+
generator.params = generator.params ? generator.params : {};
|
|
19
19
|
|
|
20
20
|
// The API name row is only used for matching the template
|
|
21
21
|
// Filter out DG_API_NAME and collect other values
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
delete require.cache[require.resolve('../core/playwright/runner/Runner')];
|
|
4
|
+
function test() {
|
|
5
|
+
const inputString = "@hc";
|
|
6
|
+
const selectedTag = ["@hc_1234"].reverse().find(tag => tag.startsWith(inputString));
|
|
7
|
+
let tagInput = null;
|
|
8
|
+
if (selectedTag) {
|
|
9
|
+
tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
console.log(tagInput);
|
|
12
|
+
}
|
|
13
|
+
test();
|