Skip to content

Conversation

@amshula-05
Copy link
Contributor

Related Issue


Description

This PR introduces a robust Jasmine-based test suite for the backend of the project, ensuring reliability and maintainability of core authentication and user management features.

What’s Included

  • Jasmine Setup:
    Jasmine is configured for backend testing, with support for .cjs test files.

  • User Model Unit Tests:

    • Verifies password hashing on save
    • Ensures password is not re-hashed if not modified
    • Tests the comparePassword method for correct and incorrect passwords
  • Auth Routes Integration Tests:

    • Signup: success and duplicate email cases
    • Login: success and failure (wrong password)
    • Logout: ensures session is properly destroyed
  • Passport Integration:
    Passport’s local strategy, serialization, and deserialization are tested indirectly through the authentication route tests.

  • Documentation:

    • README updated with clear instructions on installing dependencies, running tests, troubleshooting, and what is covered by the test suite.

How to Test

  1. Ensure MongoDB is running locally (mongod).
  2. Install all dependencies:
    npm install
    npm install --save-dev jasmine @types/jasmine supertest express-session passport passport-local bcryptjs
  3. Run the test suite:
    npx jasmine
  4. All tests should pass with no failures.

How Has This Been Tested?

Automated Jasmine Test Suite:

  • All backend tests were run using the Jasmine test runner (npx jasmine).
  • User model unit tests: Verified password hashing, schema validation, and password comparison logic.

Auth route integration tests:

  • Simulated HTTP requests for signup, login, and logout using Supertest, ensuring correct responses and database changes.

Test Environment:

  • Local MongoDB instance (mongodb://127.0.0.1:27017/github_tracker_test) was used for all tests.
  • Each test suite cleans up the database after execution to ensure isolation and repeatability.

Screenshots (if applicable)

image

Type of Change

  • Bug fix
  • New feature
  • Code style update
  • Breaking change
  • Documentation update

@netlify
Copy link

netlify bot commented Jul 25, 2025

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit a8edf9d
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/68835546c12cc90008558b77
😎 Deploy Preview https://deploy-preview-125--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mehul-m-prajapati mehul-m-prajapati merged commit 4c5a5c1 into GitMetricsLab:main Jul 25, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Add unit test cases using Jasmine framework

2 participants