模块'DynamicTestModule'导入的意外值'DecoratorFactory'。请添加@NgModule注释

问题描述 投票:3回答:1

这是我的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();
  });


});

我收到此错误:

模块'DynamicTestModule'导入的意外值'DecoratorFactory'。请添加@NgModule注释。

angular testing jasmine karma-runner
1个回答
0
投票

如果您使用了NgModule并且缺少NgModule来导入,我们希望这样的错误。因此,如果您使用它,请务必导入NgModule:"import {NgbModule} from '@ng-bootstrap/ng-bootstrap';"

© www.soinside.com 2019 - 2024. All rights reserved.