mirror of
https://github.com/appium/appium.git
synced 2026-10-21 16:26:40 +08:00
6742808345
- appium@2.14.0 - @appium/base-driver@9.14.0 - @appium/base-plugin@2.2.51 - @appium/docutils@1.0.27 - @appium/driver-test-support@0.7.2 - @appium/eslint-config-appium-ts@1.0.1 - @appium/execute-driver-plugin@4.0.0 - @appium/fake-driver@5.6.0 - @appium/fake-plugin@3.1.55 - @appium/images-plugin@3.0.25 - @appium/opencv@3.0.7 - @appium/plugin-test-support@0.3.47 - @appium/schema@0.7.1 - @appium/support@6.0.1 - @appium/test-support@3.1.1 - @appium/types@0.23.0 - @appium/universal-xml-plugin@1.0.27
@appium/test-support
A collection of test utility libs used across Appium packages
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