How do I locally test a bot?
jschuur opened this issue · 7 comments
I know I can run something like serverless invoke local --function slack
to locally invoke a handler function without needing to deploy everything every time. But how do I format my test data to trigger the right event and how do I see the output?
Serverless lets you pass in test data or the path to a JSON file with a full set of test data. I just don't know the format of the data to send in e.g. to simulate a slash command event that I want to test.
And if I can trigger it, how do I see the output?
Also wondering how to do this...
There are numerous payloads Slack can send. Maybe check on https://api.slack.com/events to find a payload you want to emulate
Yeah, I think the easiest way is to copy some of those.
Another thing though with locally testing; I'm having trouble with the .ds_store
files.
I can't seem to test locally anymore, invoking the command in terminal gives me an error that the parser can't handle .ds_store
.
How could one fix this?
There is an option to use two serverless plugins
plugins:
- serverless-dynamodb-local
- serverless-offline
( https://www.npmjs.com/package/serverless-dynamodb-local )
The thing is, serverless-dynamodb-local
requires additional configuration of AWS.DynamoDB.DocumentClient
which is instantiated in https://github.com/johnagan/serverless-slack/blob/master/src/dynamo.js#L4
I think I will create a PR for this. It should be possible to configure this object using at least env variables.
@jschuur Did you ever figure out what the syntax was to pass data to the function?
@jschuur Did you ever figure out what the syntax was to pass data to the function?
Afraid not. Didn't really make much progress with that Slack bot.
Maybe it is possible to configure it using https://github.com/localstack/localstack? It has support for lambda, api gateway and dynamodb. These is also a plugin for serverless framework to integrate with localstack https://github.com/localstack/serverless-localstack.