Last active
August 18, 2016 09:39
-
-
Save rotemtam/8ba060718b2127b5dd5a55ec8b659b6f to your computer and use it in GitHub Desktop.
Node.js AWS Lambda Unit Test with a Mock Context object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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