Skip to main content

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
Run E2E tests:

Linting

Type Checking

Backend Testing (Rust)

Running Tests

Unit Tests

apps/labrinth/src/models/project.rs

Integration Tests

Integration tests go in src/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
Run benchmarks:

Linting (Clippy)

Zero warnings required - CI will fail if there are any clippy warnings.

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

This runs:
  • ESLint
  • Prettier
  • TypeScript type checking
  • Tests
2

Backend Checks (Labrinth)

3

Build Verification

Testing Best Practices

General Principles

  1. Test behavior, not implementation - Focus on what code does, not how it does it
  2. Keep tests simple - One assertion per test when possible
  3. Use descriptive names - Test names should explain what they test
  4. Avoid test interdependence - Tests should run independently
  5. Mock external dependencies - Don’t hit real APIs or databases in unit tests

Frontend Best Practices

Backend Best Practices

Mocking

Frontend:
Rust:

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