suitest-js-api 3.6.0 → 3.7.0
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/lib/constants/keys.js +5 -0
- package/lib/testLauncher/commands/run.js +11 -0
- package/lib/testLauncher/composeConfig.js +32 -11
- package/lib/texts.js +1 -1
- package/lib/validation/jsonSchemas.js +1 -0
- package/package.json +1 -1
- package/typeDefinition/ApplicationChain.d.ts +1 -1
- package/typeDefinition/BrightScriptExpression.d.ts +1 -1
- package/typeDefinition/ClearAppData.d.ts +1 -1
- package/typeDefinition/CloseAppChain.d.ts +1 -1
- package/typeDefinition/CookieChain.d.ts +2 -2
- package/typeDefinition/ElementChain.d.ts +2 -2
- package/typeDefinition/ExecuteBrightScriptChain.d.ts +1 -1
- package/typeDefinition/ExecuteCommandChain.d.ts +1 -1
- package/typeDefinition/JavascriptExpression.d.ts +1 -1
- package/typeDefinition/LocationChain.d.ts +1 -1
- package/typeDefinition/NetworkRequest.d.ts +1 -1
- package/typeDefinition/OpenAppChain.d.ts +1 -1
- package/typeDefinition/OpenUrl.d.ts +1 -1
- package/typeDefinition/PlayStationVideoChain.d.ts +2 -2
- package/typeDefinition/PollUrl.d.ts +1 -1
- package/typeDefinition/PositionChain.d.ts +1 -1
- package/typeDefinition/PressButton.d.ts +1 -1
- package/typeDefinition/RelativePositionChain.d.ts +1 -1
- package/typeDefinition/SleepChain.d.ts +1 -1
- package/typeDefinition/SuspendAppChain.d.ts +1 -1
- package/typeDefinition/VideoChain.d.ts +2 -2
- package/typeDefinition/WindowChain.d.ts +1 -1
- package/typeDefinition/constants/Keys.d.ts +5 -0
package/lib/constants/keys.js
CHANGED
|
@@ -43,10 +43,21 @@ const builder = yargs => {
|
|
|
43
43
|
describe: 'Will launch user command with --inspect-brk execArgv, used for debugging',
|
|
44
44
|
global: false,
|
|
45
45
|
})
|
|
46
|
+
.option('override-config-file', {
|
|
47
|
+
describe: 'Specifies an additional config file which properties have precedence over properties in a standard configuration file.',
|
|
48
|
+
global: false,
|
|
49
|
+
type: 'string',
|
|
50
|
+
})
|
|
51
|
+
.option('base-config-file', {
|
|
52
|
+
describe: 'Path to a config file to override standard configuration files. Standard configuration files are ignored.',
|
|
53
|
+
global: false,
|
|
54
|
+
type: 'string',
|
|
55
|
+
})
|
|
46
56
|
.option('config-file', {
|
|
47
57
|
describe: texts.cliConfig(),
|
|
48
58
|
global: false,
|
|
49
59
|
type: 'string',
|
|
60
|
+
deprecate: 'Can have unexpected behaviour. Use --base-config-file or --override-config-file.',
|
|
50
61
|
})
|
|
51
62
|
.option('default-timeout', {
|
|
52
63
|
describe: texts.defaultTimeout(),
|
|
@@ -58,9 +58,17 @@ const DEFAULT_PATHS = [
|
|
|
58
58
|
* @param {String} filePath path to file
|
|
59
59
|
*/
|
|
60
60
|
function readConfigFile(filePath) {
|
|
61
|
+
const extension = path.extname(filePath);
|
|
62
|
+
if (extension === '.js') {
|
|
63
|
+
if (!path.isAbsolute(filePath)) {
|
|
64
|
+
// ensure correct handling of relative paths, we want to prevent searching in __dirname
|
|
65
|
+
filePath = path.join(process.cwd(), filePath);
|
|
66
|
+
}
|
|
67
|
+
return require(filePath);
|
|
68
|
+
}
|
|
61
69
|
const fileContent = fs.readFileSync(filePath, 'utf8');
|
|
62
70
|
|
|
63
|
-
switch (
|
|
71
|
+
switch (extension) {
|
|
64
72
|
case '.yaml':
|
|
65
73
|
case '.yml':
|
|
66
74
|
return yaml.load(fileContent);
|
|
@@ -68,8 +76,8 @@ function readConfigFile(filePath) {
|
|
|
68
76
|
return JSON5.parse(fileContent);
|
|
69
77
|
case '.ini':
|
|
70
78
|
return ini.parse(fileContent);
|
|
71
|
-
case '.
|
|
72
|
-
return
|
|
79
|
+
case '.json':
|
|
80
|
+
return JSON.parse(fileContent);
|
|
73
81
|
default:
|
|
74
82
|
try {
|
|
75
83
|
return JSON.parse(fileContent);
|
|
@@ -158,6 +166,7 @@ function findConfigUpToRoot(pathToSearch, filename) {
|
|
|
158
166
|
* Searches for 'extends' property for other config file and if presents merge them.
|
|
159
167
|
* cli arguments are not parsed.
|
|
160
168
|
* If file found, but json invalid, throw error.
|
|
169
|
+
* @param {string} [pathToConfig] expicit path to configuration file
|
|
161
170
|
* @returns {Object}
|
|
162
171
|
*/
|
|
163
172
|
function readRcConfig(pathToConfig) {
|
|
@@ -170,9 +179,6 @@ function readRcConfig(pathToConfig) {
|
|
|
170
179
|
.filter(defaultConfig => IS_WINDOWS ? defaultConfig.isGeneral : true);
|
|
171
180
|
|
|
172
181
|
for (const defaultConfig of defaultConfigurations) {
|
|
173
|
-
if (mainConfigFilePath) {
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
182
|
if (
|
|
177
183
|
fs.existsSync(defaultConfig.path) &&
|
|
178
184
|
fs.lstatSync(defaultConfig.path).isDirectory()
|
|
@@ -181,6 +187,9 @@ function readRcConfig(pathToConfig) {
|
|
|
181
187
|
defaultConfig.deepSearch ?
|
|
182
188
|
findConfigUpToRoot :
|
|
183
189
|
findConfig)(defaultConfig.path, defaultConfig.filename);
|
|
190
|
+
if (mainConfigFilePath) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
184
193
|
}
|
|
185
194
|
}
|
|
186
195
|
}
|
|
@@ -210,14 +219,14 @@ function readRcConfig(pathToConfig) {
|
|
|
210
219
|
}
|
|
211
220
|
|
|
212
221
|
/**
|
|
213
|
-
* Read
|
|
222
|
+
* Read config file provided by user.
|
|
214
223
|
* @param {string} path - path to config file
|
|
215
224
|
* @throws {SuitestError}
|
|
216
|
-
* @returns {Object} - parsed
|
|
225
|
+
* @returns {Object} - parsed config file
|
|
217
226
|
*/
|
|
218
227
|
function readUserConfig(path) {
|
|
219
228
|
try {
|
|
220
|
-
return
|
|
229
|
+
return readConfigFile(path);
|
|
221
230
|
} catch (error) {
|
|
222
231
|
throw new SuitestError(invalidUserConfig(path, error.message), error.code);
|
|
223
232
|
}
|
|
@@ -229,8 +238,20 @@ function readUserConfig(path) {
|
|
|
229
238
|
* @returns {{ownArgs: Object, userCommandArgs: string[]}}
|
|
230
239
|
*/
|
|
231
240
|
const composeConfig = (argv) => {
|
|
232
|
-
|
|
233
|
-
|
|
241
|
+
if (argv.configFile) {
|
|
242
|
+
console.warn('Warning: You are using deprecated argument --config-file. Please use --override-config-file or --base-config-file instead.');
|
|
243
|
+
if (argv.baseConfigFile || argv.overrideConfigFile) {
|
|
244
|
+
throw new SuitestError('Combination of deprecated --config-file with either --base-config-file or --override-config-file is not allowed');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const rcConfig = readRcConfig(argv.baseConfigFile || argv.configFile);
|
|
248
|
+
if (rcConfig.configFile) {
|
|
249
|
+
console.warn('Warning: You are using deprecated option configFile. Please use overrideConfigFile instead.');
|
|
250
|
+
}
|
|
251
|
+
if ((argv.configFile || rcConfig.configFile) && (argv.baseConfigFile || argv.overrideConfigFile || rcConfig.overrideConfigFile)) {
|
|
252
|
+
throw new SuitestError('Combination of deprecated configFile with --base-config-file or --override-config-file or overrideConfigFile is not allowed');
|
|
253
|
+
}
|
|
254
|
+
const configFilePath = argv.overrideConfigFile || rcConfig.overrideConfigFile || argv.configFile || rcConfig.configFile;
|
|
234
255
|
const userConfig = configFilePath ? readUserConfig(configFilePath) : {};
|
|
235
256
|
|
|
236
257
|
const ownArgs = {
|
package/lib/texts.js
CHANGED
|
@@ -41,7 +41,7 @@ module.exports = {
|
|
|
41
41
|
invalidInputMessage: (methodName, field) =>
|
|
42
42
|
`provided for .${methodName} function.` + (field ? ` ${field}` : ''),
|
|
43
43
|
invalidConfigObj: () => 'provided for configuration object.',
|
|
44
|
-
invalidUserConfig: template`Failed to process config file '${0}'.\n\t${1}.\n\tMake sure path is correct and file is in valid
|
|
44
|
+
invalidUserConfig: template`Failed to process config file '${0}'.\n\t${1}.\n\tMake sure path is correct and file is in valid format.`,
|
|
45
45
|
circularDependencyError: (path) => `Circular dependency found on ${path} path.`,
|
|
46
46
|
|
|
47
47
|
// WebSockets errors
|
|
@@ -362,6 +362,7 @@ schemas[validationKeys.CONFIGURE] = {
|
|
|
362
362
|
'properties': {
|
|
363
363
|
'appConfigId': {'type': 'string'},
|
|
364
364
|
'concurrency': {'type': 'number'},
|
|
365
|
+
'overrideConfigFile': {'type': 'string'},
|
|
365
366
|
'configFile': {'type': 'string'},
|
|
366
367
|
'deviceId': {'type': 'string'},
|
|
367
368
|
'disallowCrashReports': {'type': 'boolean'},
|
package/package.json
CHANGED
|
@@ -71,5 +71,5 @@ interface CookieEvalModifiers<T> extends
|
|
|
71
71
|
|
|
72
72
|
interface CookieAbandonedChain extends AbstractChain {}
|
|
73
73
|
|
|
74
|
-
type CookieQueryResult = string |
|
|
75
|
-
type CookieEvalResult = boolean |
|
|
74
|
+
type CookieQueryResult = string | undefined;
|
|
75
|
+
type CookieEvalResult = boolean | undefined;
|
|
@@ -151,5 +151,5 @@ interface ElementBaseEvalChain<TSelf> extends
|
|
|
151
151
|
|
|
152
152
|
interface ElementAbandonedChain extends AbstractChain {}
|
|
153
153
|
|
|
154
|
-
type ElementQueryResult = ElementProps |
|
|
155
|
-
type ElementEvalResult = boolean |
|
|
154
|
+
type ElementQueryResult = ElementProps | undefined;
|
|
155
|
+
type ElementEvalResult = boolean | undefined;
|
|
@@ -47,5 +47,5 @@ interface PlayStationVideoBaseEvalChain<TSelf> extends
|
|
|
47
47
|
|
|
48
48
|
interface PlayStationVideoAbandonedChain extends AbstractChain {}
|
|
49
49
|
|
|
50
|
-
type PlayStationVideoQueryResult = PlayStationVideoProps |
|
|
51
|
-
type PlayStationVideoEvalResult = boolean |
|
|
50
|
+
type PlayStationVideoQueryResult = PlayStationVideoProps | undefined;
|
|
51
|
+
type PlayStationVideoEvalResult = boolean | undefined;
|
|
@@ -52,4 +52,4 @@ interface PositionEmptyChain extends PositionBaseEvalChain<PositionEmptyChain> {
|
|
|
52
52
|
interface PositionAbandonedChain extends AbstractChain {}
|
|
53
53
|
|
|
54
54
|
type PositionQueryResult = string;
|
|
55
|
-
type PositionEvalResult = boolean |
|
|
55
|
+
type PositionEvalResult = boolean | undefined;
|
|
@@ -38,4 +38,4 @@ interface PressButtonEmptyChain extends PressButtonBaseEvalChain<PressButtonEmpt
|
|
|
38
38
|
interface PressButtonAbandonedChain extends AbstractChain {}
|
|
39
39
|
|
|
40
40
|
type PressButtonQueryResult = string;
|
|
41
|
-
type PressButtonEvalResult = boolean |
|
|
41
|
+
type PressButtonEvalResult = boolean | undefined;
|
|
@@ -45,4 +45,4 @@ interface RelativePositionEmptyChain extends RelativePositionBaseEvalChain<Relat
|
|
|
45
45
|
interface RelativePositionAbandonedChain extends AbstractChain {}
|
|
46
46
|
|
|
47
47
|
type RelativePositionQueryResult = string;
|
|
48
|
-
type RelativePositionEvalResult = boolean |
|
|
48
|
+
type RelativePositionEvalResult = boolean | undefined;
|
|
@@ -88,5 +88,5 @@ interface VideoBaseEvalChain<TSelf> extends
|
|
|
88
88
|
|
|
89
89
|
interface VideoAbandonedChain extends AbstractChain {}
|
|
90
90
|
|
|
91
|
-
type VideoQueryResult = ElementProps |
|
|
92
|
-
type VideoEvalResult = boolean |
|
|
91
|
+
type VideoQueryResult = ElementProps | undefined;
|
|
92
|
+
type VideoEvalResult = boolean | undefined;
|