nats-io / nats.ts

TypeScript Node.js client for NATS, the cloud native messaging system
https://www.nats.io
Apache License 2.0
178 stars 13 forks source link

Mock NATS server to Unit test API's that use ts-nats #62

Closed stoicAlchemist closed 4 years ago

stoicAlchemist commented 4 years ago

I've been researching for the best way to mock NATS and haven't found anything yet. I'm using ts-nats for interacting with the development server but I'm adding Unit tests to the code before I go further with this and can't seem to find any tools to make that happen. As a reference, I'm using mongo-in-memory (it's not the ideal solution, but it works now) to do the same on Database requests; is there a way to have ts-nats "faking" responses?

Please tell me if this is not the place to ask/request for this features, I apologize in advance if it's not.

aricart commented 4 years ago

Unless you are testing specific client protocol, you shouldn't mock the server. Simply start one the way we do for our tests.

onichandame commented 4 years ago

For the record, https://github.com/FrostDigital/mock-nats-client may be of interest.