Jest spy doesn't work on Microservices Controller (EventPattern) E2E Tests #13473
Closed
5 of 15 tasks
Labels
needs triage
This issue has not been looked into
Is there an existing issue for this?
Current behavior
Controller
instance - handler is called but spy does not track itController
prototype before app is initialized - handler is not calledController
prototype after app is initialized - handler is called but spy does not track itMinimum reproduction code
https://github.com/elton-okawa/nestjs-spy-controller-issue
Steps to reproduce
Expected behavior
From a similar issue comment: #8790 (comment)
(As the comment suggests, I couldn't find any related issue besides this one)
I understood that it's possible to spy/mock annotated methods as long as you do it before the app is initialized, so behavior
(1)
and(3)
is expected to fail, but not(2)
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
10.3.8
Packages versions
Node.js version
20.11.1
In which operating systems have you tested?
Other
Controller
instance - handler is called but spy does not track itController
prototype before app is initialized - handler is not calledController
prototype after app is initialized - handler is called but spy does not track itThe text was updated successfully, but these errors were encountered: