Passing arguments to setInterval and setTimeout callbacks #283

wants to merge 1 commit into


None yet
3 participants

I noticed an issue where Jasmine's mock setInterval and setTimeout functions had different behavior from most browsers (read, non-IE).

In non-IE browsers, you can pass more than two arguments to setInterval. The first two, which are implemented in Jasmine, are the callback and the time in ms. The additional arguments specify the arguments that are supposed to be applied to the callback function; Jasmine does not capture these arguments or pass them to the callback.

setInterval(callback, time, [arg1, arg2, ...])

See the attached code for an example of this usage.

I could imagine that this behavior was not included intentionally in order to avoid Internet Explorer compatibility issues. I am also aware of one basic workaround to this issue that involves wrapping the callback in an anonymous function.

However, if you agree that these specs are correct, reply to this pull request, and I can try to implement the behavior.


See also:


infews commented Oct 26, 2012

We do need to support IE so please make sure any tests/implementation you add take that into account. Happy to comment on progressions on this. Thanks!

Does anyone know what the status on this is? We also need it on our project.


infews commented Mar 6, 2013

We have fixed this on master. So 2.0 will behave properly. See

infews closed this Mar 6, 2013

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