0.0.9 • Published 9 years ago
serverless-flow-plugin v0.0.9
Serverless-Flow
A lightweight testing framework for the Serverless Framework.
Features
- Write mock events and invoke your functions with them while you write code.
- On save, this plugin automatically invokes your Function w/ each mock event and prints results in your console.
- Features a
localorremotemode.remotemode will quickly deploy your function before invoking it with mock data. - Write multiple mock events for each event for your functions.
Quick-Start
Install with npm:
npm i serverless-flow-plugin --saveAdd it to your Serverless Service plugins:
plugins
- serverless-flow-pluginAdd a mock property to your Functions:
# serverless.yml
functions
hello
handler: index.hello
events:
- http:
path: hello
method: get
mocks: ${file(./mocks.yml):hello} # References to another file which contains the mocksCreate a mocks.yml file in your service folder:
# mocks.yml
hello_http: # Contains the mock for the "hello" function and "http" event
succcess: # A mock for this function event
query:
clientId: aslkfjasf8kajsf981
fail: # Another mock for this function event
query:
clientId: falseStart the plugin:
sls flow --function helloWrite code, hit save, and your function will be auto-invoked for each mock.
When you're done working locally, switch the mode to remote to test your mocks against live Lambdas
sls flow --function hello --mode remote // Remote mode invokes the function on Lambda