We use Sinon to mock Typescript modules by using mockModule to create a function that can mock the given module. This is done at the outer-most scope of our test suite so that this
With mocks for dependencies inside functions, unit tests will be resilient to a changing codebase. And functions with mocks can be developed without a chain of dependencies.
The moral of the story is, don’t call callbacks from inside promises in NodeJS. They will swallow your exceptions unexpectedly.