@zohodesk/testinglibrary 3.2.8 → 3.2.10
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/README.md +3 -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/core/playwright/readConfigFile.js +1 -0
- package/build/core/playwright/setup/Project.js +35 -0
- package/build/core/playwright/setup/ProjectConfiguration.js +80 -0
- package/build/core/playwright/setup/config-creator.js +24 -51
- package/npm-shrinkwrap.json +392 -404
- 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
|
+
|
package/README.md
CHANGED
|
@@ -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
|
|
@@ -19,6 +19,7 @@ var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
|
|
|
19
19
|
let cachedConfig = null;
|
|
20
20
|
function getDefaultConfig() {
|
|
21
21
|
return {
|
|
22
|
+
isTearDown: true,
|
|
22
23
|
uatDirectory: _path.default.join(process.cwd(), 'uat'),
|
|
23
24
|
headless: false,
|
|
24
25
|
browsers: ['Chrome'],
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class Project {
|
|
4
|
+
constructor(name) {
|
|
5
|
+
this.properties = {};
|
|
6
|
+
this.properties.name = name;
|
|
7
|
+
}
|
|
8
|
+
setTestDir(value) {
|
|
9
|
+
this.properties.testDir = value;
|
|
10
|
+
}
|
|
11
|
+
setTestMatch(value) {
|
|
12
|
+
this.properties.testMatch = value;
|
|
13
|
+
}
|
|
14
|
+
setRetries(value) {
|
|
15
|
+
this.properties.retries = value;
|
|
16
|
+
}
|
|
17
|
+
setUse(value) {
|
|
18
|
+
this.properties.use = value;
|
|
19
|
+
}
|
|
20
|
+
setTearDown(value) {
|
|
21
|
+
this.properties.teardown = value;
|
|
22
|
+
}
|
|
23
|
+
setDependencies(value) {
|
|
24
|
+
this.properties.dependencies = value;
|
|
25
|
+
}
|
|
26
|
+
setProperty(key, value) {
|
|
27
|
+
this.properties[key] = value;
|
|
28
|
+
}
|
|
29
|
+
getProperties() {
|
|
30
|
+
return this.properties;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
module.exports = {
|
|
34
|
+
Project
|
|
35
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.cleanupConfig = cleanupConfig;
|
|
8
|
+
exports.setupConfig = setupConfig;
|
|
9
|
+
exports.smokeTestConfig = smokeTestConfig;
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _Project = require("./Project");
|
|
12
|
+
var _configUtils = require("./config-utils");
|
|
13
|
+
var _readConfigFile = require("../readConfigFile");
|
|
14
|
+
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
15
|
+
const {
|
|
16
|
+
isAuthMode,
|
|
17
|
+
isTearDown,
|
|
18
|
+
isSmokeTest,
|
|
19
|
+
bddMode,
|
|
20
|
+
authFilePath,
|
|
21
|
+
trace,
|
|
22
|
+
video,
|
|
23
|
+
testIdAttribute,
|
|
24
|
+
viewport
|
|
25
|
+
} = uatConfig;
|
|
26
|
+
function setupConfig() {
|
|
27
|
+
const setupProject = new _Project.Project('setup');
|
|
28
|
+
setupProject.setTestMatch(/.*\.setup\.js/);
|
|
29
|
+
setupProject.setTestDir(_path.default.join(process.cwd(), 'uat'));
|
|
30
|
+
setupProject.setTearDown(isTearDown ? 'cleanup' : '');
|
|
31
|
+
const setupProjectConfig = [setupProject.getProperties()];
|
|
32
|
+
return setupProjectConfig;
|
|
33
|
+
}
|
|
34
|
+
function smokeTestConfig() {
|
|
35
|
+
const smokeTestProject = new _Project.Project('smokeTest');
|
|
36
|
+
const smokeTestDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
37
|
+
featureFilesFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*.feature'),
|
|
38
|
+
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
39
|
+
outputDir: _path.default.join(process.cwd(), 'uat', '.features-smoke-gen'),
|
|
40
|
+
uatPath: _path.default.join(process.cwd(), 'uat', 'smokeTest')
|
|
41
|
+
});
|
|
42
|
+
const commonConfig = {
|
|
43
|
+
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
44
|
+
};
|
|
45
|
+
smokeTestProject.setTestDir(smokeTestDir);
|
|
46
|
+
smokeTestProject.setRetries(0);
|
|
47
|
+
smokeTestProject.setUse({
|
|
48
|
+
...commonConfig
|
|
49
|
+
});
|
|
50
|
+
smokeTestProject.setDependencies(isAuthMode ? ['setup'] : []);
|
|
51
|
+
const smokeTestProjectConfig = [smokeTestProject.getProperties()];
|
|
52
|
+
return smokeTestProjectConfig;
|
|
53
|
+
}
|
|
54
|
+
function defaultConfig() {
|
|
55
|
+
const defaultProject = new _Project.Project('default');
|
|
56
|
+
const testDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
57
|
+
featureFilesFolder: (0, _configUtils.getPathsForFeatureFiles)(process.cwd()),
|
|
58
|
+
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
59
|
+
outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
|
|
60
|
+
uatPath: _path.default.join(process.cwd(), 'uat')
|
|
61
|
+
});
|
|
62
|
+
const use = {
|
|
63
|
+
trace,
|
|
64
|
+
video,
|
|
65
|
+
viewport,
|
|
66
|
+
testIdAttribute
|
|
67
|
+
};
|
|
68
|
+
defaultProject.setUse(use);
|
|
69
|
+
defaultProject.setTestDir(testDir);
|
|
70
|
+
defaultProject.setDependencies(isSmokeTest ? ['smokeTest'] : []);
|
|
71
|
+
const defaultProjectConfig = [defaultProject.getProperties()];
|
|
72
|
+
return defaultProjectConfig;
|
|
73
|
+
}
|
|
74
|
+
function cleanupConfig() {
|
|
75
|
+
const cleanupProject = new _Project.Project('cleanup');
|
|
76
|
+
cleanupProject.setTestMatch(/.*\.teardown\.js/);
|
|
77
|
+
cleanupProject.setTestDir(_path.default.join(process.cwd(), 'uat'));
|
|
78
|
+
const cleanupProjectConfig = [cleanupProject.getProperties()];
|
|
79
|
+
return cleanupProjectConfig;
|
|
80
|
+
}
|
|
@@ -9,47 +9,36 @@ var _test = require("@playwright/test");
|
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
var _readConfigFile = require("../readConfigFile");
|
|
11
11
|
var _configUtils = require("./config-utils");
|
|
12
|
+
var _ProjectConfiguration = require("./ProjectConfiguration");
|
|
12
13
|
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
13
14
|
const {
|
|
15
|
+
bddMode,
|
|
14
16
|
browsers,
|
|
15
17
|
isSmokeTest,
|
|
16
|
-
|
|
17
|
-
video,
|
|
18
|
+
isTearDown,
|
|
18
19
|
isAuthMode,
|
|
19
20
|
openReportOn,
|
|
20
21
|
reportPath,
|
|
21
|
-
bddMode,
|
|
22
22
|
expectTimeout,
|
|
23
23
|
testTimeout,
|
|
24
24
|
authFilePath,
|
|
25
25
|
viewport,
|
|
26
|
-
featureFilesFolder,
|
|
27
|
-
stepDefinitionsFolder,
|
|
28
|
-
testIdAttribute,
|
|
29
26
|
globalTimeout,
|
|
30
|
-
customReporter
|
|
27
|
+
customReporter,
|
|
28
|
+
trace,
|
|
29
|
+
video,
|
|
30
|
+
testIdAttribute
|
|
31
31
|
} = uatConfig;
|
|
32
32
|
const projects = (0, _configUtils.getProjects)({
|
|
33
33
|
browsers,
|
|
34
34
|
isAuthMode,
|
|
35
35
|
isSmokeTest,
|
|
36
|
+
isTearDown,
|
|
36
37
|
authFilePath,
|
|
37
38
|
expectTimeout,
|
|
38
39
|
testTimeout,
|
|
39
40
|
viewport
|
|
40
41
|
});
|
|
41
|
-
const testDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
42
|
-
featureFilesFolder: (0, _configUtils.getPathsForFeatureFiles)(process.cwd()),
|
|
43
|
-
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
44
|
-
outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
|
|
45
|
-
uatPath: _path.default.join(process.cwd(), 'uat')
|
|
46
|
-
});
|
|
47
|
-
const use = {
|
|
48
|
-
trace,
|
|
49
|
-
video,
|
|
50
|
-
viewport,
|
|
51
|
-
testIdAttribute
|
|
52
|
-
};
|
|
53
42
|
let reporter = [['html', {
|
|
54
43
|
outputFolder: reportPath,
|
|
55
44
|
open: openReportOn
|
|
@@ -66,29 +55,22 @@ if (customReporter) {
|
|
|
66
55
|
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
67
56
|
*/
|
|
68
57
|
|
|
58
|
+
const use = {
|
|
59
|
+
trace,
|
|
60
|
+
video,
|
|
61
|
+
viewport,
|
|
62
|
+
testIdAttribute
|
|
63
|
+
};
|
|
64
|
+
const testDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
65
|
+
featureFilesFolder: (0, _configUtils.getPathsForFeatureFiles)(process.cwd()),
|
|
66
|
+
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
67
|
+
outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
|
|
68
|
+
uatPath: _path.default.join(process.cwd(), 'uat')
|
|
69
|
+
});
|
|
69
70
|
function getPlaywrightConfig() {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const dependencies = isAuthMode ? ['setup'] : [];
|
|
74
|
-
const smokeTestProject = isSmokeTest ? smokeTestConfig() : [];
|
|
75
|
-
function smokeTestConfig() {
|
|
76
|
-
const smokeTestDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
77
|
-
featureFilesFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*.feature'),
|
|
78
|
-
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
79
|
-
outputDir: _path.default.join(process.cwd(), 'uat', '.features-smoke-gen'),
|
|
80
|
-
uatPath: _path.default.join(process.cwd(), 'uat', 'smokeTest')
|
|
81
|
-
});
|
|
82
|
-
return [{
|
|
83
|
-
name: 'smokeTest',
|
|
84
|
-
testDir: smokeTestDir,
|
|
85
|
-
use: {
|
|
86
|
-
...commonConfig
|
|
87
|
-
},
|
|
88
|
-
dependencies: dependencies,
|
|
89
|
-
retries: 0
|
|
90
|
-
}];
|
|
91
|
-
}
|
|
71
|
+
const smokeTestProject = isSmokeTest ? (0, _ProjectConfiguration.smokeTestConfig)() : [];
|
|
72
|
+
const setupProject = isAuthMode ? (0, _ProjectConfiguration.setupConfig)() : [];
|
|
73
|
+
const cleanupProject = isTearDown ? (0, _ProjectConfiguration.cleanupConfig)() : [];
|
|
92
74
|
const playwrightConfig = {
|
|
93
75
|
testDir,
|
|
94
76
|
globalTimeout: globalTimeout || 3600000,
|
|
@@ -100,16 +82,7 @@ function getPlaywrightConfig() {
|
|
|
100
82
|
timeout: expectTimeout
|
|
101
83
|
},
|
|
102
84
|
use,
|
|
103
|
-
projects:
|
|
104
|
-
name: 'setup',
|
|
105
|
-
testMatch: /.*\.setup\.js/,
|
|
106
|
-
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
107
|
-
teardown: 'cleanup'
|
|
108
|
-
}, ...smokeTestProject, {
|
|
109
|
-
name: 'cleanup',
|
|
110
|
-
testMatch: /.*\.teardown\.js/,
|
|
111
|
-
testDir: _path.default.join(process.cwd(), 'uat')
|
|
112
|
-
}, ...projects] : [...projects, ...smokeTestProject],
|
|
85
|
+
projects: [...setupProject, ...smokeTestProject, ...projects, ...cleanupProject],
|
|
113
86
|
...uatConfig
|
|
114
87
|
};
|
|
115
88
|
return playwrightConfig;
|