Skip to content

[FEAT] Set Up Testing Suite : Jest + React Testing Library #206

Description

@YashvardhanJani

✨ Feature Description

Set up a minimal yet scalable testing infrastructure for the project using Jest and React Testing Library to enable automated testing for the Next.js App Router codebase.

This includes configuring the testing environment, adding required scripts and dependencies, and introducing a few foundational tests to validate the setup.


🤔 Problem It Solves

Currently, the project does not have any automated testing setup even though the CONTRIBUTING.md mentions that tests are planned for the future.

As a result:

  • Every PR must be manually tested
  • Contributors cannot confidently verify changes
  • Regressions are harder to catch
  • CI integration for future contributions becomes difficult

A proper testing foundation will improve development reliability, contributor experience, and long-term maintainability.


💡 Proposed Solution

Implement a lightweight and maintainable testing setup using:

Testing Stack

  • Jest
  • @testing-library/react
  • @testing-library/jest-dom
  • jest-environment-jsdom

Configuration

  • Add jest.config.ts
  • Add jest.setup.ts
  • Configure Jest for Next.js App Router compatibility
  • Add "test": "jest" script in package.json

Initial Test Coverage

Add a few basic tests to validate the infrastructure:

Unit Tests

  • lib/platforms.ts

    • Verify platform URL pattern detection
    • Test supported platform mappings
  • lib/url.ts

    • Validate URL utility/helper functions
    • Test edge cases and invalid inputs

Component Smoke Test

  • app/components/Navbar.tsx
    • Ensure component renders without crashing
    • Verify basic visible UI elements

This setup will provide a clean starting point for future contributors to add more tests incrementally.


🔄 Alternatives Considered

1. Vitest Instead of Jest

Vitest offers faster execution and modern tooling, but Jest currently has:

  • Better ecosystem maturity
  • Wider community adoption
  • More existing examples for Next.js projects

2. Cypress/Playwright Only

End-to-end testing alone would not cover unit-level logic efficiently and would introduce heavier setup complexity for an initial testing foundation.

3. No Testing Setup

Continuing without tests would increase maintenance overhead and risk of regressions as the project grows.


🗂️ Files Likely Involved

  • jest.config.ts — Jest configuration
  • jest.setup.ts — global test setup
  • package.json — add scripts and dependencies
  • __tests__/lib/platforms.test.ts — platform detection tests
  • __tests__/lib/url.test.ts — URL utility tests
  • __tests__/components/Navbar.test.tsx — Navbar smoke test
  • Other: CI workflow integration (future enhancement)

📸 Mockup / Reference

Reference implementations:

  • Next.js + Jest official documentation
  • React Testing Library examples
  • Existing community setups for Next.js App Router testing

🎯 Acceptance Criteria

  • Jest is properly configured and runs successfully
  • npm test or pnpm test executes without errors
  • React Testing Library is integrated successfully
  • Unit tests for lib/platforms.ts are added and passing
  • Unit tests for lib/url.ts are added and passing
  • Navbar component smoke test is added and passing
  • Test environment works with Next.js App Router
  • Documentation/scripts are updated where necessary

🏷️ Difficulty & Labels

  • good first issue — beginner friendly
  • medium — requires some codebase knowledge
  • hard — significant changes needed
  • level3 — advanced

Hi, @vishnukothakapu
I am a GSSoC'26 contributor and would like to work on this issue, please assign to me

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions