How to spyOn a value property (rather than a method) with Jasmine

前端 未结 10 2245
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 04:12

Jasmine\'s spyOn is good to change a method\'s behavior, but is there any way to change a value property (rather than a method) for an object? the code could be

10条回答
  •  佛祖请我去吃肉
    2020-12-01 04:43

    I'm a bit late to the party here i know but,

    You could directly access the calls object, which can give you the variables for each call

    expect(spy.calls.argsFor(0)[0].value).toBe(expectedValue)
    

提交回复
热议问题