logoalt Hacker News

sfn42today at 2:15 AM1 replyview on HN

I use test containers and similar methods to test against a "real" db, but I also use mocks. For example to mock the response of a third party api, can't very well spin that up in a test container. Nother example is simply time stamps. Can't really test time related stuff without mocking a timestamp provider.

It is a hassle a lot of the time, but I see it as a necessary evil.


Replies

supriyo-biswastoday at 3:16 AM

You can use a library like [1] to mock out a real HTTP server with responses.

[1] https://www.mock-server.com/