加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 模块’DynamicTestModule’导入的意外值’DecoratorF

发布时间:2020-12-17 17:08:43 所属栏目:安全 来源:网络整理
导读:我在创建Test组件实例时遇到错误. let comp: TaskviewComponent;let fixture: ComponentFixture;let deTaskTitle: DebugElement;let elSub: HTMLElement;describe('TaskviewComponent',() = { beforeEach( () = { TestBed.configureTestingModule({ declarat
我在创建Test组件实例时遇到错误.

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 ');
});
});

我收到错误:由模块’DynamicTestModule’错误导入的意外值’DecoratorFactory’.我注意到如果我删除“fixture = TestBed.createComponent(TaskviewComponent);”错误将得到解决.但这不会创建测试组件.另外,我注意到如果我在import []中不包含NgModule,则不会识别Ngmodel,datepicker等元素.

解决方法

您不能导入“NgModule”,因为它是装饰器而不是模块.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读