testing-unit
Run unit tests for individual code components
Works with
---
name: testing-unit
description: Run unit tests for individual code components
license: MIT
---
# Unit Testing
Test individual functions, methods, and classes in isolation from dependencies.
## When to use me
Use this skill when:
- Writing new code to ensure it works correctly
- Refactoring existing code without breaking functionality
- During continuous integration to catch regressions early
- Following Test-Driven Development (TDD) practices
## What I do
- Identify testable units (functions, methods, classes)
- Set up test fixtures and mock dependencies
- Write test cases covering normal, edge, and error conditions
- Run unit tests and report pass/fail status
- Measure code coverage for tested units
- Integrate with CI/CD pipelines for automated testing
## Examples
```bash
# Run unit tests with common frameworks
npm test # Node.js with Jest/Mocha
python -m pytest tests/ # Python with pytest
go test ./... # Go built-in testing
cargo test # Rust with Cargo
dotnet test # .NET with xUnit/NUnit
# Run specific test files
npm test -- src/utils.test.js
pytest tests/test_auth.py
# Run with coverage reporting
npm test -- --coverage
pytest --cov=src tests/
```
## Output format
```
✓ Test Suite: UserService
✓ should create user with valid data
✓ should reject duplicate email
✗ should handle database connection errors (failed)
Expected: "Connection error handled"
Received: "Unhandled database error"
Coverage: 92% (15/16 lines)
Failed: 1 test
```
## Notes
- Unit tests should be fast (milliseconds per test)
- Mock external dependencies (databases, APIs, filesystem)
- Aim for high code coverage (80-90%+)
- Tests should be independent and order-agnostic
- Follow AAA pattern: Arrange, Act, Assert
- Use test doubles (mocks, stubs, spies) appropriatelyMore Testing skills
tdd
mattpocock/skills
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
setup-pre-commit
mattpocock/skills
Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
agent-browser
vercel-labs/agent-browser
Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.

