lambda-test
v3.0.0
Published
Simple Serverless tester, which works like this:
Maintainers
Readme
Lambda test
Simple Serverless tester, which works like this:
const lambdaTest = require('lambda-test');
const { getById } = require('../../routes/users.js');
describe('GET /users/{id}', () => {
it('should get user by id', async () => {
const response = await lambdaTest(getById)
.pathParameters({ id: 123 })
.run();
})
});
API
HandlerTester
Kind: global class
- HandlerTester
- new HandlerTester(handler, [statusCode], [httpMethod])
- .queryStringParameters(query) ⇒ this
- .body(body) ⇒ this
- .headers(headers) ⇒ this
- .pathParameters(params) ⇒ this
- .run() ⇒ Promise.<object>
- .verify() ⇒ Promise.<object>
new HandlerTester(handler, [statusCode], [httpMethod])
| Param | Type | Default | | --- | --- | --- | | handler | function | | | [statusCode] | number | null | | | [httpMethod] | string | null | null |
handlerTester.queryStringParameters(query) ⇒ this
Sets query string
Kind: instance method of HandlerTester
| Param | Type | Default | Description | | --- | --- | --- | --- | | query | object | null | | the query string |
handlerTester.body(body) ⇒ this
Sets request body
Kind: instance method of HandlerTester
| Param | Type | Default | Description | | --- | --- | --- | --- | | body | object | string | | request body |
handlerTester.headers(headers) ⇒ this
Set request headers
Kind: instance method of HandlerTester
| Param | Type | Default | | --- | --- | --- | | headers | object | null | |
handlerTester.pathParameters(params) ⇒ this
Kind: instance method of HandlerTester
| Param | Type | Default | | --- | --- | --- | | params | object | null | |
handlerTester.run() ⇒ Promise.<object>
Send request
Kind: instance method of HandlerTester
handlerTester.verify() ⇒ Promise.<object>
Send request
Kind: instance method of HandlerTester
