Skip to content

Instantly share code, notes, and snippets.

@rotemtam
Last active August 18, 2016 09:39
Show Gist options
  • Save rotemtam/8ba060718b2127b5dd5a55ec8b659b6f to your computer and use it in GitHub Desktop.
Save rotemtam/8ba060718b2127b5dd5a55ec8b659b6f to your computer and use it in GitHub Desktop.
Node.js AWS Lambda Unit Test with a Mock Context object
'use strict';
const expect = require('chai').expect
, SomeLambda = require('./some-lambda-func')
, MockContext = require('./mock-lambda-context');
describe('Some Lambda Func', function() {
let ctx;
before(function() {
ctx = new MockContext();
});
describe('When Some param is greater than zero', function() {
before(function(done) {
SomeLambda({someParam: 10}, ctx, done)
});
it('should succeed with Yay', function() {
expect(ctx.succeed.calledWith('Yay')).to.equal(true)
});
after(function() {
//reset counters
ctx.reset();
})
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment