I saw this post post and was excited to try it out, but I\'m unable to get it working. Trying to keep this simple just to figure out what\'s wrong, but even this is failing.
I was still struggling a bit to get the set
to work.
const foo = {
get value() {},
set value(v) {}
};
it('can spy on getters', () => {
spyOnProperty(foo, 'value', 'get').and.returnValue(1);
expect(foo.value).toBe(1);
});
it('and on setters', () => {
const spiez = spyOnProperty(foo, 'value', 'set');
foo.value = true;
expect(spiez).toHaveBeenCalled();
});