Skip to content

feat: Add Vitest + React Testing Library for frontend unit testing #596

Description

@Shruti2110-coder

Summary

The Karmada Dashboard frontend (under ui/) currently has no unit test setup. I'd like to propose adding Vitest + React Testing Library for component-level unit testing.

Why this matters

  • The ui/ directory has grown with React + TypeScript components but has zero automated test coverage
  • Vitest is the standard testing tool for Vite-based projects (which this project uses)
  • Unit tests would help catch regressions in core UI components like cluster management, policy views, etc.
  • This is a commonly requested improvement in CNCF dashboard projects

What I propose to do

  1. Add `vitest, @testing-library/react, @testing-library/jest-dom, and jsdom as dev dependencies
  2. Configure Vitest inside the existing vite.config.ts
  3. Create a src/test/setup.ts setup file
  4. Write initial unit tests for 2–3 core components (e.g. login page, cluster list, navigation)
  5. Add a "test" script to package.json

Scope

This is frontend-only and does not touch the Go backend. The goal is to establish a baseline test setup so future contributors can add tests alongside new components.

Question for maintainers

Are you open to this? If yes, are there specific components you'd like tested first, or any conventions I should follow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions