toHaveBeenCalledWith fails with multiple arguments #35

Closed
jamesarosen opened this Issue Dec 14, 2010 · 4 comments

Comments

Projects
None yet
2 participants

First attempt:

spyOn(Foo, 'bar');
Foo.bar('baz', 'qux');
expect(Foo.bar).toHaveBeenCalledWith('baz', 'qux');

Expected spy to have been called with [ [ 'baz', 'qux' ] ] but was called with [ 'baz', 'qux' ].

Second attempt:

spyOn(Foo, 'bar');
Foo.bar('baz', 'qux');
expect(Foo.bar).toHaveBeenCalledWith(['baz', 'qux']);

Expected spy to have been called with [ [ 'baz', 'qux' ] ] but was called with [ [ 'baz', 'qux' ] ].

I believe the problem is that Jasmine is using a simple == or === comparison, rather than comparing the elements of arguments individually.

This is 1.0.1 revision 1286311016.

Whoops - the problem was a formatting issue.

poliu2s commented Nov 9, 2015

@jamesarosen What was the formatting issue? I seem to be having the same problem

poliu2s commented Nov 9, 2015

Actually, I found out that you can use the obj.method.calls.allArgs() for this to work

This issue was closed.

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