I know you have picked SAM cli to build your templates, but I would suggest you to move to Serverless (npm i serverless -g) as they are more advanced. Serverless is a framework which has been built by engineers and has no Cloud Provider attached/dependent to it, hence you would be able to easily switch from Azure to AWS from your template.
Because it is supported by a big dev community the framework has a variety of plugins, including serverless offline plugin which will allow you to run your API locally as if you were just running node index.js
. There are also plugins like "serverless-jest" or "serverless-mocha" for unit tests, but I ended up using the normal "Jest" running integration test (I use cognito user pool and need to check the auth token).
If you really want to test your code of cloudformation architecture, you can have a JS file with your function and run it with node locally and instead of having the code in your cloudformation template, you will need to zip ip, upload on S3 and then inform the path on your template.
In summary, I know you asked how to test your SAM Serverless, but since you would like to have a proper development flow (local execution, unit test, pipeline, etc) switching to Serverless framework would be the solution. You can simulate the functions through node, but this will increase your manual management of something which a framework already does.
Option 1
. But hoping i may find a better option than that :) – Privateexport
feature. SAM local is doing okay for now.. – Private