@zohodesk/testinglibrary 0.0.7 → 0.0.8
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/Changelog.md +7 -0
- package/build/core/playwright/index.js +1 -1
- package/build/core/playwright/readConfigFile.js +38 -2
- package/build/core/playwright/report-generator.js +1 -1
- package/build/core/playwright/setup/config-creator.js +53 -101
- package/build/core/playwright/setup/config-utils.js +109 -0
- package/build/core/playwright/test-runner.js +65 -93
- package/build/setup-folder-structure/samples/uat-config-sample.js +8 -1
- package/package.json +1 -1
package/Changelog.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
4
|
|
|
5
|
+
# 0.0.8
|
|
6
|
+
|
|
7
|
+
- Tags Support
|
|
8
|
+
- Enable running without bddmode feature
|
|
9
|
+
- viewport configuration
|
|
10
|
+
- Internal Change - Code refactoring
|
|
11
|
+
|
|
5
12
|
# 0.0.7
|
|
6
13
|
|
|
7
14
|
- Removed react and react-dom as dependencies. Added this as peer dependency
|
|
@@ -12,6 +12,41 @@ var _fs = require("fs");
|
|
|
12
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
13
|
var _logger = require("../../utils/logger");
|
|
14
14
|
const fileName = 'uat.config.js';
|
|
15
|
+
exports.fileName = fileName;
|
|
16
|
+
function getDefaultConfig() {
|
|
17
|
+
return {
|
|
18
|
+
browsers: ['Chrome'],
|
|
19
|
+
trace: false,
|
|
20
|
+
video: false,
|
|
21
|
+
isAuthMode: false,
|
|
22
|
+
openReportOn: 'never',
|
|
23
|
+
reportPath: _path.default.join(process.cwd(), 'uat', 'playwright-report'),
|
|
24
|
+
bddMode: false,
|
|
25
|
+
expectTimeout: 5 * 1000,
|
|
26
|
+
testTimeout: 60 * 1000,
|
|
27
|
+
authFilePath: 'uat/playwright/.auth/user.json',
|
|
28
|
+
viewport: {
|
|
29
|
+
width: 1280,
|
|
30
|
+
height: 720
|
|
31
|
+
},
|
|
32
|
+
debug: false,
|
|
33
|
+
mode: 'dev',
|
|
34
|
+
additionalPages: {}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
38
|
+
let defaultConfig = getDefaultConfig();
|
|
39
|
+
return {
|
|
40
|
+
...defaultConfig,
|
|
41
|
+
...userConfiguration
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {Object|null} viewportConfig
|
|
47
|
+
* @property {number} width - width of the viewport
|
|
48
|
+
* @property {number} height - height of the viewport
|
|
49
|
+
*/
|
|
15
50
|
|
|
16
51
|
/**
|
|
17
52
|
* Represents the user configuration object.
|
|
@@ -32,6 +67,7 @@ const fileName = 'uat.config.js';
|
|
|
32
67
|
* @property {Object} additionalPages: custom pages configuration
|
|
33
68
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
34
69
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
70
|
+
* @property {viewportConfig} viewport: viewport configuration
|
|
35
71
|
*/
|
|
36
72
|
|
|
37
73
|
/**
|
|
@@ -39,13 +75,13 @@ const fileName = 'uat.config.js';
|
|
|
39
75
|
*
|
|
40
76
|
* @returns {UserConfig}
|
|
41
77
|
*/
|
|
42
|
-
exports.fileName = fileName;
|
|
43
78
|
function generateConfigFromFile() {
|
|
44
79
|
const filePath = _path.default.resolve(process.cwd(), fileName);
|
|
45
80
|
if ((0, _fs.existsSync)(filePath)) {
|
|
46
81
|
/** @type {UserConfig} */
|
|
47
82
|
const config = require(filePath);
|
|
48
|
-
|
|
83
|
+
const modifiedConfiguration = combineDefaultConfigWithUserConfig(config);
|
|
84
|
+
return modifiedConfiguration;
|
|
49
85
|
}
|
|
50
86
|
return {};
|
|
51
87
|
}
|
|
@@ -14,7 +14,7 @@ const userArgs = process.argv.slice(3);
|
|
|
14
14
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
15
15
|
const command = playwrightPath;
|
|
16
16
|
const {
|
|
17
|
-
reportPath: htmlPath
|
|
17
|
+
reportPath: htmlPath
|
|
18
18
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
19
19
|
const args = ['show-report', htmlPath].concat(userArgs);
|
|
20
20
|
function generateReport() {
|
|
@@ -7,111 +7,63 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _test = require("@playwright/test");
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _bddFramework = require("../../../bdd-framework");
|
|
11
10
|
var _readConfigFile = require("../readConfigFile");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// import { cpus } from 'os';
|
|
15
|
-
// const numOfCpus = cpus().length;
|
|
16
|
-
const defaultBrowser = ['Chrome'];
|
|
11
|
+
var _configUtils = require("./config-utils");
|
|
17
12
|
const {
|
|
18
|
-
browsers
|
|
19
|
-
trace
|
|
20
|
-
video
|
|
13
|
+
browsers,
|
|
14
|
+
trace,
|
|
15
|
+
video,
|
|
21
16
|
isAuthMode,
|
|
22
17
|
openReportOn,
|
|
23
|
-
reportPath
|
|
24
|
-
bddMode
|
|
25
|
-
expectTimeout
|
|
26
|
-
testTimeout
|
|
27
|
-
authFilePath
|
|
18
|
+
reportPath,
|
|
19
|
+
bddMode,
|
|
20
|
+
expectTimeout,
|
|
21
|
+
testTimeout,
|
|
22
|
+
authFilePath,
|
|
23
|
+
viewport
|
|
28
24
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
37
|
-
},
|
|
38
|
-
dependencies: isAuthMode ? ['setup'] : []
|
|
39
|
-
};
|
|
40
|
-
} else if (browser === 'edge') {
|
|
41
|
-
return {
|
|
42
|
-
name: 'Microsoft Edge',
|
|
43
|
-
use: {
|
|
44
|
-
..._test.devices['Desktop Chrome'],
|
|
45
|
-
channel: 'msedge',
|
|
46
|
-
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
47
|
-
},
|
|
48
|
-
dependencies: isAuthMode ? ['setup'] : []
|
|
49
|
-
};
|
|
50
|
-
} else if (browser === 'firefox') {
|
|
51
|
-
return {
|
|
52
|
-
name: 'firefox',
|
|
53
|
-
timeout: 4 * 60 * 1000,
|
|
54
|
-
expect: {
|
|
55
|
-
timeout: 80 * 1000
|
|
56
|
-
},
|
|
57
|
-
use: {
|
|
58
|
-
..._test.devices['Desktop Firefox'],
|
|
59
|
-
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
60
|
-
},
|
|
61
|
-
dependencies: isAuthMode ? ['setup'] : []
|
|
62
|
-
};
|
|
63
|
-
} else if (browser === 'safari') {
|
|
64
|
-
return {
|
|
65
|
-
name: 'webkit',
|
|
66
|
-
timeout: 2 * 60 * 1000,
|
|
67
|
-
expect: {
|
|
68
|
-
timeout: 80 * 1000
|
|
69
|
-
},
|
|
70
|
-
use: {
|
|
71
|
-
..._test.devices['Desktop Safari'],
|
|
72
|
-
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
73
|
-
},
|
|
74
|
-
dependencies: isAuthMode ? ['setup'] : null
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}).filter(Boolean);
|
|
78
|
-
const testPath = _path.default.join(_path.default.resolve(process.cwd()), 'uat');
|
|
79
|
-
const testDir = bddMode ? (0, _bddFramework.defineBddConfig)({
|
|
80
|
-
paths: [`${testPath}/**/*.feature`],
|
|
81
|
-
import: [`${testPath}/**/steps/*.spec.js`],
|
|
82
|
-
featuresRoot: `${testPath}`,
|
|
83
|
-
outputDir: `${testPath}/.features-gen`,
|
|
84
|
-
publish: true
|
|
85
|
-
}) : _path.default.join(_path.default.resolve(process.cwd()), 'uat');
|
|
86
|
-
var _default = (0, _test.defineConfig)({
|
|
87
|
-
testDir,
|
|
88
|
-
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|
|
89
|
-
fullyParallel: true,
|
|
90
|
-
forbidOnly: !!process.env.CI,
|
|
91
|
-
retries: process.env.CI ? 2 : 0,
|
|
92
|
-
workers: process.env.CI ? 1 : 1,
|
|
93
|
-
reporter: [['html', {
|
|
94
|
-
outputFolder: reportPath,
|
|
95
|
-
open: openReportOn
|
|
96
|
-
}]],
|
|
97
|
-
timeout: testTimeout,
|
|
98
|
-
expect: {
|
|
99
|
-
timeout: expectTimeout
|
|
100
|
-
},
|
|
101
|
-
use: {
|
|
102
|
-
trace: trace ? 'on' : 'off',
|
|
103
|
-
video: video ? {
|
|
104
|
-
mode: 'on',
|
|
105
|
-
size: {
|
|
106
|
-
width: 640,
|
|
107
|
-
height: 480
|
|
108
|
-
}
|
|
109
|
-
} : 'off'
|
|
110
|
-
},
|
|
111
|
-
projects: isAuthMode ? [{
|
|
112
|
-
name: 'setup',
|
|
113
|
-
testMatch: /.*\.setup\.js/,
|
|
114
|
-
testDir: _path.default.join(_path.default.resolve(process.cwd()), 'uat')
|
|
115
|
-
}, ...projects] : [...projects]
|
|
25
|
+
const projects = (0, _configUtils.getProjects)({
|
|
26
|
+
browsers,
|
|
27
|
+
isAuthMode,
|
|
28
|
+
authFilePath,
|
|
29
|
+
expectTimeout,
|
|
30
|
+
testTimeout,
|
|
31
|
+
viewport
|
|
116
32
|
});
|
|
33
|
+
const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd());
|
|
34
|
+
function getPlaywrightConfig() {
|
|
35
|
+
return {
|
|
36
|
+
testDir,
|
|
37
|
+
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|
|
38
|
+
fullyParallel: true,
|
|
39
|
+
forbidOnly: !!process.env.CI,
|
|
40
|
+
retries: process.env.CI ? 2 : 0,
|
|
41
|
+
workers: process.env.CI ? 1 : 1,
|
|
42
|
+
reporter: [['html', {
|
|
43
|
+
outputFolder: reportPath,
|
|
44
|
+
open: openReportOn
|
|
45
|
+
}]],
|
|
46
|
+
timeout: testTimeout,
|
|
47
|
+
expect: {
|
|
48
|
+
timeout: expectTimeout
|
|
49
|
+
},
|
|
50
|
+
use: {
|
|
51
|
+
viewport,
|
|
52
|
+
trace: trace ? 'on' : 'off',
|
|
53
|
+
video: video ? {
|
|
54
|
+
mode: 'on',
|
|
55
|
+
size: {
|
|
56
|
+
width: 640,
|
|
57
|
+
height: 480
|
|
58
|
+
}
|
|
59
|
+
} : 'off'
|
|
60
|
+
},
|
|
61
|
+
projects: isAuthMode ? [{
|
|
62
|
+
name: 'setup',
|
|
63
|
+
testMatch: /.*\.setup\.js/,
|
|
64
|
+
testDir: _path.default.join(process.cwd(), 'uat')
|
|
65
|
+
}, ...projects] : [...projects]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
var _default = (0, _test.defineConfig)(getPlaywrightConfig());
|
|
117
69
|
exports.default = _default;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getProjects = getProjects;
|
|
8
|
+
exports.getTestDir = getTestDir;
|
|
9
|
+
var _test = require("@playwright/test");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _readConfigFile = require("../readConfigFile");
|
|
12
|
+
var _bddFramework = require("../../../bdd-framework");
|
|
13
|
+
function getBrowserConfig({
|
|
14
|
+
browserName,
|
|
15
|
+
isAuthMode,
|
|
16
|
+
authFilePath,
|
|
17
|
+
expectTimeout,
|
|
18
|
+
testTimeout,
|
|
19
|
+
viewport
|
|
20
|
+
}) {
|
|
21
|
+
const browser = browserName.toLowerCase();
|
|
22
|
+
const commonConfig = {
|
|
23
|
+
viewport,
|
|
24
|
+
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
25
|
+
};
|
|
26
|
+
const dependencies = isAuthMode ? ['setup'] : [];
|
|
27
|
+
if (browser === 'chrome') {
|
|
28
|
+
return {
|
|
29
|
+
name: 'chromium',
|
|
30
|
+
use: {
|
|
31
|
+
..._test.devices['Desktop Chrome'],
|
|
32
|
+
...commonConfig
|
|
33
|
+
},
|
|
34
|
+
dependencies,
|
|
35
|
+
timeout: testTimeout,
|
|
36
|
+
expect: {
|
|
37
|
+
timeout: expectTimeout
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
} else if (browser === 'edge') {
|
|
41
|
+
return {
|
|
42
|
+
name: 'Microsoft Edge',
|
|
43
|
+
timeout: testTimeout,
|
|
44
|
+
expect: {
|
|
45
|
+
timeout: expectTimeout
|
|
46
|
+
},
|
|
47
|
+
use: {
|
|
48
|
+
..._test.devices['Desktop Chrome'],
|
|
49
|
+
channel: 'msedge',
|
|
50
|
+
...commonConfig
|
|
51
|
+
},
|
|
52
|
+
dependencies
|
|
53
|
+
};
|
|
54
|
+
} else if (browser === 'firefox') {
|
|
55
|
+
return {
|
|
56
|
+
name: 'firefox',
|
|
57
|
+
timeout: 2 * testTimeout,
|
|
58
|
+
expect: {
|
|
59
|
+
timeout: 2 * expectTimeout
|
|
60
|
+
},
|
|
61
|
+
use: {
|
|
62
|
+
..._test.devices['Desktop Firefox'],
|
|
63
|
+
...commonConfig
|
|
64
|
+
},
|
|
65
|
+
dependencies
|
|
66
|
+
};
|
|
67
|
+
} else if (browser === 'safari') {
|
|
68
|
+
return {
|
|
69
|
+
name: 'webkit',
|
|
70
|
+
timeout: 4 * testTimeout,
|
|
71
|
+
expect: {
|
|
72
|
+
timeout: 4 * expectTimeout
|
|
73
|
+
},
|
|
74
|
+
use: {
|
|
75
|
+
..._test.devices['Desktop Safari'],
|
|
76
|
+
...commonConfig
|
|
77
|
+
},
|
|
78
|
+
dependencies
|
|
79
|
+
};
|
|
80
|
+
} else {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function getProjects({
|
|
85
|
+
browsers,
|
|
86
|
+
isAuthMode,
|
|
87
|
+
authFilePath,
|
|
88
|
+
expectTimeout,
|
|
89
|
+
testTimeout,
|
|
90
|
+
viewport
|
|
91
|
+
}) {
|
|
92
|
+
return browsers.map(browserName => getBrowserConfig({
|
|
93
|
+
browserName,
|
|
94
|
+
isAuthMode,
|
|
95
|
+
authFilePath,
|
|
96
|
+
expectTimeout,
|
|
97
|
+
testTimeout,
|
|
98
|
+
viewport
|
|
99
|
+
})).filter(Boolean);
|
|
100
|
+
}
|
|
101
|
+
function getTestDir(bddMode, cwd) {
|
|
102
|
+
return bddMode ? (0, _bddFramework.defineBddConfig)({
|
|
103
|
+
paths: [_path.default.join(cwd, 'uat', '**', '*.feature')],
|
|
104
|
+
import: [_path.default.join(cwd, 'uat', '**', 'steps', '*.spec.js')],
|
|
105
|
+
featuresRoot: _path.default.join(cwd, 'uat'),
|
|
106
|
+
outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
|
|
107
|
+
publish: true
|
|
108
|
+
}) : _path.default.join(cwd, 'uat');
|
|
109
|
+
}
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _child_process = require("child_process");
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
var _customCommands = require("./custom-commands");
|
|
@@ -13,94 +13,51 @@ var _envInitializer = require("./env-initializer");
|
|
|
13
13
|
var _logger = require("../../utils/logger");
|
|
14
14
|
var _readConfigFile = require("./readConfigFile");
|
|
15
15
|
var _rootPath = require("../../utils/rootPath");
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line
|
|
22
|
-
const tagArgs = userArgsObject['tags'];
|
|
23
|
-
const {
|
|
24
|
-
debug,
|
|
25
|
-
mode = 'dev',
|
|
26
|
-
bddMode = false,
|
|
27
|
-
headless = false
|
|
28
|
-
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
29
|
-
|
|
30
|
-
// Environment variables Initialization
|
|
31
|
-
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
16
|
+
function parseUserArgs() {
|
|
17
|
+
return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
|
|
18
|
+
}
|
|
19
|
+
function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
32
20
|
const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
|
|
33
21
|
if (debug) {
|
|
34
22
|
playwrightArgs.push('--debug');
|
|
35
23
|
}
|
|
36
|
-
if (tagArgs) {
|
|
37
|
-
playwrightArgs.push(
|
|
24
|
+
if (!bddMode && tagArgs) {
|
|
25
|
+
playwrightArgs.push('--grep');
|
|
26
|
+
playwrightArgs.push(tagArgs);
|
|
38
27
|
}
|
|
39
28
|
if (!headless && !userArgsObject.headed) {
|
|
40
29
|
playwrightArgs.push('--headed');
|
|
41
30
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (bddMode) {
|
|
56
|
-
const beforeCommand = 'node';
|
|
57
|
-
const bddGenPath = _path.default.resolve(_path.default.join(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js'));
|
|
58
|
-
const beforeArgs = [bddGenPath, '-c', configPath];
|
|
59
|
-
const preprocessingPromise = new Promise((resolve, reject) => {
|
|
60
|
-
const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
|
|
61
|
-
stdio: 'inherit'
|
|
62
|
-
});
|
|
63
|
-
childProcessForPreprocessing.on('error', data => {
|
|
64
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
65
|
-
reject();
|
|
66
|
-
});
|
|
67
|
-
childProcessForPreprocessing.on('exit', code => {
|
|
68
|
-
if (code === 0) {
|
|
69
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
|
|
70
|
-
resolve();
|
|
71
|
-
} else {
|
|
72
|
-
reject(`BddGen exited with code ${code}`);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
31
|
+
return playwrightArgs;
|
|
32
|
+
}
|
|
33
|
+
function runPreprocessing(tagArgs, configPath) {
|
|
34
|
+
const beforeCommand = 'node';
|
|
35
|
+
const bddGenPath = _path.default.resolve(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js');
|
|
36
|
+
const beforeArgs = [bddGenPath, '-c', configPath];
|
|
37
|
+
if (tagArgs) {
|
|
38
|
+
beforeArgs.push('--tags');
|
|
39
|
+
beforeArgs.push(tagArgs);
|
|
40
|
+
}
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
|
|
43
|
+
stdio: 'inherit'
|
|
75
44
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const bddGenPath = _path.default.resolve(_path.default.join(__dirname, '../', '../', 'parser', 'verifier.js'));
|
|
80
|
-
const beforeArgs = [bddGenPath];
|
|
81
|
-
const preprocessingPromise = new Promise((resolve, reject) => {
|
|
82
|
-
const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs);
|
|
83
|
-
|
|
84
|
-
// Handle the output and errors for the first command
|
|
85
|
-
childProcessForPreprocessing.stdout.on('data', data => {
|
|
86
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, data);
|
|
87
|
-
});
|
|
88
|
-
childProcessForPreprocessing.stderr.on('data', data => {
|
|
89
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
90
|
-
reject();
|
|
91
|
-
});
|
|
92
|
-
childProcessForPreprocessing.on('close', code => {
|
|
93
|
-
if (code === 0) {
|
|
94
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
|
|
95
|
-
resolve();
|
|
96
|
-
} else {
|
|
97
|
-
reject(`Preprocessing exited with code ${code}`);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
45
|
+
childProcessForPreprocessing.on('error', data => {
|
|
46
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
47
|
+
reject();
|
|
100
48
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
49
|
+
childProcessForPreprocessing.on('exit', code => {
|
|
50
|
+
if (code === 0) {
|
|
51
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
|
|
52
|
+
resolve();
|
|
53
|
+
} else {
|
|
54
|
+
reject(`BddGen exited with code ${code}`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function runPlaywright(command, args) {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
104
61
|
const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
|
|
105
62
|
stdio: 'inherit'
|
|
106
63
|
});
|
|
@@ -110,23 +67,38 @@ function createTestRunner() {
|
|
|
110
67
|
childProcessForRunningPlaywright.on('exit', (code, signal) => {
|
|
111
68
|
if (code !== 0) {
|
|
112
69
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
70
|
+
reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
113
71
|
} else {
|
|
114
72
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
|
|
73
|
+
resolve();
|
|
115
74
|
}
|
|
116
|
-
process.exit();
|
|
117
|
-
});
|
|
118
|
-
process.on('exit', () => {
|
|
119
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
120
|
-
//childProcess.kill();
|
|
121
|
-
return;
|
|
122
75
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function main() {
|
|
79
|
+
const userArgsObject = parseUserArgs();
|
|
80
|
+
// eslint-disable-next-line
|
|
81
|
+
const tagArgs = userArgsObject['tags'];
|
|
82
|
+
const {
|
|
83
|
+
debug,
|
|
84
|
+
mode = 'dev',
|
|
85
|
+
bddMode = false,
|
|
86
|
+
headless = false
|
|
87
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
88
|
+
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
89
|
+
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
90
|
+
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
91
|
+
const command = playwrightPath;
|
|
92
|
+
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
|
|
93
|
+
const args = ['test', '--config', configPath].concat(playwrightArgs);
|
|
94
|
+
let promises = [];
|
|
95
|
+
if (bddMode) {
|
|
96
|
+
promises.push(runPreprocessing(tagArgs, configPath));
|
|
97
|
+
}
|
|
98
|
+
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|
|
129
99
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, err);
|
|
130
|
-
process.exit();
|
|
100
|
+
process.exit(1);
|
|
131
101
|
});
|
|
132
|
-
}
|
|
102
|
+
}
|
|
103
|
+
var _default = main;
|
|
104
|
+
exports.default = _default;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object|null} viewportConfig
|
|
3
|
+
* @property {number} width - width of the viewport
|
|
4
|
+
* @property {number} height - height of the viewport
|
|
5
|
+
*/
|
|
1
6
|
/**
|
|
2
7
|
* Represents the user configuration object.
|
|
3
8
|
* @typedef {Object} UserConfig
|
|
@@ -17,6 +22,7 @@
|
|
|
17
22
|
* @property {Object} additionalPages: custom pages configuration
|
|
18
23
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
19
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 }
|
|
20
26
|
*/
|
|
21
27
|
|
|
22
28
|
/**
|
|
@@ -31,5 +37,6 @@ module.exports = {
|
|
|
31
37
|
trace: true,
|
|
32
38
|
video: true,
|
|
33
39
|
featureFilesFolder: 'feature-files',
|
|
34
|
-
stepDefinitionsFolder: 'steps'
|
|
40
|
+
stepDefinitionsFolder: 'steps',
|
|
41
|
+
viewport: null
|
|
35
42
|
}
|