Skip to content
This repository has been archived by the owner on Feb 9, 2020. It is now read-only.

TypeError: Cannot read property 'clients' of undefined #2

Open
ShaneC-C-Y opened this issue Aug 8, 2016 · 3 comments
Open

TypeError: Cannot read property 'clients' of undefined #2

ShaneC-C-Y opened this issue Aug 8, 2016 · 3 comments

Comments

@ShaneC-C-Y
Copy link

Hi there,
I am new to this module. I have a problem when using mock-awe with dynamodb
I found this doesn't support dynamodb DocumentClient.

The test.js

var AWS = require('mock-aws'),
    expect = require('chai').expect,
    get_info = require('../get_info');

const context = require('aws-lambda-mock-context');
const ctx = context();

...
var testData = require('./testData.json')
AWS.mock('DynamoDB.DocumentClient', 'scan', testData);
get_info.handler({}, ctx, function(err, data){
    ...
});
...

The following is get_info.js

var AWS = require("aws-sdk");
AWS.config.update({
  region: "us-west-2",
});

exports.handler = (event, context, callback) => {
    var docClient = new AWS.DynamoDB.DocumentClient();
    var params = {
        TableName:table,
        ProjectionExpression: "deltaEndpoint, tag"
    }
    docClient.scan(params, onScan);
    function onScan(err, data) {
         ....
    }
};

This will return TypeError: Cannot read property 'clients' of undefined

But it can work if I use

var db = new AWS.DynamoDB();
db.scan(params, onScan);

Is there any way to fix this problem?

@jestinjht
Copy link

I'm having this problem too. I'm using aws-sdk 2.2.20 and mock-aws 1.2.3

@Rukenshia
Copy link

We also have this problem.

@andrewhiles
Copy link

I'm encountering the same issue.

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

No branches or pull requests

4 participants