toHaveBeenCalled() doesn't take comment message #622

Closed
Yeti-or opened this Issue Jul 9, 2014 · 1 comment

Projects

None yet

2 participants

@Yeti-or
Yeti-or commented Jul 9, 2014

expect(spy).toHaveBeenCalled('have been called!') – doesn't work
expect(spy.calls.any()).toBe(true, 'have been called!') – works

@Yeti-or Yeti-or changed the title from toHaveBeenCalled() don't take comment message to toHaveBeenCalled() doesn't take comment message Jul 9, 2014
@slackersoft
Member

The toHaveBeenCalled matcher is actually trying to keep the developer from getting false greens when testing for a spy to have been called with specific arguments. That's why the message says "toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith".

The toBe (and other) matcher(s) don't actually do anything with any extra parameters passed to it after the first one. You see the message only for the ones that don't provide their own custom failure messages and allow jasmine to construct one.

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