suitest-js-api 2.5.1 → 3.0.2
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/config/index.js +7 -7
- package/index.d.ts +23 -71
- package/lib/api/endpoints.js +0 -7
- package/lib/api/webSockets.js +1 -1
- package/lib/api/wsContentTypes.js +0 -2
- package/lib/chains/elementChain.js +90 -19
- package/lib/chains/saveScreenshotChain.js +60 -5
- package/lib/commands/closeSession.js +4 -29
- package/lib/commands/openSession.js +13 -52
- package/lib/commands/pairDevice.js +3 -3
- package/lib/commands/releaseDevice.js +1 -1
- package/lib/commands/setAppConfig.js +0 -2
- package/lib/commands/{interactive.js → startREPL.js} +10 -8
- package/lib/composers/attributesComposer.js +18 -0
- package/lib/composers/cssPropsComposer.js +18 -0
- package/lib/composers/handleComposer.js +23 -0
- package/lib/composers/index.js +6 -0
- package/lib/composers/thenComposer.js +1 -2
- package/lib/constants/composer.js +3 -0
- package/lib/constants/element.js +2 -0
- package/lib/constants/enviroment.js +6 -1
- package/lib/constants/index.js +1 -0
- package/lib/constants/ipcMessageId.js +1 -1
- package/lib/constants/modes.js +1 -2
- package/lib/constants/session.js +1 -3
- package/lib/constants/timestamp.js +1 -1
- package/lib/constants/validationKeys.js +5 -5
- package/lib/constants/vrc.js +2 -0
- package/lib/testLauncher/SuitestLauncher.js +65 -77
- package/lib/testLauncher/buildArgs.js +3 -6
- package/lib/testLauncher/commands/run.js +111 -0
- package/lib/testLauncher/composeConfig.js +154 -15
- package/lib/testLauncher/launcherLogger.js +3 -23
- package/lib/testLauncher/repl.js +3 -3
- package/lib/texts.js +23 -39
- package/lib/utils/AuthContext.js +17 -76
- package/lib/utils/getDeviceInfo.js +16 -10
- package/lib/utils/logger.js +4 -3
- package/lib/utils/{interactiveProgressHandler.js → progressHandler.js} +1 -1
- package/lib/utils/sentry/Raven.js +1 -1
- package/lib/utils/sessionStarter.js +43 -38
- package/lib/utils/socketChainHelper.js +17 -8
- package/lib/utils/socketErrorMessages.js +21 -1
- package/lib/utils/stackTraceParser.js +25 -1
- package/lib/utils/testHelpers/mockHelpers.js +0 -2
- package/lib/utils/testHelpers/mockWebSocket.js +1 -1
- package/lib/utils/testHelpers/testLauncherTest.js +0 -43
- package/lib/utils/testLauncherHelper.js +38 -105
- package/lib/validation/elementPropTypes.js +2 -0
- package/lib/validation/jsonSchemas.js +97 -97
- package/lib/validation/validators.js +25 -3
- package/lib/validation/validatorsMap.js +13 -13
- package/package.json +7 -5
- package/suitest.js +7 -15
- package/typeDefinition/ElementChain.d.ts +29 -1
- package/typeDefinition/constants/Element.d.ts +2 -0
- package/typeDefinition/constants/Vrc.d.ts +2 -0
- package/typeDefinition/modifiers.d.ts +13 -0
- package/lib/commands/endTest.js +0 -28
- package/lib/commands/startTest.js +0 -55
- package/lib/commands/startTestPack.js +0 -93
- package/lib/testLauncher/commands/automated.js +0 -70
- package/lib/testLauncher/commands/common.js +0 -43
- package/lib/testLauncher/commands/interactive.js +0 -70
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suitest-js-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": "git@github.com:SuitestAutomation/suitest-js-api.git",
|
|
6
6
|
"author": "Suitest <hello@suite.st>",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"homepage": "https://suite.st/",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=14.0.0"
|
|
28
28
|
},
|
|
29
29
|
"bin": {
|
|
30
30
|
"suitest": "bin/suitest"
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"express": "^4.17.1",
|
|
75
75
|
"husky": "^4.2.5",
|
|
76
76
|
"mocha": "^7.2.0",
|
|
77
|
+
"mock-fs": "^5.1.0",
|
|
77
78
|
"mock-require": "^3.0.3",
|
|
78
79
|
"mock-socket": "^7.1.0",
|
|
79
80
|
"mock-spawn": "^0.2.6",
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
},
|
|
85
86
|
"dependencies": {
|
|
86
87
|
"@suitest/smst-to-text": "^4.2.2",
|
|
87
|
-
"@suitest/translate": "^4.
|
|
88
|
+
"@suitest/translate": "^4.4.0",
|
|
88
89
|
"@types/node": "^14.0.10",
|
|
89
90
|
"ajv": "^6.12.2",
|
|
90
91
|
"ansi-regex": "^5.0.0",
|
|
@@ -92,6 +93,9 @@
|
|
|
92
93
|
"colors": "^1.4.0",
|
|
93
94
|
"compare-versions": "^3.6.0",
|
|
94
95
|
"escape-string-regexp": "4.0.0",
|
|
96
|
+
"ini": "^2.0.0",
|
|
97
|
+
"js-yaml": "^4.1.0",
|
|
98
|
+
"json5": "^2.2.0",
|
|
95
99
|
"keypress": "^0.2.1",
|
|
96
100
|
"moment": "^2.26.0",
|
|
97
101
|
"node-fetch": "^2.6.0",
|
|
@@ -99,8 +103,6 @@
|
|
|
99
103
|
"prettyjson": "^1.2.1",
|
|
100
104
|
"ramda": "^0.27.0",
|
|
101
105
|
"raven": "^2.6.2",
|
|
102
|
-
"rc": "^1.2.8",
|
|
103
|
-
"read": "^1.0.7",
|
|
104
106
|
"semver": "^7.3.2",
|
|
105
107
|
"stack-trace": "^0.0.10",
|
|
106
108
|
"uuid": "8.1.0",
|
package/suitest.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
require('./lib/utils/sentry/Raven');
|
|
2
|
-
const
|
|
3
|
-
const texts = require('./lib/texts');
|
|
2
|
+
const {clone} = require('ramda');
|
|
4
3
|
|
|
5
4
|
// Commands
|
|
6
5
|
const {openSession} = require('./lib/commands/openSession');
|
|
7
6
|
const {closeSession} = require('./lib/commands/closeSession');
|
|
8
|
-
const {startTestPack} = require('./lib/commands/startTestPack');
|
|
9
7
|
const {pairDevice} = require('./lib/commands/pairDevice');
|
|
10
8
|
const releaseDevice = require('./lib/commands/releaseDevice');
|
|
11
9
|
const {setAppConfig} = require('./lib/commands/setAppConfig');
|
|
12
|
-
const startTest = require('./lib/commands/startTest');
|
|
13
|
-
const endTest = require('./lib/commands/endTest');
|
|
14
10
|
|
|
15
11
|
// Chains
|
|
16
12
|
const openAppFactory = require('./lib/chains/openAppChain');
|
|
@@ -84,13 +80,12 @@ class SUITEST_API extends EventEmitter {
|
|
|
84
80
|
this.appContext = new Context();
|
|
85
81
|
this.pairedDeviceContext = new Context();
|
|
86
82
|
this.getPairedDevice = () => this.pairedDeviceContext.context;
|
|
87
|
-
this.testContext = new Context();
|
|
88
83
|
this.configuration = configFactory();
|
|
89
84
|
this.config = this.configuration.config;
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
});
|
|
85
|
+
this.setDefaultTimeout = (defaultTimeout) => this.configuration.override({defaultTimeout});
|
|
86
|
+
this.setContinueOnFatalError = (continueOnFatalError) => this.configuration.override({continueOnFatalError});
|
|
87
|
+
this.setDisallowCrashReports = (disallowCrashReports) => this.configuration.override({disallowCrashReports});
|
|
88
|
+
this.setLogLevel = (logLevel) => this.configuration.override({logLevel});
|
|
94
89
|
|
|
95
90
|
// creating methods based on instance dependencies
|
|
96
91
|
this.logger = createLogger(this.configuration.config, this.pairedDeviceContext);
|
|
@@ -102,9 +97,6 @@ class SUITEST_API extends EventEmitter {
|
|
|
102
97
|
this.pairDevice = (...args) => pairDevice(this, ...args);
|
|
103
98
|
this.setAppConfig = (...args) => setAppConfig(this, ...args);
|
|
104
99
|
this.closeSession = (...args) => closeSession(this, ...args);
|
|
105
|
-
this.startTestPack = (...args) => startTestPack(this, ...args);
|
|
106
|
-
this.startTest = (...args) => startTest(this, ...args);
|
|
107
|
-
this.endTest = (...args) => endTest(this, ...args);
|
|
108
100
|
this.releaseDevice = (...args) => releaseDevice(this, ...args);
|
|
109
101
|
|
|
110
102
|
const {openApp, openAppAssert} = openAppFactory(this);
|
|
@@ -123,7 +115,7 @@ class SUITEST_API extends EventEmitter {
|
|
|
123
115
|
const {jsExpression, jsExpressionAssert} = jsExpressionFactory(this);
|
|
124
116
|
const {networkRequest, networkRequestAssert} = networkRequestFactory(this);
|
|
125
117
|
const {video, videoAssert} = videoFactory(this);
|
|
126
|
-
const {element, elementAssert} = elementFactory(this
|
|
118
|
+
const {element, elementAssert} = elementFactory(this);
|
|
127
119
|
const {playstationVideo, playstationVideoAssert} = playstationVideoFactory(this);
|
|
128
120
|
const {pollUrl, pollUrlAssert} = pollUrlFactory(this);
|
|
129
121
|
const {runTestAssert} = runTestFactory(this);
|
|
@@ -256,7 +248,7 @@ class SUITEST_API extends EventEmitter {
|
|
|
256
248
|
}
|
|
257
249
|
|
|
258
250
|
getConfig() {
|
|
259
|
-
return
|
|
251
|
+
return clone(this.configuration.config);
|
|
260
252
|
}
|
|
261
253
|
}
|
|
262
254
|
|
|
@@ -15,10 +15,14 @@ import {
|
|
|
15
15
|
MoveToModifier,
|
|
16
16
|
Repeatable,
|
|
17
17
|
Intervalable,
|
|
18
|
+
BaseEmptyChain,
|
|
18
19
|
BaseChain,
|
|
19
20
|
UntilModifier,
|
|
20
21
|
VisibleModifier,
|
|
21
22
|
VideoStateModifiers,
|
|
23
|
+
GetCssModifiers,
|
|
24
|
+
HandleModifier,
|
|
25
|
+
GetAttributesModifier,
|
|
22
26
|
} from './modifiers';
|
|
23
27
|
import {ElementProps} from "./constants/ElementProps";
|
|
24
28
|
|
|
@@ -34,7 +38,10 @@ export interface ElementChain extends
|
|
|
34
38
|
ScrollModifier<ElementRepeatIntervalChain>, // scroll
|
|
35
39
|
SwipeModifier<ElementRepeatIntervalChain>, // swipe
|
|
36
40
|
MoveToModifier<ElementEmptyChain>, // moveTo
|
|
37
|
-
VisibleModifier<ElementWithoutEvalChain
|
|
41
|
+
VisibleModifier<ElementWithoutEvalChain>,// visible
|
|
42
|
+
GetCssModifiers<ElementGetPropertiesChain>, // getCssProperties
|
|
43
|
+
HandleModifier<ElementHandleChain>, // handle
|
|
44
|
+
GetAttributesModifier<ElementGetAttributesChain> // getAttributes
|
|
38
45
|
{}
|
|
39
46
|
|
|
40
47
|
// -matchers +timeout +negation
|
|
@@ -107,6 +114,27 @@ interface ElementEvalModifiers<T> extends
|
|
|
107
114
|
ElementMatchModifiers<T>
|
|
108
115
|
{}
|
|
109
116
|
|
|
117
|
+
/*
|
|
118
|
+
* @description represents return value of calling getCssProperties function.
|
|
119
|
+
*/
|
|
120
|
+
interface ElementGetPropertiesChain extends
|
|
121
|
+
BaseEmptyChain<ElementGetPropertiesChain, Record<string, string>, ElementAbandonedChain>
|
|
122
|
+
{}
|
|
123
|
+
|
|
124
|
+
/*
|
|
125
|
+
* @description represents return value of calling "handle" function.
|
|
126
|
+
*/
|
|
127
|
+
interface ElementHandleChain extends
|
|
128
|
+
BaseEmptyChain<ElementHandleChain, string[], ElementAbandonedChain>
|
|
129
|
+
{}
|
|
130
|
+
|
|
131
|
+
/*
|
|
132
|
+
* @description represents return value of calling "getAttributes" function.
|
|
133
|
+
*/
|
|
134
|
+
interface ElementGetAttributesChain extends
|
|
135
|
+
BaseEmptyChain<ElementGetAttributesChain, Record<string, string>, ElementAbandonedChain>
|
|
136
|
+
{}
|
|
137
|
+
|
|
110
138
|
interface ElementEvalModifiersWithNegation<T> extends
|
|
111
139
|
ExistsModifiers<T>,
|
|
112
140
|
VisibleModifier<T>
|
|
@@ -241,3 +241,16 @@ export interface ElementMatchModifiers<T> {
|
|
|
241
241
|
export interface HasExitedModifiers<T> {
|
|
242
242
|
hasExited(): T;
|
|
243
243
|
}
|
|
244
|
+
|
|
245
|
+
export interface GetCssModifiers<T> {
|
|
246
|
+
getCssProperties(properties: string[]): T;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface HandleModifier<T> {
|
|
250
|
+
handle(multiple?: boolean): T;
|
|
251
|
+
handle(opts?: {multiple?: boolean}): T;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface GetAttributesModifier<T> {
|
|
255
|
+
getAttributes(attributes?: string[]): T;
|
|
256
|
+
}
|
package/lib/commands/endTest.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* End test command.
|
|
3
|
-
* This command explicitly closes current test.
|
|
4
|
-
* Can be omitted, in that case test will be closed implicitly with following startTest call or when session ends.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const wsContentTypes = require('../api/wsContentTypes');
|
|
8
|
-
const chainPromise = require('../utils/chainPromise');
|
|
9
|
-
const {commandExecuted, commandWillBeExecuted} = require('../texts');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* End automated session test, clear test context.
|
|
13
|
-
* @param {Object} instance of main class
|
|
14
|
-
* @returns {ChainablePromise.<void>}
|
|
15
|
-
*/
|
|
16
|
-
async function endTest({webSockets, authContext, testContext, logger}) {
|
|
17
|
-
logger.delayed(commandWillBeExecuted('endTest'));
|
|
18
|
-
// authorize
|
|
19
|
-
const authedContent = await authContext.authorizeWs({type: wsContentTypes.endTest}, endTest.name);
|
|
20
|
-
|
|
21
|
-
// make ws request
|
|
22
|
-
await webSockets.send(authedContent);
|
|
23
|
-
|
|
24
|
-
testContext.clear();
|
|
25
|
-
logger.log(commandExecuted('endTest'));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = chainPromise(endTest);
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Start test command.
|
|
3
|
-
* This command allows user to define that all following commands must be recorded as new test.
|
|
4
|
-
* Only relevant for automated test runs.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const util = require('util');
|
|
8
|
-
const wsContentTypes = require('../api/wsContentTypes');
|
|
9
|
-
const {validate, validators} = require('../validation');
|
|
10
|
-
const chainPromise = require('../utils/chainPromise');
|
|
11
|
-
const {testWasStarted, testWillBeStarted, startTestDeprecate} = require('../texts');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Start test
|
|
15
|
-
* @info using .startTest with arguments is deprecated
|
|
16
|
-
* @param {Object} instance of main class
|
|
17
|
-
* @param {string} clientTestId - user-defined id of the test, must be unique per test pack
|
|
18
|
-
* @param {string} [name] - human readable name of the test, optional.
|
|
19
|
-
* @param {string} [description] - arbitrary description of the test
|
|
20
|
-
* @throws {SuitestError} - when context of the test run is wrong
|
|
21
|
-
* @returns {ChainablePromise.<void>}
|
|
22
|
-
*/
|
|
23
|
-
async function startTest({webSockets, authContext, testContext, logger}, clientTestId, {name, description} = {}) {
|
|
24
|
-
logger.info(testWillBeStarted(name || clientTestId));
|
|
25
|
-
|
|
26
|
-
const content = {
|
|
27
|
-
clientTestId,
|
|
28
|
-
name,
|
|
29
|
-
description,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// authorize
|
|
33
|
-
const authedContent = await authContext.authorizeWs({
|
|
34
|
-
type: wsContentTypes.startTest,
|
|
35
|
-
}, startTest.name);
|
|
36
|
-
|
|
37
|
-
// make ws request
|
|
38
|
-
await webSockets.send(authedContent);
|
|
39
|
-
|
|
40
|
-
testContext.clear();
|
|
41
|
-
testContext.setContext(content);
|
|
42
|
-
logger.info(testWasStarted(name || clientTestId));
|
|
43
|
-
}
|
|
44
|
-
const deprecateStartTest = util.deprecate(startTest, startTestDeprecate());
|
|
45
|
-
|
|
46
|
-
function startTestWrapper(...args) {
|
|
47
|
-
// first argument is instance of SUITEST_API
|
|
48
|
-
if (args.length > 1) {
|
|
49
|
-
return deprecateStartTest(...args);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return startTest(...args);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = chainPromise(startTestWrapper);
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Suitest method to start test pack run and generate session token.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const {omit} = require('ramda');
|
|
6
|
-
|
|
7
|
-
const sessionConstants = require('../constants/session');
|
|
8
|
-
const request = require('../api/request');
|
|
9
|
-
const endpoints = require('../api/endpoints');
|
|
10
|
-
const {validate, validators} = require('../validation');
|
|
11
|
-
const chainPromise = require('../utils/chainPromise');
|
|
12
|
-
const {
|
|
13
|
-
invalidInputMessage,
|
|
14
|
-
authFailedAutomated,
|
|
15
|
-
notWhitelistedIp,
|
|
16
|
-
testPackWillBeStarted,
|
|
17
|
-
testPackWasStarted,
|
|
18
|
-
testPackNotFound,
|
|
19
|
-
} = require('../texts');
|
|
20
|
-
const SuitestError = require('../utils/SuitestError');
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Start test pack on suitest server by testPackId.
|
|
24
|
-
* Set automated session context on success.
|
|
25
|
-
*
|
|
26
|
-
* @param {Object} instance of main class
|
|
27
|
-
* @param {schema} testPackData
|
|
28
|
-
* @returns {Promise} response object
|
|
29
|
-
*/
|
|
30
|
-
async function startTestPack({authContext, webSockets, logger}, testPackData) {
|
|
31
|
-
const tpData = {
|
|
32
|
-
includeChangelist: false,
|
|
33
|
-
...testPackData,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
logger.delayed(testPackWillBeStarted(tpData.testPackId));
|
|
37
|
-
// validate authData json
|
|
38
|
-
validate(
|
|
39
|
-
validators.START_TEST_PACK,
|
|
40
|
-
tpData,
|
|
41
|
-
invalidInputMessage('startTestPack', 'TestPack data'),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
// if token key and pass explicitly provided, set corresponding access token
|
|
45
|
-
if ('accessTokenKey' in tpData && 'accessTokenPassword' in tpData) {
|
|
46
|
-
authContext.setContext(
|
|
47
|
-
sessionConstants.ACCESS_TOKEN,
|
|
48
|
-
tpData.accessTokenKey,
|
|
49
|
-
tpData.accessTokenPassword
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// authorize
|
|
54
|
-
const authedRequestObject = await authContext.authorizeHttp(endpoints.testPackGenTokens, {
|
|
55
|
-
method: 'POST',
|
|
56
|
-
body: omit(
|
|
57
|
-
['testPackId', 'accessTokenKey', 'accessTokenPassword'],
|
|
58
|
-
tpData
|
|
59
|
-
),
|
|
60
|
-
}, {type: SuitestError.AUTH_FAILED});
|
|
61
|
-
|
|
62
|
-
// make api request
|
|
63
|
-
const response = await request(
|
|
64
|
-
[endpoints.testPackGenTokens, {id: tpData.testPackId}],
|
|
65
|
-
authedRequestObject,
|
|
66
|
-
err => new SuitestError(...(
|
|
67
|
-
err.status === 404
|
|
68
|
-
? [testPackNotFound(tpData.testPackId), SuitestError.SERVER_ERROR]
|
|
69
|
-
: (
|
|
70
|
-
err.status === 403
|
|
71
|
-
? [notWhitelistedIp(), SuitestError.AUTH_FAILED]
|
|
72
|
-
: [authFailedAutomated(), SuitestError.AUTH_FAILED]
|
|
73
|
-
)
|
|
74
|
-
)),
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// if success, set interactive session context
|
|
78
|
-
authContext.setContext(sessionConstants.AUTOMATED, response.deviceAccessToken);
|
|
79
|
-
|
|
80
|
-
// authorize ws connection
|
|
81
|
-
const authedWsConnection = await authContext.authorizeWsConnection({}, startTestPack.name);
|
|
82
|
-
|
|
83
|
-
// connect ws
|
|
84
|
-
await webSockets.connect(authedWsConnection);
|
|
85
|
-
logger.delayed(testPackWasStarted(tpData.testPackId));
|
|
86
|
-
|
|
87
|
-
return response;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
module.exports = {
|
|
91
|
-
startTestPack: chainPromise(startTestPack),
|
|
92
|
-
startTestPackUnchained: startTestPack,
|
|
93
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 'automated' test launcher command
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const SuitestLauncher = require('../SuitestLauncher');
|
|
6
|
-
const suitest = require('../../../index');
|
|
7
|
-
const {applyCommonArgs} = require('./common');
|
|
8
|
-
const {once} = require('ramda');
|
|
9
|
-
const {composeConfig} = require('../composeConfig');
|
|
10
|
-
|
|
11
|
-
const command = 'automated';
|
|
12
|
-
|
|
13
|
-
const describe = 'Automatically start new test pack run and spawn user '
|
|
14
|
-
+ 'defined test command for each device from the test pack in parallel.';
|
|
15
|
-
|
|
16
|
-
const builder = yargs => {
|
|
17
|
-
applyCommonArgs(yargs);
|
|
18
|
-
|
|
19
|
-
yargs
|
|
20
|
-
.option('token-key', {
|
|
21
|
-
alias: 'k',
|
|
22
|
-
describe: 'Suitest Token Id, can be generated on the profile page',
|
|
23
|
-
global: false,
|
|
24
|
-
})
|
|
25
|
-
.option('token-id', {
|
|
26
|
-
describe: 'Suitest Token Id, can be generated on the profile page',
|
|
27
|
-
global: false,
|
|
28
|
-
})
|
|
29
|
-
.option('token-password', {
|
|
30
|
-
alias: 'p',
|
|
31
|
-
describe: 'Suitest Token Password, can be generated on the profile page',
|
|
32
|
-
global: false,
|
|
33
|
-
})
|
|
34
|
-
.option('test-pack-id', {
|
|
35
|
-
alias: 't',
|
|
36
|
-
describe: 'Id of the test pack to launch',
|
|
37
|
-
global: false,
|
|
38
|
-
})
|
|
39
|
-
// --config-override configOverride no a JSON object with config override. Format for JSON is same as we have on FE
|
|
40
|
-
// --vcs-commit-hash vcsCommitHash no a commit hash in version control system. Will be used on the results page
|
|
41
|
-
// --vcs-branch vcsBranch no a branch name in version control system. Will be used on the results page
|
|
42
|
-
// --app-version appVersion no an application version. Will be used on the results page
|
|
43
|
-
// --metadata metadata no any additional data user might want to include. As plain string. Will be displayed on results page
|
|
44
|
-
.option('concurrency', {
|
|
45
|
-
alias: 'c',
|
|
46
|
-
describe: 'How many parallel sessions of the test runner should be spawned. '
|
|
47
|
-
+ 'I.e. on how many devices will it run in parallel. 0 = unlimited',
|
|
48
|
-
default: 0,
|
|
49
|
-
global: false,
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const handler = async(argv) => {
|
|
54
|
-
const {ownArgs, userCommandArgs} = await composeConfig(argv, false);
|
|
55
|
-
|
|
56
|
-
suitest.configuration.override(ownArgs);
|
|
57
|
-
|
|
58
|
-
const suitestLauncher = new SuitestLauncher(ownArgs, userCommandArgs);
|
|
59
|
-
|
|
60
|
-
await suitestLauncher.runAutomatedSession();
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/* istanbul ignore next */
|
|
64
|
-
module.exports = {
|
|
65
|
-
command,
|
|
66
|
-
describe,
|
|
67
|
-
builder,
|
|
68
|
-
// Make sure async handler is called only once (yargs bug)
|
|
69
|
-
handler: global._suitestTesting ? handler : once(handler),
|
|
70
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const texts = require('../../texts');
|
|
2
|
-
const logLevels = require('../../constants/logLevels');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Apply cli args common for interactive and automated commands
|
|
6
|
-
* @param {*} yargs
|
|
7
|
-
*/
|
|
8
|
-
function applyCommonArgs(yargs) {
|
|
9
|
-
yargs
|
|
10
|
-
.option('config-file', {
|
|
11
|
-
describe: texts.cliConfig(),
|
|
12
|
-
global: false,
|
|
13
|
-
type: 'string',
|
|
14
|
-
})
|
|
15
|
-
.option('default-timeout', {
|
|
16
|
-
describe: texts.defaultTimeout(),
|
|
17
|
-
global: false,
|
|
18
|
-
type: 'number',
|
|
19
|
-
})
|
|
20
|
-
.option('disallow-crash-reports', {
|
|
21
|
-
describe: texts.cliDisallowCrashReports(),
|
|
22
|
-
global: false,
|
|
23
|
-
type: 'boolean',
|
|
24
|
-
})
|
|
25
|
-
.option('log-dir', {
|
|
26
|
-
describe: texts['tl.logDirDescription'](),
|
|
27
|
-
global: false,
|
|
28
|
-
})
|
|
29
|
-
.option('log-level', {
|
|
30
|
-
describe: texts.cliLogLevel(),
|
|
31
|
-
global: false,
|
|
32
|
-
choices: Object.values(logLevels),
|
|
33
|
-
})
|
|
34
|
-
.option('timestamp', {
|
|
35
|
-
describe: texts.cliTimestamp(),
|
|
36
|
-
global: false,
|
|
37
|
-
type: 'string',
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
module.exports = {
|
|
42
|
-
applyCommonArgs,
|
|
43
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 'interactive' test launcher command
|
|
3
|
-
*/
|
|
4
|
-
const SuitestLauncher = require('../SuitestLauncher');
|
|
5
|
-
const suitest = require('../../../index');
|
|
6
|
-
const {applyCommonArgs} = require('./common');
|
|
7
|
-
const {once} = require('ramda');
|
|
8
|
-
const {composeConfig} = require('../composeConfig');
|
|
9
|
-
|
|
10
|
-
const command = 'interactive';
|
|
11
|
-
|
|
12
|
-
const describe = 'Run defined test command a single time in interactive session mode on a single device. '
|
|
13
|
-
+ 'It\'s intended for test authoring and application debugging.';
|
|
14
|
-
|
|
15
|
-
const builder = yargs => {
|
|
16
|
-
applyCommonArgs(yargs);
|
|
17
|
-
|
|
18
|
-
yargs
|
|
19
|
-
.option('username', {
|
|
20
|
-
alias: 'u',
|
|
21
|
-
describe: 'E-mail you\'re using to login to Suitest',
|
|
22
|
-
global: false,
|
|
23
|
-
})
|
|
24
|
-
.option('password', {
|
|
25
|
-
alias: 'p',
|
|
26
|
-
describe: 'Password for your Suitest account.',
|
|
27
|
-
global: false,
|
|
28
|
-
})
|
|
29
|
-
.option('org-id', {
|
|
30
|
-
alias: 'o',
|
|
31
|
-
describe: 'Id of the organisation you want to log in into',
|
|
32
|
-
global: false,
|
|
33
|
-
})
|
|
34
|
-
.option('device-id', {
|
|
35
|
-
alias: 'd',
|
|
36
|
-
describe: 'Device you want to connect to',
|
|
37
|
-
global: false,
|
|
38
|
-
})
|
|
39
|
-
.option('app-config-id', {
|
|
40
|
-
alias: 'c',
|
|
41
|
-
describe: 'Application configuration id to launch the app with',
|
|
42
|
-
global: false,
|
|
43
|
-
})
|
|
44
|
-
.option('inspect', {
|
|
45
|
-
describe: 'Will launch user command with --inspect execArgv, used for debugging',
|
|
46
|
-
global: false,
|
|
47
|
-
})
|
|
48
|
-
.option('inspect-brk', {
|
|
49
|
-
describe: 'Will launch user command with --inspect-brk execArgv, used for debugging',
|
|
50
|
-
global: false,
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const handler = async(argv) => {
|
|
55
|
-
const {ownArgs, userCommandArgs} = await composeConfig(argv, true);
|
|
56
|
-
|
|
57
|
-
suitest.configuration.override(ownArgs);
|
|
58
|
-
const suitestLauncher = new SuitestLauncher(ownArgs, userCommandArgs);
|
|
59
|
-
|
|
60
|
-
await suitestLauncher.runInteractiveSession();
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/* istanbul ignore next */
|
|
64
|
-
module.exports = {
|
|
65
|
-
command,
|
|
66
|
-
describe,
|
|
67
|
-
builder,
|
|
68
|
-
// Make sure async handler is called only once (yargs bug)
|
|
69
|
-
handler: global._suitestTesting ? handler : once(handler),
|
|
70
|
-
};
|