lambda-test

3.0.0 • Public • Published

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

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

Package Sidebar

Install

npm i lambda-test

Weekly Downloads

259

Version

3.0.0

License

MIT

Unpacked Size

16.9 kB

Total Files

13

Last publish

Collaborators

  • pragonauts