简体   繁体   中英

Jasmine Spy Undefined

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.

()关闭的端部Subscription.prototype.runSimulation()

  expect(Subscription.prototype.runSimulation).toHaveBeenCalled()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM