jeudi 13 septembre 2018

How to configure middleware in e2e test in nestjs

In real app, we write:

export class AppModule implements NestModule {
  constructor() {}

  configure(consumer: MiddlewareConsumer) {
    consumer.apply(JwtExtractionMiddleware).forRoutes({
      path: 'graphql',
      method: RequestMethod.ALL,
    });
  }
}

In e2e test, I do something like this:

const module = await Test.createTestingModule({
  imports: [ GraphQLModule.forRoot(e2eGqlConfig) ],
  providers: [ PubUserResolver ],
}).compile();
app = await module.createNestApplication().init();

So how can I specific middleware in e2e test?

Aucun commentaire:

Enregistrer un commentaire