This project enforces container-only testing to ensure consistent, reproducible test environments across all development platforms. All testing is performed through Docker Compose with Podman priority, eliminating platform-specific inconsistencies.
Install Podman (recommended) or Docker:
# Podman (recommended)
brew install podman
podman machine start
# OR Docker
brew install --cask docker# Run all tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Run tests in watch mode
pnpm test:watchAll test commands automatically run in Linux containers, ensuring identical environments regardless of your host platform.
- Base Image:
node:22-alpine3.19(Alpine Linux 3.19 + Node.js 22) - Runtime: Podman (priority) with Docker Compose fallback
- Orchestration: Docker Compose with volume mounting
- Isolation: Full Linux container environment
- Platform Consistency: 100% Linux container execution
- Zero Local Dependencies: No native testing on host machines
- Fast Iteration: Optimized layer caching and volume mounting
- Developer Experience: One-command testing workflows
├── Dockerfile # Testing container definition
├── docker-compose.yml # Container orchestration
├── scripts/container-test.js # Container detection & execution
├── package.json # Container-only test scripts
└── .dockerignore # Build optimization
- Base:
node:22-alpine3.19 - Dependencies: Native addon build tools (gcc, make, python3)
- Security: Non-root
nodeuser - Optimization: Layer caching and .dockerignore
node-syslog-test: Standard testingnode-syslog-test-watch: Watch mode developmentnode-syslog-coverage: Coverage reporting
The scripts/container-test.js automatically:
- Detects Podman (preferred) or Docker
- Validates Docker Compose availability
- Builds container image with caching
- Executes tests in isolated environment
- Consistent Environment: Same Linux container everywhere
- No Setup Hassles: Works out of the box on macOS, Linux, Windows
- Fast Performance: Optimized for sub-10-second startup
- IDE Integration: Full debugging and watch support
- Environment Parity: Local containers match GitHub Actions
- Reliable Testing: No platform-specific flakiness
- Consistent Results: Identical test runs everywhere
# Access container shell
podman-compose run --rm node-syslog-test bash
# Build container manually
podman build -t node-syslog-test .
# Run specific tests
podman-compose run --rm node-syslog-test pnpm vitest test/syslog.test.tsCONTAINERIZED: Set totrueinside containersFORCE_COLOR: Preserves colored outputCI=true: Enables CI-optimized behavior
- Project:
/app(live code changes) - Dependencies: Separate
node_modulesvolume - Coverage: Mounted to host
./coverage
Podman not found
brew install podman
podman machine startPermission denied
# Fix volume permissions
podman-compose run --rm node-syslog-test chown -R node:node /appContainer build fails
# Clear cache and rebuild
podman system prune -f
pnpm test # Triggers rebuildSlow performance
- Ensure SSD storage
- Check available RAM (minimum 4GB recommended)
- Verify Podman machine resources
Enable verbose logging:
NODE_ENV=development pnpm testIf migrating from local testing:
- No Local Tests: All
pnpm testcommands now run in containers - Same Interface: Existing commands work unchanged
- Better Results: More reliable, consistent testing
- Tests no longer run directly on host machines
- Native addon compilation happens in containers
- Platform-specific test differences eliminated
- Cold Start: ~8-12 seconds (including build)
- Warm Start: ~2-3 seconds (cached layers)
- Test Execution: ~200-300ms (20 tests)
- Memory Usage: ~200-300MB per container
- Layer Caching: Reuses unchanged dependencies
- Volume Mounting: Live code updates without rebuilds
- Parallel Execution: Multiple containers can run simultaneously
- ✅ Core Testing: Fully functional
- ✅ Coverage Reports: Working with volume mounting
- ✅ Watch Mode: Development-ready
- ✅ CI/CD Integration: GitHub Actions compatible
- 🔄 Native Addon: Mocked during container testing
- 🔄 Performance: Ongoing optimization
When contributing:
- All tests must pass in containers:
pnpm test - Ensure container compatibility
- Test on multiple platforms if possible
- Document any container-specific requirements
Containerized testing ensures consistent, reliable development for all contributors.