Advertisement
kwandes

Nestjs supertest setup

Jun 6th, 2022
1,323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     app = moduleFixture.createNestApplication();
  2.     app.useGlobalFilters(new EntityNotFoundExceptionFilter());
  3.     // ensure that the requests contain valid data
  4.     app.useGlobalPipes(
  5.       new ValidationPipe({
  6.         transform: true,
  7.         // Strip data of properties without decorators
  8.         whitelist: true,
  9.  
  10.         // Throw an error if non-whitelisted values are provided
  11.         forbidNonWhitelisted: true,
  12.  
  13.         // Throw an error if unknown values are provided
  14.         forbidUnknownValues: true,
  15.       })
  16.     );
  17.     await app.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement