简体   繁体   English

Angular 单元测试:错误:无法匹配任何路由

[英]Angular Unit testing : Error: Cannot match any routes

I Am working on unit testing under my angular 15 app.我正在我的 angular 15 应用程序下进行单元测试。 I am getting the below error while running the test:运行测试时出现以下错误:

Error: Cannot match any routes.URL Segment: 'signin'错误:无法匹配任何路由。URL 段:'signin'

Below is the unit test code for my component:下面是我的组件的单元测试代码:

 fdescribe('ExtensionListComponent',()=>{
   BeforeEach(() => {
     TestBed.configureTestingModule({
       imports: [
        RouteTestingModule.withRoutes([{
        path: 'extensions-list',
       component: ExtensionListComponent}]),
       HttpClientTestingModule
       ],
       declarations:[
       ExtensionListComponent
       ],
       providers: [
       TaskService
       ]
  }).compileComponents();
 });

Your test is trying to navigate to login .您的测试正在尝试导航到login You need to define your signin Path here:您需要在此处定义您的signin路径:

   RouteTestingModule.withRoutes([
      {
        path: 'extensions-list',
        component: ExtensionListComponent
      },
      {
        path: 'signin',
       component: SigninComponentProbably
      }
  ]),

Or fake the login access somehow.或者以某种方式伪造登录访问权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 间歇性错误无法匹配任何路线单元测试Angular - Intermittent error cannot match any routes unit testing Angular Angular 单元测试:错误:无法匹配任何路由。 URL 段:'home/advisor' - Angular Unit testing : Error: Cannot match any routes. URL Segment: 'home/advisor' 错误:无法匹配Angular 4中的任何路线 - Error: Cannot match any routes in Angular 4 Angular 2收到“错误:无法匹配任何路线:” - Angular 2 getting “Error: Cannot match any routes: ''” 无法匹配任何路线Angular 6上的错误 - Cannot match any routes Error on Angular 6 错误:无法匹配 Angular 5 中的任何路由 - Error: Cannot match any routes in Angular 5 Angular 路由错误:无法匹配任何路由 - Angular Routing Error: Cannot match any routes 无法匹配任何路线。 角度误差? - Cannot match any routes. Error in angular? 角单元测试:未捕获错误:未捕获(承诺中):错误:无法匹配任何路线。 网址段:“注销” - Angular Unit Test: Uncaught Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'logout' Angular 测试:未捕获错误:未捕获(承诺中):错误:无法匹配任何路由。 URL 段:“家” - Angular Testing: Uncaught Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'home'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM