{"id":18687275,"url":"https://github.com/junosuarez/moquire","last_synced_at":"2025-09-05T08:18:58.349Z","repository":{"id":6776943,"uuid":"8023999","full_name":"junosuarez/moquire","owner":"junosuarez","description":"node module: because mocking `require`d modules for unit tests should be easy","archived":false,"fork":false,"pushed_at":"2014-06-09T17:27:45.000Z","size":184,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-01T12:24:57.149Z","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/junosuarez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-05T06:45:50.000Z","updated_at":"2014-06-09T17:27:45.000Z","dependencies_parsed_at":"2022-09-20T17:43:51.081Z","dependency_job_id":null,"html_url":"https://github.com/junosuarez/moquire","commit_stats":null,"previous_names":["jden/moquire"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/junosuarez/moquire","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fmoquire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fmoquire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fmoquire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fmoquire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junosuarez","download_url":"https://codeload.github.com/junosuarez/moquire/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fmoquire/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273728838,"owners_count":25157294,"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-09-05T02:00:09.113Z","response_time":402,"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-11-07T10:32:17.057Z","updated_at":"2025-09-05T08:18:58.291Z","avatar_url":"https://github.com/junosuarez.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# moquire\nbecause mocking `require`d modules for unit tests should be easy\n\n`moquire` loads modules in a new vmContext so you can be sure they're tested in isolation.\n\nIt uses [resolve](https://npmjs.org/package/resolve) to support the same module path resolution strategy as node's `require`.\n\nUse moquire to test your modules in isolation without trying to hack around `require`.\n\n`moquire` makes it stupid simple to intercept calls to node's favorite service locator, `require`.\n\n`moquire` is designed to be as similar to `require` as possible - down to the name. The api footprint is intentionally small. If you need more functionality, see [sandboxed-module](https://npmjs.org/package/sandboxed-module) or [proxyquire](https://npmjs.org/package/proxyquire).\n\n## install\n\n    $ npm install moquire\n\n## usage\n\n    var moquire = require('moquire')\n\n    var moduleUnderTest = moquire('../test', {\n      depA: {},\n      depB: function (){}\n    })\n\n    // moduleUnderTest is loaded with `depA` and `depB` mocked\n\nSome test runners will keep the same instance of `moquire` between runs when in watch mode (for example, for Test-Driven Development). In this case, you probably don't want caching. You can access a version of `moquire` with caching disabled like so:\n\n    var moquire = require('moquire').nocache\n\nor\n\n    var moquire = require('moquire')\n    moquire.nocache('foo', {})\n\n## relquire\n\nSince 1.5.0, `moquire` supports mocking [`relquire`](https://npm.im/relquire) dependencies like so:\n\nLet's imagine a project laid out like:\n\n    ├── a.js\n    ├── foo.js\n    └── test\n        └── test.js\n\n`a.js`:\n\n    var relquire = require('relquire')\n    var foo = relquire('~/foo')\n\n`test.js`:\n\n    var moquire = require('moquire')\n    var fakeFoo = {}\n    var a = moquire('../a', {'~/foo': fakeFoo})\n\nOf course, you can use relative requires in `moquire`, too:\n\n    var a = moquire('~/a', {'~/foo': fakeFoo})\n\n\n## running the tests\n\n    $ npm test\n\n## inspiration \u0026 kudos\n * @nathanmacinnes' [injectr](https://npmjs.org/package/injectr)\n * @vojtajina's article [Testing Private State and Mocking Dependencies](http://howtonode.org/testing-private-state-and-mocking-deps)\n * @thlorenz for the pointer on [#1](https://github.com/jden/moquire/issues/1)\n\n## contributors\n\njden \u003cjason@denizac.org\u003e @leJDen\n\n## license\n\n(c) 2013 Agile Diagnosis \u003chello@agilediagnosis.com\u003e See LICENSE.md","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunosuarez%2Fmoquire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunosuarez%2Fmoquire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunosuarez%2Fmoquire/lists"}