Last active
September 20, 2024 02:32
-
-
Save jessireedev/0fb28afa821399091e61b5323efd1488 to your computer and use it in GitHub Desktop.
How to mock NATs in unit test (Nest.js)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ClientProxy } from '@nestjs/microservices'; | |
const clientMock: Partial<ClientProxy> = {}; | |
describe('test', () => { | |
beforeEach(async () => { | |
const app: TestingModule = await Test.createTestingModule({ | |
/* | |
... | |
*/ | |
providers: [ | |
{ | |
provide: 'NATS', | |
useValue: clientMock | |
} | |
] | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment