I'm new to sinon
and can't achieve the results I want.
I'm trying to stub AWS S3 API getObject
to return a test-provided object.
My production code has:
let s3 = new AWS.S3({ apiVersion: '2006-03-01' });
let params = {
Bucket: aws_bucket,
Key: path
};
s3.getObject(params, function(err, data) {
...
});
My test code has:
describe('GET /image', function() {
beforeEach(function() {
let stub = sinon.createStubInstance(AWS.S3);
stub.getObject.callsFake(() => { console.log('stubbed'); });
});
The AWS S3 class instance is fully stubbed when I run the test, which is great, but it is not calling my fake.
What am I missing?