aws-sdk-mock icon indicating copy to clipboard operation
aws-sdk-mock copied to clipboard

Broken by [email protected]

Open rclark opened this issue 9 years ago • 9 comments

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)

rclark avatar Sep 11 '16 15:09 rclark

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

nelsonic avatar Sep 11 '16 16:09 nelsonic

+1 just saw this break our specs today.

bdruth avatar Sep 12 '16 20:09 bdruth

Pull Requests v. much welcomed!

nelsonic avatar Sep 12 '16 20:09 nelsonic

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.

rclark avatar Sep 12 '16 20:09 rclark

+1 it broke my specs today.

khalidjaz avatar Sep 13 '16 12:09 khalidjaz

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

license2e avatar Sep 20 '16 15:09 license2e

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.

chrisradek avatar Sep 21 '16 20:09 chrisradek

@chrisradek That worked!

license2e avatar Sep 21 '16 21:09 license2e

any idea when you can support latest version of [email protected]? I don't want to go back to previous version if we didn't have to. thanks!

jkpchang avatar Aug 02 '17 22:08 jkpchang