@appium/support
TypeScript icon, indicating that this package has built-in type declarations

5.1.6 • Public • Published

@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.

Category Description
console Wrappers for the command line interface abstraction used by the Appium server
doctor Common doctor utilities that can be used by drivers and plugins
env Several helpers needed by the server to cope with internal dependencies and manifests
fs Most of the functions here are just thin wrappers over utility functions available in Promises API
image-util Utilities to work with images. Use sharp under the hood.
‼️ Node >=18.17 is required to use these utilities
logging See the logging section below
mjpeg Helpers needed to implement MJPEG streaming
net Helpers needed for network interactions, for example, upload and download of files
node Set of Node.js-specific utility functions needed, for example, to ensure objects immutability or to calculate their sizes
npm Set of npm-related helpers
plist Set of utilities used to read and write data from plist files in javascript
process Helpers for interactions with system processes. These APIs don't support Windows.
system Set of helper functions needed to determine properties of the current operating system
tempdir Set of helpers that allow interactions with temporary folders
timing Helpers that allow to measure execution time
util Miscellaneous utilities
zip Helpers 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.

Variable Description
_TESTING If set to 1, logging output is stopped
_FORCE_LOGS If 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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.1.6102,810latest

Version History

VersionDownloads (Last 7 Days)Published
5.1.6102,810
5.1.514,665
5.1.422,714
5.1.340,578
5.1.265,593
5.1.18,313
5.1.02,864
5.0.34,686
5.0.27
5.0.18
4.5.039,350
4.4.014
4.3.09
4.2.62,238
4.2.562,417
4.2.41,215
4.2.31,804
4.2.216,974
4.2.15,659
4.2.010,923
4.1.11237
4.1.101,956
4.1.91,924
4.1.81,365
4.1.71,852
4.1.67,909
4.1.579
4.1.42
4.1.31,293
4.1.23,314
4.1.11,237
4.1.0945
4.0.32
4.0.21
4.0.1704
4.0.056
3.1.114,073
3.1.102
3.1.91,138
3.1.876
3.1.71,690
3.1.6426
3.1.5450
3.1.495
3.1.3315
3.0.11,605
3.0.01,351
2.61.19,565
2.61.00
2.60.0106
2.59.510
2.59.41
2.59.33
2.59.2115
2.59.11
2.59.00
2.58.0118
2.57.418
2.57.31
2.57.20
2.57.12
2.57.00
2.56.112
2.56.01
2.55.41
2.55.33
2.55.26
2.55.12
2.55.03
2.54.21
2.54.00
2.53.01

Package Sidebar

Install

npm i @appium/support

Homepage

appium.io

Weekly Downloads

446,908

Version

5.1.6

License

Apache-2.0

Unpacked Size

410 kB

Total Files

105

Last publish

Collaborators

  • jlipps
  • nick.mokhnach
  • kazucocoa
  • boneskull