Testing
How to run and write tests for Claude Code Setup.
Running Tests
All Tests
./tests/test.shSpecific Scenario
./tests/test.sh 01 # Run scenario 01
./tests/test.sh version # Pattern match on nameVerbose Output
Tests show progress by default. For debugging, check the test output files in /tmp/claude-test-*/.
Test Environment
Tests run in isolation:
- Creates
/tmp/claude-test-XXXXX/directory - Sets
HOMEto test directory - Doesn’t touch your real
~/.claude
After tests complete, check the test directory to see installed files.
Test Scenarios
Tests are in tests/scenarios/:
| Scenario | Tests |
|---|---|
| 01-fresh-install.sh | Clean installation |
| 02-update.sh | Updating existing install |
| 03-add.sh | Adding modules with —add |
| 04-list.sh | Listing installed modules |
| … | … |
Writing Tests
Using expect
Tests use expect for interactive simulation:
#!/usr/bin/env expect
spawn ./install.sh
# Wait for prompt
expect "Select modules"
# Send input
send "j j \r" # Move down twice, press enter
# Verify output
expect "Installation complete"Test Helpers
tests/helpers.sh provides:
# Setup test environment
setup_test_env
# Assert file exists
assert_file_exists "$HOME/.claude/CLAUDE.md"
# Assert file contains
assert_contains "$HOME/.claude/installed.json" '"version"'
# Cleanup
cleanup_test_envAdding a New Test
- Create
tests/scenarios/XX-your-test.sh - Source helpers:
source "$(dirname "$0")/../helpers.sh" - Use expect for interactive parts
- Use assertions for verification
- Run:
./tests/test.sh XX
Manual Testing
Test without affecting your real setup:
HOME=/tmp/claude-manual-test ./install.shCheck results:
ls /tmp/claude-manual-test/.claude/
cat /tmp/claude-manual-test/.claude/installed.jsonCI/CD
Tests run on GitHub Actions:
- On every push
- On every PR
- Matrix: Ubuntu, macOS
See .github/workflows/test.yml for configuration.