dwyl / aws-sdk-mock

:rainbow: AWSomocks for Javascript/Node.js aws-sdk tested, documented & maintained. Contributions welcome!
Apache License 2.0
1.12k stars 110 forks source link

Broken by aws-sdk@2.6.x #47

Open rclark opened 8 years ago

rclark commented 8 years ago

At least some of the service objects in aws-sdk v2.6.x are now getter/setter-only properties. This hits an upstream bug: https://github.com/sinonjs/sinon/issues/1018.

var AWS = require('aws-sdk'); // @2.6.1
var MockAWS = require('aws-sdk-mock');
MockAWS.mock('ECS', 'listTasks', function() {});

/Users/r/tmp/nope/node_modules/aws-sdk-mock/node_modules/sinon/lib/sinon/util/core.js:91
                    throw error;
                    ^

TypeError: Attempted to wrap undefined property ECS as function
    at checkWrappedMethod (/Users/r/tmp/nope/node_modules/aws-sdk-mock/node_modules/sinon/lib/sinon/util/core.js:78:29)
    at Object.wrapMethod (/Users/r/tmp/nope/node_modules/aws-sdk-mock/node_modules/sinon/lib/sinon/util/core.js:121:21)
    at Object.stub (/Users/r/tmp/nope/node_modules/aws-sdk-mock/node_modules/sinon/lib/sinon/stub.js:67:26)
    at mockService (/Users/r/tmp/nope/node_modules/aws-sdk-mock/index.js:67:27)
    at Object.AWS.mock (/Users/r/tmp/nope/node_modules/aws-sdk-mock/index.js:43:5)
    at Object.<anonymous> (/Users/r/tmp/nope/test.js:4:9)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
nelsonic commented 8 years ago

@rclark thanks very much for informing us ... please let us know if you make any progress with your investigation on in the Sinon issue.

bdruth commented 8 years ago

+1 just saw this break our specs today.

nelsonic commented 8 years ago

Pull Requests v. much welcomed!

rclark commented 8 years ago

Even though the sinon bug shouldn't be too hard to solve, it'll be backed up in a sinon v2 release. I wonder if aws-sdk-mock needs to hack around the bug to get working on the updated aws-sdk sooner?

@nelsonic generally, I've found that I can't do this with sinon anymore:

var stub = sinon.stub(AWS, 'ECS');

... but I can do this:

var stub = sinon.stub();
var ECS = AWS.ECS;
AWS.ECS = stub;

Would an approach like this work in aws-sdk-mock? If that sounds like a direction to pursue I can try and PR.

khalidjaz commented 8 years ago

+1 it broke my specs today.

license2e commented 8 years ago

We locked our aws-sdk @ version 2.5.6 in package.json to get things working again.

chrisradek commented 8 years ago

Can you give version 2.6.4 of the SDK a try? We updated the SDK to lazy-load service client models instead of the entire service client class. I ran one of the examples in this project's README and it succeeded with the latest version of the SDK.

license2e commented 8 years ago

@chrisradek That worked!

jkpchang commented 7 years ago

any idea when you can support latest version of aws-sdk@2.9.0? I don't want to go back to previous version if we didn't have to. thanks!