Socket
Book a DemoInstallSign in
Socket

mock-bin

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-bin

Mock any executable binary

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
2
Created
Source

mock-bin Build Status: Linux Build Status: Windows

Mock any executable binary

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

Install

$ npm install --save-dev mock-bin

Usage

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

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

API

mockBin(bin, shebang, code)

Returns a promise which resolves with an unmock() function.

bin

Type: string

EG: 'git'.

shebang

Type: string

Shebang or environment

EG: '#!/usr/bin/env node' or 'bash'

code

Type: string

The actual code you want to execute.

  • mock-git - Mock any git command

License

MIT © Steve Mao

Keywords

mock

FAQs

Package last updated on 14 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts