suitest-js-api 2.5.0 → 2.5.3

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/index.d.ts CHANGED
@@ -38,6 +38,7 @@ import {SetScreenOrientationChain} from './typeDefinition/SetScreenOrientationCh
38
38
  import {ScreenOrientation} from './typeDefinition/constants/ScreenOrientation';
39
39
  import {CloseAppChain} from './typeDefinition/CloseAppChain';
40
40
  import {SuspendAppChain} from './typeDefinition/SuspendAppChain';
41
+ import {LaunchMode} from './typeDefinition/constants/LaunchMode';
41
42
 
42
43
  // --------------- Suitest Interface ---------------------- //
43
44
 
@@ -150,6 +151,7 @@ declare namespace suitest {
150
151
  TAP_TYPES: TapTypes;
151
152
  DIRECTIONS: Directions;
152
153
  SCREEN_ORIENTATION: ScreenOrientation;
154
+ LAUNCH_MODE: LaunchMode;
153
155
 
154
156
  authContext: AuthContext;
155
157
  appContext: Context;
package/lib/texts.js CHANGED
@@ -154,6 +154,11 @@ ${leaves}`,
154
154
  'errorType.testPackNoDevices': () => 'There are no devices associated with this test pack.',
155
155
  'errorType.testCannotBeFetched': (testId, mainTest) => `Test cannot be fetched test id: ${mainTest ? mainTest + ' > ... > ' + testId : testId}`,
156
156
 
157
+ 'commandError.notSupportedPlatform': () => 'Screenshots are not supported on this device.',
158
+ 'commandError.timeout': () => 'Failed to take a screenshot due to timeout.',
159
+ 'commandError.generalError': () => 'Failed to take a screenshot.',
160
+ 'commandError.notSupportedDriver': () => 'Screenshots are not supported on this driver.',
161
+
157
162
  executorStopped: () => 'Test execution was stopped. See our documentation for possible reasons: https://suite.st/docs/error-messages/results-errors/#test-execution-was-stopped',
158
163
 
159
164
  executionAborted: () => 'Test execution was aborted.',
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable max-len */
2
2
  const {EOL} = require('os');
3
- const {path} = require('ramda');
3
+ const {path, has} = require('ramda');
4
4
 
5
5
  const t = require('../texts');
6
6
  const chainUtils = require('./chainUtils');
@@ -94,6 +94,22 @@ const getSnippetLogs = ({testId, definitions, results, level, verbosity}, transl
94
94
  }, []).filter(Boolean).join('\n');
95
95
  };
96
96
 
97
+ const commandErrors = {
98
+ 'notSupportedPlatform': () => t['commandError.notSupportedPlatform'](),
99
+ 'timeout': () => t['commandError.timeout'](),
100
+ 'generalError': () => t['commandError.generalError'](),
101
+ 'notSupportedDriver': () => t['commandError.notSupportedDriver'](),
102
+ };
103
+
104
+ /**
105
+ * @description check that response error is related to "command" (not "line") execution.
106
+ * For now it is related only for taking screenshots
107
+ * @param response
108
+ */
109
+ function isCommandError(response) {
110
+ return response.result === 'error' && has(response.errorType, commandErrors);
111
+ }
112
+
97
113
  /**
98
114
  * @description Create human readable error message from suitest error response
99
115
  * @param verbosity
@@ -109,6 +125,10 @@ function getErrorMessage({response, jsonMessage, verbosity, snippets}) {
109
125
  );
110
126
  }
111
127
 
128
+ if (isCommandError(response)) {
129
+ return commandErrors[response.errorType]();
130
+ }
131
+
112
132
  return chainUtils.translateLineResult(jsonMessage, verbosity, response);
113
133
  }
114
134
 
@@ -396,7 +396,7 @@ function runAllDevices(cmdArgv, ownArgv, devices, ipcPort) {
396
396
 
397
397
  log.finalAutomated(failedDevices.length, result.length - failedDevices.length);
398
398
  warnNewVersionAvailable(version, suitestVersion);
399
- handleChildResult(failedDevices.length - result.length >= 0);
399
+ handleChildResult(failedDevices.length !== 0);
400
400
  });
401
401
  }
402
402
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suitest-js-api",
3
- "version": "2.5.0",
3
+ "version": "2.5.3",
4
4
  "main": "index.js",
5
5
  "repository": "git@github.com:SuitestAutomation/suitest-js-api.git",
6
6
  "author": "Suitest <hello@suite.st>",
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  AbstractChain,
3
3
  BaseChain,
4
- LaunchMode
4
+ LaunchModeModifier
5
5
  } from './modifiers';
6
6
 
7
7
  export interface OpenAppChain extends
8
8
  BaseChain<OpenAppChain, OpenAppEvalResult, OpenAppAbandonedChain>,
9
- LaunchMode<OpenAppChain>
9
+ LaunchModeModifier<OpenAppChain>
10
10
  {}
11
11
 
12
12
  interface OpenAppAbandonedChain extends AbstractChain {}
@@ -0,0 +1,6 @@
1
+ export type LaunchMode = {
2
+ RESUME: 'resume',
3
+ RESTART: 'restart',
4
+ }
5
+
6
+ export type LaunchModeValues = LaunchMode[keyof LaunchMode];
@@ -1,3 +1,5 @@
1
+ import {LaunchModeValues} from './constants/LaunchMode';
2
+
1
3
  export interface Thenable <R> {
2
4
  then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
3
5
  then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
@@ -38,8 +40,8 @@ export interface Clonable<T> {
38
40
  clone(): T;
39
41
  }
40
42
 
41
- export interface LaunchMode<T> {
42
- launchMode(mode: 'resume' | 'restart'): T;
43
+ export interface LaunchModeModifier<T> {
44
+ launchMode(mode: LaunchModeValues): T;
43
45
  }
44
46
 
45
47
  export interface Abandable<T> {