# mock-git

> Mock any git command

Latest version **2.0.0** (published 2017-05-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install mock-git
pnpm add mock-git
yarn add mock-git
bun add mock-git
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2017-05-14 |
| First published | 2016-05-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Steve Mao |
| Maintainers | stevemao, tapppi |
| Keywords | mock, test, git, executable |

## Links

- npm: https://www.npmjs.com/package/mock-git
- Repository: https://github.com/stevemao/mock-git
- Homepage: https://github.com/stevemao/mock-git#readme
- Issues: https://github.com/stevemao/mock-git/issues
- npm.io page: https://npm.io/package/mock-git

## Dependencies (2)

- [shelljs](https://npm.io/package/shelljs.md) ^0.7.0
- [mock-bin](https://npm.io/package/mock-bin.md) ^2.0.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2017-05-14
- 1.0.3 — 2016-06-23
- 1.0.2 — 2016-05-27
- 1.0.1 — 2016-05-27
- 1.0.0 — 2016-05-07
- 0.0.0 — 2016-05-07

## 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)

> Mock any git command

Useful for mocking tests that run git command, especially to fake edge cases and increase test coverage.


## Install

```
$ npm install --save-dev mock-git
```


## Usage

```js
const mockGit = require('mock-git');
const log = 'mocking git bla!';
const unmock = await mockGit(`console.log('${log}')`, 'bla');
let actual = shell.exec('git bla').stdout;
t.is(log + '\n', actual);

actual = shell.exec('git').stdout;
t.not(log + '\n', actual);

unmock();
actual = shell.exec('git bla').stdout;
t.not(log + '\n', actual);
```

Checkout the [tests](./test.js) for more details


## API

### mockGit(js, [command])

Returns a promise which resolves with an unmock function.

##### js

Type: `string`  

Nodejs code.

#### command

Type: `string`

EG: `'commit'`.

If omitted, it will mock the git binary.


## Related

- [mock-bin](https://github.com/stevemao/mock-bin) - Mock any executable binary


## License

MIT © [Steve Mao](https://github.com/stevemao)

---
_Source: https://npm.io/package/mock-git · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
