# morph-cli Testing Infrastructure
## Overview
The testing infrastructure provides snapshot-based transform testing, fixture repositories, and comparison utilities.
## Structure
```
tests/
├── fixtures/ # Multi-file test fixtures
│ ├── express_to_fastify/
│ └── js_to_ts/
├── snapshots/ # Expected transform outputs
│ └── *.snap
├── integration/ # Integration test helpers
├── mod.rs # Test runner and utilities
├── fixtures.rs # FixtureRepo management
├── snapshot.rs # SnapshotManager
└── integration.rs # IntegrationTest helpers
```
## Usage
### Running Tests
```bash
# Run all tests
cargo test
# Run snapshot tests only
cargo test --test snapshot
# Run fixture tests only
cargo test --test fixtures
# Run integration tests only
cargo test --test integration
```
### Updating Snapshots
When transforms produce expected changes, update snapshots:
```bash
# Update all snapshots (requires code change)
# Set UPDATE_SNAPSHOTS env var in snapshot.rs
```
### Creating New Fixtures
1. Add fixture files to `tests/fixtures/<recipe>/`
2. Create corresponding snapshots in `tests/snapshots/`
### Snapshot Format
```javascript
// @snapshot <name>
const fastify = require('fastify');
// ... expected output
```
## Testing Helpers
- `normalize_for_comparison()` - Strip line endings for cross-platform comparison
- `assert_transform_eq()` - Assert input matches expected
- `assert_snapshot_eq()` - Compare actual vs expected with diff output
- `print_diff()` - Pretty-print line-by-line diffs
- `format_test_summary()` - Format test results summary
## Fixture Repos
Load multi-file fixture repos:
```rust
let repo = load_fixture_repo("express_to_fastify", &Path::new("tests/fixtures"))?;
for file in repo.list_files() {
// Process each file
}
```
## Pipeline Testing
Verify pipeline execution:
```rust
let result = verify_pipeline_execution("express-to-fastify", &fixture_path);
assert_eq!(result.stages_passed, result.stages_total);
```