Files
appium/packages/test-support
Jonathan Lipps 715fd03c45 chore: publish
- appium@2.16.1
 - @appium/base-driver@9.16.1
 - @appium/base-plugin@2.3.2
 - @appium/docutils@1.0.31
 - @appium/driver-test-support@0.7.6
 - @appium/fake-plugin@3.2.2
 - @appium/images-plugin@3.0.29
 - @appium/plugin-test-support@0.3.51
 - @appium/schema@0.8.1
 - @appium/support@6.0.5
 - @appium/test-support@3.1.5
 - @appium/tsconfig@0.3.4
 - @appium/types@0.25.1
 - @appium/universal-xml-plugin@1.0.29
2025-02-20 11:04:05 -08:00
..
2025-02-20 11:04:05 -08:00
2021-11-18 12:08:50 -08:00
2025-02-20 11:04:05 -08: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