首页 > 解决方案 > 如何在角度测试用例中配置路由器

问题描述

在我的 Angular 4 应用程序中,我正在为一个导航到不同路线的方法编写一个测试用例。在我的测试用例中,我正在导入 RouterTestingModule.withRoutes 并传递路由。

const testRoutes: Routes = [ { path: 'sampleApp', component: SampleComponent}];
 imports: [RouterTestingModule.withRoutes(testRoutes)]

这似乎不起作用我仍然得到错误,

角茉莉错误:'未处理的承诺拒绝:','无法匹配任何路线。网址段...

我该如何解决这个问题。

标签: angularjasminerouter

解决方案


推荐阅读