Locally invoke Serverless functions via their HTTP event as specified in Serverless.yml for testing purposes.
Clone or download
Latest commit 5976600 Jun 7, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode fixes #7 Jan 8, 2018
docs Create PULL_REQUEST_TEMPLATE.md Jan 8, 2018
test fixes #7 Jan 8, 2018
.gitignore Initial commit Jul 23, 2017
.travis.yml travis minor changes. Jan 8, 2018
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Jan 8, 2018
CONTRIBUTING.md Create CONTRIBUTING.md Jan 8, 2018
LICENSE Initial commit Jul 23, 2017
README.md added js standard style to readme. Jan 8, 2018
index.js Updates serverless and lambda-wrapper May 28, 2018
package.json v0.8.6 Jun 7, 2018
yarn.lock Updates serverless and lambda-wrapper May 28, 2018

README.md

npm version license Build Status JavaScript Style Guide

serverless-http-invoker

Locally invoke Serverless functions via their HTTP event as specified in Serverless.yml.

It makes it easy to test not only your handler logic, but also ensures that you have your http events setup properly in serverless.yml without deploying.

Usage

Use it in tests of Serverless functions to test your HTTP endpoints along with the handler code. For example, you can write the following to test a Serverless function:

it('should invoke simple path', function () {
  let response = invoker.invoke('GET api/hello')  
  return expect(response).to.eventually.have.property('statusCode', 200)
})

The test above is a test of a Serverless function defined in Serverless.yml as follows:

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: api/hello
          method: get

Many more examples and exaustive list of what is supported in the tests. Some additional real-world examples are demonstrated in the sheetmonkey-server project. See PluginsHandler.js and PluginAuthHandler.js among others.

Installation

npm (npm install serverless-http-invoker --save-dev) or yarn (yarn add serverless-http-invoker --dev)