Skip to content

"Expecting a result, but received an error" when using Promise returned from function #64

Description

@paul-uz

I am calling a function which returns a Promise, but it isn't working.

This works:

const self = {
    handler: (event, context, callback) => {
        return Promise.resolve(true).then((response) => {
             callback(null, {success:response})
        });
    }
}

module.exports = self

This doesn't

const self = {
    handler: (event, context, callback) => {
        return self.foo().then((response) => {
            callback('null', {success:response})
        })
    },
    foo: () => {
        return Promise.resolve(true)
    }
}

module.exports = self

My test:

it('Checks foo', () => {
        return lambdaTester(index.handler).event({foo: 'bar'}).expectResult((result) => {
            expect(result.success).to.equal(true)
        })
    })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions