Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call original method from within a mock function #229

Open
Pavel910 opened this issue Feb 21, 2021 · 0 comments
Open

Call original method from within a mock function #229

Pavel910 opened this issue Feb 21, 2021 · 0 comments

Comments

@Pavel910
Copy link

Pavel910 commented Feb 21, 2021

Hi! Is it possible to execute the original implementation of the method from within the mock? It would help simulate events which are otherwise performed in the cloud (like DynamoDB Streams, etc.). I'm using Dynalite to run tests against DynamoDB and the ability to call the original method would help a lot.

Here's an example:

AWS.mock("DynamoDB", "putItem", function(params, callback, original) {
   // Call original implementation
   const result = original(params);
   // Now insert data to Elasticsearch (which is otherwise performed in a lambda triggered by DynamoDB)
   elastic.index(result)
   // And finally execute mock callback
   callback(result);
});

There are other use cases as well, like conditionally returning a mocked result, and executing original otherwise...

Thanks for any info!
Cheers 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant