Skip to content
Back to skills

Testing Cast

ASecurity

Guides pytest test writing for LangGraph casts with mocking patterns for LLM/API/Store calls. Use when writing tests, need mock strategies, setting up fixtures, testing nodes/graphs, or ask "write tests", "mock LLM", "test coverage".

  • 28 stars
  • 0 votes
  • 0 copies
  • 18 views
  • Added February 7, 2026
testingpythonbashnodetestingapi

Works with

  • api

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add Proact0/act-operator --skill testing-cast --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Testing Cast?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Testing Cast
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/proact0-testing-cast/badge)](https://www.skillsdirectory.com/skills/proact0-testing-cast)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: testing-cast
description: Guides pytest test writing for LangGraph casts with mocking patterns for LLM/API/Store calls. Use when writing tests, need mock strategies, setting up fixtures, testing nodes/graphs, or ask "write tests", "mock LLM", "test coverage".
---

# Testing Cast Skill

Write effective pytest tests for {{ cookiecutter.act_name }} Act's casts.

## When NOT to Use

- Writing implementation → `developing-cast`
- Designing architectures → `architecting-act`
- Project setup → `engineering-act`

## Quick Reference

```bash
# Run tests
uv run pytest                              # All tests
uv run pytest tests/test_nodes.py          # Specific file
uv run pytest -k "test_my_function"        # Match name
uv run pytest -v                           # Verbose
uv run pytest -x                           # Stop on first failure
uv run pytest --lf                         # Last failed only

# With coverage
uv run pytest --cov=casts --cov-report=html
```

## Resources

| Task | Resource |
|------|----------|
| Test nodes (sync/async) | `./resources/testing-nodes.md` |
| Test graphs | `./resources/testing-graphs.md` |
| Mock LLMs, APIs, Store | `./resources/mocking.md` |
| Reusable fixtures | `./resources/fixtures.md` |
| Coverage strategies | `./resources/coverage.md` |

## Test Patterns

### Node Test
```python
class TestMyNode:
    def test_execute(self):
        node = MyNode()
        result = node.execute({"input": "test"})
        assert "output" in result
```

### Async Node Test
```python
@pytest.mark.asyncio
async def test_async_node():
    node = AsyncNode()
    result = await node.execute({"query": "test"})
    assert "data" in result
```

### Graph Test
```python
def test_graph_invoke(graph):
    result = graph.invoke({"input": "test"})
    assert result is not None
```

### Mock LLM
```python
def test_with_mock(monkeypatch):
    class MockLLM:
        def invoke(self, messages):
            return {"content": "mocked"}
    
    node = LLMNode()
    monkeypatch.setattr(node, "llm", MockLLM())
    result = node.execute({"messages": []})
```

## Test Organization

```
casts/{cast_name}/
└── tests/
    ├── conftest.py      # Fixtures
    ├── test_nodes.py    # Node tests
    └── test_graph.py    # Graph tests
```

## Best Practices

**DO:**
- Test behavior, not implementation
- Use descriptive names
- Arrange-Act-Assert pattern
- Mock external dependencies
- Test error paths

**DON'T:**
- Test private methods
- Order-dependent tests
- Use `sleep()` for timing
- Aim for 100% coverage

Files in this skill

  • SKILL.md2.5 KB
  • resources/coverage.md1.8 KB
  • resources/fixtures.md3.4 KB
  • resources/mocking.md2.7 KB
  • resources/testing-graphs.md3.2 KB
  • resources/testing-nodes.md2.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.