Karma jasmine NullInjectorError:在角度规范文件测试中没有ReducerManager的提供程序

Karma jasmine NullInjectorError:在角度规范文件测试中没有ReducerManager的提供程序,karma-jasmine,angular7,angular-test,Karma Jasmine,Angular7,Angular Test,我正在测试基于ngrx/store的组件。测试时获取NullInjectorError:没有ReducerManager的提供程序 错误消息: StaticInjectorError(Platform: core)[StoreFeatureModule -> ReducerManager]: NullInjectorError: No provider for ReducerManager! Error: StaticInjectorError(DynamicTestModu

我正在测试基于
ngrx/store
的组件。测试时获取
NullInjectorError:没有ReducerManager的提供程序

错误消息:

  StaticInjectorError(Platform: core)[StoreFeatureModule -> ReducerManager]: 
    NullInjectorError: No provider for ReducerManager!
Error: StaticInjectorError(DynamicTestModule)[StoreFeatureModule -> ReducerManager]: 
  StaticInjectorError(Platform: core)[StoreFeatureModule -> ReducerManager]: 
    NullInjectorError: No provider for ReducerManager!
如何解决这个问题?这是我的测试规范文件:


    import { HeaderNavShellComponent } from './header-nav-shell.component';
    import { HeaderComponent } from './../../header/header.component';
    import { HeaderNavComponent } from './../../components/header-nav/header-nav.component';
    import { StoreModule, Store  } from '@ngrx/store';
    import { TranslateFakeLoader,TranslateLoader,TranslateModule,TranslateService, TranslateStore } from '@ngx-translate/core';
    import { RouterTestingModule } from '@angular/router/testing';
    import { reducerShared } from "./../../state/reducers/shared.reducer";
    import { HttpClientModule, HttpClient } from '@angular/common/http';
    import { of } from 'rxjs';
    import * as fromRoot from  "./../../../calendar/state";
    // import { reducerCalendar } from  "./../../../calendar/state/calendar.reducer";


    describe('HeaderNavShellComponent', () => {

        let component: HeaderNavShellComponent;
        let fixture: ComponentFixture<HeaderNavShellComponent>;
        let dispatchSpy;
        let store:Store<fromRoot.NewState>

        beforeEach(async(() => {
            TestBed.configureTestingModule({
                declarations: [ HeaderNavShellComponent, HeaderComponent, HeaderNavComponent ],
                imports:[
                    HttpClientModule,
                    StoreModule.forFeature("shared", reducerShared ),
                    RouterTestingModule,
                    TranslateModule.forChild({
                      loader: {
                            provide: TranslateLoader,
                            useClass: TranslateFakeLoader
                      }
                    })
                ],
                providers:[TranslateService, TranslateStore, HttpClient ]
            })
            .compileComponents();
        }));

         beforeEach(fakeAsync(() => {

            store = TestBed.get(Store);
            spyOn(store, 'dispatch').and.callThrough();

            fixture = TestBed.createComponent(HeaderNavShellComponent);
            component = fixture.componentInstance;
            fixture.detectChanges();

        }));


        it('should create', fakeAsync(() => {
            expect(component).toBeTruthy();
        }));

    });

从“./header nav shell.component”导入{HeaderNavShellComponent};
从'./../../header/header.component'导入{HeaderComponent};
从“./../components/header nav/header nav.component”导入{HeaderNaviComponent};
从'@ngrx/Store'导入{StoreModule,Store};
从“@ngx translate/core”导入{TranslateFakeLoader、TranslateLoader、TranslateModule、TranslateService、TranslateStore};
从“@angular/router/testing”导入{RouterTestingModule};
从“/./../state/reducers/shared.reducer”导入{reducerShared}”;
从'@angular/common/http'导入{HttpClientModule,HttpClient};
从'rxjs'导入{of};
从“/../../../../calendar/state”以根目录形式导入*;
//从“/../../../../calendar/state/calendar.reducer”导入{reducerCalendar}”;
描述('HeaderNavShellComponent',()=>{
let组件:HeaderNavShellComponent;
let夹具:组件夹具;
让派遣间谍;
让商店:商店
beforeach(异步(()=>{
TestBed.configureTestingModule({
声明:[HeaderNavShellComponent,HeaderComponent,HeaderNavComponent],
进口:[
HttpClientModule,
StoreModule.forFeature(“共享”,reducerShared),
路由器测试模块,
TranslateModule.forChild({
          加载器:{
            提供:TranslateLoader,
            useClass:TranslateFakeLoader
          }
                })
],
提供者:[TranslateService、TranslateStore、HttpClient]
})
.compileComponents();
}));
beforeach(fakeAsync(()=>{
store=TestBed.get(store);
spyOn(存储,'dispatch')。和.callThrough();
fixture=TestBed.createComponent(HeaderNavShellComponent);
组件=fixture.componentInstance;
fixture.detectChanges();
}));
它('should create',fakeAsync(()=>{
expect(component.toBeTruthy();
}));
});
以下是ts文件:

    import { Component, OnInit } from '@angular/core';
    import { Router } from '@angular/router';
    import { Store, select } from "@ngrx/store";
    import { Observable } from "rxjs";
    import { ModelEvent, EventState } from "./../../../calendar/models/model.event";
    import { ModelLang, ModelLonguage } from "./../../../shared-components/models/models";
    import { CalendarActions, Load, EventSelected } from "./../../../calendar/state/calendar.actions";
    import * as fromRoot from  "./../../../calendar/state";
    import * as fromObservables from  "./../../state";
    import { Lang, LoadLang } from "./../../state/actions/shared.actions";
    import { ShowNavi } from "./../../../shared-components/state/actions/shared.actions";

    @Component({
        selector: 'header-nav-shell',
        templateUrl: './header-nav-shell.component.html',
        styleUrls: ['./header-nav-shell.component.scss']
    })
    export class HeaderNavShellComponent implements OnInit {

        eventList$:Observable<ModelEvent[]>;
        eventListSize$:number;
        currentLang$:Observable<string>;
        langList$:Observable<ModelLonguage[]>;

        constructor(private store:Store<fromRoot.NewState>, private router:Router) { }

        ngOnInit() {
            this.store.dispatch(new Load());
            this.store.dispatch( new LoadLang());
            this.eventList$ = this.store.pipe(select(fromRoot.getEvents));
            this.currentLang$ = this.store.pipe(select(fromObservables.getCurrentLang));
            this.langList$ = this.store.pipe(select(fromObservables.getLangList));
        }

        eventSelected(event) {
            this.store.dispatch(new EventSelected(event));
            this.router.navigateByUrl("iboCalendar");
        }

        langChanged(event) {
            this.store.dispatch( new Lang(event.Name));
        }

        leftNaviHandler(event):void {
            this.store.dispatch(new ShowNavi(event));
        }

    }
从'@angular/core'导入{Component,OnInit};
从'@angular/Router'导入{Router};
导入{Store,从“@ngrx/Store”中选择};
从“rxjs”导入{observeable};
从“/../../../../calendar/models/models.event”导入{ModelEvent,EventState}”;
从“/../../../../shared components/models/models”导入{ModelLang,ModelLonguage}”;
从“/../../../../calendar/state/calendar.actions”导入{CalendarActions,Load,EventSelected};
从“/../../../../calendar/state”以根目录形式导入*;
从“/./../state”导入*作为可观察对象;
从“/./../state/actions/shared.actions”导入{Lang,LoadLang}”;
从“/../../../../shared components/state/actions/shared.actions”导入{ShowNavi};
@组成部分({
选择器:“标题导航外壳”,
templateUrl:'。/header nav shell.component.html',
样式URL:['./标题nav shell.component.scss']
})
导出类HeaderNavShellComponent实现OnInit{
eventList$:可观察的;
eventListSize$:编号;
currentLang$:可观察的;
langList$:可观察;
构造函数(私有存储:存储,私有路由器:路由器){}
恩戈尼尼特(){
this.store.dispatch(new Load());
this.store.dispatch(new LoadLang());
this.eventList$=this.store.pipe(选择(fromRoot.getEvents));
this.currentLang$=this.store.pipe(选择(fromObservables.getCurrentLang));
this.langList$=this.store.pipe(选择(fromObservables.getLangList));
}
已选择事件(事件){
this.store.dispatch(选择新事件(事件));
这个.router.navigateByUrl(“iboCalendar”);
}
语言变化(事件){
this.store.dispatch(newlang(event.Name));
}
leftNaviHandler(事件):无效{
此.store.dispatch(新ShowNavi(事件));
}
}
提前谢谢