2.0.0 • Published 7 years ago

mock-git v2.0.0

Weekly downloads
19
License
MIT
Repository
github
Last release
7 years ago

mock-git Build Status: Linux Build Status: Windows

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

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

License

MIT © Steve Mao

2.0.0

7 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.0

8 years ago