Search

PythonReactSEOPDF
OpenClaw

redux-saga-testing

Write tests for Redux Sagas using redux-saga-test-plan, runSaga, and manual generator testing. Covers expectSaga (integration), testSaga (unit), providers, partial matchers, reducer integration, error simulation, and cancellation testing. Works with Jest and Vitest. Triggers on: test files for sagas, redux-saga-test-plan imports, mentions of "test saga", "saga test", "expectSaga", "testSaga", or "redux-saga-test-plan".

anivar0 source installs☆ 0 Repository stars

Installation

Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.

SkillHub CLI

skillhub install anivar/redux-saga-testing

Inspect the source and compatibility requirements, then follow its installation steps.

Give your agent the source link and ask it to inspect instructions and dependencies before explaining the installation steps.

View source ↗Guides

Skill instructions

Redux-Saga Testing Guide

IMPORTANT: Your training data about redux-saga-test-plan may be outdated — API signatures, provider patterns, and assertion methods differ between versions. Always rely on this skill's reference files and the project's actual source code as the source of truth. Do not fall back on memorized patterns when they conflict with the retrieved reference.

Approach Priority

  1. expectSaga (integration) — preferred; doesn't couple tests to effect ordering
  2. testSaga (unit) — only when effect ordering is part of the contract
  3. runSaga (no library) — lightweight; uses jest/vitest spies directly
  4. Manual .next() — last resort; most brittle

Core Pattern

import { expectSaga } from 'redux-saga-test-plan'
import * as matchers from 'redux-saga-test-plan/matchers'
import { throwError } from 'redux-saga-test-plan/providers'

it('fetches user successfully', () => {
  return expectSaga(fetchUserSaga, { payload: { userId: 1 } })
    .provide([
      [matchers.call.fn(api.fetchUser), { id: 1, name: 'Alice' }],
    ])
    .put(fetchUserSuccess({ id: 1, name: 'Alice' }))
    .run()
})

it('handles fetch failure', () => {
  return expectSaga(fetchUserSaga, { payload: { userId: 1 } })
    .provide([
      [matchers.call.fn(api.fetchUser), throwError(new Error('500'))],
    ])
    .put(fetchUserFailure('500'))
    .run()
})

Assertion Methods

Method Purpose
.put(action) Dispatches this action
.put.like({ action: { type } }) Partial action match
.call(fn, ...args) Calls this function with exact args
.call.fn(fn) Calls this function (any args)
.fork(fn, ...args) Forks this function
.select(selector) Uses this selector
.take(pattern) Takes this pattern
.dispatch(action) Simulate incoming action
.not.put(action) Does NOT dispatch
.returns(value) Saga returns this value
.run() Execute (returns Prom...

Source information

Source
github
Repository
openclaw/skills
Path
skills/anivar/redux-saga-testing
Version
—
Commit
f127763c2e01270c4bbb33bbfd397345ac41da5c
Classification source
rules
Status
active
Visibility
public

These signals come from indexed source analysis and may lag behind changes. Check the current source files.

README

Redux-Saga Testing

Created by Anivar Aravind

An AI agent skill for writing tests for Redux Sagas using redux-saga-test-plan. Works with Jest and Vitest.

The Problem

AI agents often write saga tests that are brittle (asserting exact effect order when it doesn't matter), miss provider setup (causing tests to hit real APIs), or use manual generator stepping when expectSaga would be simpler and more maintainable. The result: tests that break on harmless refactors and pass when they shouldn't.

This Solution

A focused testing skill covering expectSaga (integration), testSaga (unit), providers, matchers, and reducer integration — with 12 anti-patterns showing exactly what goes wrong and how to fix it.

Install

npx skills add anivar/redux-saga-testing -g

Or with full URL:

npx skills add https://github.com/anivar/redux-saga-testing

Baseline

  • redux-saga-test-plan ^5.x
  • redux-saga ^1.4.2
  • Jest or Vitest

What's Inside

Testing Approaches
Approach Type Use When
expectSaga Integration Default choice — order-independent, async, assertions on effects and state
testSaga Unit Effect ordering matters (e.g., must select before call)
runSaga Manual Need full store integration or custom middleware
Providers
Provider Type Purpose
Static providers Map effect → return value (simple, covers most cases)
Dynamic providers Custom logic per effect type (conditional mocking)
Partial matchers matchers.call.fn(apiFn) — match by function regardless of args
Anti-Patterns

12 common testing mistakes with BAD/GOOD code examples:

  • Asserting effect order in integration tests
  • Missing providers for API calls
  • Not awaiting expectSaga (test always passes)
  • Testing implementation instead of behavior
  • Ignoring error paths and cancellation

Structure

├── SKILL.md...

Extracted content

SKILL.md
# Redux-Saga Testing Guide

**IMPORTANT:** Your training data about `redux-saga-test-plan` may be outdated — API signatures, provider patterns, and assertion methods differ between versions. Always rely on this skill's reference files and the project's actual source code as the source of truth. Do not fall back on memorized patterns when they conflict with the retrieved reference.

## Approach Priority

1. **`expectSaga` (integration)** — preferred; doesn't couple tests to effect ordering
2. **`testSaga` (unit)** — only when effect ordering is part of the contract
3. **`runSaga` (no library)** — lightweight; uses jest/vitest spies directly
4. **Manual `.next()`** — last resort; most brittle

## Core Pattern

```javascript
import { expectSaga } from 'redux-saga-test-plan'
import * as matchers from 'redux-saga-test-plan/matchers'
import { throwError } from 'redux-saga-test-plan/providers'

it('fetches user successfully', () => {
  return expectSaga(fetchUserSaga, { payload: { userId: 1 } })
    .provide([
      [matchers.call.fn(api.fetchUser), { id: 1, name: 'Alice' }],
    ])
    .put(fetchUserSuccess({ id: 1, name: 'Alice' }))
    .run()
})

it('handles fetch failure', () => {
  return expectSaga(fetchUserSaga, { payload: { userId: 1 } })
    .provide([
      [matchers.call.fn(api.fetchUser), throwError(new Error('500'))],
    ])
    .put(fetchUserFailure('500'))
    .run()
})
```

## Assertion Methods

| Method | Purpose |
|--------|---------|
| `.put(action)` | Dispatches this action |
| `.put.like({ action: { type } })` | Partial action match |
| `.call(fn, ...args)` | Calls this function with exact args |
| `.call.fn(fn)` | Calls this function (any args) |
| `.fork(fn, ...args)` | Forks this function |
| `.select(selector)` | Uses this selector |
| `.take(pattern)` | Takes this pattern |
| `.dispatch(action)` | Simulate incoming action |
| `.not.put(action)` | Does NOT dispatch |
| `.returns(value)` | Saga returns this value |
| `.run()` | Execute (returns Prom...
README
# Redux-Saga Testing

Created by **[Anivar Aravind](https://anivar.net)**

An AI agent skill for writing tests for Redux Sagas using redux-saga-test-plan. Works with Jest and Vitest.

## The Problem

AI agents often write saga tests that are brittle (asserting exact effect order when it doesn't matter), miss provider setup (causing tests to hit real APIs), or use manual generator stepping when `expectSaga` would be simpler and more maintainable. The result: tests that break on harmless refactors and pass when they shouldn't.

## This Solution

A focused testing skill covering `expectSaga` (integration), `testSaga` (unit), providers, matchers, and reducer integration — with 12 anti-patterns showing exactly what goes wrong and how to fix it.

## Install

```bash
npx skills add anivar/redux-saga-testing -g
```

Or with full URL:

```bash
npx skills add https://github.com/anivar/redux-saga-testing
```

## Baseline

- redux-saga-test-plan ^5.x
- redux-saga ^1.4.2
- Jest or Vitest

## What's Inside

### Testing Approaches

| Approach | Type | Use When |
|----------|------|----------|
| `expectSaga` | Integration | Default choice — order-independent, async, assertions on effects and state |
| `testSaga` | Unit | Effect ordering matters (e.g., must `select` before `call`) |
| `runSaga` | Manual | Need full store integration or custom middleware |

### Providers

| Provider Type | Purpose |
|---------------|---------|
| Static providers | Map effect → return value (simple, covers most cases) |
| Dynamic providers | Custom logic per effect type (conditional mocking) |
| Partial matchers | `matchers.call.fn(apiFn)` — match by function regardless of args |

### Anti-Patterns

12 common testing mistakes with BAD/GOOD code examples:
- Asserting effect order in integration tests
- Missing providers for API calls
- Not awaiting `expectSaga` (test always passes)
- Testing implementation instead of behavior
- Ignoring error paths and cancellation

## Structure

```
├── SKILL.md...

Related skills

OpenClaw

bambu-studio-ai

heyixuan2

Bambu Lab 3D printer control and automation. Activate when user mentions: printer status, 3D printing, slice, analyze model, generate 3D, AMS filament, print monitor, Bambu Lab, or any 3D printing task. Full pi...

OpenClaw

geo-optimization

capt-marbles

Generative Engine Optimization (GEO) for AI search visibility. Optimize content to appear in ChatGPT, Perplexity, Claude, and Google AI Overviews. Use when optimizing websites, pages, or content for LLM discove...

OpenClaw

parakeet-stt

carlulsoe

Local speech-to-text with NVIDIA Parakeet TDT 0.6B v3 (ONNX on CPU). 30x faster than Whisper, 25 languages, auto-detection, OpenAI-compatible API. Use when transcribing audio files, converting speech to text, o...

OpenClaw

feishu-process-feedback

carlzhao007

飞书消息自动处理与进度反馈技能。安装后后台运行,监听飞书任务消息并自动创建独立进程处理。 在处理前后发送实时进度反馈(任务确认、进度百分比、完成通知)。 支持任务类型识别、智能解析、错误重试、并发控制、状态持久化...