<tohavebeencalled>:期待间谍,但未定义

时间:2018-06-11 17:18:58

标签: javascript extjs jasmine mocking

我正在尝试在Ext4js中测试下面的功能

functionA: function {
   functionB();
}

这是我在测试中尝试的内容:

beforeEach(function (){
   somePanel= mockControlItem(subject, 'parentPanel', ['functionB']);
}

it("will run function B when functionA runs", function() {
   spyOn(subject,'onIdChanged');
   expect(subject).toHaveListener('show', 'functionA');
   somePanel.functionB.and.returnValue(true);
   subject.functionA();
   expect(somePanel.functionB).toHaveBeenCalled();
}

我收到错误:toHaveBeenCalled> : Expected a spy, but got undefined.

1 个答案:

答案 0 :(得分:0)

我认为你应该改变这条线

spyOn(somePanel, 'functionB').and.returnValue(true);

这个

.get_next()

an old reply

希望有所帮助