{"id":29215403,"url":"https://github.com/aackerman/injected-loader","last_synced_at":"2025-07-03T00:09:46.139Z","repository":{"id":29915706,"uuid":"33461577","full_name":"aackerman/injected-loader","owner":"aackerman","description":null,"archived":false,"fork":false,"pushed_at":"2015-05-30T16:31:37.000Z","size":172,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-09T16:54:55.098Z","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/aackerman.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":"2015-04-06T01:29:56.000Z","updated_at":"2015-05-17T08:07:26.000Z","dependencies_parsed_at":"2022-09-17T10:12:46.214Z","dependency_job_id":null,"html_url":"https://github.com/aackerman/injected-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aackerman/injected-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aackerman%2Finjected-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aackerman%2Finjected-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aackerman%2Finjected-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aackerman%2Finjected-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aackerman","download_url":"https://codeload.github.com/aackerman/injected-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aackerman%2Finjected-loader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263234966,"owners_count":23434922,"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":"2025-07-03T00:09:40.895Z","updated_at":"2025-07-03T00:09:46.123Z","avatar_url":"https://github.com/aackerman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## injected-loader [![Build Status](https://travis-ci.org/aackerman/injected-loader.png?branch=master)](https://travis-ci.org/aackerman/injected-loader)\n\nWebpack dependency injection for testing\n\n### Usage\n\n```js\n// my_great_method.js\nexport default function() { return false; };\n```\n\n```js\n// great_method_proxy.js\nimport MyGreatMethod from './my_great_method.js';\n\nexport default function(input) {\n  return MyGreatMethod(input);\n}\n```\n\n```js\n// import/require a dependency with the `injected` loader\n// a function is returned that allows injecting dependecies to override\nimport GreatMethodProxyInjector from 'injected!./great_method_proxy';\nvar MockGreatMethod = jasmine.createSpy().and.returnValue(true);\n\n// invoke the function with an object, keys must match\n// import/require statements, the key './my_great_method.js'\n// matches the import statement in great_method_proxy.js\nlet GreatMethodProxy = GreatMethodProxyInjector({\n  './my_great_method.js': MockGreatMethod\n});\n\ndescribe('GreatMethodProxy', function(){\n  it('calls our mocked method', function(){\n    // our mocked method returns true instead of using the\n    // original method and returning false\n    expect(GreatMethodProxy()).toBe(true);\n    expect(MockGreatMethod).toHaveBeenCalled();\n  });\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faackerman%2Finjected-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faackerman%2Finjected-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faackerman%2Finjected-loader/lists"}