Package Exports
- aws-lambda-testing
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aws-lambda-testing) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
aws-lambda-testing
Module to test the aws-lambda functions
aws-lambda-testing for JavaScript
Installing
$ npm install aws-lambda-testingGetting starter
let AwsTest = require( 'aws-lambda-testing' )
let awsTest = new AwsTest() // you can pass a handler.
let handler = function (params, ctx, cb) {
//the handler receive the params, ctx and cb
assert(params.test === 'test')
ctx.done(null, 'test') // the ctx object has the method done, fail and success
}
awsTest.addHandler(handler)
.exec({test: 'test'},function (error, res) { // The exec function can receive the params and execback
// to use in the hadler to test
assert(!error)
assert(res === 'test')
return 'testing the promise'
// the return object is passed to the promise resolving
})
.then(function (res) {
assert(res === 'testing the promise')
})
.catch(errorHandler) // every error is catched and the promise is rejected
})Class aws-lambda-testing
aws-lambda-testing([handler, params, cb, ctx])
To instance the aws-lambda-testing you can pass the handler to test, the params and execback to be used when the handler is execed and the context to be used to exec it.
Instance aws-lambda-testing
aws-lambda-testing.exec([params,execback])
This method exec the handler and return a promise, this promise is resolve with the return valur of execback passed to this function and rejected with every error catched or values passed to ctx.fail or ctx.done.
aws-lambda-testing.addHandler(handler)
This method added the handler to be tested and return itself instance.
aws-lambda-testing.addParams(params)
This method added the params to be passed to the handler and return itself instance.
aws-lambda-testing.addexecback(execback)
This method added the execback to be passed to the handler and return itself instance.
aws-lambda-testing.addCtx(ctx)
This method added the context to be passed like thisArg to the handler and return itself instance.
aws-lambda-testing.setTimeout(timeout)
This method added the timeout, if the timeout in exec is broken a error is throw and passed to execback or promise if is not managed.
Ctx object
The ctx object has the method done, success and fail. If the error or error like passed to done or fail method is not controlled by the execback is passed to reject method.
Testing
Running the tests
npm testContributing
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code. For any bugs report please contact to me via e-mail: cereceres@ciencias.unam.mx.
Licence
The MIT License (MIT)
Copyright (c) 2015 Futurecommerce .
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.