fix: resolve Bun mock isolation contamination across test files
- storage.service.ts: use dynamic import() inside each function so the current @aws-sdk mock is always picked up regardless of module load order - images.test.ts + image.service.test.ts: replace module-level storage.service mock with @aws-sdk/client-s3 mock to avoid contaminating storage.service.test.ts - routes/auth.test.ts: remove unnecessary oauth.service mock (no test uses verifyAccessToken) which was contaminating oauth.service.test.ts - middleware/auth.test.ts: complete oauth.service mock shape with all exports All 464 tests now pass in a single bun test run. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,10 +12,17 @@ mock.module("@hono/oidc-auth", () => ({
|
||||
revokeSession: async () => {},
|
||||
}));
|
||||
|
||||
// Mock verifyAccessToken from oauth.service
|
||||
// Mock oauth.service — all exports included so later test files don't see
|
||||
// a partial module shape when Bun's module registry is shared across files.
|
||||
const mockVerifyAccessToken = mock(() => Promise.resolve(false));
|
||||
mock.module("../../src/server/services/oauth.service", () => ({
|
||||
verifyAccessToken: mockVerifyAccessToken,
|
||||
registerClient: mock(() => Promise.resolve({ clientId: "id" })),
|
||||
getClient: mock(() => Promise.resolve(null)),
|
||||
createAuthorizationCode: mock(() => Promise.resolve({ code: "code" })),
|
||||
exchangeCode: mock(() => Promise.resolve(null)),
|
||||
refreshAccessToken: mock(() => Promise.resolve(null)),
|
||||
cleanExpiredOAuthData: mock(() => Promise.resolve()),
|
||||
}));
|
||||
|
||||
// Import middleware AFTER mocks are set up
|
||||
|
||||
Reference in New Issue
Block a user