{"id":16349353,"url":"https://github.com/stevemao/mock-git","last_synced_at":"2026-03-08T17:38:07.063Z","repository":{"id":57300032,"uuid":"58256809","full_name":"stevemao/mock-git","owner":"stevemao","description":"Mock any git command","archived":false,"fork":false,"pushed_at":"2020-01-26T23:52:54.000Z","size":32,"stargazers_count":11,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-19T20:00:07.140Z","etag":null,"topics":["bin","binary","git","mock","mocking","test","testing","testing-tools","tests"],"latest_commit_sha":null,"homepage":"","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/stevemao.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":"2016-05-07T08:23:38.000Z","updated_at":"2022-05-12T17:08:26.000Z","dependencies_parsed_at":"2022-09-06T04:20:20.330Z","dependency_job_id":null,"html_url":"https://github.com/stevemao/mock-git","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/stevemao%2Fmock-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemao%2Fmock-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemao%2Fmock-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemao%2Fmock-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevemao","download_url":"https://codeload.github.com/stevemao/mock-git/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234659817,"owners_count":18867627,"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":["bin","binary","git","mock","mocking","test","testing","testing-tools","tests"],"created_at":"2024-10-11T00:59:16.498Z","updated_at":"2025-10-01T03:30:24.007Z","avatar_url":"https://github.com/stevemao.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mock-git [![Build Status: Linux](https://travis-ci.org/stevemao/mock-git.svg?branch=master)](https://travis-ci.org/stevemao/mock-git) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/76bg3fbqo2ox9s11/branch/master?svg=true)](https://ci.appveyor.com/project/stevemao/mock-git/branch/master)\n\n\u003e Mock any git command\n\nUseful for mocking tests that run git command, especially to fake edge cases and increase test coverage.\n\n\n## Install\n\n```\n$ npm install --save-dev mock-git\n```\n\n\n## Usage\n\n```js\nconst mockGit = require('mock-git');\nconst log = 'mocking git bla!';\nconst unmock = await mockGit(`console.log('${log}')`, 'bla');\nlet actual = shell.exec('git bla').stdout;\nt.is(log + '\\n', actual);\n\nactual = shell.exec('git').stdout;\nt.not(log + '\\n', actual);\n\nunmock();\nactual = shell.exec('git bla').stdout;\nt.not(log + '\\n', actual);\n```\n\nCheckout the [tests](./test.js) for more details\n\n\n## API\n\n### mockGit(js, [command])\n\nReturns a promise which resolves with an unmock function.\n\n##### js\n\nType: `string`  \n\nNodejs code.\n\n#### command\n\nType: `string`\n\nEG: `'commit'`.\n\nIf omitted, it will mock the git binary.\n\n\n## Related\n\n- [mock-bin](https://github.com/stevemao/mock-bin) - Mock any executable binary\n\n\n## License\n\nMIT © [Steve Mao](https://github.com/stevemao)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevemao%2Fmock-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevemao%2Fmock-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevemao%2Fmock-git/lists"}