Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

waitsFor() should work if you pass it a spy (and optional timeout) #139

paxunix opened this Issue Oct 3, 2011 · 3 comments


None yet
4 participants

paxunix commented Oct 3, 2011

In that case it should simply wait for that spy to be called within the timeout.
I find myself doing this quite a bit in tests for async code:
var onSuccess = jasmine.createSpy();
waitsFor(function() {return onSuccess.wasCalled; }, "waiting on spy", 2000);

It seems like I should be able to just write:
waitsFor(onSuccess, 2000);

Bonus points for making its return work like a matcher:
waitsFor(onSuccess, 2000).toHaveBeenCalledWith(42);

Agreed. This would be pretty much perfect for my cases as well.

I wonder how this would interact with spyOn. Could you do something like:

spyOn(someObject, 'spiedFunction');



rbuels commented Jul 9, 2012



infews commented May 26, 2013

Closing. waitsFor/runs is removed from master and 2.0 in favor of the less verbose done-callback style as Mocha uses.

@infews infews closed this May 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment