Files
appium/packages/test-support
Jonathan Lipps c00cbfa1fb chore: publish
- appium@3.1.0
 - @appium/base-driver@10.1.0
 - @appium/base-plugin@3.0.3
 - @appium/docutils@2.1.1
 - @appium/driver-test-support@1.0.3
 - @appium/eslint-config-appium-ts@2.0.3
 - @appium/execute-driver-plugin@5.0.2
 - @appium/fake-driver@6.0.1
 - @appium/fake-plugin@4.0.3
 - @appium/images-plugin@4.0.2
 - @appium/logger@2.0.2
 - @appium/opencv@4.0.2
 - @appium/plugin-test-support@1.0.2
 - @appium/relaxed-caps-plugin@2.0.1
 - @appium/storage-plugin@1.0.2
 - @appium/support@7.0.2
 - @appium/test-support@4.0.2
 - @appium/types@1.1.0
 - @appium/universal-xml-plugin@2.0.1
2025-10-08 14:02:07 -07:00
..
2025-10-08 14:02:07 -07:00
2021-11-18 12:08:50 -08:00
2025-10-08 14:02:07 -07:00

@appium/test-support

A collection of test utility libs used across Appium packages

NPM version Downloads

Installation

npm install @appium/test-support --save-dev

Usage

withSandbox

Use when mixing up sinon APIs (mocks, spies, stubs).

import { withSandbox } from '@appium/test-support';

let api = {
  abc: () => { return 'abc'; }
};

describe('MyTest', withSandbox({mocks: {api}}, (S) => {
  it('stubbing api, stubbing dog', () => {
    S.mocks.api.expects('abc').once().returns('efg');
    let dog = { bark: () => { return 'ouaf!'; } };
    S.sandbox.stub(dog, 'bark').returns('miaou');
    api.abc().should.equal('efg');
    dog.bark().should.equal('miaou');
    S.verify();
  });
}));

withMocks

When using mainly stubs.

import { withMocks } from '@appium/test-support';

let api = {
  abc: () => { return 'abc'; }
};

describe('withMocks', withMocks({api}, (mocks) => {
  it('should mock api', () => {
    mocks.api.expects('abc').once().returns('efg');
    api.abc().should.equal('efg');
    mocks.verify();
  });
}));

License

Apache-2.0