Any way to modify Jasmine spies based on arguments?
In Jasmine versions 3.0 and above you can use withArgs describe(‘my fn’, function() { it(‘gets user name and ID’, function() { spyOn(externalApi, ‘get’) .withArgs(‘abc’).and.returnValue(‘Jane’) .withArgs(‘123’).and.returnValue(98765); }); }); For Jasmine versions earlier than 3.0 callFake is the right way to go, but you can simplify it using an object to hold the return values describe(‘my fn’, … Read more