Files
you-music/TESTING.md
T
2025-11-02 23:11:05 +11:00

1.7 KiB

Testing Guide

Backend Tests (Python)

Setup

cd backend
uv pip install pytest pytest-asyncio

Run All Tests

pytest

Run Specific Test File

pytest tests/test_artist_normalization.py

Run With Verbose Output

pytest -v

Run Specific Test

pytest tests/test_artist_normalization.py::TestArtistNormalization::test_multiple_artists_slash_separator

Frontend Tests (TypeScript/Jest)

Setup

cd frontend
npm install

Run All Tests

npm test

Run Specific Test File

npm test utils.test.ts

Run Tests in Watch Mode

npm test -- --watch

What's Tested

Artist Normalization (test_artist_normalization.py)

  • Single artist names
  • Multiple artists with / separator
  • Multiple artists with , separator
  • Mixed separators
  • Whitespace cleanup
  • Unicode characters (Chinese, special chars)
  • Real-world examples from database
  • All artists are preserved (not just first one)

Artist Display Formatting (utils.test.ts)

  • Display all artists when space permits
  • Smart truncation: "FirstArtist, +N"
  • Single vs multiple artist handling
  • Edge cases (very short maxLength)
  • Real-world player scenarios

Continuous Integration

Add to your CI/CD pipeline:

# Backend
- cd backend && pytest

# Frontend  
- cd frontend && npm test -- --ci

Writing New Tests

Backend

def test_your_feature():
    """Test description"""
    result = function_to_test(input)
    assert result == expected_output

Frontend

test('description', () => {
  const result = functionToTest(input)
  expect(result).toBe(expectedOutput)
})