Jan Rubio

Returning Consecutive Values in Jasmine

spyOnAndReturnConsecutive(foo, 'getBar', [1, 2, 3]);

expect(foo.getBar()).toEqual(1);
expect(foo.getBar()).toEqual(2);
expect(foo.getBar()).toEqual(3);
expect(foo.getBar()).toEqual(3);

Jasmine provides the ability to stub methods and return specific values. You can even return different values based on the arguments. So how do we get the snippet above to work?

read more