Skip to content

test: set up vitest and cover auth and users - #2

Merged
esdrassantos06 merged 5 commits into
mainfrom
test/setup
Nov 12, 2026
Merged

esdrassantos06 merged 5 commits into
mainfrom
test/setup

Conversation

@esdrassantos06

Copy link
Copy Markdown
Owner

What changed

  • Replaced Jest and ts-jest with Vitest and SWC. @nestjs/typeorm 12 and TypeORM 1 ship as ESM only, which Jest couldn't load; Vite handles them, and SWC emits the decorator metadata Nest's dependency injection needs.
  • Unit tests for AuthService (duplicate email returns 409, Argon2id hash stored, hash never returned, validateUser, login), UsersService with a mocked repository, the controllers and the password rules in CreateUserDTO.
  • An end-to-end test that boots the app against PostgreSQL and goes through register, login and /auth/profile, plus 409 on a duplicate email and 401 on a wrong password or a missing token.
  • Fix: @IsStrongPassword already required a symbol by default, but the message didn't say so, so Secret123 failed with an error that didn't explain why. The rule is now explicit and the message mentions the symbol. The README examples use Secret123!.
  • CI: the build job now runs lint:check, the unit tests and the build; a new e2e job runs the end-to-end test against a PostgreSQL 18 service container.
  • README: removed the "tests don't run yet" warning and added a Tests section.

How to check

npm run lint:check
npm run test        # 18 unit tests
docker compose up -d
npm run test:e2e    # 4 end-to-end tests

@esdrassantos06
esdrassantos06 merged commit 2a4064d into main Nov 12, 2026
3 checks passed
@esdrassantos06
esdrassantos06 deleted the test/setup branch November 12, 2026 18:54
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.

1 participant