Search code examples
jasmine

Expected spy unknown to have been called


I'm new to Jasmine, and am getting this error:

Expected spy unknown to have been called.

What does this mean? I'm spying on a method, but am not sure what unknown means.


Solution

  • The answer is really simple! The spy didnt have a name, so it's called "unknown" by default.

    To name it, I simply did this

    var mySpy = jasmine.createSpy("JamesBond");
    

    Then it failed with something more readable!

    Expected spy JamesBond to have been called.