How to manually test input validation with NestJS and class-validator
问题 TLNR: I was trying to test DTO validation in the controller spec instead of in e2e specs, which are precisely crafted for that. McDoniel's answer pointed me to the right direction. I develop a NestJS entrypoint, looking like that: @Post() async doStuff(@Body() dto: MyDto): Promise<string> { // some code... } I use class-validator so that when my API receives a request, the payload is parsed and turned into a MyDto object, and validations present as annotations in MyDto class are performed.