获取错误模块'DynamicTestModule'声明了意外的值'undefined'

我在Stack Overflow中检查了几个答案,但无法解决我的问题

这是我的Spec文件代码

    import { async,ComponentFixture,TestBed } from '@angular/core/testing';
    import { DashboardComponent } from './dashboard.component';
    import { MatMenuModule} from '@angular/material/menu';
    import { Dashboardmodule } from './dashboard.module';
    import { DataService } from 'src/app/shared/data.service';




    describe('DashboardComponent.forRoot()',() => {
      let component: DashboardComponent;
      let fixture: ComponentFixture<DashboardComponent>;
      let menu: MatMenuModule;

      beforeEach(async(() => {
        TestBed.configureTestingModule({
          imports:[
              Dashboardmodule.forRoot()
            ],declarations: [ DashboardComponent,menu ]
        })
        .compileComponents();
      }));

      beforeEach(() => {
        fixture = TestBed.createComponent(DashboardComponent);
        component = fixture.componentInstance;
        fixture.detectChanges();
      });

      it('should create',() => {
        expect(component).toBeTruthy();
      });
      it(`should not provide 'DataService' service`,() => {
        expect(() => TestBed.get(DataService)).toThrowError(/No provider for/);
        });
    });

我遇到错误了

Failed: Unexpected value 'undefined' declared by the module 'DynamicTestModule'

我该如何解决?

keith_ye_mao 回答:获取错误模块'DynamicTestModule'声明了意外的值'undefined'

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2789356.html

大家都在问