quality / commitlint (push) Skipped
CD / update-wiki (push) Failing after 7s
quality / changes (push) Successful in 4s
quality / docker-check (push) Skipped
quality / web (push) Failing after 38s
quality / api (push) Successful in 49s
CD / quality (push) Failing after 1m36s
CD / publish (push) Skipped
27 lines
664 B
Plaintext
27 lines
664 B
Plaintext
---
|
|
description: Backend Vitest + Fastify inject
|
|
globs: apps/api/**/*,packages/db/**/*,packages/shared/**/*
|
|
alwaysApply: false
|
|
---
|
|
|
|
# Backend Testing
|
|
|
|
Vitest + `app.inject()` (встроено в Fastify).
|
|
|
|
## Требования
|
|
|
|
- Каждый route plugin → минимум 1 integration test
|
|
- Sync/DNS → parity fixtures
|
|
- `:memory:` SQLite для unit; file DB для integration
|
|
- `beforeEach` — fresh schema migrate
|
|
|
|
## Паттерн
|
|
|
|
```ts
|
|
const app = await buildApp({ db: testDb })
|
|
const res = await app.inject({ method: 'GET', url: '/health' })
|
|
expect(res.statusCode).toBe(200)
|
|
```
|
|
|
|
См. [`vitest-best-practices.mdc`](vitest-best-practices.mdc).
|