Angular6测试:Ngrx Select上的茉莉花错误保护

时间:2019-03-27 21:19:50

标签: angular jasmine karma-jasmine ngrx

我有一个后卫,我在哪里呼叫NGRX选择来设置后卫

pipe of undefined

下面是我在没有使用JEST的情况下编写的测试案例 ,并且在fdescribe('AppGuard', () => { let service: AppGuard; beforeEach(() => { const storeStub = { pipe: () => ({ pipe: () => ({}) }), dispatch: () => ({}) }; TestBed.configureTestingModule({ providers: [AppGuard, { provide: Store, useValue: storeStub }] }); service = TestBed.get(AppGuard); }); it('can load instance', () => { expect(service).toBeTruthy(); }); describe('canActivate', () => { it('makes expected calls', () => { spyOn(service, 'checkAppStore'); service.canActivate(); expect(service.checkAppStore).toHaveBeenCalled(); }); }); describe('checkAppStore', () => { it('makes expected calls', () => { const storeStub: Store<any> = TestBed.get(Store); spyOn(storeStub, 'pipe'); spyOn(storeStub, 'dispatch'); service.checkAppStore(); expect(storeStub.pipe).toHaveBeenCalled(); expect(storeStub.dispatch).toHaveBeenCalled(); }); }); }); 上出现了错误

TypeError: Cannot read property 'pipe' of undefined

我得到的错误是 library(dplyr) library(tidyr) library(tibble) library(parallel) #You seem to have rows of data that should be columns, # this puts things in a form more suitable for work in R df_new <- df %>% mutate(row = 1:n()) %>% gather(key = sample,value = val,sample1:sample4) %>% arrange(row,sample) #Data in rownames is not terribly useful traits_new <- rownames_to_column(traits,"sample") #Now we can put it all in *one* data frame df_new <- left_join(df_new, traits_new, by = "sample") #...and split it into a list representing each of the df's you # want a lm() fit on df_new_split <- split(df_new,df_new$row) #Wrapper for lm with the only formula we need fit_lm <- function(x){ lm(val ~ var1,data = x) } num_cores <- detectCores() - 1 cl <- makeCluster(num_cores) results <- parLapply(cl = cl,df_new_split,fit_lm)

(甚至可以在没有JEST或模拟存储的情况下对NGRX选择命令进行单元测试吗?)

0 个答案:

没有答案