1.2.0 • Published 2 years ago
rx-spy-util v1.2.0
rx-spy-util
Collect all your spies to observable values in one util. SpyUtil helps you keep track on each call without all that boilerplate code
Usage
For extended excamples, see main.spec.ts
const key = 'someKey';
const spyUtil: SpyUtil = new SpyUtil();
// before each
spyUtil.spySubscribe(service.someObservable, key);
spyUtil.spyException(service.someObservable, 'someOtherId');
....
// tests
expect(spyUtil.get(key)).toHaveBeenCalledTimes(1) ...
expect(spyUtil.get('someOtherId')).not.toHaveBeenCalled() ...
expect(spyUtil.allCounts()).toEqual([1, 0]) ...
expect(spyUtil.argsFor(key, 0).toEqual('some string')) ...
expect(spyUtil.lastOf(key).toEqual('some string')) ...
...
// after each
spyUtil.unsubscribe() ...
Test
$> npm i && npm test
Dependencies
Your project should have rxjs,and jasmine installed - these are omitted in the bundle to avoid version conflicts
Todo
karma singleRun=false not working