Set up unit tests for the web app (Vitest) with a first test

Open
#108 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript, vite

Research direction

Start with apps/web/package.json and apps/web/vite.config.ts to see how the web app is built, then the root package.json and the .github/workflows files to see how npm test runs in CI. The timeAgo helper is defined in apps/web/src/components/PostCard.tsx and may be moved to apps/web/src/lib. Done means Vitest is configured in apps/web, root npm test runs both web and API suites locally and in CI, and a first timeAgo test covering seconds, minutes, hours, days and a future date passes.

Written by the indexing model from the issue text.

Description

help wanted tests web

The API has a Vitest suite, but apps/web has no unit-test setup, so helpers such as timeAgo are untested.

What to do

Add Vitest (and Testing Library if you need it) to apps/web, a test script, and make the root npm test run it. Add a first test file for timeAgo in apps/web/src/components/PostCard.tsx (seconds, minutes, hours, days, and a future date). Move timeAgo into apps/web/src/lib if that keeps the test simple.

Where to look

apps/web/package.json, apps/web/vite.config.ts, root package.json, .github/workflows.

Done when

npm test runs web and API tests locally and in CI, and the first test passes.

How to work on it

Fork the repo, branch from main, and follow CONTRIBUTING.md. Run npm run typecheck, npm test and npm run lint before opening a PR. Comment here if you'd like to take it, and ask if anything is unclear.


Generated by Claude Code

Dominant language
TypeScript
Stars
6
Forks
6
Avg merge
1h 59m
Merged PRs (30d)
59

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Haseeb-MernStack/commune

All issues in Haseeb-MernStack/commune

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.