@zohodesk/testinglibrary 0.1.2 → 0.1.4
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/readConfigFile.js +20 -4
- package/build/core/playwright/setup/config-creator.js +21 -12
- package/build/core/playwright/setup/config-utils.js +34 -2
- package/build/setup-folder-structure/samples/uat-config-sample.js +5 -3
- package/changelog.md +10 -0
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ const fileName = 'uat.config.js';
|
|
|
15
15
|
exports.fileName = fileName;
|
|
16
16
|
function getDefaultConfig() {
|
|
17
17
|
return {
|
|
18
|
+
headless: false,
|
|
18
19
|
browsers: ['Chrome'],
|
|
19
20
|
trace: false,
|
|
20
21
|
video: false,
|
|
@@ -31,14 +32,28 @@ function getDefaultConfig() {
|
|
|
31
32
|
},
|
|
32
33
|
debug: false,
|
|
33
34
|
mode: 'dev',
|
|
34
|
-
additionalPages: {}
|
|
35
|
+
additionalPages: {},
|
|
36
|
+
featureFilesFolder: 'feature-files',
|
|
37
|
+
stepDefinitionsFolder: 'steps',
|
|
38
|
+
testIdAttribute: 'data-testid'
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
38
42
|
let defaultConfig = getDefaultConfig();
|
|
43
|
+
let configurationObj = {};
|
|
44
|
+
Object.keys(userConfiguration).forEach(configKey => {
|
|
45
|
+
let configValue = userConfiguration[configKey];
|
|
46
|
+
if (configValue !== null && configValue !== undefined) {
|
|
47
|
+
configurationObj[configKey] = configValue;
|
|
48
|
+
} else if (defaultConfig[configKey]) {
|
|
49
|
+
configurationObj[configKey] = defaultConfig[configKey];
|
|
50
|
+
} else {
|
|
51
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `key - ${configKey} is not yet supported in uat configuration. This will not be used while creating playwright configuration`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
39
54
|
return {
|
|
40
55
|
...defaultConfig,
|
|
41
|
-
...
|
|
56
|
+
...configurationObj
|
|
42
57
|
};
|
|
43
58
|
}
|
|
44
59
|
|
|
@@ -56,7 +71,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
56
71
|
* @property {boolean} video - video for test cases,
|
|
57
72
|
* @property {boolean} debug - debug mode
|
|
58
73
|
* @property {string} mode: mode in which the test cases needs to run
|
|
59
|
-
* @property {boolean} isAuthMode - Auth Mode
|
|
74
|
+
* @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
|
|
60
75
|
* @property {string} authFilePath - File Path where the cookies stored
|
|
61
76
|
* @property {any} browsers: List of browsers
|
|
62
77
|
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
@@ -67,7 +82,8 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
67
82
|
* @property {Object} additionalPages: custom pages configuration
|
|
68
83
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
69
84
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
70
|
-
* @property {viewportConfig} viewport: viewport configuration
|
|
85
|
+
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
|
|
86
|
+
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
71
87
|
*/
|
|
72
88
|
|
|
73
89
|
/**
|
|
@@ -20,7 +20,10 @@ const {
|
|
|
20
20
|
expectTimeout,
|
|
21
21
|
testTimeout,
|
|
22
22
|
authFilePath,
|
|
23
|
-
viewport
|
|
23
|
+
viewport,
|
|
24
|
+
featureFilesFolder,
|
|
25
|
+
stepDefinitionsFolder,
|
|
26
|
+
testIdAttribute
|
|
24
27
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
25
28
|
const projects = (0, _configUtils.getProjects)({
|
|
26
29
|
browsers,
|
|
@@ -30,7 +33,22 @@ const projects = (0, _configUtils.getProjects)({
|
|
|
30
33
|
testTimeout,
|
|
31
34
|
viewport
|
|
32
35
|
});
|
|
33
|
-
const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd()
|
|
36
|
+
const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd(), {
|
|
37
|
+
featureFilesFolder,
|
|
38
|
+
stepDefinitionsFolder
|
|
39
|
+
});
|
|
40
|
+
const testOptions = (0, _configUtils.getTestUseOptions)({
|
|
41
|
+
trace,
|
|
42
|
+
video,
|
|
43
|
+
viewport,
|
|
44
|
+
testIdAttribute
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Playwright configuration object
|
|
49
|
+
*
|
|
50
|
+
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
51
|
+
*/
|
|
34
52
|
function getPlaywrightConfig() {
|
|
35
53
|
return {
|
|
36
54
|
testDir,
|
|
@@ -47,16 +65,7 @@ function getPlaywrightConfig() {
|
|
|
47
65
|
expect: {
|
|
48
66
|
timeout: expectTimeout
|
|
49
67
|
},
|
|
50
|
-
use:
|
|
51
|
-
viewport,
|
|
52
|
-
trace: trace ? 'on' : 'off',
|
|
53
|
-
video: video ? {
|
|
54
|
-
mode: 'on',
|
|
55
|
-
size: {
|
|
56
|
-
...viewport
|
|
57
|
-
}
|
|
58
|
-
} : 'off'
|
|
59
|
-
},
|
|
68
|
+
use: testOptions,
|
|
60
69
|
projects: isAuthMode ? [{
|
|
61
70
|
name: 'setup',
|
|
62
71
|
testMatch: /.*\.setup\.js/,
|
|
@@ -6,10 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getProjects = getProjects;
|
|
8
8
|
exports.getTestDir = getTestDir;
|
|
9
|
+
exports.getTestUseOptions = getTestUseOptions;
|
|
9
10
|
var _test = require("@playwright/test");
|
|
10
11
|
var _path = _interopRequireDefault(require("path"));
|
|
11
12
|
var _readConfigFile = require("../readConfigFile");
|
|
12
13
|
var _bddFramework = require("../../../bdd-framework");
|
|
14
|
+
/**
|
|
15
|
+
** Playwright project configuration
|
|
16
|
+
* @returns {import('@playwright/test').Project}
|
|
17
|
+
*/
|
|
13
18
|
function getBrowserConfig({
|
|
14
19
|
browserName,
|
|
15
20
|
isAuthMode,
|
|
@@ -81,6 +86,12 @@ function getBrowserConfig({
|
|
|
81
86
|
return false;
|
|
82
87
|
}
|
|
83
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param {*} param0
|
|
93
|
+
* @returns {import('@playwright/test').Project[]}
|
|
94
|
+
*/
|
|
84
95
|
function getProjects({
|
|
85
96
|
browsers,
|
|
86
97
|
isAuthMode,
|
|
@@ -98,12 +109,33 @@ function getProjects({
|
|
|
98
109
|
viewport
|
|
99
110
|
})).filter(Boolean);
|
|
100
111
|
}
|
|
101
|
-
function getTestDir(bddMode, cwd
|
|
112
|
+
function getTestDir(bddMode, cwd, {
|
|
113
|
+
stepDefinitionsFolder
|
|
114
|
+
}) {
|
|
102
115
|
return bddMode ? (0, _bddFramework.defineBddConfig)({
|
|
103
116
|
paths: [_path.default.join(cwd, 'uat', '**', '*.feature')],
|
|
104
|
-
import: [_path.default.join(cwd, 'uat', '**',
|
|
117
|
+
import: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js')],
|
|
105
118
|
featuresRoot: _path.default.join(cwd, 'uat'),
|
|
106
119
|
outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
|
|
107
120
|
publish: true
|
|
108
121
|
}) : _path.default.join(cwd, 'uat');
|
|
122
|
+
}
|
|
123
|
+
function getTestUseOptions({
|
|
124
|
+
viewport,
|
|
125
|
+
trace,
|
|
126
|
+
video,
|
|
127
|
+
testIdAttribute
|
|
128
|
+
}) {
|
|
129
|
+
let defaultTestuseOptions = {
|
|
130
|
+
viewport,
|
|
131
|
+
testIdAttribute,
|
|
132
|
+
trace: trace ? 'on' : 'off',
|
|
133
|
+
video: video ? {
|
|
134
|
+
mode: 'on',
|
|
135
|
+
size: {
|
|
136
|
+
...viewport
|
|
137
|
+
}
|
|
138
|
+
} : 'off'
|
|
139
|
+
};
|
|
140
|
+
return defaultTestuseOptions;
|
|
109
141
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @property {boolean} video - video for test cases,
|
|
12
12
|
* @property {boolean} debug - debug mode
|
|
13
13
|
* @property {string} mode: mode in which the test cases needs to run
|
|
14
|
-
* @property {boolean} isAuthMode - Auth Mode
|
|
14
|
+
* @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
|
|
15
15
|
* @property {string} authFilePath - File Path where the cookies stored
|
|
16
16
|
* @property {any} browsers: List of browsers
|
|
17
17
|
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
* @property {Object} additionalPages: custom pages configuration
|
|
23
23
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
24
24
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
25
|
-
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is {width: 1280, height: 720 }
|
|
25
|
+
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
|
|
26
|
+
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -36,7 +37,8 @@ module.exports = {
|
|
|
36
37
|
authFilePath: 'uat/playwright/.auth/user.json',
|
|
37
38
|
trace: true,
|
|
38
39
|
video: true,
|
|
40
|
+
bddMode: true,
|
|
39
41
|
featureFilesFolder: 'feature-files',
|
|
40
42
|
stepDefinitionsFolder: 'steps',
|
|
41
|
-
viewport:
|
|
43
|
+
viewport: { width: 1280, height: 720 }
|
|
42
44
|
}
|
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.4
|
|
6
|
+
|
|
7
|
+
- `testIdAttribute` config added
|
|
8
|
+
- Fixed issue while reading boolean configuration values
|
|
9
|
+
|
|
10
|
+
# 0.1.3
|
|
11
|
+
|
|
12
|
+
- uat config sample file updated with `bddMode` and `viewport` values
|
|
13
|
+
- user configuration issue fix when the value is undefined
|
|
14
|
+
|
|
5
15
|
# 0.1.2
|
|
6
16
|
|
|
7
17
|
- Bdd version updated to `5.4.0`
|