Overview
Modrinth uses a comprehensive testing strategy across both frontend (TypeScript/Vue) and backend (Rust) codebases.Test Types
Frontend Testing (TypeScript/Vue)
Running Tests
Unit Tests (Vitest)
Frontend tests use Vitest for fast unit testing.Component Testing
src/components/ProjectCard.test.ts
Utility Function Testing
src/helpers/format.test.ts
Composable Testing
src/composables/useProject.test.ts
E2E Tests (Playwright)
End-to-end tests simulate real user interactions.tests/e2e/project-page.spec.ts
Linting
Type Checking
Backend Testing (Rust)
Running Tests
Unit Tests
apps/labrinth/src/models/project.rs
Integration Tests
Integration tests go insrc/test/ or tests/ directory.
apps/labrinth/src/test/project.rs
API Route Tests
apps/labrinth/src/test/routes.rs
Database Tests
apps/labrinth/src/test/database.rs
Benchmark Tests
benches/search_benchmark.rs
Linting (Clippy)
Code Formatting
Test Coverage
Frontend Coverage
Backend Coverage (Tarpaulin)
CI/CD Testing
GitHub Actions runs tests automatically on:- Every push to any branch
- Every pull request
- Merge queue checks
CI Workflow
.github/workflows/check-rust.yml
Frontend CI
.github/workflows/check-generic.yml
Pre-PR Checklist
Before opening a pull request, ensure:1
Frontend Checks
- ESLint
- Prettier
- TypeScript type checking
- Tests
2
Backend Checks (Labrinth)
3
Build Verification
Testing Best Practices
General Principles
- Test behavior, not implementation - Focus on what code does, not how it does it
- Keep tests simple - One assertion per test when possible
- Use descriptive names - Test names should explain what they test
- Avoid test interdependence - Tests should run independently
- Mock external dependencies - Don’t hit real APIs or databases in unit tests
Frontend Best Practices
Backend Best Practices
Mocking
Frontend:Debugging Tests
Frontend
Backend
Performance Testing
Load Testing (Backend)
Use tools like k6 or Apache Bench:load-test.js
Next Steps
Code Style
Follow coding standards and conventions
Local Setup
Set up local development environment
Deployment
Learn about CI/CD and deployment
Contributing
Submit your first pull request
