api: mock avatar multer in test setup to prevent S3_BUCKET error
multer-s3 validates the bucket option at construction time, so importing the users route caused an immediate crash in CI where S3_BUCKET is unset, which was never caught locally because the values are set, duh
Parents:
8b7a4381 file(s) changed
- api/tests/setup.ts +5 -0
api/tests/setup.ts
1 1
import { vi } from 'vitest'
2 2
3 3
const mockQueue = () => ({
4 4
add: vi.fn().mockResolvedValue({}),
5 5
addBulk: vi.fn().mockResolvedValue([]),
▸ 18 unchanged lines
24 24
// syncMedicineReminderJobs imports getQueue directly from QueueRegistry
25 25
vi.mock('@app/lib/queue/QueueRegistry', () => ({
26 26
getQueue: vi.fn(() => mockQueue()),
27 27
closeAllQueues: vi.fn(),
28 28
}))
29 +
30 +
// avatar.ts constructs multer-s3 at import time and requires S3_BUCKET env var
31 +
vi.mock('@app/services/avatar', () => ({
32 +
default: { single: vi.fn(() => (_req: any, _res: any, next: any) => next()) },
33 +
}))