package
Mock any git command
npm install mock-gitGitHub-flavored package documentation.
Across all versions, last 30 days.
416 in 30 days
Runtime metadata.
Tagged topics.
Mock any git command
Useful for mocking tests that run git command, especially to fake edge cases and increase test coverage.
$ npm install --save-dev mock-gitconst 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
Checkout the tests for more details
Returns a promise which resolves with an unmock function.
Type: string
Nodejs code.
Type: string
EG: 'commit'.
If omitted, it will mock the git binary.
MIT © Steve Mao
stevemao
maochenyan@gmail.com