Skip to content

Commit 74da2c8

Browse files
committed
chore: Jest에서 Vitest 4.0.15로 마이그레이션
백엔드 테스트 프레임워크를 Jest에서 Vitest로 교체 - vitest 4.0.15 및 unplugin-swc 설치 (NestJS 데코레이터 메타데이터 지원) - jest, ts-jest, @types/jest 패키지 제거 - vitest.config.ts 및 vitest-e2e.config.ts 생성 - tsconfig.json에 vitest/globals 타입 추가 - 테스트 파일의 jest.fn/spyOn/mock을 vi로 변경 - justfile 테스트 명령어 vitest로 업데이트 - .gemini/styleguide.md 문서 Vitest로 갱신
1 parent c213e3f commit 74da2c8

18 files changed

+3324
-6740
lines changed

.gemini/styleguide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ _Function placement in functional files:_
154154

155155
**Recommended libraries**
156156

157-
- Testing: Jest, Playwright
157+
- Testing: Vitest, Playwright
158158
- Utility: es-toolkit, dayjs
159159
- HTTP: ky, @tanstack/query, @apollo/client
160160
- Form: React Hook Form
@@ -289,15 +289,15 @@ Allow multiple related assertions in one test, but separate tests when verifying
289289

290290
### Test Framework
291291

292-
Use Jest. Maintain consistency within project.
292+
Use Vitest. Maintain consistency within project.
293293

294294
### Structuring
295295

296296
Group methods/features with `describe`, write individual cases with `it`. Can classify scenarios with nested `describe`.
297297

298298
### Mocking
299299

300-
Utilize Jest's `jest.mock()`, `jest.spyOn()`. Mock external modules at top level, use `mockReturnValue`, `mockImplementation` for per-test behavior changes.
300+
Utilize Vitest's `vi.mock()`, `vi.spyOn()`. Mock external modules at top level, use `mockReturnValue`, `mockImplementation` for per-test behavior changes.
301301

302302
### Async Tests
303303

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,15 @@ test target="all" *args:
287287

288288
just setup-testdb
289289
cd "{{ backend_dir }}"
290-
DATABASE_URL="postgres://postgres:postgres@localhost:5432/test?pool_timeout=60" NODE_OPTIONS="--max_old_space_size=8192" PRISMA_CLIENT_ENGINE_TYPE={{ prisma_engine }} pnpm exec jest --runInBand --logHeapUsage --no-compilation-cache --silent=false --passWithNoTests {{ args }}
290+
DATABASE_URL="postgres://postgres:postgres@localhost:5432/test?pool_timeout=60" NODE_OPTIONS="--max_old_space_size=8192" PRISMA_CLIENT_ENGINE_TYPE={{ prisma_engine }} pnpm exec vitest run {{ args }}
291291
;;
292292
e2e)
293293
echo "NodeJS:" $(node -v)
294294
echo "Prisma Engine:" {{ prisma_engine }}
295295

296296
just setup-testdb
297297
cd "{{ backend_dir }}"
298-
DATABASE_URL="postgres://postgres:postgres@localhost:5432/test?pool_timeout=60" NODE_OPTIONS="--max_old_space_size=8192" PRISMA_CLIENT_ENGINE_TYPE={{ prisma_engine }} pnpm exec jest --config ./jest-e2e.json --runInBand --no-compilation-cache --forceExit --passWithNoTests {{ args }}
298+
DATABASE_URL="postgres://postgres:postgres@localhost:5432/test?pool_timeout=60" NODE_OPTIONS="--max_old_space_size=8192" PRISMA_CLIENT_ENGINE_TYPE={{ prisma_engine }} pnpm exec vitest run --config ./vitest-e2e.config.ts {{ args }}
299299
;;
300300
e2e-ui)
301301
set +x

src/backend/jest-e2e.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/backend/jest.config.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/backend/package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
"start:debug": "nest start --debug --watch",
1616
"start:prod": "node dist/src/main",
1717
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
18-
"test": "jest",
19-
"test:watch": "jest --watch",
20-
"test:cov": "jest --coverage",
21-
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
22-
"test:e2e": "jest --config ./jest-e2e.json"
18+
"test": "vitest run",
19+
"test:watch": "vitest",
20+
"test:cov": "vitest run --coverage",
21+
"test:e2e": "vitest run --config ./vitest-e2e.config.ts"
2322
},
2423
"dependencies": {
2524
"@apollo/server": "4.11.2",
@@ -58,9 +57,9 @@
5857
"@nestjs/cli": "10.0.0",
5958
"@nestjs/schematics": "10.0.0",
6059
"@nestjs/testing": "10.0.0",
60+
"@swc/core": "1.15.3",
6161
"@types/express": "5.0.0",
6262
"@types/express-session": "1.18.1",
63-
"@types/jest": "29.5.2",
6463
"@types/node": "20.3.1",
6564
"@types/passport": "1.0.17",
6665
"@types/passport-discord": "0.1.14",
@@ -70,15 +69,15 @@
7069
"enforce-unique": "1.3.0",
7170
"eslint": "9.37.0",
7271
"eslint-plugin-perfectionist": "4.15.1",
73-
"jest": "29.5.0",
7472
"nestjs-console": "9.0.0",
7573
"source-map-support": "0.5.21",
7674
"supertest": "7.0.0",
77-
"ts-jest": "29.1.0",
7875
"ts-loader": "9.4.3",
7976
"ts-node": "10.9.1",
8077
"tsconfig-paths": "4.2.0",
8178
"typescript": "5.1.3",
82-
"typescript-eslint": "8.46.0"
79+
"typescript-eslint": "8.46.0",
80+
"unplugin-swc": "1.5.9",
81+
"vitest": "4.0.15"
8382
}
8483
}

0 commit comments

Comments
 (0)