这是我的spec文件:
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();
});
});
我收到此错误:
模块导入的意外值'DecoratorFactory' 'DynamicTestModule'。请添加@NgModule注释。
答案 0 :(得分:0)
如果您使用了NgModule并且缺少NgModule来导入,我们希望这样的错误。
因此,如果您使用NgModule,请务必导入:"import {NgbModule} from '@ng-bootstrap/ng-bootstrap';"