Skip to content

Adding the Testing Infrastructure (Vitest) #1423

@Slambot01

Description

@Slambot01

Problem

The project currently has 0% test coverage. I verified there are no .test. or .spec. files in the codebase. This means no automated way to catch regressions, verify refactors, or validate PR changes.

Proposed solution

Set up Vitest testing infrastructure with initial coverage for core modules.

Implementation:

  1. Configure Vitest + React Testing Library + happy-dom
  2. Write 50+ unit tests for:
    • src/robotoff.ts (API client)
    • src/off.ts (Open Food Facts API)
    • src/utils.ts (utilities)
  3. Add GitHub Actions workflow for CI testing
  4. Create TESTING.md documentation

Why Vitest: Vite-native (already using Vite), faster than Jest, compatible API.

Additional context

Deliverables:

  • vitest.config.ts configuration
  • 50+ test files
  • .github/workflows/test.yml CI workflow
  • Testing documentation

Timeline: 3-4 days

Design & mockups

N/A - Infrastructure contribution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    To Discuss & Validate

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions