Невозможно провести модульное тестирование эпопеи, наблюдаемой - PullRequest
0 голосов
/ 22 октября 2018

Я новичок в наблюдении за редуксом и пишу свое первое тестирование на моем первом эпосе.Этот эпос в основном имеет дело с функцией входа в Facebook.

export const facebookLoginEpic = action$ => action$.pipe(
  ofType(authActionTypes.FACEBOOK_LOGIN_INIT),
  switchMap(() => from$(FacebookSDK.fbLogin()).pipe(
    mergeMap(data=> {
      navigate('DRAWER');
      return of$(
        fetchUserSuccess(data),
        saveUserInfoSuccess(data),
      );
    }),
    catchError(error => fetchUserFailure(error)),
  )),
);

Затем я пытаюсь зарегистрировать вывод $, чтобы проверить мою идею.

test.js

import { ActionsObservable } from 'redux-observable';
import * as authActionTypes from '../authTypes';
import { facebookLoginEpic } from '../authEpics';

it('Should return the fetchUserSuccess and saveUserInfoSuccess actions', () => {
  const action$ = ActionsObservable.of({
    type: authActionTypes.FACEBOOK_LOGIN_INIT,
  });

  const output$ = facebookLoginEpic(action$);
  console.log(output$)
});

но всегда получаю ошибку

xxxxxxx/node_modules/rxjs/internal/util/hostReportError.js:4
    setTimeout(function () { throw err; });
                             ^

TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
    at Object.<anonymous>.exports.subscribeTo (/Users/rae/Project/partido/node_modules/rxjs/internal/util/subscribeTo.js:42:15)
    at Object.subscribeToResult (/Users/rae/Project/partido/node_modules/rxjs/internal/util/subscribeToResult.js:10:26)
    at CatchSubscriber.Object.<anonymous>.CatchSubscriber.error (/Users/rae/Project/partido/node_modules/rxjs/internal/operators/catchError.js:57:33)
    at MergeMapSubscriber.Object.<anonymous>.Subscriber._error (/Users/rae/Project/partido/node_modules/rxjs/internal/Subscriber.js:96:26)
    at MergeMapSubscriber.Object.<anonymous>.Subscriber.error (/Users/rae/Project/partido/node_modules/rxjs/internal/Subscriber.js:74:18)
    at /Users/rae/Project/partido/node_modules/rxjs/internal/util/subscribeToPromise.js:10:43
    at tryCallOne (/Users/rae/Project/partido/node_modules/promise/lib/core.js:37:12)
    at /Users/rae/Project/partido/node_modules/promise/lib/core.js:123:15
    at flush (/Users/rae/Project/partido/node_modules/asap/raw.js:50:29)
    at process._tickCallback (internal/process/next_tick.js:172:11)
error Command failed with exit code 1.

Я прочитал много статей и потратил много времени на эту проблему.Но до сих пор нет никакого прогресса.Что-то я не так сделал в своем тесте или эпопее?

...