Skip to content

Implement a complete test suite with Vitest and React Testing Library #36

Description

@Benalex8797

Category: Testing / DX
Difficulty: High

Description

There are zero tests in the codebase. No unit tests, no integration tests, no component tests. package.json has no test script. Given that all logic lives in contexts and hooks (no backend), the unit test surface is rich and important.

Technical Requirements

  • Install vitest, @testing-library/react, @testing-library/user-event, @testing-library/jest-dom, and jsdom
  • Configure Vitest in vite.config.ts with environment: 'jsdom' and coverage reporting
  • Write tests for: AuthContext (login/signup/logout/changePassword), BookingContext (bookSession/updateSessionStatus), ForumContext (createPost/addComment/likePost), MessageContext (createThread/sendMessage/markAsRead), useDebounce, search.ts, recommendations.ts
  • Write component tests for: BookingModal (renders, submits, shows success), PasswordStrength (renders correct strength indicator), AnimatedCounter (counts from 0 to target)
  • Achieve ≥80% code coverage on all context files
  • Add "test": "vitest --run" and "test:coverage": "vitest run --coverage" to package.json

Acceptance Criteria

  • pnpm test runs all tests and passes
  • Coverage report shows ≥80% on context files
  • AuthContext login tests cover: valid credentials, invalid credentials, demo users
  • ForumContext like toggle test verifies per-user behavior
  • No test uses any — all mocks are typed

Deliverables

  • src/**/__tests__/*.test.ts(x) (min 25 test files)
  • Updated vite.config.ts
  • Updated package.json

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third Campaign

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions