Skip to content

Conversation

MoonLGH
Copy link

@MoonLGH MoonLGH commented Sep 28, 2025

What

  • Added test/utils/testServer.ts as a reusable test helper for mounting userRoutes.
    • Fixed Express typing by returning void instead of Response.
    • Removed use of '*' in app.use to avoid path-to-regexp errors in Express 5.
  • Cleaned up old __tests__/helpers folder (Jest was treating it as a test suite).
  • Updated __tests__/api/routes/userRoutes.test.ts:
    • Imports the new helper (../../../test/utils/testServer).
    • Provides a baseline probe test ensuring the router mounts and does not produce 5xx errors.
  • Ensured devDependencies (jest, ts-jest, supertest, @types/*) exist for consistent test runs.
  • Kept test style consistent with existing authRoutes test suite.

Why

  • Previous tests failed due to:
    • Broken relative import path mangled by the generator.
    • Express type errors (Response not assignable to void).
    • path-to-regexp crash from app.use('*', handler).
    • Jest treating helper files under __tests__ as tests.
  • This patch fixes those issues and aligns the userRoutes test style with existing route tests.

How to verify

  • Run npm test → all route tests (authRoutes + userRoutes) should pass.
  • Coverage report includes userRoutes.

Fixes #33

@MoonLGH
Copy link
Author

MoonLGH commented Sep 28, 2025

resolved the issue

@MoonLGH MoonLGH requested a review from tjtanjin September 28, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Add unit test cases for userRoutes route
2 participants