| title | Testing Guide | |||
|---|---|---|---|---|
| description | Comprehensive testing guide covering unit, integration, and e2e tests | |||
| lastUpdated | 2026-01-09 | |||
| tags |
|
This project includes comprehensive testing across multiple layers: unit tests, integration tests, and end-to-end (e2e) tests.
Run all tests from the root:
pnpm testThis will execute:
- CLI unit tests (Go)
- CLI integration tests (Go)
- Web e2e tests (Playwright)
Location: cli/src/
Unit Tests
- Fast tests that don't require external dependencies
- Run with:
pnpm test:cli:unitorcd cli && go test -v -short ./src/... - Use
-shortflag to skip integration tests
Integration Tests
- Tests that may require external services or longer execution time
- Run with:
pnpm test:cli:integrationorcd cli && go test -v -tags=integration -timeout=10m ./src/... - Require
integrationbuild tag
Location: web/tests/
E2E Tests
- Browser-based end-to-end tests
- Run with:
pnpm test:weborcd web && pnpm test - Multi-browser testing (Chrome, Firefox, Safari)
- Responsive design testing (mobile, tablet, desktop)
- Accessibility (a11y) compliance tests
# Run all tests
pnpm test
# Run only CLI tests (unit + integration)
pnpm test:cli
# Run only CLI unit tests
pnpm test:cli:unit
# Run only CLI integration tests
pnpm test:cli:integration
# Run only web e2e tests
pnpm test:webcd cli
# Using Mage (recommended)
mage test # Unit tests only
mage testIntegration # Integration tests only
mage testAll # All tests
mage testCoverage # Tests with coverage report
# Using Go directly
go test -v -short ./src/... # Unit tests
go test -v -tags=integration -timeout=10m ./src/... # Integration tests
go test -v -tags=integration ./src/... # All testscd web
# Run all tests
pnpm test
# Run with browser UI
pnpm test:headed
# Debug mode
pnpm test:debug
# View test report
pnpm test:report
# Run specific test file
pnpm exec playwright test homepage.spec.ts
# Run specific browser
pnpm exec playwright test --project=chromium- Go 1.26.0 or later
- Optional:
golangci-lintfor linting
- Node.js 18 or later
- pnpm 9 or later
- Playwright browsers (install with
pnpm exec playwright install)
Generate coverage report:
cd cli
mage testCoverageThis creates cli/coverage/coverage.html with a detailed coverage report.
All tests run automatically in CI pipelines. The pnpm test command is designed to be CI-friendly:
- Exits with non-zero code on test failure
- Provides verbose output for debugging
- Web tests automatically start/stop dev server
- Create
*_test.gofile in appropriate package - Use
-shortflag checks for integration tests - Follow existing test patterns
- Create
*_integration_test.gofile - Add
//go:build integrationbuild tag at top - May require external services/longer timeout
- Create
*.spec.tsinweb/tests/ - Follow Playwright patterns
- Test across multiple browsers
- Include accessibility checks
CLI tests fail with "package not found"
- Run
go mod downloadincli/directory
Web tests fail with "browser not found"
- Run
pnpm exec playwright installinweb/directory
Integration tests timeout
- Set
TEST_TIMEOUTenvironment variable:TEST_TIMEOUT=20m pnpm test:cli:integration
Specific package integration test
- Set
TEST_PACKAGEenvironment variable:TEST_PACKAGE=executor pnpm test:cli:integration
Specific test by name
- Set
TEST_NAMEenvironment variable:TEST_NAME=TestKeyVault pnpm test:cli:integration
- Keep unit tests fast - Mock external dependencies
- Mark integration tests - Use build tags and skip in unit test runs
- Write descriptive test names - Test names should explain what's being tested
- Test edge cases - Include error scenarios and boundary conditions
- Maintain test independence - Tests should not depend on execution order
- Update tests with code - Keep tests in sync with implementation changes