0

I am trying to test a simple component with jasmine that have the constructor below

constructor(public sanitizer: DomSanitizer) { }

In my test, i have a testBed like

describe("Component: myComponent", () => {
    let component: myComponent;
    let fixture: ComponentFixture<myComponent>;

    beforeEach(async(() => {
        TestBed.configureTestingModule({
            imports: [FormsModule, CommonModule],
            declarations: [myComponent],
        }).compileComponents().then(() => {
            fixture = TestBed.createComponent(myComponent);
            component = fixture.componentInstance;
        });
    }));
});

I am getting the error

Failed: Can't resolve all parameters for myComponent

I have tried everything. I followed the suggestion on the question here Test pipe with dependencies on services and imported browserModule instead of CommonModule all to no avail. Please how do i inject this dependency ? Any help would be appreciated

Nuru Salihu
  • 4,756
  • 17
  • 65
  • 116

1 Answers1

0

Just importing the dependency below in my tests.ts fixed the issue for me.

import "core-js/es7/reflect";

Thanks to Odolha from the thread here https://github.com/angular/angular/issues/19417

Nuru Salihu
  • 4,756
  • 17
  • 65
  • 116