A collection of test utility libs used across Appium packages
npm install @appium/test-support --save-dev
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();
});
}));
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();
});
}));
Apache-2.0