martin-markovic / learn-connect

Multi-feature platform designed to enhance the online learning experience.
MIT License
0 stars 0 forks source link

fix integration tests #6

Closed martin-markovic closed 2 months ago

martin-markovic commented 2 months ago

Summary

This pull request addresses several enhancements and fixes related to user authentication functionalities:

  1. Improved Controller Responses: Fixed controller functions to ensure explicit return of responses and errors from catch blocks, ensuring better error handling and response consistency.

  2. Integration of Database and Security Dependencies: Integrated mongoose for database operations with the User model and bcrypt for password hashing and comparison directly into theuserAuth.test.js test suite.

  3. Enhanced Test Setup: Added robust database connection setup and teardown mechanisms using before and after hooks, ensuring clean and predictable test environments. Additionally, implemented user cleanup (deleteMany) in beforeEach to maintain test isolation and reliability.

  4. Updated Test Data: Modified test data strings for registerUser and loginUser tests to use different names and email addresses.

These changes collectively improve the reliability and clarity of user authentication tests and related controller functions.