Jasmine spyOn with specific arguments
问题 Suppose I have spyOn($cookieStore,'get').and.returnValue('abc'); This is too general for my use case. Anytime we call $cookieStore.get('someValue') --> returns 'abc' $cookieStore.get('anotherValue') --> returns 'abc' I want to setup a spyOn so I get different returns based on the argument: $cookieStore.get('someValue') --> returns 'someabc' $cookieStore.get('anotherValue') --> returns 'anotherabc' Any suggestions? 回答1: You can use callFake: spyOn($cookieStore,'get').and.callFake(function(arg)