[英]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.