1. hoax.js
Mock objects with ease
hoax.js
Package: hoax.js
Created by: ecrmnn
Last modified: Sat, 18 Jun 2022 21:01:21 GMT
Version: 1.0.1
License: MIT
Downloads: 8
Repository: https://github.com/ecrmnn/hoax.js

Install

npm install hoax.js
yarn add hoax.js

hoax.js

Mock objects with ease

travis
npm version
npm downloads
npm license
prs Welcome
eslint

Installation

 npm install hoax.js --save

Usage

 const hoax = require('hoax.js');

const mock = hoax(console, 'log');

// Do not actually log to console
console.log('unicorn');
console.log('rainbow');
console.log('magic');

// Get calls to the mocked function
mock.calls;
//=> [
//=>   ['unicorn'],
//=>   ['rainbow'],
//=>   ['magic'],
//=> ]

// Reset when done
mock.reset();

// Does log to console
console.log('This will be logged');

// You may also provide a function to return whatever you want 
const mock = hoax(process, 'cwd', () => '/fake/path');

process.cwd();
//=> /fake/path

mock.reset();

process.cwd();
//=> /ecrmnn/hoax.js

License

MIT © Daniel Eckermann

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code