- Unit tests:
internal/,commands/- Fast, isolated logic tests - E2E tests:
e2e/- Browser automation, Docker integration tests - Golden tests:
golden_test.go- Template output validation
make test-fastRuns only unit tests. Use during development for fast feedback.
make test-commitRuns unit + e2e tests. Run before creating commits.
make test-allIncludes deployment tests. Run before PRs.
GOWORK=off go test -v -run=TestTutorialE2E ./e2eThe test suite uses several optimizations to achieve <6 minute execution:
-
Shared Docker Base Image: All e2e tests build on
lvt-base:latestcontaining Go, sqlc, and dependencies. Each test builds only app-specific code (~10s vs ~60s). -
Chrome Container Pool: 4 Chrome containers started once in TestMain. Tests borrow from pool instead of starting fresh containers.
-
Parallel Execution: Tests run with
-p 4(4 packages concurrently) andt.Parallel()within packages. -
Optimized Timeouts: Local development uses 10s WebSocket and 20s browser timeouts vs 30s/60s in CI.
| Metric | Before | After | Improvement |
|---|---|---|---|
| Total time | 10-15 min | 3-6 min | 50%+ faster |
| Docker builds | 12 min | 2 min | 83% faster |
| Chrome startups | 2.5 min | 1 min (once) | 60% faster |
| Memory peak | 4 GB | 2.2 GB | 45% less |
WEBSOCKET_TIMEOUT: Override WebSocket ready timeout (default: 10s local, 30s CI)BROWSER_TIMEOUT: Override browser operation timeout (default: 20s local, 60s CI)CI=true: Enables CI-specific timeouts
make test-cleanRemoves all test Docker containers and images.
make test-fast- Unit tests only (~30s)make test-commit- Validation before commit (~3-4min)make test-all- Full suite including deployment (~5-6min)make test-e2e- E2E tests onlymake test-unit- Unit tests only (not short mode)make test-clean- Clean up Docker resources
The test suite has a 5-minute timeout for test-commit and 10-minute timeout for test-all. If tests are timing out:
- Run specific test packages to identify slow tests
- Check Docker container status:
docker ps - Clean up lingering resources:
make test-clean - Monitor system resources during test run
E2E tests require Docker and may fail if:
- Docker is not running
- Ports are already in use
- Previous test containers are still running (run
make test-clean)
E2E tests use Chrome containers which can consume memory. If you see memory-related failures:
- Close other applications
- Run
make test-cleanto remove old containers - Run tests in smaller batches