5.1.6 • Published 2 months ago

@appium/support v5.1.6

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

@appium/support

Utility functions used to support Appium drivers and plugins

NPM version Downloads

Usage in drivers and plugins

Drivers and plugins are recommended to have Appium as a peer dependency, as it already includes these utility functions. Add the following line to peerDependencies section of your module's package.json:

  "peerDependencies": {
    "appium": "^<minimum_server_version>"
  }

Afterwards import it in your code similarly to the below example:

import {timing, util} from 'appium/support';

Usage in helper modules

If you want to use this module in a helper library, which is not a driver or a plugin, then add the following line to dependencies section of your module's package.json:

  "dependencies": {
    "@appium/support": "<module_version>"
  }

Afterwards import it in your code similarly to the below example:

import {timing, util} from '@appium/support';

Categories

All utility functions are split into a bunch of different categories. Each category has its own file under the lib folder. All utility functions in these files are documented.

CategoryDescription
consoleWrappers for the command line interface abstraction used by the Appium server
doctorCommon doctor utilities that can be used by drivers and plugins
envSeveral helpers needed by the server to cope with internal dependencies and manifests
fsMost of the functions here are just thin wrappers over utility functions available in Promises API
image-utilUtilities to work with images. Use sharp under the hood.:bangbang: Node >=18.17 is required to use these utilities
log-internalUtilities needed for internal Appium log config assistance
loggingSee the logging section below
mjpegHelpers needed to implement MJPEG streaming
netHelpers needed for network interactions, for example, upload and download of files
nodeSet of Node.js-specific utility functions needed, for example, to ensure objects immutability or to calculate their sizes
npmSet of npm-related helpers
plistSet of utilities used to read and write data from plist files in javascript
processHelpers for interactions with system processes. These APIs don't support Windows.
systemSet of helper functions needed to determine properties of the current operating system
tempdirSet of helpers that allow interactions with temporary folders
timingHelpers that allow to measure execution time
utilMiscellaneous utilities
zipHelpers that allow to work with archives in .zip format

logging

This is a basic logger defaulting to npmlog with special consideration for running tests (doesn't output logs when run with _TESTING=1).

Logging levels

There are a number of levels, exposed as methods on the log object, at which logging can be made. The built-in ones correspond to those of npmlog, and are: silly, verbose, info, http, warn, and error. There is also a debug level.

The default threshold level is verbose.

The logged output, by default, will be level prefix message. So

import {logging} from 'appium/support';
let log = logging.getLogger('mymodule');
log.warn('a warning');`

Will produce

warn mymodule a warning

Environment variables

There are two environment variable flags that affect the way logger works.

VariableDescription
_TESTINGIf set to 1, logging output is stopped
_FORCE_LOGSIf set to 1, overrides the value of _TESTING

Usage

log.level

  • Get and set the threshold level at which to display the logs. Any logs at or above this level will be displayed. The special level silent will prevent anything from being displayed ever. See npmlog#level for more details.

log[level](message)

  • Logs message at the specified level
import {logging} from 'appium/support';
let log = logging.getLogger('mymodule');

log.info('hi!');
// => info mymodule hi!

log.unwrap()

  • Retrieves the underlying npmlog object, in order to manage how logging is done at a low level (e.g., changing output streams, retrieving an array of messages, adding log levels, etc.).
import {logging} from 'appium/support';
let log = logging.getLogger('mymodule');

log.info('hi!');

let npmlogger = log.unwrap();

// any `npmlog` methods
let logs = npmlogger.record;
// logs === [ { id: 0, level: 'info', prefix: 'mymodule', message: 'hi!', messageRaw: [ 'hi!' ] }]

log.errorWithException(error)

  • Logs the error passed in, at error level, and then returns the error. If the error passed in is not an instance of Error (either directly, or a subclass of Error), it will be wrapped in a generic Error object.
import {logging} from 'appium/support';
let log = logging.getLogger('mymodule');

// previously there would be two lines
log.error('This is an error');
throw new Error('This is an error');

// now is compacted
throw log.errorWithException('This is an error');

License

Apache-2.0

5.1.6

2 months ago

5.1.5

2 months ago

5.1.4

3 months ago

5.1.3

5 months ago

5.1.2

6 months ago

5.1.1

6 months ago

5.1.0

6 months ago

4.4.0

7 months ago

5.0.3

6 months ago

5.0.2

6 months ago

5.0.1

6 months ago

4.2.6

7 months ago

4.5.0

7 months ago

4.3.0

7 months ago

4.2.5

8 months ago

4.2.4

8 months ago

4.2.3

9 months ago

4.2.2

10 months ago

4.2.1

11 months ago

4.2.0

12 months ago

4.1.11

1 year ago

4.1.10

1 year ago

4.1.9

1 year ago

4.1.8

1 year ago

4.1.7

1 year ago

4.1.4

1 year ago

4.1.3

1 year ago

4.1.6

1 year ago

4.1.5

1 year ago

4.1.2

1 year ago

4.1.1

1 year ago

4.1.0

2 years ago

4.0.3

2 years ago

4.0.2

2 years ago

3.1.11

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

3.1.10

2 years ago

3.1.9

2 years ago

3.1.8

2 years ago

3.1.7

2 years ago

3.1.6

2 years ago

3.1.5

2 years ago

3.1.3

2 years ago

3.1.4

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.61.0

2 years ago

2.61.1

2 years ago

2.60.0

2 years ago

2.59.2

3 years ago

2.59.3

2 years ago

2.59.4

2 years ago

2.59.5

2 years ago

2.59.0

3 years ago

2.59.1

3 years ago

2.58.0

3 years ago

2.57.4

3 years ago

2.57.0

3 years ago

2.56.1

3 years ago

2.57.1

3 years ago

2.57.2

3 years ago

2.57.3

3 years ago

2.56.0

3 years ago

2.55.3

3 years ago

2.55.4

3 years ago

2.55.0

3 years ago

2.55.1

3 years ago

2.55.2

3 years ago

2.54.2

3 years ago

2.54.0

3 years ago

2.53.0

4 years ago