{"id":16374475,"url":"https://github.com/azz/jest-magic-mock","last_synced_at":"2026-02-27T20:36:55.827Z","repository":{"id":44128453,"uuid":"192559278","full_name":"azz/jest-magic-mock","owner":"azz","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-04T00:46:45.000Z","size":998,"stargazers_count":4,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-19T23:15:02.381Z","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/azz.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":"2019-06-18T14:43:13.000Z","updated_at":"2023-07-18T11:56:21.000Z","dependencies_parsed_at":"2023-02-01T15:31:24.897Z","dependency_job_id":null,"html_url":"https://github.com/azz/jest-magic-mock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/azz/jest-magic-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fjest-magic-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fjest-magic-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fjest-magic-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fjest-magic-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azz","download_url":"https://codeload.github.com/azz/jest-magic-mock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azz%2Fjest-magic-mock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29912351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"ssl_error","status_checked_at":"2026-02-27T19:37:41.463Z","response_time":57,"last_error":"SSL_read: 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":[],"created_at":"2024-10-11T03:17:22.646Z","updated_at":"2026-02-27T20:36:55.797Z","avatar_url":"https://github.com/azz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `jest-magic-mock`\n\n\u003e **EXPERIMENT**: Do not actually use this, I think?\n\nThis is a JavaScript implementation of a Magic Mock, inspired by Python's [`unittest.mock.MagicMock`](https://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock). It is implemented using [`Proxy`](https://mdn.io/proxy).\n\n## API\n\n```js\nimport magicMock from 'jest-magic-mock';\n\ntest('has all of the properties', () =\u003e {\n  const mock = magicMock();\n\n  expect(mock.foo.bar.baz[2]).toBeDefined();\n});\n\ntest('can mock individual properties', () =\u003e {\n  const mock = magicMock();\n\n  mock.foo.mockReturnValue(3);\n  mock.bar.baz.mockImplementation(x =\u003e x * x);\n\n  expect(mock.foo()).toEqual(3);\n  expect(mock.bar.baz(3)).toEqual(9);\n  expect(mock()).toEqual(undefined);\n});\n```\n\nSee [the tests](./src/__tests__/index.test.js) for more examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazz%2Fjest-magic-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazz%2Fjest-magic-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazz%2Fjest-magic-mock/lists"}