Skip to content

Instantly share code, notes, and snippets.

@jessireedev
Last active September 20, 2024 02:32
Show Gist options
  • Save jessireedev/0fb28afa821399091e61b5323efd1488 to your computer and use it in GitHub Desktop.
Save jessireedev/0fb28afa821399091e61b5323efd1488 to your computer and use it in GitHub Desktop.
How to mock NATs in unit test (Nest.js)
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