Actually, I was wrong with proxyquire. Yes, you can simulate a module 2 or more depths below the source module that you are testing, and it works fine, as they showed in their example. Just put the stub with the path to the module you are mocking at. If you mimic layer3, the stub path must match the path to layer3 written to layer2 (therefore it refers to layer2, not layer1 or some root).
We are doing integration testing, and this is difficult because we use the mongoDB database and there is no built-in database for mongo. There are some attempts and alternatives, but, as I saw, they are not good enough. So there was a root in my problems, we had to make fun of the entire data layer.
Before that, we had a real database on some machines, and integration tests on a CI server (Jenkins) used this real database, but this is not very good, because you cannot, for example, run tests on your laptop.
Thus, prototyping the entire data layer of the application is also a very bad solution, but, as I see it, there is no alternative. If someone had the same or similar situation, feel free to write your solution here.
source share