Redux ofType不是rxjs大理石图测试中的函数

Redux ofType不是rxjs大理石图测试中的函数,redux,rxjs,rxjs6,redux-observable,Redux,Rxjs,Rxjs6,Redux Observable,我正在使用rxjs 6和redux observable 1,并为epic编写测试 const signInEpic = action$ => action$ .ofType(authActions.signIn) .pipe( switchMap(mapSignInAction$) ) 我使用TestScheduler通过大理石图进行测试,运行测试时返回错误action$。of type不是一个函数 测试: 错误是正确的,因为您创建了hot()O

我正在使用rxjs 6和redux observable 1,并为epic编写测试

const signInEpic = action$ =>
  action$
    .ofType(authActions.signIn)
    .pipe(
      switchMap(mapSignInAction$)
    )
我使用TestScheduler通过大理石图进行测试,运行测试时返回错误
action$。of type不是一个函数

测试:


错误是正确的,因为您创建了
hot()
Observable,然后将其传递给
signenepic
方法。但是,ofType的
在Observable类上不存在,此方法特定于
redux Observable

只需快速查看源代码,您就可以创建一个可以自己观察的模拟
$actions

例如:

import { ActionsObservable } from 'redux-observable';

scheduler.run(({ cold, hot, expectObservable }) => {
  const source = hot('-a', { a: { type: 'HFJKDHF' } });
  const actions$ = ActionsObservable.of(source);

  const state$ = null
  const output$ = signInEpic(action$, state$)

  expectObservable(output$).toBe('--b', {
    b: actions.signInSuccess(response);
  });
});

相反,
action$of type
需要使用
action$.pipe(of type(…),…)


非常感谢。你知道为什么在epic中使用hot创建模拟流动作时不存在动作流,而动作来自SubscriptionLoggable吗?我想我不明白你有什么问题。它返回的是
SubscriptionLoggable
?是的,如果我在epic-come
{type:''.',payload:{…}}
中删除hot-come,但是使用hot-come
SubscriptionLoggable
,当它通过类型
时,就不存在
{type:'.'''.',payload:{…}
,并且epic不调用
import { ActionsObservable } from 'redux-observable';

scheduler.run(({ cold, hot, expectObservable }) => {
  const source = hot('-a', { a: { type: 'HFJKDHF' } });
  const actions$ = ActionsObservable.of(source);

  const state$ = null
  const output$ = signInEpic(action$, state$)

  expectObservable(output$).toBe('--b', {
    b: actions.signInSuccess(response);
  });
});
import { ofType } from 'redux-observable'

action$
    .pipe(
      ofType(authActions.signIn),
      switchMap(mapSignInAction$)
    )