Testing Overview
Kubernetes Dashboard uses multiple testing strategies to ensure code quality:- Unit Tests - Test individual components and functions
- Integration Tests - Test module interactions
- End-to-End (E2E) Tests - Test complete user workflows
- Linting & Code Quality - Ensure code style and standards
Running All Tests
To run all tests across all modules:- Ensures all required tools are installed
- Cleans up temporary directories
- Runs test suites for all modules
- Includes Go tests and JavaScript/TypeScript tests
Unit Tests
Go Unit Tests
Go unit tests are run as part of the global test suite. They test the backend modules:- API module
- Auth module
- Metrics Scraper
- Common modules
JavaScript/TypeScript Unit Tests
The web module uses Jest for unit testing. Run web unit tests:Test Configuration
Jest is configured with:- Custom configuration in
jest.config.js - Angular preset via
jest-preset-angular - TypeScript support via
ts-jest
Code Coverage
To generate code coverage reports:- Runs all test suites with coverage enabled
- Generates coverage reports for all modules
Web Module Coverage
For detailed web module coverage:End-to-End Tests
E2E tests use Cypress to test complete user workflows in a real browser.Running E2E Tests
Automated E2E (headless):- Start the development server
- Wait for the server to be ready
- Run Cypress tests in headless mode
- Kill the server when tests complete
Running Cypress Directly
If you already have the development server running:http://127.0.0.1:8080 and runs Cypress tests.
Source: modules/web/package.json:31
E2E Test Requirements
Before running E2E tests, ensure:- Development server is running or will be started
- Port 8080 is available
- Required endpoints are accessible:
http://127.0.0.1:8080/api/v1/nodehttp://127.0.0.1:8080/confighttp://127.0.0.1:8080
Code Quality Checks
Running All Checks
Run all code quality checks across all modules:- Runs linters for Go code (golangci-lint)
- Runs linters for TypeScript/JavaScript (eslint)
- Runs style linters for CSS/SCSS (stylelint)
- Runs formatters (prettier)
- Checks license headers
- Checks i18n files
Web Module Checks
For detailed web module checks:- i18n checks
- HTML formatting checks
- SCSS linting
- TypeScript linting
Individual Check Commands
Auto-Fixing Issues
Fix All Issues
Many linting and formatting issues can be automatically fixed:- Auto-fixes Go code issues
- Auto-fixes TypeScript/JavaScript issues
- Auto-fixes CSS/SCSS issues
- Auto-fixes HTML formatting
- Adds missing license headers
Web Module Auto-Fix
- i18n fixes
- HTML formatting
- SCSS auto-fixes
- TypeScript auto-fixes
Individual Fix Commands
License Checks
The project requires license headers on all source files. Check license headers:Pre-Commit Checks
All pull requests must pass the following checks:- Unit Tests - All unit tests must pass
- Linting - Code must meet style guidelines
- License Headers - All files must have proper license headers
- Build - Project must build successfully
Run
make check and make test locally before submitting a pull request to ensure all checks pass.Lint-Staged
The project useslint-staged to automatically run checks on staged files:
Configuration from package.json:
- TypeScript files - Auto-fix with eslint
- SCSS files - Auto-fix with stylelint
- HTML files - Format with prettier
Testing Tools
The project uses the following testing tools:| Tool | Purpose | Used For |
|---|---|---|
| Jest | Unit testing | JavaScript/TypeScript tests |
| Cypress | E2E testing | Browser-based integration tests |
| golangci-lint | Go linting | Go code quality |
| eslint | JS/TS linting | TypeScript/JavaScript code quality |
| stylelint | CSS linting | SCSS/CSS code quality |
| prettier | Code formatting | HTML/TS/JS formatting |
Continuous Integration
All tests and checks run automatically on pull requests via GitHub Actions. The following must pass before merging:- All unit tests
- All linting checks
- License header checks
- Build verification
Troubleshooting
Tests Failing
-
Ensure dependencies are installed:
-
Clean and rebuild:
-
Check for port conflicts:
- E2E tests require port 8080
- Development server requires port 8080
E2E Tests Timing Out
- Increase wait timeout in E2E configuration
- Ensure development server is running
- Check that all required endpoints are accessible
Linting Errors
Most linting errors can be automatically fixed:Next Steps
Contributing
Learn how to contribute your changes
Getting Started
Back to development overview