Can't resolve all parameters for Router: (?, ?, ?, ?, ?, ?, ?) in Angular RC 5 when unit testing

前端 未结 8 1434
闹比i
闹比i 2020-12-24 10:30

I just upgraded to Angular RC 5 and now all component that uses \'ROUTER_DIRECTIVES\' fails with \'Can\'t resolve all parameters for Router: (?, ?, ?, ?, ?, ?, ?)\' when I t

8条回答
  •  [愿得一人]
    2020-12-24 11:04

    Try adding RouterModule:

    import { ROUTER_DIRECTIVES, Router, RouterModule } from '@angular/router';
    
    beforeEach(() => {
            TestBed.configureTestingModule({
                providers: [
                     ...
                    {provide: Router, useClass: RouterModule},
            });
        });
    

提交回复
热议问题