title: Error: Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?)
body: <p>I am trying to test an Angular Component using the ActivatedRoute Class in Karma/Jasmine but I'm having a very annoying error that I can't fix. <code>Error: Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?)</code></p>
  <p>I have tried all solutions I found online, mocking an Activated Route in various ways. But I just can't get it to work.</p>
  <pre class="lang-js prettyprint-override"><code>import { ComponentFixture, TestBed } from '@angular/core/testing';
  import { ActivatedRoute, convertToParamMap } from '@angular/router';
  import { RouterTestingModule } from '@angular/router/testing';
  import { of } from 'rxjs';
  
  import { SearchbarComponent } from './searchbar.component';
  
  describe('SearchbarComponent', () =&gt; {
    let component: SearchbarComponent;
    let fixture: ComponentFixture&lt;SearchbarComponent&gt;;
  
    beforeEach(async () =&gt; {
      await TestBed.configureTestingModule({
        imports: [ RouterTestingModule ],
        declarations: [ SearchbarComponent ],
        providers: [
          {
            provide: ActivatedRoute,
            useValue: {
              queryParams: of(convertToParamMap({ 
                search: &quot;&quot;         
              }))
            }
          }
      ]
      })
      .compileComponents();
    });
  
    beforeEach(() =&gt; {
      fixture = TestBed.createComponent(SearchbarComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();
    });
  
    it('should create', () =&gt; {
      expect(component).toBeTruthy();
    });
  });
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>import { Input, Component, HostListener, OnInit } from '@angular/core';
  import { ActivatedRoute, Router } from '@angular/router';
  ...
  @Component({
    selector: 'searchbar',
    templateUrl: './searchbar.component.html',
    styleUrls: ['./searchbar.component.scss'],
    providers: [ ActivatedRoute ]
  })
  export class SearchbarComponent implements OnInit {
  
    constructor(private route: ActivatedRoute) { 
      this.route.queryParams
      .subscribe(params =&gt; {
          this.currentSearch = params.search;
      });
    }
  ...
  }
  </code></pre>