How can I spy on a getter property using jasmine?
var o = { get foo() {}, }; spyOn(o, \'foo\').and.returnValue(\'bar\'); // Doesn\'t work.
You can do this if you are unable to use the latest jasmine (2.6.1)
const getSpy = jasmine.createSpy().and.returnValue('bar') Object.defineProperty(o, 'foo', { get: getSpy });
Documentation for defineProperty, here