General Assertions

Other general assertions and helpers available are is, isDone, returns, and inspect.

Assertion Description
is General purpose deep equal assertion
isDone Assert at end of saga
returns Assert saga returns a value and is done
inspect Inspect the next yielded value for more fine-grained, custom testing

Generic Example

import { take } from 'redux-saga/effects';

function* mainSaga() {
  yield 42;
  yield { foo: { bar: 'baz' } };

let saga = testSaga(mainSaga);


  .is({ foo: { bar: 'baz' } })


returns Example

function* otherSaga(x) {
  return x * 2;

const saga = testSaga(otherSaga, 21);


inspect Example

If your saga yields a nondeterministic type of value or something not easily covered by the effect assertions or other general assertions, then you can use inspect to retrieve the actual yielded value and perform your own assertions with your favorite assertion library.

function* saga() {
  yield () => 42;

  .inspect((fn) => {

results matching ""

    No results matching ""