Purpose of this post
With a module A requiring a module B
When I want to test A
Show how to replace B by a mock using JestJS
I am a Java developper. I am a heavy user of Mockito.
Often, I need to test a service and replace external systems, injected into my service, by Mocks.
I use “Inject Mocks”.
As I write “lambdas” for AWS.
I need to test them and avoid calling S3, SNS, DynamoDB, …
Let’s say we have a “Father” and a “Son”.
“Son” is required by “Father”
Simple test : everything is synchronous
asynchronous test with callbacks
Mocking a function with a callback is easy
I should update this post to add Promises