【发布时间】:2015-09-28 16:24:52
【问题描述】:
我正在使用 chai-spies 来确保调用了我的控制器中的函数,这是我的测试:
it('Should show right season and analysts when competition has been selected', function (done) {
scope.selectedCompetition = scope.competitions[3];
var spy = chai.spy(scope.selectedCompetitionChanged);
scope.selectedCompetitionChanged();
expect(spy).to.have.been.called();
done();
});
scope.selectedCompetitionChanged 是一个函数。测试失败并出现以下错误:
AssertionError: expected { Spy } to have been called
at Context.<anonymous> (base/tests/client/controllers/prediction.js?02f216981852d0775780926989e7266c6afb0af6:61:30)
如果我显式调用该函数,怎么会发生这种情况? 谢谢
【问题讨论】:
-
我最终使用了诗乃
标签: angularjs unit-testing chai