Skip to content

Set up Vitest + React Testing Library with one example test #4

@KonstantinMB

Description

@KonstantinMB

The frontend has no test suite. Adding test infrastructure now — with one passing example test — unblocks all future test contributions and gives us something to gate CI on down the road.

What to do

  • Add vitest, @testing-library/react, @testing-library/jest-dom, and happy-dom (or jsdom) to frontend/package.json as devDependencies
  • Create frontend/vitest.config.ts that reuses the path aliases from vite.config.ts
  • Add an npm test script (and npm run test:watch)
  • Write one example test against a simple leaf component — suggestion: a Radix-wrapped UI primitive from frontend/src/components/ui/, or one of the smaller display components. Render it, assert something obvious (text content, a class, a callback firing)
  • Update the README "Testing" section to mention npm test

Acceptance criteria

  • cd frontend && npm test runs and the one test passes
  • cd frontend && npm run build still works after the changes (no type regressions)
  • Test file co-located with the component (Button.test.tsx) or under src/__tests__/ — your call
  • Vitest is dev-only (not bundled into production builds)
  • README mentions the new command

Why this matters

Once this lands, every future PR can add a test in 5 minutes. Right now nobody can, because there's no infrastructure. This is the kind of foundational change that compounds.

Scope

Touches 4–5 files. Estimated time: 1-2 hours.

Want to take this on? Comment below and I'll assign it to you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions