{"id":15581170,"url":"https://github.com/sevinf/require-mocked","last_synced_at":"2025-03-29T08:22:34.952Z","repository":{"id":9810634,"uuid":"11792197","full_name":"SevInf/require-mocked","owner":"SevInf","description":"Node.js library that allows you to inject your mocks into modules code","archived":false,"fork":false,"pushed_at":"2013-09-19T15:05:47.000Z","size":160,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T22:39:06.228Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SevInf.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":"2013-07-31T14:02:14.000Z","updated_at":"2014-04-29T19:43:02.000Z","dependencies_parsed_at":"2022-09-04T18:22:42.776Z","dependency_job_id":null,"html_url":"https://github.com/SevInf/require-mocked","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SevInf%2Frequire-mocked","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SevInf%2Frequire-mocked/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SevInf%2Frequire-mocked/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SevInf%2Frequire-mocked/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SevInf","download_url":"https://codeload.github.com/SevInf/require-mocked/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246157668,"owners_count":20732656,"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","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-10-02T19:41:50.087Z","updated_at":"2025-03-29T08:22:34.930Z","avatar_url":"https://github.com/SevInf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"require-mocked\n==============\n\nNode.js library that allows you to inject your mocks into your modules code.\n\n## Installation\n\n```\nnpm install require-mocked\n```\n\n## Usage\n\nSuppose you want to test some module that uses `fs` (eiser directly, or throught one of its dependencies) but\nyou want it to use some stub instead of the real FS.\n\n```javascript\nvar requireMocked = require('require-mocked')(__filename);\n\nvar moduleUnderTest = requireMocked('./path/to/your/module', {\n    mocks: {\n        fs: {\n            //your stub code\n        }\n    }\n});\n```\n\nTo create `requireMocked` function you need to pass your module's file name. It will be used to resolve\npaths the same way as original `require` for your module.\n`requireMocked` accepts following parameters:\n\n* `path` - path to the module you want to load;\n* `opts` - loading options:\n    * `opts.mocks` - mocks to use when loading module or its dependencies. Keys of the object represents module\n    ids, values - the object to use instead of real module.\n    * `opts.resolves` - stub `require.resolve` for the loaded module so it will return given path for\n    instead of original. Format is `{\"moduleId\": \"stub/path\"}`.\n    * `opts.ignoreMocks` - array of the module id that will always load real modules instead of mocks.\n\n## Similar projects\n\n* [SandboxedModule](https://github.com/felixge/node-sandboxed-module) - doesn't support recursive mocking, but\nmay be more functional in other areas.\n\n## License\n\nLicensed under MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevinf%2Frequire-mocked","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsevinf%2Frequire-mocked","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevinf%2Frequire-mocked/lists"}