gpt4 book ai didi

angular - 模块 'DecoratorFactory' 导入了意外值 'DynamicTestModule'。请添加@NgModule 注解

转载 作者:太空狗 更新时间:2023-10-29 19:33:45 25 4
gpt4 key购买 nike

这是我的规范文件:

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


});

我收到这个错误:

Unexpected value 'DecoratorFactory' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation.

最佳答案

如果您使用了 NgModule 并且缺少 NgModule 来导入,我们预计会出现此类错误。因此,如果您正在使用它,请确保导入 NgModule:"import {NgbModule} from '@ng-bootstrap/ng-bootstrap';"

关于angular - 模块 'DecoratorFactory' 导入了意外值 'DynamicTestModule'。请添加@NgModule 注解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47747353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com