vandium-io / lambda-tester

Helper for unit testing AWS Lambda functions
BSD 3-Clause "New" or "Revised" License
272 stars 51 forks source link

Is it possible to use async/await? #21

Closed andrewoh531 closed 7 years ago

andrewoh531 commented 7 years ago

I had a quick look at the code and I'm assuming it's not possible in its current state since the verifier is passed in to the expectResult method. Is that right?

dc00p commented 7 years ago

For compatibility reasons we are not supporting async/await and other ES7 features until AWS Lambda rolls out support for Node.js version 7. Once these features have been rolled out by AWS we will look at support for async/await.

andrewoh531 commented 7 years ago

Ok no problem. Thanks for responding back.

jamesdixon commented 6 years ago

Hello, is this possible now that Lamda supports Node 8?

danielclementspariveda commented 5 years ago

@jamesdixon I have used lambda-tester with async handler functions by using expectResolve and expectReject rather than expectResult and expectError.

ex. handler


// in handler
export const handler = async (event, context) => {
  const promise = new Promise(resolve => { resolve("success!") }); 
  return await promise(); 
}
// in unit test
describe('Async', () => {
 it('works with async', () => {
   return LambdaTester(MyLambda.handler)
            .expectResolve(result => {
                assert.equal(result, "success!");
            });
 }
}
ArcadeRenegade commented 5 years ago

I keep getting Error: Promise.reject() called instead of Promise.resolve()