I'm getting error during creating Test component instance.
let comp: TaskviewComponent;
let fixture: ComponentFixture;
let deTaskTitle: DebugElement;
let elSub: HTMLElement;
describe('TaskviewComponent', () => {
beforeEach( () => {
TestBed.configureTestingModule({
declarations: [
TaskviewComponent
],
imports: [
NgModule,
RouterTestingModule,
TranslateModule.forRoot(),
],
providers: [
RestDataService,
Restangular,
{provide: OAuthService, useClass: OAuthServicMock},
{provide: ComponentFixtureAutoDetect, useValue: true},
{provide: UserInfoService, useClass: UserInfoServiceMock},
{
provide: LocalStorageService, //provide: LOCAL_STORAGE_SERVICE_CONFIG,
useValue: {
prefix: ApplicationConstants.ANGULAR2_LOCAL_STORAGE_ID,
storageType: 'sessionStorage'
}
}],,
})
fixture = TestBed.createComponent(TaskviewComponent);
comp = fixture.componentInstance;
deTaskTitle = fixture.debugElement.query((By.css('.Subject')));
elSub = deTaskTitle.nativeElement;
});
it('should have a subject', () => {
expect(elSub.textContent).toContain('Client Data Maintenance2 ');
});
});
I'm getting Error: Unexpected value 'DecoratorFactory' imported by the module 'DynamicTestModule' error. I notice that if I remove "fixture = TestBed.createComponent(TaskviewComponent);" error would be resolved. but this will not create the Test Component. Also, I notice that if I don't include NgModule in imports[], elements like Ngmodel, datepicker etc.are not recognized.
You can't import "NgModule" as it is a decorator and not a module.