A mock that can be used for anything
npm install proxy-mock-js
$ npm install proxy-mock-js
`
Use
`js
const mock = getProxyMock();
const { a, b, c} = mock; // a, b, c will be new proxy-mock copies
const nested = mock.db.users[3].address.street; // will work, all the keys will be created as new proxy-mock copies
const fnResult = mock.get('/cats'); // will result in yet another proxy-mock copy
const math = mock * 2; // will result in 84, since in case of toPrimitive calls we return primitive value, in this case it's 42
`
$3
proxy mock supports auto spying on newly created properties, you just have to pass the the spy function to proxy-mock
`js
const spyFn = (name, fn) => {
return jasmine.createSpy(name, fn).and.callThrough();
}
const mock = getProxyMock({}, 'httpClient', spyFn);
mock.post('/api/call');
expect(mock.post).toHaveBeenCalled();
``