-
Notifications
You must be signed in to change notification settings - Fork 20
Implement Integration Tests for Core User and Mentor Workflows #72
Copy link
Copy link
Open
Description
Problem Statement
As the Ment2Be backend logic expands, the risk of introducing regressions during refactoring or feature additions increases. Currently, there is no automated mechanism to verify that critical workflows—specifically User Authentication and Mentor Profile creation—function as expected. Relying on manual testing (e.g., via Postman) is time-consuming and prone to human error.
Current Behavior / Limitation
- The project currently lacks an automated integration testing framework.
- There are no scripts in
package.jsonto execute a test suite. - API validation is manual, meaning bugs in the authentication or mentor onboarding flow might go unnoticed until deployment.
Expected Improvement
- A testing environment using Jest and Supertest should be established.
- Automated integration tests should verify that API endpoints return the correct HTTP status codes (200, 201, 400, 401) and data structures.
- Running
npm testshould execute these tests and provide a pass/fail report.
Proposed Approach
- Dependencies: Install
jest,supertest, andcross-env(if needed for environment variables) as dev dependencies. - Configuration: Update
package.jsonto include a test script (e.g.,"test": "jest"). Ensure the tests run in a test environment (connecting to a test database or an in-memory database instance is recommended to avoid polluting development data). - Auth Tests (
server/tests/auth.test.js):- Test
POSTendpoint for User Signup (verify successful creation and duplicate user error). - Test
POSTendpoint for User Login (verify token receipt on success and 401 on bad credentials).
- Test
- Mentor Tests (
server/tests/mentor.test.js):- Test endpoints related to creating or updating a Mentor profile.
- Ensure proper authorization headers are mocked or passed during the test.
Verification Steps
To verify that the testing suite is implemented correctly, follow these steps:
- Clone the repository and switch to the contribution branch.
- Run
npm installto ensure testing dependencies are present. - Execute the test suite by running:
npm test - Success Condition:
- The terminal should display a list of tests with Green checkmarks.
- The output should show a summary (e.g.,
Tests: 5 passed, 5 total). - No actual production data should be modified during the test run.
label ECWoC26
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels