{"id":30699674,"url":"https://github.com/mohsen-d/ajab","last_synced_at":"2026-05-18T09:33:37.986Z","repository":{"id":65525003,"uuid":"506035499","full_name":"mohsen-d/ajab","owner":"mohsen-d","description":"ajab makes modules' private functions reachable for testing","archived":false,"fork":false,"pushed_at":"2023-03-17T09:56:08.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T13:43:18.032Z","etag":null,"topics":["nodejs","testing","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mohsen-d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-21T23:36:05.000Z","updated_at":"2022-07-02T18:24:45.000Z","dependencies_parsed_at":"2023-01-27T07:55:13.047Z","dependency_job_id":null,"html_url":"https://github.com/mohsen-d/ajab","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mohsen-d/ajab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fajab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fajab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fajab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fajab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohsen-d","download_url":"https://codeload.github.com/mohsen-d/ajab/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen-d%2Fajab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33172610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["nodejs","testing","unit-testing"],"created_at":"2025-09-02T11:12:07.783Z","updated_at":"2026-05-18T09:33:37.965Z","avatar_url":"https://github.com/mohsen-d.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ajab\n\najab makes modules' private (not-exported) functions reachable and testable in testing frameworks like jest\n\n## installing\n\ninstall `ajab` by running `npm i ajab --save-dev` in terminal\n\n## using\n\nIf `myModule.js` contains the following:\n\n    module.exports.publicFunction = function (a, b){\n        return a + b;\n    }\n\n    function privateFunction(a, b){\n        return a * b;\n    }\n\n    const anotherPrivateFunction = (a, b) =\u003e {\n        return a / b;\n    }\n\nTo test the private functions, in your tests, instead of `require`, import your module using `ajab` :\n\n    const ajab = required('ajab');\n    const myModule = ajab('./myModule');\n\n`ajab` makes your private functions available just like an exported function so you can test them directly:\n\n    // in jest:\n    test(\"My private function should be testable\", () =\u003e {\n        expect(myModule.privateFunction(2, 4)).toBe(8);\n    });\n\n### module.exports assigned to a function\n\nif `module.exports` is assigned to a function,\n\n    module.exports = function(a, b){ return a + b; }\n\n`ajab` puts that function in the `module.exports.public`\n\n    // in jest:\n    test(\"testing module.exports assigned to a function\", () =\u003e {\n        expect(myModule.public(2, 4)).toBe(6);\n    });\n\n### nested function\n\n`ajab` also finds functions defined inside the public functions and adds them to module.exports\n\n    function publicFunc(){\n        const privateFunc = function(){...};\n        ...\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohsen-d%2Fajab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohsen-d%2Fajab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohsen-d%2Fajab/lists"}