# Unit Tests

> Unit test writing with Jest (JS/TS) or pytest (Python). Test structure, mocking, edge cases, coverage. Don't use for E2E or integration tests.

- Skill: `neuron-one/unit-tests` (Agent Skill)
- Install (CLI): `npx skillmds@latest add neuron-one/unit-tests`
- Raw SKILL.md: https://api.skillmd.com/api/skills/neuron-one/unit-tests/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: neuron-one (https://skillmd.com/u/neuron-one)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/neuron-one/unit-tests

---


# Unit Testing

## Structure (Arrange-Act-Assert)
```
describe('ServiceName', () => {
  it('should [expected behavior] when [condition]', () => {
    // Arrange: setup
    // Act: call function
    // Assert: verify result
  });
});
```

## What to Test
- Happy path (normal operation)
- Edge cases (empty, null, boundary values)
- Error cases (invalid input, network failure)
- Business logic (calculations, transformations)

## Mocking
- Mock external dependencies (DB, API, filesystem)
- Never mock the thing you're testing
- Use dependency injection for testability

## Coverage Target
- New code: 80%+ line coverage
- Critical paths: 100%
