Mocking a specific command only
See original GitHub issueApologies if I’m missing something obvious here but is there a way for me to only mock a specific command and for the client to use the real behaviour of the client of all the other commands? For a bit of context, I have a bunch of tests that run against dynamodb-local
. I am trying to test a function that uses the batchWrite
command but the function I’m testing makes other calls to dynamo before that. I would like to only mock the batchWrite
function and allow the other commands to pass through to the local DB using the actual SDK. Is this possible?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Mocking a command and getting different results based on the ...
Mocking a command and getting different results based on the number of times the Mock is called · On the first call use...
Read more >Is there an easier way to stub a specific command or script ...
I just found this bat-mock tool and it looks very promising for unit testing bash code. I wonder if there is any progress...
Read more >Mock - Pester
This injects the mock into the specified module. If you do not specify a module name, the mock will be created in the...
Read more >Enabling mocks from command-line (with py.test) - Medium
My goal was to be able to dynamically, via command-line parameters to py.test , switch certain mocks on and off, while using patch...
Read more >unittest.mock — getting started — Python 3.11.1 documentation
Mocking Classes A common use case is to mock out classes instantiated by your code under test. When you patch a class, then...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can access the underlying Sinon stub with:
There is a
stub.callThrough()
method:So you can try something like this:
No guarantee it will work, although please let me know if it does (or not).
That worked perfectly. Thanks for the prompt reply and moreover, thanks for the great library!