rx-spy-utildeprecated

Spyutils to subscribeables spies

Usage no npm install needed!

<script type="module">
  import rxSpyUtil from 'https://cdn.skypack.dev/rx-spy-util';
</script>

README

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

gt; 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