The aws-sdk has always returned an AWS.Request object in response to a method call, regardless of whether or not you provided a callback. This object is an event emitter, in addition to providing a .promise property and several other of its own methods.
Before #24, if I wanted to mock the request object, I would do something like:
AWS.mock('s3', 'putObject', function() {
var request = new events.EventEmitter();
// ... etc ...
return request;
});
Now I can't do this -- once I call .putObject without a callback I have no access to the replacement function without using the .promise property.
This is kinda rambling, but my point is that you're now mocking the AWS.Request object, but only one of its properties, making it impossible for me to use this library to mock the AWS.Request object myself.
In https://github.com/dwyl/aws-sdk-mock/pull/24 logic was introduced that forks the way a service method is mocked depending on whether or not a callback is provided.
The aws-sdk has always returned an AWS.Request object in response to a method call, regardless of whether or not you provided a callback. This object is an event emitter, in addition to providing a
.promise
property and several other of its own methods.Before #24, if I wanted to mock the request object, I would do something like:
... and I could use this to test logic like:
Now I can't do this -- once I call
.putObject
without a callback I have no access to the replacement function without using the.promise
property.This is kinda rambling, but my point is that you're now mocking the AWS.Request object, but only one of its properties, making it impossible for me to use this library to mock the AWS.Request object myself.