Created
November 11, 2020 13:32
-
-
Save FloStar3000/0e2c953f1a54e9147d7e203cbeb156b1 to your computer and use it in GitHub Desktop.
Serverless Framework: Easy shortcut to test a function with event JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Normally, you would test a serverless function like this: | |
serverless invoke local -f methodName --path path/to/event.json | |
Shortcut: | |
1. All event files must be in the same folder (e.g. mocks-folder/) and named like this: [methodname].json | |
2. In package.json, add script: "test":"serverless invoke local -f $method --path mocks-path/$method.json" | |
3. Test a function with: method=functionName npm run test | |
You can adapt this for remote testing: | |
- "test-remote":"serverless invoke -f $method --path mocks-path/$method.json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment