New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redux-saga-test

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-saga-test

My finest module

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
57
decreased by-22.97%
Maintainers
2
Weekly downloads
 
Created
Source

redux-saga-test Build Status

A little helper to test [redux-saga][rs].

Install

$ npm install --save-dev redux-saga-test

Usage

The saga under test.

function * testSaga () {
  try {
    yield put({type: 'FETCHING'})
    const data = yield call(loadData)
    yield put({type: 'FETCHED', payload: data})
  } catch (e) {
    yield put({type: 'FETCHED', payload: e})
  }

The test looks like this:

const fromGenerator = require('redux-saga-test');

test('saga', (t) => {
  const expect = fromGenerator(t, testSaga()) // <= pass your assert library with a `deepEqual` method.

  expect.next().put({type: 'FETCHING'})
  expect.next().call(loadData)
  expect.next(mockData).put({type: 'FETCHED', payload: mockData})
  expect.next().returns()
})

To test a watcher you can use expect.takeEvery/takeLatest.

The watcher:

function * watchEvery () {
  yield * takeEvery('TEST_ACTION', testSaga)
}

The test:

test('takeEvery', (t) => {
  const expect = fromGenerator(t, watchEvery())
  expect.takeEvery('TEST_ACTION', testSaga)
})

For more examples look at the tests

License

MIT © Stoeffel

Keywords

FAQs

Package last updated on 16 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc