Unexpected value of DecoratorFactory imported by DynamicTestModule - karma jasmine

I get an error while instantiating a test component.

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 get an error: Unexpected value of "DecoratorFactory" imported by module "DynamicTestModule". I notice that if I remove "fixture = TestBed.createComponent (TaskviewComponent)"; the error will be resolved. but this will not create a test component. In addition, I notice that if I do not include NgModule in import [], elements such as Ngmodel, datepicker, etc., are not recognized.

+4
source share
1 answer

"NgModule", , .

+1

Source: https://habr.com/ru/post/1664519/


All Articles