{"id":16594135,"url":"https://github.com/jsdf/jest-alias-module-loader","last_synced_at":"2025-08-24T16:32:15.671Z","repository":{"id":66018862,"uuid":"43555784","full_name":"jsdf/jest-alias-module-loader","owner":"jsdf","description":null,"archived":false,"fork":false,"pushed_at":"2015-10-02T14:04:11.000Z","size":124,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-16T04:04:10.545Z","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/jsdf.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":"2015-10-02T13:59:09.000Z","updated_at":"2020-04-27T03:34:00.000Z","dependencies_parsed_at":"2023-02-19T21:30:24.621Z","dependency_job_id":null,"html_url":"https://github.com/jsdf/jest-alias-module-loader","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jsdf/jest-alias-module-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdf%2Fjest-alias-module-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdf%2Fjest-alias-module-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdf%2Fjest-alias-module-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdf%2Fjest-alias-module-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsdf","download_url":"https://codeload.github.com/jsdf/jest-alias-module-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdf%2Fjest-alias-module-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271902281,"owners_count":24841173,"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-24T02:00:11.135Z","response_time":111,"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-10-11T23:45:15.952Z","updated_at":"2025-08-24T16:32:15.628Z","avatar_url":"https://github.com/jsdf.png","language":"JavaScript","readme":"# jest-alias-module-loader\n\nJest doesn't really have a simple way of globally replacing certain modules, but I've come up with a couple. Firstly, the hacky and gross way to [replace modules is by using a regexp replace in the preprocessor](https://github.com/facebook/react/pull/4656/files). But let's not do that. Instead, this module extends the default `HasteModuleLoader` to allow us to alias some modules at `require` time:\n\n```js\n// test/aliasedModuleLoader.js\n\nvar JestAliasModuleLoader = require('jest-alias-module-loader');\n\nmodule.exports = JestAliasModuleLoader({\n   aliasedModules: {\n    // use compiled react for faster loading\n    'react': 'react/dist/react-with-addons',\n    'react/addons': 'react/dist/react-with-addons',\n  },\n});\n```\n\nTo use this, just add a line to your Jest config (eg. in `package.json`):\n\n```json\n{\n  \"jest\": {\n    \"moduleLoader\": \"\u003crootDir\u003e/test/aliasedModuleLoader.js\"\n  }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdf%2Fjest-alias-module-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsdf%2Fjest-alias-module-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdf%2Fjest-alias-module-loader/lists"}