JSPM

  • Created
  • Published
  • Downloads 54
  • Score
    100M100P100Q69060F
  • License MIT

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

Package Exports

  • serverless-http-invoker

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 (serverless-http-invoker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm version license

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

More complex real-world examples are demonstrated in the sheetmonkey-server project. See PluginsHandler.js and PluginAuthHandler.js.

Installation

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