{"id":22199268,"url":"https://github.com/pmarkert/lambda-testing-framework","last_synced_at":"2025-10-09T16:07:37.699Z","repository":{"id":57175698,"uuid":"75263349","full_name":"pmarkert/lambda-testing-framework","owner":"pmarkert","description":"Unit testing framework for testing requests/responses for Amazon Alexa skills","archived":false,"fork":false,"pushed_at":"2018-04-24T20:16:12.000Z","size":26,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-24T16:52:44.513Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmarkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-01T06:39:22.000Z","updated_at":"2023-03-08T23:39:16.000Z","dependencies_parsed_at":"2022-08-29T00:10:53.145Z","dependency_job_id":null,"html_url":"https://github.com/pmarkert/lambda-testing-framework","commit_stats":null,"previous_names":["pmarkert/alexa-skill-tester"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/pmarkert/lambda-testing-framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarkert%2Flambda-testing-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarkert%2Flambda-testing-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarkert%2Flambda-testing-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarkert%2Flambda-testing-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmarkert","download_url":"https://codeload.github.com/pmarkert/lambda-testing-framework/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmarkert%2Flambda-testing-framework/sbom","scorecard":{"id":738650,"data":{"date":"2025-08-11","repo":{"name":"github.com/pmarkert/lambda-testing-framework","commit":"17fccd139db200405999a06f09a207839dcf6cc6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"16 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4","Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T16:40:48.862Z","repository_id":57175698,"created_at":"2025-08-22T16:40:48.862Z","updated_at":"2025-08-22T16:40:48.862Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272374880,"owners_count":24923455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T15:13:48.246Z","updated_at":"2025-10-09T16:07:32.663Z","avatar_url":"https://github.com/pmarkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lambda-testing-framework\nUnit testing framework for testing requests/responses for Amazon Lambda functions (including Amazon Alexa skills)\n\nLambda Testing Framework depends upon [https://mochajs.org/](mocha).\n\n## Summary\nThe lambda-testing-framework is an easy way to perform unit testing for AWS Lambda functions and Amazon Alexa skills by automatically generating mocha test-cases with response validation from a directory of static .json files. \n\nlambda-testing-framework framework uses a data-driven static files approach. You create test-cases in a directory with `*.request.json` files to represent the event data that should be sumitted to the lambda function under test. The testing framework loads the event/request data, invokes your handler, and then compares the handler's response to the contents of a matching `*.response.json` file.\n\n## Getting Started\n\n1. Install lambda-testing-framework as a devDependency.\n    `npm install -D lambda-testing-framework`\n2. Create a `test` directory with the test-driver in it (let's call it `index.js`)\n    ```javascript\n    const path = require(\"path\");\n    const method_under_test = require(\"../index\").handler; // the handler function you are testing\n\n    const test = require(\"lambda-testing-framework\");\n    describe(\"Event tests\", () =\u003e test(method_under_test, { path: path.resolve(__dirname, \"events\") }));\n    ```\n3. Create a `test/events` sub-directory.\n4. Place some `*.requests.json` files in the ./tests/events folder.\n5. Place matching `*.response.json` files in the same folder.\n6. Setup your package.json to run the tests with:\n    ```json\n    \"scripts\": {\n      \"test\": \"mocha\"\n    }\n    ```\n\n    and then run them with `npm test` or `npm test debug`.\n\n## Requests and Responses\nIt can be tedious to build the input .request.json files by hand, especially if your function handles API Gateway requests. I find it convenient to copy/paste request events from CloudWatch logs.\n\nAs an alternative to building the .response.json files by hand, you can allow lambda-testing-framework to save missing response files automatically to create a baseline. To do this, add `saveMissingResponses: true` to the options object. HINT: I typically have my test/index.js check for the existence of some environment variable to toggle this property.\n\n    ```javascript\n    // ...\n    options.saveMissingResponses = process.env.SAVE_RESPONSES===\"true\";\n    // ...\n    ```\nThen run it with\n    ```\n    $ SAVE_RESPONSES=true npm test\n    ```\n\n## API\n```javascript\n// Executes all *.request.json test cases in the options.path directory\nmodule.exports = function(method_under_test, options) \n```\n\n* method_under_test - The lambda handler function(event, context, callback) you are testing.\n* options.path - path to the directory containing the test cases\n* options.errorExpected - boolean flag to indicate that test case should expect an error to be thrown (in the future, this value may allow for specific errors to be matched)\n* before - function(request, test_case_name, options) : hook that is called before the test is executed\n* after - function(error, response, request, test_case_name, options, validate) - hook that is called after the test is executed, but before validation\n\n### The `options.before` Hook\nThe `options.before` hook allows you to provide a custom function that can be used to perform setup tasks or to modify the request object before it is submited for testing. The function must either return the request object or a promise that resolves to the request object. The returned request object will be used for the test, so you can apply custom transformations to the request before processing.\n\n### The `options.after` Hook\nThe `options.after` hook can be used to perform custom validation on the error/response, or to modify the error/response before passing on to the normal validation routine. The `options.after` function may return a promise. The function should throw an error if the response/error fails your custom validation. The built-in validation routine is provided as the last parameter if you decide to invoke it to perform the normal validation. The built-in validation function takes the same parameters as the `options.after` hook and returns a promise.\n\n### Example use of `options.after` w/validation chaining\n```javascript\nfunction after_hook(error, response, request, test_case_name, options, validate) {\n\t// Do some custom validation on the response or error objects and\n\t// throw new Error(\"If the validation fails.\");\n\n        // or you can modify the response/error objects to clear out non-deterministic values (such as datestamps, or unique-ids)\n\t// before passing on to the default validation routine which compare the results to a static response.\n\n\t// Call the built-in validation if you want to keep the built-in response checking.\n\treturn validate(error, response, request, test_case_name, options);\n}\n```\n\n## Response Validation\n### `*.response.json`\nMatches the Lambda response against the provided .json object.\n\n### `*.response.pattern`\nMatches the JSON serialized value of the Lambda response against the provided regex pattern. The file content is read in as the pattern and default options are used.\n\n### `*.response.js`\nA module that exports a javascript function that will be invoked with the same interface/requirements as the `options.after` hook (minus the final `validate` parameter).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmarkert%2Flambda-testing-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmarkert%2Flambda-testing-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmarkert%2Flambda-testing-framework/lists"}