How to use redux-saga-tester - 10 common examples

To help you get started, we’ve selected a few redux-saga-tester examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / addons-frontend / tests / unit / test_helpers.js View on Github external
function startSagaTester(handler, { startSaga = true } = {}) {
      const sagaTester = new SagaTester({
        initialState: {},
        reducers: { example: (state = {}) => state },
      });

      function* exampleSaga() {
        yield takeLatest(START_EXAMPLE, handler);
      }

      sagaTester.start(exampleSaga);
      if (startSaga) {
        sagaTester.dispatch({ type: START_EXAMPLE });
      }

      return sagaTester;
    }
github mlaursen / react-md / documentation / src / sagas / __tests__ / sassdocs.js View on Github external
it('should correctly handle sassdocs that have a section', async () => {
    const sagaTester = new SagaTester({ initialState: { sassdocs: {} } });
    const data = { name: 'layovers' };
    fetchSassdoc.mockImplementation(() => data);
    sagaTester.start(watchSassdocRequests);
    sagaTester.dispatch(sassdocRequest('layovers', 'helpers'));
    sagaTester.dispatch(done());

    await sagaTester.waitFor(DONE);
    expect(fetchSassdoc).toBeCalledWith('helpers/layovers');
    const expected = [
      sassdocRequest('layovers', 'helpers'),
      sassdocSuccess(['helpers', 'layovers'], data),
      done(),
    ];
    expect(sagaTester.getCalledActions()).toEqual(expected);
  });
github mozilla / addons-frontend / tests / unit / disco / sagas / test_disco.js View on Github external
beforeEach(() => {
      errorHandler = createStubErrorHandler();
      mockApi = sinon.mock(api);

      const { state } = dispatchSignInActions();
      apiState = state.api;
      sagaTester = new SagaTester({
        initialState: state,
        reducers: {
          addons: addonsReducer,
          api: apiReducer,
          discoResults: discoResultsReducer,
        },
      });

      sagaTester.start(discoSaga);
    });
github mozilla / addons-frontend / tests / unit / core / sagas / test_versions.js View on Github external
beforeEach(() => {
    errorHandler = createStubErrorHandler();
    mockApi = sinon.mock(versionsApi);
    clientData = dispatchClientMetadata();
    sagaTester = new SagaTester({
      initialState: clientData.state,
      reducers: {
        api: apiReducer,
        versions: versionsReducer,
      },
    });
    sagaTester.start(versionsSaga);
  });
github mozilla / addons-frontend / tests / unit / core / sagas / test_autocomplete.js View on Github external
beforeEach(() => {
    errorHandler = createStubErrorHandler();
    mockApi = sinon.mock(api);
    const initialState = dispatchSignInActions().state;
    sagaTester = new SagaTester({
      initialState,
      reducers: {
        api: apiReducer,
        autocomplete: autocompleteReducer,
      },
    });
    sagaTester.start(autocompleteSaga);
  });
github mozilla / addons-frontend / tests / unit / amo / sagas / test_landing.js View on Github external
beforeEach(() => {
      errorHandler = createStubErrorHandler();
      mockSearchApi = sinon.mock(searchApi);

      const { state } = dispatchClientMetadata();
      apiState = state.api;
      sagaTester = new SagaTester({
        initialState: state,
        reducers: {
          api: apiReducer,
          landing: landingReducer,
        },
      });

      sagaTester.start(landingSaga);
    });
github mozilla / addons-frontend / tests / unit / amo / sagas / test_home.js View on Github external
beforeEach(() => {
    errorHandler = createStubErrorHandler();
    mockCollectionsApi = sinon.mock(collectionsApi);
    mockHeroApi = sinon.mock(heroApi);
    mockSearchApi = sinon.mock(searchApi);
    sagaTester = new SagaTester({
      initialState: dispatchClientMetadata().state,
      reducers: {
        api: apiReducer,
        home: homeReducer,
      },
    });
    sagaTester.start(homeSaga);
  });
github mozilla / addons-frontend / tests / unit / amo / sagas / test_guides.js View on Github external
beforeEach(() => {
    errorHandler = createStubErrorHandler();
    mockApi = sinon.mock(searchApi);
    guids = ['support@lastpass.com', '{b76ed4e7-12a6-4f25-a27b-fc3f93289008}'];

    const initialState = dispatchClientMetadata().state;

    sagaTester = new SagaTester({
      initialState,
      reducers: {
        api: apiReducer,
        guides: addonsReducer,
      },
    });
    sagaTester.start(guidesSaga);
  });
github mozilla / addons-frontend / tests / unit / amo / sagas / test_recommendations.js View on Github external
beforeEach(() => {
    const clientData = dispatchClientMetadata();
    errorHandler = createStubErrorHandler();
    mockApi = sinon.mock(recommendationsApi);
    sagaTester = new SagaTester({
      initialState: clientData.state,
      reducers: {
        api: apiReducer,
        recommendations: recommendationsReducer,
      },
    });
    sagaTester.start(recommendationsSaga);
  });
github mozilla / addons-frontend / tests / unit / core / sagas / test_search.js View on Github external
beforeEach(() => {
    errorHandler = createStubErrorHandler();
    mockApi = sinon.mock(api);
    const initialState = dispatchSignInActions().state;
    sagaTester = new SagaTester({
      initialState,
      reducers: { api: apiReducer, search: searchReducer },
    });
    sagaTester.start(searchSaga);
  });

redux-saga-tester

Full redux environment testing helper for redux-saga

MIT
Latest version published 4 years ago

Package Health Score

57 / 100
Full package analysis

Popular redux-saga-tester functions