Angular 意外值';装饰工厂';由模块导入';DynamicTestModule';。请添加@NgModule注释
这是我的规范文件:Angular 意外值';装饰工厂';由模块导入';DynamicTestModule';。请添加@NgModule注释,angular,testing,jasmine,karma-runner,Angular,Testing,Jasmine,Karma Runner,这是我的规范文件: import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; import { ScorecardComponent } from './scorecard.componen
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { ScorecardComponent } from './scorecard.component';
import { DataService } from '../data.service';
import { HttpModule } from '@angular/http';
import { Component } from '@angular/core';
describe('ScorecardComponent', () => {
let comp: ScorecardComponent;
let fixture: ComponentFixture<ScorecardComponent>;
let de: DebugElement;
let el: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ScorecardComponent ],
imports: [ Component, HttpModule ],
providers: [ DataService ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ScorecardComponent);
comp = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(comp).toBeTruthy();
});
});
从'@angular/core/testing'导入{ComponentFixture,TestBed,async};
从“@angular/platform browser”导入{By}”;
从“@angular/core”导入{DebugElement};
从“./scorecard.component”导入{ScorecardComponent};
从“../data.service”导入{DataService};
从'@angular/http'导入{HttpModule};
从'@angular/core'导入{Component};
描述('记分卡组件',()=>{
let comp:记分卡组件;
let夹具:组件夹具;
设de:DebugElement;
让el:HTMLElement;
beforeach(异步(()=>{
TestBed.configureTestingModule({
声明:[记分卡组件],
导入:[组件,HttpModule],
提供者:[数据服务]
})
.compileComponents();
}));
在每个之前(()=>{
fixture=TestBed.createComponent(记分卡组件);
comp=夹具。组件状态;
fixture.detectChanges();
});
它('应该创建',()=>{
expect(comp.toBeTruthy();
});
});
我得到这个错误:
模块导入的意外值“DecoratorFactory”
“动态测试模块”。请添加@NgModule注释
如果您在导入时使用了NgModule和缺少NgModule,我们预计会出现此类错误。
因此,如果您正在使用NgModule,请确保导入它:
“从'@ng bootstrap/ng bootstrap'导入{NgbModule};”“
从导入阵列中删除组件
如果我从导入阵列中删除组件,我会在下面的错误中删除它导入:[Component,HttpModule],
如果我从导入数组中删除组件,我会得到以下错误-失败:模板分析错误:没有将“exportAs”设置为“ngbDropdown”的指令导入NgbDropdownModule