Closed ianzone closed 1 year ago
I'll have a look. But it might be related to this one: https://github.com/Papooch/nestjs-cls/issues/49
Okay, so after looking into it, I found the error. In your tests, you never bound the ClsMiddleware
- it is only bound in your main.ts
, which is not used in the test.
I see you're binding the AuthenticationMiddleware
in your AppModule
, so I removed the ClsMiddleware
registration out from main and added it to your AppModule
before the AuthenticationMiddleware
like so:
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(ClsMiddleware).forRoutes('(.*)');
consumer.apply(AuthenticationMiddleware).exclude('/').forRoutes('(.*)');
}
}
Now the test passes as expected.
Log
To reproduce: