Skip to content

Khoa: Backend Auth API Testing (Vitest + Supertest) #3

@kn-dev-code

Description

@kn-dev-code
Image

cd backend npm install -D vitest supertest

Please add this test script to your package.json:

Image

Context: Test the security boundary of the backend/src/routes/auth-routes.ts.

Primary Task: Create backend/tests/auth.api.test.ts.

Specific Test Cases:

Registration: Send a POST to /auth/register. Expect 201 and verify the password is not returned in the JSON response.

Login Flow: Test valid login (200 OK) and invalid login (401 Unauthorized).

Security: Verify that the JWT or Session cookie is actually sent in the Set-Cookie header.

Constraint: Use a test database (like mongodb-memory-server) so you don't delete our real users.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions