import { HTTP_CODE_METADATA } from '@nestjs/common/constants'; jest.mock('../application/auth.service', () => ({ AuthService: class AuthService {}, })); import { AuthController } from './auth.controller'; describe('AuthController response statuses', () => { it.each(['register', 'login', 'refresh'] as const)( '%s explicitly returns HTTP 200', (handler) => { // Nest stores @HttpCode metadata on the unbound handler function. const handlerTarget = Object.getOwnPropertyDescriptor( AuthController.prototype, handler, )?.value as object; expect(Reflect.getMetadata(HTTP_CODE_METADATA, handlerTarget)).toBe(200); }, ); });