Unit testing 如何在测试用例中覆盖localStorage和subscribe函数项的代码
我正在为Angular 7项目创建测试用例。在这方面,我无法对localStorage和subscribe及其err函数进行代码覆盖 //未涵盖的报表Unit testing 如何在测试用例中覆盖localStorage和subscribe函数项的代码,unit-testing,angular7,Unit Testing,Angular7,我正在为Angular 7项目创建测试用例。在这方面,我无法对localStorage和subscribe及其err函数进行代码覆盖 //未涵盖的报表 localStorage.setItem('email', email); this.valService.checkVal(email,pwd).subscribe((data : any)=>{ }, (err : HttpErrorResponse)=>{ this.isLoginError = true;
localStorage.setItem('email', email);
this.valService.checkVal(email,pwd).subscribe((data : any)=>{
},
(err : HttpErrorResponse)=>{
this.isLoginError = true;
});
//未涵盖的功能
localStorage.setItem('email', email);
this.valService.checkVal(email,pwd).subscribe((data : any)=>{
},
(err : HttpErrorResponse)=>{
this.isLoginError = true;
});