When I run my jasmine specs I get the following error:
Error: Expected a spy, but got undefined.
My coffeescript code:
describe "setupForm", ->
beforeEach ->
spyOn(Subscription.prototype, 'runSimulation')
it "calls subscription.runSimulation when form is submitted with number", ->
Subscription.prototype.runSimulation()
expect(Subscription.prototype.runSimulation()).toHaveBeenCalled()
I have simplfied my erroring code to the above for debugging, but I can't figure out why it is saying the spy is never called when I'm explicitly calling it my test. I am testing the method in other places, so I think the error has to be with how I am using the Jasmine Spy. Thanks.
When I run my jasmine specs I get the following error:
Error: Expected a spy, but got undefined.
My coffeescript code:
describe "setupForm", ->
beforeEach ->
spyOn(Subscription.prototype, 'runSimulation')
it "calls subscription.runSimulation when form is submitted with number", ->
Subscription.prototype.runSimulation()
expect(Subscription.prototype.runSimulation()).toHaveBeenCalled()
I have simplfied my erroring code to the above for debugging, but I can't figure out why it is saying the spy is never called when I'm explicitly calling it my test. I am testing the method in other places, so I think the error has to be with how I am using the Jasmine Spy. Thanks.
Share Improve this question asked Aug 19, 2012 at 5:28 JohnJohn 4,3825 gold badges34 silver badges50 bronze badges1 Answer
Reset to default 14Take the ()
off the end of Subscription.prototype.runSimulation()
:
expect(Subscription.prototype.runSimulation).toHaveBeenCalled()