您想在我的角度组件中测试真实服务。但我得到低于错误。 没有服务blservice的提供商
def __OnClickSaveLoginButton(self):
id = self.idEditLine.GetText()
pwd = self.pwdEditLine.GetText()
if (len(id) == 0 or len(pwd) == 0):
self.PopupNotifyMessage("ID and Password required",self.SetIDEditLineFocus)
return
file_object = open("account.cfg", "w")
file_object.write(id+"\n"+pwd)
self.PopupNotifyMessage("Saved.",self.SetIDEditLineFocus)
file_object.close()
错误:
错误:没有BlService的提供者! 错误:没有BlService的提供者! 在ReflectiveInjector_.prototype._throwOrNull(http://localhost:9876/_karma_webpack_/vendor.bundle.js:42115:13) 在ReflectiveInjector_.prototype._getByKeyDefault(http://localhost:9876/_karma_webpack_/vendor.bundle.js:42154:13) 在ReflectiveInjector_.prototype._getByKey(http://localhost:9876/_karma_webpack_/vendor.bundle.js:42086:13) 在ReflectiveInjector_.prototype.get(http://localhost:9876/_karma_webpack_/vendor.bundle.js:41955:9) at resolveNgModuleDep(http://localhost:9876/_karma_webpack_/vendor.bundle.js:48958:5) 在NgModuleRef_.prototype.get(http://localhost:9876/_karma_webpack_/vendor.bundle.js:50028:9)
答案 0 :(得分:5)
以这种方式解决:
import {async} from '@angular/core/testing';
beforeEach(async(() => {
TestBed.configureTestingModule({
providers: [BlService]
});
}));