Javascript has mocking with jest: https://jestjs.io/docs/mock-functions
There’s an example there of mocking our axios (a common library for network requests, a la python requests)
It’s been a long time since I’ve used java, but mockito exists: https://site.mockito.org/javadoc/current/org/mockito/Mockito.html#2
(Usage note for anyone unfamiliar, but despite the name java and JavaScript are radically different languages.)






It’s not really that different from like
my_get_mock = Mock(side_effect=Some exception("oh no")) result = some_func(http_getter=my_get_mock)There’s many ways of writing bad code and tests, but mocks and patches aren’t always a bad tool. But sure, you can definitely fuck things up with them.