小编kar*_*nal的帖子

如何在 angular 应用程序中对 router.navigate 进行单元测试

我正在为 angular 应用程序运行单元测试,我想对导航在 angular 应用程序中是否正常工作进行单元测试。

 if (this.customer.length == 0) {
     this.router.navigate(['/nocustomer']);
 } 

Run Code Online (Sandbox Code Playgroud)

以及为此的单元测试

 it(`should navigate to nocustomer`,()=>{
   component.customers.length=0;
   //what must be written here to check this
})
Run Code Online (Sandbox Code Playgroud)

router unit-testing navigateurl angular

8
推荐指数
2
解决办法
2万
查看次数

标签 统计

angular ×1

navigateurl ×1

router ×1

unit-testing ×1